<template>
	<view>
		<view class="vheigh"></view>
		<!-- 金额明细 -->
		<view class="yt-list">
			<view class="yt-list-cell b-b">
				<text class="cell-tit clamp">积分和钱抵扣</text>
				<view class="cell-tip"><radio @click="jf()" color=" #5dbc7c" :checked="integral" /></view>
			</view>
			<view class="yt-list-cell b-b">
				<text class="cell-tit clamp">{{ '（当前积分：' + integralAll + '）' }}{{ '（当前钱：' + integralyw + '）' }}</text>
			</view>
		</view>
		<view class="yt-list">
			<view class="yt-list-cell b-b">
				<text class="cell-tit clamp">支付金额</text>
				<text class="cell-tip">￥{{ info.price }}</text>
			</view>
			<view class="yt-list-cell b-b" v-if="integral">
				<text class="cell-tit clamp">积分抵扣</text>
				<text class="cell-tip">-￥{{ info.sy_integral }}</text>
			</view>
			<view class="yt-list-cell b-b" v-if="integral">
				<text class="cell-tit clamp">钱抵扣</text>
				<text class="cell-tip">-￥{{ info.sy_barter_integral }}</text>
			</view>
		</view>

		<!-- 底部 -->
		<view class="footer">
			<view class="price-content">
				<text>实付款</text>
				<text class="price-tip">￥</text>
				<text class="price">{{ info.pay_price }}</text>
			</view>
			<text class="submit" :class="{ submitNo: !payType }" @click="payType ? submit() : ''">提交订单</text>
		</view>

		<!-- 优惠券面板 -->
	</view>
</template>

<script>
import { calculation } from '@/api/order.js';
import { getUserInfo } from '@/api/user.js';
export default {
	data() {
		return {
			payType: true, //是否可支付
			store_id: '',
			info: {},
			integralAll: 0, //可使用的积分
			integralyw: 0, //可使用的易物积分
			integral: true //是否积分抵扣
		};
	},
	onLoad(opt) {
		this.price = opt.money;
		this.store_id = opt.id;
		this.loadData();
		this.getUserInfo();
	},
	methods: {
		loadData() {
			calculation({ price: this.price, store_id: this.store_id, integral: this.integral ? 1 : 0 }).then(({ data }) => {
				this.info = data;
			});
		},
		// 加载用户基础信息
		getUserInfo() {
			getUserInfo({}).then(({ data }) => {
				this.integralAll = data.integral;
				this.integralyw = data.barter_integral;
			});
		},
		jf() {
			this.integral = !this.integral;
			this.loadData;
		},
		submit() {
			let url = '/pages/store/pay?key=' + this.info.cache + '&money=' + this.info.pay_price;
			uni.navigateTo({
				url
			});
		}
	}
};
</script>

<style lang="scss">
page {
	background: #fff;
	padding-bottom: 100rpx;
}
.vheigh {
	height: var(--status-bar-height);
	background-color: #fff;
}
.yt-list {
	margin-top: 16rpx;
	background: #fff;
}
.yt-list-cell {
	display: flex;
	align-items: center;
	padding: 10rpx 30rpx 10rpx 40rpx;
	line-height: 70rpx;
	position: relative;

	&.cell-hover {
		background: #fafafa;
	}

	&.b-b:after {
		left: 30rpx;
	}

	.cell-icon {
		height: 32rpx;
		width: 32rpx;
		font-size: 22rpx;
		color: #fff;
		text-align: center;
		line-height: 32rpx;
		background: #f85e52;
		border-radius: 4rpx;
		margin-right: 12rpx;

		&.hb {
			background: #ffaa0e;
		}

		&.lpk {
			background: #3ab54a;
		}
	}

	.cell-more {
		align-self: center;
		font-size: 24rpx;
		color: $font-color-light;
		margin-left: 8rpx;
		margin-right: -10rpx;
	}

	.cell-tit {
		flex: 1;
		font-size: 26rpx;
		color: $font-color-light;
		margin-right: 10rpx;
	}

	.cell-tip {
		font-size: 26rpx;
		color: $font-color-dark;
		&.disabled {
			color: $font-color-light;
		}
		&.active {
			color: $base-color;
		}
		&.red {
			color: $base-color;
		}
	}

	&.desc-cell {
		.cell-tit {
			max-width: 90rpx;
		}
	}
	.desc {
		flex: 1;
		text-align: right;
		font-size: $font-base;
		color: $font-color-dark;
	}
}

