<view class="pay_time">
<image src="{{imgUrls_pay_time}}"></image>
<text>支付剩余时间:</text>
<text>{{clock}} </text>
</view>
// pages/order/take_order/pay/pay.js
var app = getApp()
Page({
data: {
imgUrls_pay_time: '/image/icon_orderstatus_countdown.png',
"productName": "",
"productPrice": "",
"payDetail": [],
"wxPayMoneyDesc": "",
"expireTime": "",
clock: ''
},
onLoad: function (options) {
// 页面初始化 options为页面跳转所带来的参数
new app.WeToast()
var that = this;
that.count_down();
},
onReady: function () {
// 页面渲染完成
},
onShow: function () {
// 页面显示
},
onHide: function () {
// 页面隐藏
},
onUnload: function () {
// 页面关闭
},
/* 毫秒级倒计时 */
count_down: function () {
var that = this
//2016-12-27 12:47:08 转换日期格式
var a = that.data.expireTime.split(/[^0-9]/);
//截止日期:日期转毫秒
var expireMs = new Date(a[0], a[1] - 1, a[2], a[3], a[4], a[5]);
//倒计时毫秒
var duringMs = expireMs.getTime() - (new Date()).getTime();
// 渲染倒计时时钟
that.setData({
clock: that.date_format(duringMs)
});
if (duringMs <= 0) {
that.setData({
clock: "支付已截止,请重新下单"
});
// timeout则跳出递归
return;
}
setTimeout(function () {
// 放在最后--
duringMs -= 10;
that.count_down();
}
, 10)
},
/* 格式化倒计时 */
date_format: function (micro_second) {
var that = this
// 秒数
var second = Math.floor(micro_second / 1000);
// 小时位
var hr = Math.floor(second / 3600);
// 分钟位
var min = that.fill_zero_prefix(Math.floor((second - hr * 3600) / 60));
// 秒位
var sec = fill_zero_prefix(second % 60);// equal to => var sec = second % 60;
return hr + ":" + min + ":" + sec + " ";
},
/* 分秒位数补0 */
fill_zero_prefix: function (num) {
return num < 10 ? "0" + num : num
}
})
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有