The realization method of displaying the guide page, splash screen and login page of WeChat applet only once

1. Obtain global user information in the onLaunch life cycle function of the applet, and print the information:

Note: My index is a tabBar page, and splash is a normal page, so switchTab is used for tabBar page jump, and redirectTo is used for normal page.

2. According to the printing information, the conditional judgment jumps:

3. Complete code:

App({ 

  onLaunch: function() {
    var user = wx.getStorageInfoSync("userInfo");
    console.log(user)
    if (user.keys.length>0) {
      wx.switchTab({
        url: 'pages/index/index/index',
      })
    } else {
      wx.redirectTo({
        url: 'pages/splash/splash',
      })
    }
  },
})

4. For other similar requirements, you can make corresponding judgments to realize the jump based on the value you put in the local cache.

Guess you like

Origin blog.csdn.net/qq_29644709/article/details/89390127