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',
})
}
},
})