国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > JavaScript > 正文

微信小程序顯示倒計(jì)時(shí)功能示例【測試可用】

2019-11-19 12:25:29
字體:
供稿:網(wǎng)友

本文實(shí)例講述了微信小程序顯示倒計(jì)時(shí)功能。分享給大家供大家參考,具體如下:

微信小程序中顯示倒計(jì)時(shí):

index.wxml:

<view class='countdown'>剩:<text style='color:#6B4EFD'> {{countDownDay}} </text> 天 <text style='color:#6B4EFD'>{{countDownHour}} </text> <text style='color:#6B4EFD'>{{countDownMinute}} </text> <text style='color:#6B4EFD'>{{countDownSecond}} </text></view>

index.js:

Page( { data: {  windowHeight: 654,  maxtime: "",  isHiddenLoading: true,  isHiddenToast: true,  dataList: {},  countDownDay: 0,  countDownHour: 0,  countDownMinute: 0,  countDownSecond: 0, }, //事件處理函數(shù) bindViewTap: function() {  wx.navigateTo( {   url: '../logs/logs'  }) }, onLoad: function() {  this.setData( {   windowHeight: wx.getStorageSync( 'windowHeight' )  }); }, // 頁面渲染完成后 調(diào)用 onReady: function () {  var totalSecond = Date.parse(new Date("2018/12/12")) / 1000 - Date.parse(new Date()) / 1000;  var interval = setInterval(function () {   // 秒數(shù)   var second = totalSecond;   // 天數(shù)位   var day = Math.floor(second / 3600 / 24);   var dayStr = day.toString();   if (dayStr.length == 1) dayStr = '0' + dayStr;   // 小時(shí)位   var hr = Math.floor((second - day * 3600 * 24) / 3600);   var hrStr = hr.toString();   if (hrStr.length == 1) hrStr = '0' + hrStr;   // 分鐘位   var min = Math.floor((second - day * 3600 *24 - hr * 3600) / 60);   var minStr = min.toString();   if (minStr.length == 1) minStr = '0' + minStr;   // 秒位   var sec = second - day * 3600 * 24 - hr * 3600 - min*60;   var secStr = sec.toString();   if (secStr.length == 1) secStr = '0' + secStr;   this.setData({    countDownDay: dayStr,    countDownHour: hrStr,    countDownMinute: minStr,    countDownSecond: secStr,   });   totalSecond--;   if (totalSecond < 0) {    clearInterval(interval);    wx.showToast({     title: '活動(dòng)已結(jié)束',    });    this.setData({     countDownDay: '00',     countDownHour: '00',     countDownMinute: '00',     countDownSecond: '00',    });   }  }.bind(this), 1000); }, //cell事件處理函數(shù) bindCellViewTap: function (e) {  var id = e.currentTarget.dataset.id;  wx.navigateTo({   url: '../babyDetail/babyDetail?id=' + id  }); }})

運(yùn)行結(jié)果如下圖所示:

 

希望本文所述對(duì)大家微信小程序開發(fā)有所幫助。

發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 张掖市| 阳东县| 康定县| 永胜县| 师宗县| 安顺市| 宿松县| 会泽县| 泗洪县| 齐齐哈尔市| 宝应县| 抚顺市| 仪征市| 甘泉县| 颍上县| 四会市| 息烽县| 大安市| 海原县| 湖北省| 和硕县| 全南县| 宁河县| 德化县| 青阳县| 保康县| 犍为县| 木兰县| 栖霞市| 久治县| 甘肃省| 天等县| 漳浦县| 巴塘县| 靖宇县| 敦化市| 福清市| 喀什市| 龙门县| 岳阳市| 长沙市|