首页 > 其他 > 详细

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

时间:2017-10-24 11:41:58      阅读:291      评论:0      收藏:0      [点我收藏+]

摘要

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

 

需求: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;

           }

}

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

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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!