<template>
	<!--pages/pay/pay.wxml-->
	<view>
		<view class="pay">
			<view class="payt">
				<image src="/static/pages/images/wcico.png" v-if="isSuccess=='true'"></image>
				<image src="/static/pages/images/sbico.png" v-else></image>
				<view v-if="isSuccess=='true'">支付成功</view>
				<block v-else>
					<view class="fail">支付失败，请重新支付</view>
					<view class="price">￥<text>{{money}}</text></view>
				</block>
			</view>
			<view class="btn">
				<block v-if="isSuccess=='true'">
					<block v-if="isRx=='1'">
						<navigator :url="'/prescription/Consultation/index?orderId=' + orderId" class="order"
							hover-class="none">去开处方</navigator>
					</block>
					<block v-else>
						<view v-if="vip=='true'||balance=='true'">
							<navigator url="/wallet/index/index" class="order" hover-class="none"
								v-if="balance=='true'">查看余额</navigator>
							<navigator url="/mine/vip/vip" class="order" hover-class="none" v-if="vip=='true'">会员中心
							</navigator>
						</view>
						<navigator url="/mine/order/order" open-type="redirect" class="order" hover-class="none" v-else>
							查看订单</navigator>
						<!-- <navigator url="/pages/shop/shop" open-type="reLaunch" hover-class="none" class="back" wx:if="{{isSuccess}}">返回首页</navigator> -->
						<view
							@click="goHome()" class="back">返回首页
						</view>
					</block>
				</block>
				<!-- <view @tap="payOrder" class="back" v-else>重新支付</view> -->

			</view>
		</view>
		<view class="tip" v-if="isRx=='1'">您的订单中包含处方药，需要医生开处方后才能发货，请及时完成开处方流程！</view>
		<view class="cai pdlr20" v-if="likeList.length>0">
			<view class="cai-tit dflex">
				<image src="/static/pages/images/cai_bg1.png"></image>猜您喜欢<image src="/static/pages/images/cai_bg2.png">
				</image>
			</view>
			<view class="tabcon dflex">
				<block v-for="(item, index) in likeList" :key="index">
					<view class="li" @tap="toDetail" :data-id="item.id">
						<view class="jsdimgs" @tap="toDetail" :data-id="item.id">
							<image :src="item.pic + '?x-oss-process=style/w210'" mode="aspectFit" class="jsdpro">
							</image>
							<image src="/static/pages/images/jishida.png" v-if="item.isJs" class="jsdimg"></image>
						</view>
						<view class="jsdinfo">
							<view class="proname" @tap="toDetail" :data-id="item.id">{{item.title}}</view>
							<view class="operate dflex">
								<view class="price proprice">
									￥<text>{{item.salePrice}}</text>
									<text class="vip"
										v-if="about.show_membership_price==1&&item.actualPrice < item.salePrice"><text
											class="sale">VIP</text><text
											class="members">{{item.actualPrice}}</text></text>
									<text class="vip"
										v-if="about.show_membership_price==1&&item.membersPrice<item.salePrice"><text
											class="sale">VIP</text><text
											class="members">{{item.membersPrice}}</text></text>
									<text class="del" v-if="about.show_membership_price!=1">
										￥{{item.marketPrice}}
									</text>
								</view>
								<view class="add-cart">
									<view class="nums dflex" v-if="item.count > 0">
										<image src="/static/pages/images/jian.png"></image>
										<view class="num">{{item.count}}</view>
										<image src="/static/pages/images/jia1.png"></image>
									</view>
									<image src="/static/pages/images/jia.png" v-else>
									</image>
								</view>
							</view>
						</view>
					</view>
				</block>
			</view>
		</view>
	</view>
</template>

<script>
import h5util from "../../utils/h5util.js";
	const req = require("../../utils/request.js");
	const app = getApp();
	export default {
		data() {
			return {
				isSuccess: true,
				header: req.header,
				likeList: [],
				isLikeLoad: true,
				page: 1,
				config: ''
			};
		},

		components: {},
		props: {},

		onLoad(options) {
			this.config = JSON.parse(req.getStorage('configRes'));
			this.setData(options);
			this.getLikeList();
			// console.log(options);
		},

		methods: {
			goHome(){
				h5util.jumpIndex('/pages/tabBar/index')
				// app.globalData.openHome();
			},
			payOrder() {
				let _ts = this;

				req.payOrder(this.id, success => {
					_ts.setData({
						isSuccess: success
					});
				});
			},
			getLikeList() {
				//Recommend
				if (!this.isLikeLoad) return false;
				this.isLikeLoad = false;
				let that = this;
				req.getRequest('/api/product/list', {
					page: that.page,
					limit: 10,
					attr: 'sell_well'
				}, res => {
					if (res && res.length >= 10) that.isLikeLoad = true;
					if (that.page > 1) res = that.likeList.concat(res);
					res = res.map(it => {
						if (it.deliverWay && JSON.parse(it.deliverWay).indexOf(3) != -1) it.isJs = true;
						return it;
					});
					that.setData({
						likeList: res
					});
				});
			},
			toDetail(e) {
				let id = e.currentTarget.dataset.id;
				let url = 'product/detail/detail?id=' + id
				app.globalData.redirectTab('product/detail/detail?id=' + id);
			},

		}
	};
</script>
<style>
	@import "./pay.css";
</style>
