Did WeChat Mini Programs log in again after quitting and did not enter the login page resulting in the expiration of token?

my Mini Program, after opening it, first go to the-> login page and successfully log in to save the token obtained by the server to globalData (the expiration time of token is 1 hour), then go to the index page, and then exit Mini Program.
enter Mini Program after an hour. Mini Program directly entered the page of the last exit: index, did not go to login to get token,. The token saved in globalData before getting globalData is expired. How to deal with this problem?


when you enter Mini Program, you need to determine whether the token has expired. When you enter Mini Program, you will call aap.js,. It is best to write the acquisition token in app.js, so that when token expires, you can call


at any time.

solve

enter Mini Program in one hour-> enter Index page on exit-> request API-> token expiration-> pop-up prompt user-> user click OK-> Jump to login page

ideas

in fact, you can make the expiration of token into a general response process, which can be judged automatically every time the request is completed. If it expires, you will be prompted to log in again

.
Menu