<em id="09ttv"></em>
    <sup id="09ttv"><pre id="09ttv"></pre></sup>
    <dd id="09ttv"></dd>

        • 微信小程序實現倒計時,蘋果手機不顯示

          2018-8-30    seo達人

          如果您想訂閱本博客內容,每天自動發到您的郵箱中, 請點這里

          JS頁面代碼段:

          
              
          1. const app = getApp()
          2. let goodsList = [
          3. { actEndTime: '2018-07-21 21:00:34' },
          4. { actEndTime: '2028-07-17 21:00:37' },
          5. { actEndTime: '2018-09-21 05:00:59' },
          6. { actEndTime: '2018-08-19 07:00:48' },
          7. { actEndTime: '2018-08-28 03:00:11' }
          8. ]
          9. Page({
          10. data: {
          11. countDownList: [],
          12. actEndTimeList: []
          13. },
          14. onLoad: function () {
          15. let endTimeList = [];
          16. // 將活動的結束時間參數提成一個單獨的數組,方便操作
          17. goodsList.forEach(o => { endTimeList.push(o.actEndTime) })
          18. this.setData({ actEndTimeList: endTimeList });
          19. // 執行倒計時函數
          20. this.countDown();
          21. },
          22. //當時間小于兩位數時十位數補零。
          23. timeFormat: function (param) {//小于10的格式化函數
          24. return param < 10 ? '0' + param : param;
          25. },
          26. //倒計時函數
          27. countDown: function () {
          28. // 獲取當前時間,同時得到活動結束時間數組
          29. let newTime = new Date().getTime();//當前時間
          30. let endTimeList = this.data.actEndTimeList;//結束時間的數組集合
          31. let countDownArr = [];//初始化倒計時數組
          32. // 對結束時間進行處理渲染到頁面
          33. endTimeList.forEach(o => {
          34. let endTime = new Date(o).getTime();
          35. let obj = null;
          36. // 如果活動未結束,對時間進行處理
          37. if (endTime - newTime > 0) {
          38. let time = (endTime - newTime) / 1000;
          39. // 獲取天、時、分、秒
          40. let day = parseInt(time / (60 * 60 * 24));
          41. let hou = parseInt(time % (60 * 60 * 24) / 3600);
          42. let min = parseInt(time % (60 * 60 * 24) % 3600 / 60);
          43. let sec = parseInt(time % (60 * 60 * 24) % 3600 % 60);
          44. obj = {
          45. day: this.timeFormat(day),
          46. hou: this.timeFormat(hou),
          47. min: this.timeFormat(min),
          48. sec: this.timeFormat(sec)
          49. }
          50. } else {//活動已結束,全部設置為'00'
          51. obj = {
          52. day: '00',
          53. hou: '00',
          54. min: '00',
          55. sec: '00'
          56. }
          57. }
          58. countDownArr.push(obj);
          59. })
          60. //每隔一秒執行一次倒計時函數, 渲染
          61. this.setData({ countDownList: countDownArr })
          62. setTimeout(this.countDown, 1000);
          63. }
          64. })

          wxml頁面代碼段

          
              
          1. <view class='tui-countdown-content' wx:for="{{countDownList}}" wx:key="countDownList">
          2. 距結束
          3. <text class='tui-conutdown-box'>{{item.day}}</text>天
          4. <text class='tui-conutdown-box'>{{item.hou}}</text>時
          5. <text class='tui-conutdown-box'>{{item.min}}</text>分
          6. <text class='tui-conutdown-box tui-countdown-bg'>{{item.sec}}</text>秒
          7. </view>

           

          wxss頁面代碼段

          
              
          1. page{
          2. background: #f5f5f5;
          3. }
          4. .tui-countdown-content{
          5. height: 50px;
          6. line-height: 50px;
          7. text-align: center;
          8. background-color: #fff;
          9. margin-top: 15px;
          10. padding: 0 15px;
          11. font-size: 18px;
          12. }
          13. .tui-conutdown-box{
          14. display: inline-block;
          15. height: 26px;
          16. width: 26px;
          17. line-height: 26px;
          18. text-align: center;
          19. background:#ccc;
          20. color: #000;
          21. margin: 0 5px;
          22. }
          23. .tui-countdown-bg{
          24. background: red;
          25. color: #fff;
          26. }
          27. .container{
          28. width: 100%;
          29. display: flex;
          30. justify-content: center;
          31. }
          32. .backView{
          33. width:690rpx;
          34. background: #fff;
          35. display: flex;
          36. flex-direction: column;
          37. margin-bottom: 30rpx;
          38. }
          39. .createDate
          40. {
          41. background: #f5f5f5;
          42. padding:15rpx 15rpx 10rpx 15rpx;
          43. line-height: 50rpx;
          44. font-size: 28rpx;
          45. color: gainsboro;
          46. text-align: center;
          47. }
          48. .backViewitem1{
          49. display: flex;
          50. flex-direction: row;
          51. height: 55rpx;
          52. align-items: center;
          53. padding:8rpx 40rpx;
          54. border-bottom: 2rpx solid #f5f5f5;
          55. }
          56. .ico
          57. {
          58. width:35rpx;
          59. height:35rpx;
          60. }
          61. .name
          62. {
          63. color: #c13176;
          64. margin-left: 20rpx;
          65. font-size: 28rpx;
          66. }
          67. .details
          68. {
          69. font-size:24rpx;
          70. letter-spacing: 2rpx;
          71. }
          72. .backViewitem2{
          73. display: flex;
          74. flex-direction: row;
          75. line-height: 35rpx;
          76. min-height: 70rpx;
          77. padding: 15rpx 40rpx 10rpx 40rpx;
          78. border-bottom: 2rpx solid #f5f5f5;
          79. }
          80. .details1
          81. {
          82. color:#888;
          83. font-size:23rpx;
          84. letter-spacing: 2rpx;
          85. }

           藍藍設計www.sdgs6788.com )是一家專注而深入的界面設計公司,為期望卓越的國內外企業提供卓越的UI界面設計、BS界面設計 、 cs界面設計 、 ipad界面設計 、 包裝設計 、 圖標定制 、 用戶體驗 、交互設計、 網站建設 平面設計服務

          日歷

          鏈接

          個人資料

          藍藍設計的小編 http://www.sdgs6788.com

          存檔

          亚洲伊人久久综合影院| 久久久久国产精品熟女影院| 久久99热这里只有精品国产| 久久人人爽人人爽人人片AV麻豆 | 久久99精品国产一区二区三区| 91精品国产色综久久| 2019久久久高清456| 国产精品久久久久久吹潮| 青草久久久国产线免观| 国产精品免费福利久久| 久久久久久久免费视频| 青青草国产精品久久久久| 中文精品99久久国产| 国产精品日韩深夜福利久久| 久久精品国产亚洲AV嫖农村妇女| 草草久久久无码国产专区| 久久精品国产亚洲AV电影| 亚洲性久久久影院| 久久久久99精品成人片| 久久w5ww成w人免费| 久久久久久国产精品美女| 人妻无码精品久久亚瑟影视| 国产精品久久久久9999高清| 亚洲欧美日韩中文久久| 99久久免费国产精品特黄| 久久丝袜精品中文字幕| 精品久久久久一区二区三区| 91精品国产91热久久久久福利| 久久精品99久久香蕉国产色戒 | MM131亚洲国产美女久久| 国产免费久久精品99re丫y| 久久久久久国产精品美女| 精品无码久久久久久久久久| 精品综合久久久久久88小说| 2021国产成人精品久久| 精品国产综合区久久久久久| 国产成人精品久久亚洲高清不卡 国产成人精品久久亚洲高清不卡 国产成人精品久久亚洲 | 久久99中文字幕久久| 国产精品一区二区久久国产| 国产精品久久久久久福利69堂| 久久久久亚洲AV成人片|