金诚优选前端代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

91 lines
2.2 KiB

<template>
<view>
<lf-nav title="等待用户支付" :showIcon="true" bgColor="#fff"></lf-nav>
<view style="height: 50rpx;"></view>
<lf-nocontent src="/static/images/empty.png" text="等待用户支付…"></lf-nocontent>
<view class="lf-row-center" style="margin-top: -100rpx;">
<countdown-time minute="2" second="0" :showDay="false" :showHour="false" color="#FF9D9D" splitorColor="#FF9D9D"></countdown-time>
</view>
</view>
</template>
<script>
import countdownTime from '@/components/uni-countdown/uni-countdown.vue';
export default {
components: {
countdownTime
},
data(){
return {
user_id: 0,
amount: 0,
timer: null,
num: 5,
count: 0,
overtime: false
}
},
onLoad(options){
this.user_id = options.user_id;
this.amount = options.amount;
this.startTimer();
},
onUnload(){
if(this.timer){
clearInterval(this.timer);
this.timer = null;
}
},
methods: {
startTimer(){
if(this.timer){
clearInterval(this.timer);
this.timer = null;
}
this.count++;
let max_date = 60 * 2; // 两分钟
let current_date = this.count * 5; // 当前秒数
if(current_date >= max_date){
this.overtime = true;
}
this.checkOrderPay();
this.timer = setInterval(() => {
this.num--;
if(this.num <= 0){
clearInterval(this.timer);
this.timer = null;
this.num = 5;
this.startTimer();
}
}, 1000);
},
checkOrderPay(){
let token = this.$cookieStorage.get('store_token');
this.$http.get({
api: 'api/supplier/offline/check_order_pay',
data: {
user_id: this.user_id
},
header: {
token: token
}
}).then(res => {
if(this.$isRight(res.data.data) && res.data.data.status == 2){
let url = '/pages/business/payment/paystate';
url += '?payState=1';
url += '&amount='+ this.amount;
this.$url(url, {type: 'redirect'});
}else if(this.overtime || (res.data.data && res.data.data.status == 3)){
let url = '/pages/business/payment/paystate';
url += '?payState=0';
this.$url(url, {type: 'redirect'});
}
})
}
}
}
</script>
<style lang="scss" scoped="scoped">
</style>