WeChat applet: camouflage the page to achieve the goal of regularly changing the content of the page

Step1: In app.js, import the util package to get the time

var util=require('/utils/util.js')

Step2: In app.js, add the onLaunch function to the following content:

  onLaunch: function () {
    
    
    var time='2022/05/22 13:00:00' //这个时间是预计审核通过后的时间
    var t=util.formatTime(new Date());
   
    this.globalData.ischeck = t<time?true:false
    console.log(this.globalData.ischeck)
    console.log(t)
  },

Step3: In app.js, add a variable to globalData;

ischeck:true,

Step4: Make the following modifications in the wxml that needs to camouflage the page:

<view wx:if="{
     
     {ischeck==false}}">
		 注:真正的界面内容,直接将之前的页面所有复制到这个框体下
</view>
<view wx:else>
	      注:给审核人员看的东西,加载ing,可以在wxss修改样式等
</view>

Step5: Import the app global in the js that needs to camouflage the page;

var app = getApp();

Step6: Add variables to the js data of the page that needs to be disguised;

ischeck:true,

Step7: Add the following content to the onLoad function of js that needs to disguise the page:

this.setData({
    
    
      ischeck:app.globalData.ischeck,
    })

So far the camouflaged page is complete, and before the set time, you can only see the camouflaged content!

Guess you like

Origin blog.csdn.net/weixin_46043195/article/details/125394254