<template>
	<view class="content" :style="[theme]">
		<view class="towcontentitem">
			<image class="towcontentitemimage" :src="data.img" mode="aspectFill"></image>
			<view class="towcontentitemone flex-start">
				<view class="towcontentitemonetext flex-colum-start">
					<text class="towcontentitemonetextone" style="color: #fff;">{{data.title}}</text>
					<text class="towcontentitemonetexttow" style="color: #fff;">{{data.show}}</text>
				</view>
			</view>
			<view class="towcontentitemtow flex-between">
				<text class="towcontentitemtowetext" style="color: #fff;">￥{{data.price}}<text
						class="towcontentitemtowetexts" style="color: #fff;">/{{data.frequ}}次</text></text>
				<text class="towcontentitemtowetext_s" style="color: #fff;">{{data.end_time}}</text>
			</view>
		</view>
		<view class="therecontentitem">
			<view class="therecontentitemtext">
				商品
			</view>
			<view class="therecontentitemtextitem flex-between">
				<view class="therecontentitemtextitem_left">
					{{data.title}}
				</view>
				<view class="therecontentitemtextitem_right">
					￥{{data.price}}
				</view>
			</view>
			<view class="therecontentitemtextitemt_one">
				{{data.show}}
			</view>
			<view class="therecontentitemtext" style="margin-top: 14rpx;">
				权益
			</view>
			<view class="therecontentitemtextitemt_one">
				<text style="color: #333333;">{{data.frequ}}次</text>{{data.show}}
			</view>
		</view>
		<view class="therecontentitem">
			<view class="therecontentitem_tow flex-start">
				手机号码<text>{{data.mobile}}</text>
			</view>
			<view class="therecontentitem_tows">
				该号码不会提供给商家，仅用于接收平台通知信息
			</view>
		</view>
		<view class="therecontentitem">
			<view class="therecontentitemtext">
				使用说明
			</view>
			<view class="therecontentitemtextthere" style="margin-top: 14rpx;margin-bottom: 30rpx;"
				v-html="data.notice">

			</view>
		</view>
		<view class="fixedview flex-between">
			<view class="fixedview_one flex-start">
				<view class="fixedview_oneone">
					应付金额：
				</view>
				<view class="fixedview_onetow flex-colum-start">
					<text>￥{{data.price}}</text>
				</view>
			</view>
			<view class="fixedview_tow" @tap="$u.debounce(showpopupclick,1000)">
				立即付款
			</view>
		</view>
		<u-overlay :show="overlayshow" @click="overlayshow = false">
			<view class="warp">
				<view class="rect" @tap.stop>
					<view class="onerect flex-center">
						<view>【洗剪吹】新娘造型</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">
							年卡会员
						</view>
						<view class="thererecttow">
							<text>￥</text>300
						</view>
					</view>
					<view class="fourrect flex-between">
						<view class="fourrectone">
							<text>共计:</text>￥300
						</view>
						<view class="fourrecttow">
							立即购买
						</view>
					</view>
				</view>
			</view>
		</u-overlay>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				overlayshow: false,
				numberbox: "",
				data: {
					mobile: ''
				}
			}
		},
		computed: {
			theme() {
				return this.$store.getters.theme
			},
		},
		async onLoad(e) {
			console.log(e)
			let res = await this.api.reservationvipdetail({
				id: e.id
			})
			this.data = res
			this.data.notice = res.notice.replace(/\<img/g, '<img style="max-width:100%;height:auto" ');
			this.data.mobile = uni.cache.get('loginuser').userinfo.mobile
		},
		async onShow() {
			let res = await this.api.useruserinfo()
			uni.cache.set('loginuser', res);
		},
		mounted() {
			var query = uni.createSelectorQuery().in(this).select('.fixedview')
			query.boundingClientRect(ele => {
				var that = this;
				uni.getSystemInfo({
					success(res) {
						that.height = (ele.height) + "px";
						that = null;
					}
				})
			}).exec();
		},
		methods: {
			async showpopupclick() {
				if (!uni.cache.get('loginuser').userinfo.mobile) {
					uni.showModal({
						title: '提示',
						content: '确认订单需要获取您的手机号',
						success: function(res) {
							if (res.confirm) {
								uni.redirectTo({
									url: '/pages/my/setup/index'
								});
							} else if (res.cancel) {}
						}
					});
				} else {
					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: 5;
			}

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

				.towcontentitemoneimage {
					width: 76rpx;
					height: 76rpx;
				}

				.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 {
					margin-left: 16rpx;

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

					.towcontentitemonetexttow {
						width: 100%;
						overflow: hidden;
						text-overflow: ellipsis;
						white-space: nowrap;
						margin-top: 16rpx;
						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 {
				margin-top: 24rpx;
				background: linear-gradient(318deg, #6E6E6E 0%, #404040 100%);
				box-shadow: 0px 4rpx 8rpx 2rpx #8D8D8D;
				border-radius: 28rpx;
				font-size: 28rpx;
				font-family: Source Han Sans CN-Bold, Source Han Sans CN;
				font-weight: bold;
				color: #FFFFFF;
			}

			.towcontentitemtow {
				z-index: 10;
				position: relative;
				margin-top: 68rpx;
				font-size: 24rpx;

				.towcontentitemtowetext {
					font-size: 30rpx;
					font-family: Source Han Sans CN-Medium, Source Han Sans CN;
					font-weight: bold;
					color: #333333;

					.towcontentitemtowetexts {
						font-size: 20rpx;
						font-family: Source Han Sans CN-Medium, Source Han Sans CN;
						font-weight: 500;
						color: #333333;
					}
				}

				.towcontentitemtowetext_s {
					font-size: 24rpx;
					font-family: Source Han Sans CN-Medium, Source Han Sans CN;
					font-weight: 500;
					color: #333333;
				}

			}
		}

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

			.therecontentitem_tow {
				font-size: 32rpx;
				font-family: PingFang SC-Bold, PingFang SC;
				font-weight: bold;
				color: #999999;

				text {
					margin-left: 20rpx;
					font-size: 32rpx;
					font-family: PingFang SC-Bold, PingFang SC;
					font-weight: bold;
					color: #333333;
				}
			}

			.therecontentitem_tows {
				margin-top: 16rpx;
				font-size: 24rpx;
				font-family: PingFang SC-Bold, PingFang SC;
				font-weight: bold;
				color: #999999;
				padding-bottom: 30rpx;
			}

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

			.therecontentitemtextthere {
				font-size: 24rpx;
				font-family: PingFang SC-Regular, PingFang SC;
				font-weight: 400;
				color: #666666;
			}

			.therecontentitemtextitem {
				margin-top: 24rpx;

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

				.therecontentitemtextitem_right {
					font-size: 32rpx;
					font-family: Roboto-Bold, Roboto;
					font-weight: bold;
					color: #333333;
				}
			}

			.therecontentitemtextitemt_one {
				margin-top: 6rpx;
				font-size: 24rpx;
				font-family: PingFang SC-Regular, PingFang SC;
				font-weight: 400;
				color: #999999;
				padding-bottom: 16rpx;
				border-bottom: 1rpx dashed #F7F7F7;
			}
		}

		.fixedview {
			position: fixed;
			bottom: 0;
			left: 0;
			width: 100%;
			padding: 24rpx 28rpx;
			background: #FFFFFF;

			.fixedview_one {
				.fixedview_oneone {
					font-size: 28rpx;
					font-family: SourceHanSansCN-Bold-, SourceHanSansCN-Bold;
					font-weight: normal;
					color: #333333;
				}

				.fixedview_onetow {
					font-size: 44rpx;
					font-family: SourceHanSansCN-Bold-, SourceHanSansCN-Bold;
					font-weight: normal;
					color: #F45C4C;
					font-weight: bold;

					text {
						font-size: 28rpx;
					}
				}
			}

			.fixedview_tow {
				background: var(--bg-color-button);
				border-radius: 34rpx;
				padding: 10rpx 44rpx;
				font-size: 32rpx;
				font-family: PingFang SC-Bold, PingFang SC;
				font-weight: bold;
				color: #FFFFFF;
			}

		}

		.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>