|
@ -12,7 +12,7 @@ |
|
|
<view class="u-progress-dot"></view> |
|
|
<view class="u-progress-dot"></view> |
|
|
<view class="u-progress-info"> |
|
|
<view class="u-progress-info"> |
|
|
<u-icon :name="orderStyle.icon" v-if="orderStyle.icon" size="30"></u-icon> |
|
|
<u-icon :name="orderStyle.icon" v-if="orderStyle.icon" size="30"></u-icon> |
|
|
<template v-else>{{ time }}</template> |
|
|
<template v-else>{{ computeDurationText() }}</template> |
|
|
</view> |
|
|
</view> |
|
|
</view> |
|
|
</view> |
|
|
</u-circle-progress> |
|
|
</u-circle-progress> |
|
@ -127,6 +127,39 @@ export default { |
|
|
return `是否要重新开始此任务`; |
|
|
return `是否要重新开始此任务`; |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
// 计算进行中状态剩余时间 |
|
|
|
|
|
// 预计结束时间 = realStart(实际开始) + planDuration(计划时长) |
|
|
|
|
|
// 剩余时间 = 预计结束时间 - 当前时间 |
|
|
|
|
|
// 剩余时间 = realStart + planDuration - Date.now() |
|
|
|
|
|
computeDurationText() { |
|
|
|
|
|
try { |
|
|
|
|
|
const { realStart, planDuration } = this.task; |
|
|
|
|
|
const leftTime = +realStart + +planDuration - Date.now(); // 剩余时间 |
|
|
|
|
|
console.log('leftTime: ', leftTime, this.$moment.duration(leftTime)); |
|
|
|
|
|
if (leftTime < 0) return '0'; |
|
|
|
|
|
const { years, months, days, hours, minutes, seconds, milliseconds } = this.$moment.duration(leftTime); |
|
|
|
|
|
let num = 0; |
|
|
|
|
|
let time = 'seconds'; |
|
|
|
|
|
if (years > 0) { |
|
|
|
|
|
num = years; |
|
|
|
|
|
} else if (months > 0) { |
|
|
|
|
|
num = months; |
|
|
|
|
|
} else if (days > 0) { |
|
|
|
|
|
num = days; |
|
|
|
|
|
} else if (hours > 0) { |
|
|
|
|
|
num = hours; |
|
|
|
|
|
} else if (minutes > 0) { |
|
|
|
|
|
num = minutes; |
|
|
|
|
|
} else if (seconds > 0) { |
|
|
|
|
|
num = seconds; |
|
|
|
|
|
} else if (milliseconds > 0) { |
|
|
|
|
|
num = milliseconds; |
|
|
|
|
|
} |
|
|
|
|
|
} catch (e) { |
|
|
|
|
|
//TODO handle the exception |
|
|
|
|
|
} |
|
|
|
|
|
}, |
|
|
}, |
|
|
}, |
|
|
}; |
|
|
}; |
|
|
</script> |
|
|
</script> |
|
|