<template>
	<view>
		<image src="@/static/bg.png" mode="" style="width: 100%;height: 928rpx;"></image>
		<view class="top" @click="previous">
			<view class="xuzou">
				<uni-icons type="left" size="18"></uni-icons>
				<text class="title">订单确认</text>
			</view>
		</view>
		<view class="mendian">
			<view class="mddz">
				<view class="huiy">
					<image class="huiyimg" src="@/static/huangguan.png" mode=""></image>
					<view class="huiywz">运动湾会员</view>
				</view>
				<view class="mddz1">
					<view class="mddz1wz">{{mandianxinxi.name}}</view>
				</view>
				<view class="mddz2">
					<view class="">
						<image class="mddz1img1" src="@/static/定位1.png" mode=""></image>
						<text class="dz">地址：{{mandianxinxi.address}}</text>
					</view>

					<!-- <image class="mddz1img2" src="@/static/电话o.png" mode=""></image> -->
					<view class="qihuanmd" @click="qhmd">切换门店</view>
				</view>
			</view>
			<view class="taoc">
				<view class="taoctitle">
					会员套餐
				</view>
				<view class="taoctitle1">
					<view class="taoctitle1wz">{{vipxinxi.name}}</view>
					<view class="taoctitle1q">￥{{vipxinxi.price}}</view>
				</view>
				<view class="taoctitle2">
				<view class="smwz" v-if='vipxinxi.validity_num>0'>次数：{{vipxinxi.validity_num}}次</view>
				<view class="smwz" v-if='vipxinxi.validity_day>0'>期限：{{vipxinxi.validity_day}}天</view>
				<view class="smwz hengxian">原价￥{{vipxinxi.original_price}}</view>
				</view>
				<view class="smwz">说明：{{vipxinxi.introduce}}</view>
				<view class="smwz">限购{{vipxinxi.buy_limit}}次</view>
			</view>
			<view class="zhif">
				<view class="zfwi">支付方式</view>
				<view class="zhifright">
					<image class="wxpay" src="@/static/wxpay.png" mode=""></image>
					<view class="zfwi1">微信支付</view>
				</view>
			</view>
		</view>
		<checkbox-group class="chgroup" v-model="checkboxValue1" @change='change'>
			<label class="radio">
				<checkbox value="r1" />
				已阅读并同意
				<text class="xy" @click="yhxy('yonghu')">《用户协议》</text>
			</label>
		</checkbox-group>
		<view class="fot">
			<view class="fotwz">
				支付<text style="color: #F0503E;">{{vipxinxi.price}}</text>元
			</view>
			<view class="fotbtn" @click="zfsub">
				立即支付
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				mandianxinxi: {},
				vipxinxi: {},
				yhxyactive: false
			}
		},
		onLoad(option) {
			console.log('option', option);
			var that = this
			var tuijianlist = JSON.parse(option.tuijianlist)
			var vipxinxi = JSON.parse(option.item)
			that.vipxinxi = vipxinxi
			that.mandianxinxi = tuijianlist
		},
		onShow() {
			var xzmd = uni.getStorageSync('xzmd')
			console.log('xzmd',xzmd);
			if (xzmd != '') {
				this.mandianxinxi = JSON.parse(xzmd)
				this.mandianxinxi.id=this.mandianxinxi.store_id
			}
			console.log('this.mandianxinxi',this.mandianxinxi);
		},
		methods: {
			qhmd() {
				uni.navigateTo({
					url: '/pages/mendainlist/mendainlist'
				})
			},
			change(e) {
				console.log(123, e);
				if (e.detail.value.length != 0) {
					this.yhxyactive = true
				} else {
					this.yhxyactive = false
				}
			},
			previous() {
				uni.navigateBack()
			},
			yhxy() {},
			zfsub() {
				if (!this.yhxyactive) {
					uni.showToast({
						icon: "none",
						title: '请先勾选用户协议',
						duration: 3000
					});
				} else {
					this.$api.cardBuy({
						card_id: this.vipxinxi.card_id,
						store_id: this.mandianxinxi.id
					}).then(res => {
						if (res.code == 200) {
							this.$api.cardPay({
								order_no: res.data.order_no,
								pay_type: 1
							}).then(res => {
							uni.requestPayment({
							    provider: 'wxpay',
								timeStamp:res.data.timeStamp,
								nonceStr: res.data.nonceStr,
								package: res.data.package,
								signType: res.data.signType,
								paySign:res.data.paySign,
								success: function (res) {
									console.log('success:' + JSON.stringify(res));
									uni.switchTab({
										url: '/pages/user/index'
									})
								},
								fail: function (err) {
									console.log('fail:' + JSON.stringify(err));
								}
							});
							})
						}
					})
				}
			},
		}
	}
</script>

