码迷,mamicode.com
首页 > 其他好文 > 详细

小程序-判断一天的不同时间段显示不同的内容

时间:2017-10-24 11:47:43      阅读:171      评论:0      收藏:0      [点我收藏+]

标签:on()   ons   摘要   style   bsp   内容   nba   bar   col   

摘要

好吧,判断一天的不同时间段显示不同的内容又是在我的项目中的一个需求,没办法呀,容易忘,还是写着吧

 

需求:1.把一天分为3个时间段,5:00-11:00    11:00-15:00   15:00-5:00

           2.不同的时间段顶部背景色颜色不同

onLoad:function(){

         var time = parseInt(new Data().getHours());    //返回小时数

          var times = 1;

          if(5 < time && time < 11){

               times = 1;

               console.log("早")

          }else if (11 <= time && time <15){

              times = 2;

               console.log("中")

          }else{

                times = 3;

                console.log("晚")

          }

          var that = this;

          switch (times){

                 case 1:

                           that.setData({ });

                          wx.setNavigationBarColor({

                                   frontColor:"#fff",

                                   backgroundColor:"#ff0000"

                          });

                          break;

                 case 2:

                          that.setData({ });

                          wx.setNavigationBarColor({

                                   frontColor:"#fff",

                                   backgroundColor:"#ff0304"

                          });

                          break;

                default:

                             that.setData({ });

                             wx.setNavigationBarColor({

                                        frontColor:"#fff",

                                        backgroundColor:"#ff0304"

                              });

                             break;

           }

}

小程序-判断一天的不同时间段显示不同的内容

标签:on()   ons   摘要   style   bsp   内容   nba   bar   col   

原文地址:http://www.cnblogs.com/liuqingxia/p/7722694.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!