/* 支付列表 */
.pay-list {
	padding-left: 40rpx;
	margin-top: 16rpx;
	background: #fff;
	.pay-item {
		display: flex;
		align-items: center;
		padding-right: 20rpx;
		line-height: 1;
		height: 110rpx;
		position: relative;
	}
	.icon-weixinzhifu {
		width: 80rpx;
		font-size: 40rpx;
		color: #6bcc03;
	}
	.icon-alipay {
		width: 80rpx;
		font-size: 40rpx;
		color: #06b4fd;
	}
	.icon-xuanzhong2 {
		display: flex;
		align-items: center;
		justify-content: center;
		width: 60rpx;
		height: 60rpx;
		font-size: 40rpx;
		color: $base-color;
	}
	.tit {
		font-size: 32rpx;
		color: $font-color-dark;
		flex: 1;
	}
}

.footer {
	position: fixed;
	left: 0;
	bottom: 0;
	z-index: 995;
	display: flex;
	align-items: center;
	width: 100%;
	height: 90rpx;
	justify-content: space-between;
	font-size: 30rpx;
	background-color: #fff;
	z-index: 998;
	color: $font-color-base;
	box-shadow: 0 -1px 5px rgba(0, 0, 0, 0.1);
	.price-content {
		padding-left: 30rpx;
	}
	.price-tip {
		color: $font-color-base;
		margin-left: 8rpx;
	}
	.price {
		font-size: 36rpx;
		color: $font-color-base;
	}
	.submit {
		display: flex;
		align-items: center;
		justify-content: center;
		width: 280rpx;
		height: 100%;
		color: #fff;
		font-size: 32rpx;
		background-color: $base-color;
		&.submitNo {
			background-color: $font-color-disabled;
		}
	}
}

/* 优惠券面板 */
.mask {
	display: flex;
	align-items: flex-end;
	position: fixed;
	left: 0;
	top: var(--window-top);
	bottom: 0;
	width: 100%;
	background: rgba(0, 0, 0, 0);
	z-index: 9995;
	transition: 0.3s;
	.mask-content {
		width: 100%;
		max-height: 70vh;
		background: #f3f3f3;
		transform: translateY(100%);
		transition: 0.3s;
		overflow-y: scroll;
	}
	&.none {
		display: none;
	}
	&.show {
		background: rgba(0, 0, 0, 0.4);

		.mask-content {
			transform: translateY(0);
		}
	}
}

/* 优惠券列表 */
.coupon-item {
	display: flex;
	flex-direction: column;
	margin: 20rpx 24rpx;
	background: #fff;
	.con {
		display: flex;
		align-items: center;
		position: relative;
		height: 120rpx;
		padding: 0 30rpx;
		&:after {
			position: absolute;
			left: 0;
			bottom: 0;
			content: '';
			width: 100%;
			height: 0;
			border-bottom: 1px dashed #f3f3f3;
			transform: scaleY(50%);
		}
	}
	.left {
		display: flex;
		flex-direction: column;
		justify-content: center;
		flex: 1;
		overflow: hidden;
		height: 100rpx;
	}
	.title {
		font-size: 32rpx;
		color: $font-color-dark;
		margin-bottom: 10rpx;
	}
	.time {
		font-size: 24rpx;
		color: $font-color-light;
	}
	.right {
		display: flex;
		flex-direction: column;
		justify-content: center;
		align-items: center;
		font-size: 26rpx;
		color: $font-color-base;
		height: 100rpx;
	}
	.price {
		font-size: 44rpx;
		color: $base-color;
		&:before {
			content: '￥';
			font-size: 34rpx;
		}
	}
	.tips {
		font-size: 24rpx;
		color: $font-color-light;
		line-height: 60rpx;
		padding-left: 30rpx;
	}
	.circle {
		position: absolute;
		left: -6rpx;
		bottom: -10rpx;
		z-index: 10;
		width: 20rpx;
		height: 20rpx;
		background: #f3f3f3;
		border-radius: 100px;
		&.r {
			left: auto;
			right: -6rpx;
		}
	}
}
.personal {
	margin-top: 15rpx;
	display: flex;
	flex-direction: column;
	background-color: #ffffff;

	.box-right {
		width: 100%;
		font-size: 30rpx;
		text-align: right;
		padding-right: 25rpx;
	}

	.info {
		padding: 10rpx 25rpx;
		display: flex;
		align-items: center;
		font-size: 30rpx;
		justify-content: space-between;

		.name {
			width: 120rpx;
		}

		input {
			margin-left: 12rpx;
			width: 100%;
			// background-color: pink;
			display: block;
			color: #999999;
		}
	}
}
</style>
