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


    摘要

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

    需求: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:"#ffffff",        //设置16进制的颜色值哦   必须写的哦

                                       backgroundColor:"#ff0000"

                              });

                              break;

                     case 2:

                              that.setData({ });

                              wx.setNavigationBarColor({

                                       frontColor:"#ffffff",

                                       backgroundColor:"#ff0304"

                              });

                              break;

                    default:

                                 that.setData({ });

                                 wx.setNavigationBarColor({

                                            frontColor:"#ffffff",

                                            backgroundColor:"#ff0304"

                                  });

                                 break;

               }

    }

  • 相关阅读:
    深入理解Node.js垃圾回收与内存管理
    【File System】Node.js中文件操作模块File System
    【事件流】事件冒泡和事件捕获
    undefined 和null的区别?
    localStorage实现登录注册功能
    解刨for循环
    react中嵌入高德地图并Marker标点
    react页面中嵌入地图,标识出某个地点,使用插件react-amap
    react中使用antd的List组件,以及下载文件,List隔行变色
    公众号页面数据处理
  • 原文地址:https://www.cnblogs.com/liuqingxia/p/7722694.html
Copyright © 2020-2023  润新知