rt-sim-training-client/src/views/components/pay/finish.vue

82 lines
2.0 KiB
Vue
Raw Normal View History

2019-07-26 13:32:43 +08:00
<template>
2019-08-29 17:16:33 +08:00
<el-card shadow="never">
<div style="width: 400px; margin-top:180px; margin-bottom:220px; margin-left: auto; margin-right: auto; text-align: center">
<div>
<template v-if="finishStatus === '02' || finishStatus === '03'">
<img :src=" images.img_pay_success" width=" 100px">
</template>
<template v-else>
<img :src="images.img_pay_fail" width=" 100px">
</template>
</div>
<div>
<span style="line-height: 30px;font-size: 14px;">{{ count }}s</span>
</div>
<div>
<a
href="#"
style="border-style: dashed; border-width: 1px; padding: 1px; border-color:darkgray; border-radius:5px;"
@click="finish"
>
<span v-if="finishStatus === '02'" style=" color: green;">{{ $t('global.paymentSuccessful') }}</span>
<span v-else-if="finishStatus === '03'" style=" color: green;">{{ $t('global.cancelSuccessfully') }}</span>
<span v-else style=" color: red;">{{ $t('global.paymentFailed') }}</span>
</a>
</div>
</div>
2019-07-26 13:32:43 +08:00
2019-08-29 17:16:33 +08:00
</el-card>
2019-07-26 13:32:43 +08:00
</template>
<script>
2019-08-29 17:16:33 +08:00
import img_pay_fail from '@/assets/pay_images/PayFail.png';
import img_pay_success from '@/assets/pay_images/PaySuccess.png';
export default {
name: 'FinishDraft',
props: {
finishStatus: {
type: String,
required: true
}
},
data() {
return {
count: 0,
maxTime: 5,
timer: null,
images: {
img_pay_fail,
img_pay_success
}
};
},
beforeDestroy() {
this.destroy();
},
methods: {
// 设置计时器maxTime后返回
createCountTimer() {
const that = this;
// 如果计时器已存在,则先注销
this.destroy();
// 重新创建定时器
if (this.timer == null) {
this.count = this.maxTime;
this.timer = setInterval(() => {
(that.count-- <= 0) && that.finish();
}, 1000);
}
},
// 返回到课程首页
finish() {
this.$emit('finish');
},
// 注销计时器
destroy() {
clearInterval(this.timer);
this.timer = null;
}
}
};
</script>