<template>
	<view class="content">
		<view class="towcontentitem">
			<image class="towcontentitemimage" :src="data.img" mode="aspectFill"></image>
			<view class="fourcontentitemabsolute">
				<!-- 年卡会员 -->
			</view>
			<view class="towcontentitemone flex-start">
				<image class="towcontentitemoneimage" :src="data.store_avatar" mode="aspectFill"></image>
				<view class="towcontentitemonetext flex-colum-start">
					<text class="towcontentitemonetextone">{{data.title}}</text>
					<text class="towcontentitemonetexttow">{{data.show}}</text>
				</view>
				<view class="towcontentitemoneabsolute" @click="overlayshow = true">
					加购
				</view>
			</view>
			<view class="towcontentitemprogress">
				{{Number(data.user_sec_y_frequ)}}/{{Number(data.user_sec_z_frequ)}} 次
			</view>
			<view class="towcontentitemtow flex-between">
				<text class="towcontentitemtowetext">{{data.vip_number || ''}}</text>
				<text class="towcontentitemtowetext">{{data.end_time}}</text>
			</view>
		</view>
		<view class="therecontentitem">
			<view class="therecontentitemtext">
				会员详情
			</view>
			<view class="therecontentitemone">
				<!-- 	<view class="therecontentitemoneiten flex-between" @click="order">
					<text class="therecontentitemoneitentetxt">账单明细</text>
					<u-icon name="arrow-right" color="#808080" size="18"></u-icon>
				</view> -->
				<view class="therecontentitemoneiten flex-between" @click="overlayshow = true">
					<text class="therecontentitemoneitentetxt">订单明细</text>
					<u-icon name="arrow-right" color="#808080" size="18"></u-icon>
				</view>
			</view>
		</view>
		<u-overlay :show="overlayshow" @click="overlayshow = false">
			<view class="warp">
				<view class="rect" @tap.stop>
					<view class="onerect flex-center">
						<view>{{data.store_title}}</view>
						<u-icon @click="overlayshow = false" class="onerecticon" name="backspace" color="#000000"
							size="28"></u-icon>
					</view>
					<view class="towrect">
						商品
					</view>
					<view class="thererect flex-between">
						<view class="thererectone">
							{{data.title}}
						</view>
						<view class="thererecttow">
							<text>￥</text>{{data.price}}
						</view>
					</view>
					<view class="fourrect flex-between">
						<view class="fourrectone">
							<text>共计:</text>￥{{data.price}}
						</view>
						<view class="fourrecttow" @tap="$u.debounce(showpopupclick,1000)">
							立即购买
						</view>
					</view>
				</view>
			</view>
		</u-overlay>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				overlayshow: false,
				numberbox: "",
				data: {}
			}
		},
		async onLoad(e) {
			console.log(e)
			let res = await this.api.reservationvipdetail({
				id: e.id
			})
			this.data = res
			console.log(this.data)
		},
		methods: {
			async showpopupclick() {
				try {
					let res = await this.api.useropenuserseccrd({
						id: this.data.id
					}) //判断是否支付成功
					if (res) {
						// #ifdef MP-WEIXIN
						uni.requestPayment({
							provider: 'wxpay', //支付类型-固定值
							partnerid: res.payAppId, // 微信支付商户号
							timeStamp: res.payTimeStamp, // 时间戳（单位：秒）
							nonceStr: res.paynonceStr, // 随机字符串
							package: res.payPackage, // 固定值
							signType: res.paySignType, //固定值
							paySign: res.paySign, //签名
							success: (res) => {
								uni.showToast({
									title: "支付成功"
								})
								uni.redirectTo({
									url: "/my/member/index?e=" + 1,
								});
							},
							fail: (err) => {
								setTimeout(res => {
									uni.showToast({
										icon: 'none',
										title: '支付失败'
									})
									uni.hideLoading()
								}, 2000)
								uni.redirectTo({
									url: "/my/member/index?e=" + 1,
								});
							}
						});
						// #endif	
					}
				} catch (e) {
					//TODO handle the exception
				}
			},
			order(e) {
				uni.pro.navigateTo('my/order/index', {
					e: 0
				})
			}
		}
	}
</script>

