小程序每天弹窗1次

主要思路

1. 先对当天缓存

2. 再次点击或者获取的时候进行对比

 

// 是否当前日期
  isDay(){
    // 测试
    // let newDay = (new Date()).getMinutes();
    let newDay = (new Date()).getDate();  // 今天
    let lastDay = wx.getStorageSync("lastDay"); // 昨天
    let isClick = wx.getStorageSync("isClick") === false ? false : true ;  // 是否点击过 true:未存在值,点击,false已点击,或者
    console.log(newDay,lastDay,'----000----')
    
    if(lastDay && newDay === lastDay && isClick === false){
      return false ;    // 不存在或者当前页
    }else{
      return true
    }

  },

点击时

let nowDay = (new Date()).getDate() ;
        wx.setStorageSync("lastDay",nowDay) ; // 记录当前日
        this.setData({
          show:true
        })

 

弹窗内按钮

wx.setStorageSync("isClick",false); // 点击之前设置
posted @ 2023-01-18 13:08  Panax  阅读(160)  评论(0编辑  收藏  举报