From 8009a4ba941b544ef8a1d7a39f69f10581ba089c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E6=99=96?= Date: Mon, 11 Mar 2019 14:02:03 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A0=8D=E4=BB=B7=E5=88=B8=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E5=BC=80=E6=9E=AA=E6=97=B6=E9=97=B4=E9=99=90=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/coupon/detail/index.js | 47 ++++++++++++++++++++++++++++++++-- pages/coupon/detail/index.wxml | 1 + 2 files changed, 46 insertions(+), 2 deletions(-) diff --git a/pages/coupon/detail/index.js b/pages/coupon/detail/index.js index 61a3c9c..68aaf61 100644 --- a/pages/coupon/detail/index.js +++ b/pages/coupon/detail/index.js @@ -56,7 +56,12 @@ Page({ isSamePeople:true, statusText:'', isReceived:false, - receivedDisabled:false + receivedDisabled:false, + clock02: "00", + day02: "00", + hour02: "00", + min02: "00", + sec02: "00", }, phone: function (e) { let that = this; @@ -311,7 +316,37 @@ Page({ that.countdown(end_time); }, 1000) }, - + countdown02(end_time) { + let that = this; + var EndTime = end_time; + var NowTime = new Date().getTime(); + var total_micro_second = EndTime - NowTime || []; + // 渲染倒计时时钟 + let obj = that.dateformat(total_micro_second); + console.log(obj,111) + if (total_micro_second > 0) { + that.setData({ + clock02: obj, + day02: obj.a1, + hour02: obj.b1, + min02: obj.c1, + sec02: obj.d1, + }) + } else { + that.setData({ + clock02: "00", + day02: "00", + hour02: "00", + min02: "00", + sec02: "00", + showbutton1: false + }) + } + setTimeout(function () { + total_micro_second -= 1000; + that.countdown02(end_time); + }, 1000) + }, // 时间格式化输出,如11:03 25:19 每1s都会调用一次 dateformat(micro_second) { // 总秒数 @@ -381,6 +416,14 @@ Page({ title: "卡详情" }) } + var EndTime = res.data.validStartDate; + var NowTime = new Date().getTime(); + if (EndTime - NowTime>0){ + that.setData({ + showbutton1:true + }) + } + that.countdown02(res.data.validStartDate) if (res.data.endTime) { that.countdown(res.data.endTime); //当前时间与优惠券下架时间做计算 diff --git a/pages/coupon/detail/index.wxml b/pages/coupon/detail/index.wxml index 69bfcfe..0a69bc5 100644 --- a/pages/coupon/detail/index.wxml +++ b/pages/coupon/detail/index.wxml @@ -43,6 +43,7 @@ 剩余{{data.remainInventory}}件 + 砍价活动将于{{day02+'天'+hour02+':'+min02+':'+sec02}}后准时开始 有效期:自领取之日起 {{validDays}}天内有效 有效期: