feat(客户页面): 添加时间格式化工具并应用于剩余时间显示

在客户页面添加WXS时间格式化工具,将秒数转换为"天小时分秒"格式显示,提升时间展示的可读性
This commit is contained in:
maclien
2025-06-30 22:59:09 +08:00
parent a15e3cf220
commit 79d69cef3b
+17 -1
View File
@@ -1,3 +1,19 @@
<wxs module="tool">
var formatTime = function(time) {
// 总秒数
var totalSecond = Math.floor(time);
//天
var day = Math.floor(totalSecond / 3600 / 24);
// 小时
var hour = Math.floor(totalSecond / 3600);
// 分钟
var minute = Math.floor(totalSecond / 60) % 60;
// 秒
var second = totalSecond % 60;
return day + '天' + hour + '小时' + minute + '分' + second + '秒';
}
exports.formatTime = formatTime;
</wxs>
<view class="container">
<view>
@@ -75,7 +91,7 @@
<text class="text-middle font-26 color-666">({{item.mobile}})</text>
</view>
<view class="absolute right-0 top-0">
<view class="font-26 mt10" style="color:#f63c51">{{'距转派还剩'+item.left_time+'秒'}}</view>
<view class="font-26 mt10" style="color:#f63c51">{{'距转派还剩'+tool.formatTime(item.left_time)}}</view>
</view>
</view>
<view class="relative">