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.
shop-app/pages/order/detail/components/StatusTips.vue

112 lines
2.6 KiB

3 years ago
<!--
* @Author: ch
* @Date: 2022-03-31 17:53:43
* @LastEditors: ch
3 years ago
* @LastEditTime: 2022-04-15 17:43:17
3 years ago
* @Description: file content
-->
<template>
<view class="status">
<image class="status--icon" :src="ctxCon.icon"></image>
<view class="status--name">{{ctxCon.name}}</view>
<view class="status--desc">{{ctxCon.tips}}</view>
</view>
</template>
<script>
export default {
props : {
orderInfo : {
type : Object,
default : {}
}
},
data(){
return {
ctxData : {
3 years ago
// 待付款
'1' : {name:'待付款', tips:'', icon: require('@/static/order/fk.png')},
// 关闭
'2' : {name:'交易关闭' , tips:'关闭原因', icon: require('@/static/order/qx.png')},
// 已支付
'3' : {name:'等待发货', tips:'您的包裹整装待发', icon: require('@/static/order/fh.png')},
// 已发货
'4' : {name:'已发货', tips:'您的包裹正向您飞来', icon: require('@/static/order/fh.png')},
// 已收货
'5' : {name:'已收货', icon: require('@/static/order/fh.png')},
// 已完成
'6' : {name:'交易成功', icon: require('@/static/order/cg.png')},
3 years ago
},
ctxCon : {},
3 years ago
startSecondNum : 0,
timerStop : null
3 years ago
}
},
watch : {
orderInfo(nVal){
3 years ago
const {orderStatus} = this.orderInfo;
this.ctxCon = this.ctxData[orderStatus];
if(orderStatus === '1'){
// 待支付 开始倒计时
if(this.timerStop){
clearTimeout(this.timerStop);
}
this.calcTimerStartSecondNum();
this.timer();
}else if(orderStatus === '2'){
3 years ago
this.ctxCon.tips = this.orderInfo.closeReason;
}
}
},
methods:{
/**
3 years ago
* 计算倒计时开始秒数
*/
calcTimerStartSecondNum(){
let expireTime = (new Date(this.orderInfo.expireTime)).getTime(),
curTime = (new Date(this.orderInfo.serverTime)).getTime(),
second = Math.floor((expireTime - curTime) / 1000);
this.startSecondNum = second > 0 ? second : 0;
},
/**
* 待付款的倒计时
3 years ago
*/
timer(){
3 years ago
if(this.startSecondNum == 0){
3 years ago
this.$emit('close');
return;
}
3 years ago
this.startSecondNum--;
let minute = parseInt(this.startSecondNum / 60);
let second = parseInt(this.startSecondNum % 60);
3 years ago
this.ctxCon.tips = `剩余${minute > 0 ? `${minute}` : ''} ${second}`;
3 years ago
this.timerStop = setTimeout(()=>this.timer(),1000)
3 years ago
}
}
}
</script>
<style lang="scss" scoped>
.status{
3 years ago
padding: 48rpx 60rpx 0;
margin-bottom: 48rpx;
min-height: 130rpx;
3 years ago
position: relative;
&--icon{
width: 100rpx;
height: 100rpx;
position: absolute;
right: 60rpx;
top: 10rpx;
}
&--name{
font-size: 36rpx;
margin-bottom: 20rpx;
}
&--desc{
font-size: $font-size-base;
color: $color-grey4;
3 years ago
margin-bottom: 48rpx;
}
}
</style>