<style lang="scss">
	page {
		background: #F9F9F9;
	}

	.content {
		padding: 32rpx 28rpx;

		.towcontentitem {
			margin-top: 22rpx;
			width: 100%;
			position: relative;
			padding: 32rpx;
			border-radius: 12rpx;

			.fourcontentitemabsolute {
				z-index: 9;
				position: absolute;
				right: 0;
				top: 0;
				padding: 6rpx 28rpx;
				font-size: 20rpx;
				font-family: Source Han Sans CN-Medium, Source Han Sans CN;
				font-weight: 500;
				color: #FFFFFF;
				text-shadow: 0px 6rpx 12rpx rgba(255, 255, 255, 0.19);
				background: linear-gradient(NaNdeg, #4A4A4A 0%, #919191 100%);
				border-radius: 0px 12rpx 0px 12rpx;
				opacity: 1;
			}

			.towcontentitemimage {
				top: 0;
				left: 0;
				position: absolute;
				width: 100%;
				height: 100%;
				border-radius: 12rpx;
				z-index: 0;
			}

			.towcontentitemone {
				width: 100%;
				position: relative;
				z-index: 9;

				.towcontentitemoneimage {
					width: 76rpx;
					height: 76rpx;
					border-radius: 50%;
				}

				.towcontentitemoneabsolute {
					position: absolute;
					padding: 8rpx 44rpx;
					right: 0;
					font-size: 28rpx;
					font-family: Source Han Sans CN-Medium, Source Han Sans CN;
					font-weight: 500;
					color: #FFFFFF;
					background: linear-gradient(130deg, #F4AE46 0%, #EE9437 100%);
					box-shadow: 0px 4rpx 8rpx 2rpx rgba(243, 169, 67, 0.37);
					border-radius: 28rpx;
				}

				.towcontentitemonetext {
					width: 80%;
					height: 76rpx;
					margin-left: 16rpx;

					.towcontentitemonetextone {
						width: 80%;
						overflow: hidden;
						white-space: nowrap;
						text-overflow: ellipsis;
						font-size: 32rpx;
						font-family: Source Han Sans CN-Medium, Source Han Sans CN;
						font-weight: 500;
						color: #422A07;
					}

					.towcontentitemonetexttow {
						width: 80%;
						overflow: hidden;
						white-space: nowrap;
						text-overflow: ellipsis;
						width:400rpx;
						font-size: 24rpx;
						font-family: Source Han Sans CN-Regular, Source Han Sans CN;
						font-weight: 400;
						color: #422A07;
					}

				}
			}

			.towcontentitemprogressa {
				padding: 8rpx 44rpx;
				width: 50%;
				z-index: 10;
				position: relative;
				margin-top: 54rpx;
			}

			.towcontentitemprogress {
				position: relative;
				z-index: 99;
				margin-top: 24rpx;
				border-radius: 28rpx;
				font-size: 28rpx;
				font-family: Source Han Sans CN-Bold, Source Han Sans CN;
				font-weight: bold;
				color: #000;
			}

			.towcontentitemtow {
				z-index: 10;
				position: relative;
				margin-top: 68rpx;
				font-size: 24rpx;
				font-family: Source Han Sans CN-Regular, Source Han Sans CN;
				font-weight: 400;
				color: #422A07;
			}
		}

		.therecontentitem {
			margin-top: 32rpx;
			width: 100%;
			padding: 32rpx 32rpx 0 32rpx;
			background: #FFFFFF;
			border-radius: 24rpx;

			.therecontentitemtext {
				font-size: 32rpx;
				font-family: PingFang SC-Bold, PingFang SC;
				font-weight: bold;
				color: #333333;
			}

			.therecontentitemone {
				.therecontentitemoneiten:nth-child(1) {
					border-top: none !important;
				}

				.therecontentitemoneiten {
					padding: 32rpx 0;
					border-top: 1px solid #F7F7F7;

					.therecontentitemoneitentetxt {
						font-size: 28rpx;
						font-family: PingFang SC-Regular, PingFang SC;
						font-weight: 400;
						color: #333333;
					}
				}
			}
		}

		.warp {
			position: relative;
			height: 100%;

			.rect {
				position: absolute;
				bottom: 0;
				width: 100%;
				background: #FFFFFF;
				border-radius: 60rpx 60rpx 0px 0px;
				padding: 48rpx 32rpx 32rpx 32rpx;

				.onerect {
					position: relative;
					padding-bottom: 48rpx;

					image {
						width: 124rpx;
						height: 124rpx;
					}

					view {
						margin-left: 16rpx;
						font-size: 32rpx;
						font-family: Source Han Sans CN-Medium, Source Han Sans CN;
						font-weight: 500;
						color: #1A1A1A;
					}

					.onerecticon {
						position: absolute;
						top: 0;
						right: 0;
					}
				}

				.towrect {
					font-size: 32rpx;
					font-family: PingFang SC-Bold, PingFang SC;
					font-weight: bold;
					color: #333333;
				}

				.thererect {
					margin-top: 16rpx;

					.thererectone {
						font-size: 28rpx;
						font-family: PingFang SC-Regular, PingFang SC;
						font-weight: 400;
						color: #333333;
					}

					.thererecttow {
						text {
							font-size: 16rpx;
						}

						font-size: 32rpx;
						font-family: PingFang SC-Heavy,
						PingFang SC;
						font-weight: 800;
						color: #333333;
					}

				}

				.fourrect {
					margin-top: 44rpx;

					.fourrectone {
						text {
							font-size: 24rpx;
							color: #333333;
						}

						font-size: 40rpx;
						font-family: PingFang SC-Bold,
						PingFang SC;
						font-weight: bold;
						color: #FC5F69;
					}

					.fourrecttow {
						background: linear-gradient(143deg, #8689AF 0%, #494A5F 100%);
						border-radius: 34rpx;
						padding: 10rpx 44rpx;
						font-size: 32rpx;
						font-family: PingFang SC-Bold, PingFang SC;
						font-weight: bold;
						color: #FFFFFF;
					}
				}
			}
		}

	}
</style>