<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. }

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

          日歷

          鏈接

          個人資料

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

          存檔

          亚洲国产另类久久久精品| 久久久久人妻一区精品| 91久久精品国产免费直播| 国产综合免费精品久久久| 久久亚洲国产成人影院网站| 97精品伊人久久大香线蕉| 久久国产高潮流白浆免费观看| 国产精品成人无码久久久久久 | 久久精品夜夜夜夜夜久久| 国产精品久久网| 一本色道久久综合狠狠躁| 久久久久久亚洲精品无码| 久久精品无码专区免费青青 | 久久免费小视频| 久久综合亚洲色一区二区三区| 久久国产乱子精品免费女| 色综合久久中文字幕综合网| 99久久99这里只有免费的精品| 久久久久久久女国产乱让韩| 久久国产精品视频| 99久久人妻无码精品系列| 久久精品免费全国观看国产| 久久精品国产免费| 久久精品国产一区| 99久久人妻无码精品系列蜜桃 | 久久亚洲熟女cc98cm| 精品无码久久久久久国产| 久久免费视频网站| 久久精品九九亚洲精品天堂 | 亚洲精品国产自在久久| 久久本道综合久久伊人| 精品久久久久久久中文字幕 | 久久91综合国产91久久精品| 亚洲av成人无码久久精品| 色婷婷综合久久久久中文| 丁香色欲久久久久久综合网| 久久精品国产精品亚洲精品| 无码AV波多野结衣久久| 久久精品中文闷骚内射| 国产欧美久久久精品| 99久久精品免费观看国产|