<style scoped>
	.hengxian{
		text-decoration-line: line-through;
	}
	.xy {
		color: #F8A617;
	}

	.chgroup {
		position: fixed;
		left: 24rpx;
		bottom: 127rpx;
	}

	.fot {
		width: 750rpx;
		height: 101rpx;
		background: #FFFFFF;
		box-shadow: 0rpx -4rpx 10rpx 0rpx rgba(41, 24, 0, 0.08);
		border: 1px solid #EAEAEA;
		position: fixed;
		left: 0;
		bottom: 0;
		display: flex;
		justify-content: space-between;
	}

	.fotwz {
		line-height: 101rpx;
		margin-left: 26rpx;
	}

	.fotbtn {
		width: 200rpx;
		height: 70rpx;
		background: #F8A617;
		box-shadow: 0rpx 4rpx 13rpx 0rpx rgba(19, 14, 4, 0.14);
		border-radius: 35rpx;
		font-family: PingFang SC;
		font-weight: 500;
		font-size: 28rpx;
		color: #FFFFFF;
		text-align: center;
		line-height: 70rpx;
		margin-top: 15rpx;
		margin-right: 24rpx;
	}

	.zhif {
		width: 650rpx;
		padding: 20rpx 28rpx;
		margin-top: 20rpx;
		background: #FFFFFF;
		display: flex;
		justify-content: space-between;
		border-radius: 20rpx;
	}

	.zfwi {
		font-family: PingFang SC;
		font-weight: 500;
		font-size: 30rpx;
		color: #222222;
	}

	.zfwi1 {
		font-family: PingFang SC;
		font-weight: 500;
		font-size: 30rpx;
		color: #222222;
	}

	.zhifright {
		display: flex;
	}

	.taoctitle1q {
		font-family: Alibaba PuHuiTi;
		font-weight: 400;
		font-size: 30rpx;
		color: #EF3D25;
	}

	.wxpay {
		width: 44rpx;
		height: 44rpx;
	}

	.taoctitle1wz {
		font-family: PingFang SC;
		font-weight: bold;
		font-size: 30rpx;
		color: #222222;
	}

	.smwz {
		font-family: Alibaba PuHuiTi;
		font-weight: 400;
		font-size: 28rpx;
		color: #999999;
		margin-top: 23rpx;
	}

	.taoctitle1 {
		display: flex;
		justify-content: space-between;
		margin-top: 36rpx;
	}
	.taoctitle2{
		display: flex;
		justify-content: space-between;
	}
	.taoctitle {
		font-family: PingFang SC;
		font-weight: bold;
		font-size: 36rpx;
		color: #222222;
	}

	.taoc {
		width: 650rpx;
		/* height: 322rpx; */
		background: #FFFFFF;
		box-shadow: 0rpx 3rpx 9rpx 0rpx rgba(19, 14, 4, 0.08);
		border-radius: 20rpx;
		padding: 20rpx 28rpx;
		margin-top: 20rpx;
	}

	.huiyimg {
		width: 51rpx;
		height: 40rpx;
	}

	.huiywz {
		margin-left: 21rpx;
		margin-top: 5rpx;
	}

	.huiy {
		display: flex;
		margin-bottom: 20rpx;
	}

	.top {
		display: flex;
		position: absolute;
		top: 96rpx;
		left: 20rpx;
	}

	.title {
		padding-left: 14rpx;
	}

	.mddz1img2 {
		width: 44rpx;
		height: 44rpx;
		float: right;
	}

	.qihuanmd {
		width: 150rpx;
		height: 50rpx;
		background: rgba(248, 166, 23, 0);
		border-radius: 25rpx;
		border: 1px solid #F8A617;
		font-family: PingFang SC;
		font-weight: 500;
		font-size: 24rpx;
		color: #F8A617;
		text-align: center;
		line-height: 50rpx;
		/* margin-top: 20rpx; */
		/* float: right; */
	}

	.mddz2 {
		margin-top: 32rpx;
		display: flex;
		justify-content: space-between;
	}

	.dz {
		margin-left: 17rpx;
		font-family: PingFang SC;
		font-weight: 500;
		font-size: 26rpx;
		color: #999999;
	}

	.mddz1img1 {
		width: 22rpx;
		height: 27rpx;
	}

	.mddz1 {
		display: flex;
	}

	.mddz1img {
		width: 60rpx;
		height: 60rpx;
	}

	.mddz1wz {
		font-family: PingFang SC;
		font-weight: bold;
		font-size: 30rpx;
		color: #222222;
		/* margin-left: 21rpx; */
		margin-top: 12rpx;
	}

	.mddz {
		width: 650rpx;
		/* height: 192rpx; */
		background: #FFFFFF;
		box-shadow: 0rpx 3rpx 9rpx 0rpx rgba(19, 14, 4, 0.08);
		border-radius: 20rpx;
		margin-top: 24rpx;
		padding: 45rpx 28rpx;
	}

	.mendian {
		position: absolute;
		top: 152rpx;
		left: 24rpx;
	}
</style>