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

首頁(yè) > 課堂 > 小程序 > 正文

微信小程序中顯示倒計(jì)時(shí)代碼實(shí)例

2020-03-21 15:57:01
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友

wxml文件中:

 <!--倒計(jì)時(shí) -->  <view class="countDownTimeView countDownAllView" >   <view class="voteText countDownTimeText">{{countDownDay}}天</view>   <view class="voteText countDownTimeText">{{countDownHour}}時(shí)</view>   <view class="voteText countDownTimeText">{{countDownMinute}}分</view>   <view class="voteText countDownTimeText">{{countDownSecond}}秒</view>  </view>

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' )  }); },  // 頁(yè)面渲染完成后 調(diào)用 onReady: function () {  var totalSecond = 1505540080 - 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  }); }})

效果圖:

微信小程序,倒計(jì)時(shí),代碼

以上所述是小編給大家介紹的微信小程序中顯示倒計(jì)時(shí)詳解整合,希望對(duì)大家有所幫助,如果大家有任何疑問(wèn)請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)VEVB武林網(wǎng)網(wǎng)站的支持!


發(fā)表評(píng)論 共有條評(píng)論
用戶(hù)名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 时尚| 清流县| 梧州市| 左贡县| 东宁县| 财经| 象山县| 衢州市| 阿城市| 都匀市| 玉环县| 宜黄县| 金乡县| 金川县| 华池县| 武穴市| 汉沽区| 定襄县| 噶尔县| 中牟县| 双江| 韶山市| 恭城| 温州市| 中西区| 祁连县| 高州市| 潍坊市| 寿宁县| 分宜县| 新密市| 太仓市| 利辛县| 乐清市| 绿春县| 临沭县| 马关县| 怀来县| 锦州市| 河南省| 锦州市|