<template>
	<view v-if="istrue" class="plr20 pay pos">
		
	</view>
</template>

<script>
	export default {
		data() {
			return {
				
			}
		},
		onLoad(options) {
			
		},
		computed: {
		
		},
		methods: {
			goover() {
				if (!this.ischeck) {
					uni.showToast({
						title: '请先勾选并阅读',
						icon: 'none'
					})
					return false
				}
				this.loading = true
				this.api.paymoney({
					orderNo: this.order_no,
					redirectUrl: "http://39.98.117.3/pages/pay/over"
				}).then((res) => {
					console.log(res)
					if (res.data.code == 200) {
						window.open(res.data.data, "_self");
					} else {
						uni.showToast({
							title: res.data.message,
							icon: "none"
						})
					}
				})
			},
			// 秒钟转分钟
			changs(times) {
				let durationMi = `${parseInt(times / 60)}`
				this.minutes = durationMi
				this.add()
			},
			add() {
				var _this = this;
				_this.istrue = true
				uni.hideLoading()
				var time = window.setInterval(function() {
					if (_this.seconds === 0 && _this.minutes !== 0) {
						_this.seconds = 59;
						_this.minutes -= 1;
					} else if (_this.minutes === 0 && _this.seconds === 0) {
						_this.seconds = 0;
						_this.timeShow = false;
						window.clearInterval(time);
						uni.showModal({
							title: '提示',
							content: '支付已超时！',
							showCancel: false,
							success: function(res) {
								if (res.confirm) {
									console.log('用户点击确定')
									uni.navigateBack({
										delta: 1,
									})
								} else {
									console.log('用户点击取消')
								}
							}
						})
					} else {
						_this.seconds -= 1;
					}
				}, 1000);
			},
			submit() {
				uni.showLoading({
					title: "提交中..."
				})
				this.api.creatorder(this.form).then((res) => {
					console.log(res)
					if (res.data.code == 200) {
						uni.hideLoading()
						// uni.showToast({
						// 	title: "提交成功",
						// 	icon: "none",
						// 	duration: 1200
						// })
						this.card_num = res.data.data.card_num
						this.discount = res.data.data.discount
						this.totalAmount = res.data.data.totalAmount
						this.name = res.data.data.product.name
						this.createorder()
						// let that = this
						// setTimeout(function() {
						// 	that.showpop = true
						// }, 1200);
					} else {
						uni.showToast({
							icon: "none",
							title: res.data.message
						})
					}
				})
			},
		}
	}
</script>

<style>
	page {
		background: #FAFAFA !important;
	}

	/deep/ uni-checkbox .uni-checkbox-input {
		width: 35rpx;
		height: 35rpx;
		border: 2rpx solid #5262E8;
		transform: rotateZ(360deg);
		background-color: rgba(255, 255, 255, 0) !important;
		pointer-events: none;
	}

	/deep/ uni-checkbox .uni-checkbox-input-checked {
		border: 2rpx solid #CACFFF !important;
		transform: rotateZ(360deg);
		background-color: #556FFE !important;
	}

	/deep/ uni-checkbox .uni-checkbox-input-checked::before {
		font-size: 12px !important;
		font-weight: bold;
		color: #fff;
	}
</style>