<template>
	<view>
		<image src="@/static/bg.png" mode="widthFix" class="bg" style="width: 100%;height: 928rpx;"></image>
		<view class="top" @click="previous" :style="{'padding-top': top+'px'}">
			<view class="xuzou">
				<uni-icons type="left" size="22" style="margin-left: 25rpx;"></uni-icons>
				<text class="title">订单确认</text>
			</view>
			<image src="@/static/bg.png" mode="widthFix" class="hs"></image>
		</view>
		<view class="content" :style="{'top': (top+44)+'px'}">
			<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="address">
							<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" v-if="vipxinxi.original_price">原价￥{{vipxinxi.original_price}}</view>
					</view>
					<view class="smwz" v-if="vipxinxi.introduce">说明：{{vipxinxi.introduce}}</view>
					<view class="smwz" v-if="vipxinxi.buy_limit >= 1">限购{{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" color="#F8A617" />
					已阅读并同意
					<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>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				mandianxinxi: {},
				vipxinxi: {},
				yhxyactive: false,
				top: 0,
				userxixin: {}
			}
		},
		onLoad(option) {
			console.log('option', option);
			var that = this
			var tuijianlist = JSON.parse(decodeURIComponent(option.tuijianlist))
			var vipxinxi = JSON.parse(decodeURIComponent(option.item))
			that.vipxinxi = vipxinxi
			that.mandianxinxi = tuijianlist
			that.top = uni.getSystemInfoSync().statusBarHeight
		},
		onShow() {
			this.memberInfo();
			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'
				})
			},
			memberInfo() {
				this.$api.memberInfo().then(res => {
					this.userxixin = res.data
				})
			},
			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 {
					if(!this.userxixin.face_id) {
						uni.showModal({
							title: "温馨提示",
							content:"当前用户没有人脸识别，是否立即前往？",
							confirmColor: "#F8A617",
							confirmText: "前往",
							success(res) {
								if(res.confirm){
									uni.navigateTo({
										url: "/pages/face/face?type=order"
									})
								}
							}
						})
						return  ;
					}
					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;
		
		font-size: 26rpx;
		color: #666;
	}

	.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;
		font-weight: 500;
		font-size: 30rpx;
		color: #222222;
	}

	.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: 30rpx 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;
		margin-right: 20rpx;
	}

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

	.smwz {
		font-weight: 400;
		font-size: 28rpx;
		color: #999999;
		margin-top: 20rpx;
	}

	.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;
		align-items: center;
	}

	.bg{
		width: 100%;
		height: 100%;
		position: absolute;
		left: 0;
		top: 0;
		z-index: 1;
		background: #f5f5f5;
	}
	.content{
		width: 100%;
		position: relative;
		left: 0;
		top: 0;
		z-index: 2;
	}
	.top {
		width: 100%;
		left: 0;
		z-index: 22;
		height: 88rpx;
		overflow: hidden;
		position: fixed;
	}
	.top .xuzou{
		width: 100%;
		height: 88rpx;
		display: flex;
		position: fixed;
		align-items: center;
		position: relative;
		z-index: 23;
	}
	.top .hs{
		width: 100%;
		height: 100%;
		position: absolute;
		left: 0;
		top: 0;
		z-index: 1;
	}
	.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: 20rpx;
		display: flex;
		justify-content: space-between;
	}
	.mddz2 .address{
		flex: 1;
		margin-right: 20rpx;
	}
	.dz {
		margin-left: 17rpx;
		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: 25rpx 28rpx;
	}
	.mendian {
		padding: 0 25rpx 25rpx;
		overflow: hidden;
	}
</style>