Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How does HTML judge whether the login is invalid?

2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

Most people do not understand the knowledge points of this article "HTML how to judge whether the landing is invalid", so the editor summarizes the following content to you, detailed content, clear steps, and has a certain reference value. I hope you can get something after reading this article. Let's take a look at this "HTML how to determine whether the landing is invalid" article.

Varthat=this

NewPromise ((resolve,reject) = > {

/ / check whether the wx.login is invalid, and re-wx.login if it fails

Wx.checkSession ({

Success () {

Console.log ('code',wx.getStorageSync (' code'))

Console.log ('globalData',wx.getStorageSync (' globalData'))

/ / if Mini Program enters the foreground from the background again, it is worthwhile to save it with storage

/ / if you use this.globalData to save the data, the next time you enter the foreground from the background, the value is still empty.

}

Fail () {

Wx.login ({

Success (res) {

Wx.getUserInfo ({

Success (re) {

Wx.setStorageSync ('code',res.code)

That.globalData.code=res.code

That.globalData.userInfo=re.userInfo

Wx.setStorageSync ('globalData',that.globalData)

}

})

}

Fail:function (err) {

}

})

}

})

Resolve ()

}) .then ((res) = > {

Varcode=wx.getStorageSync ('code')

VarglobalData=wx.getStorageSync ('globalData')

})

First of all, wx.checkSession judges whether the login state of wx.login method is invalid or not.

Train of thought

Wx.checkSession ({

Success () {/ / the landing state is not invalid at this time, and you don't have to go to wx.login anymore.

/ / but according to my needs, I'm going to connect to the interface next. I need the login data, but how to get the data at this time?

1. If Mini Program enters the foreground from the background again, it is worthwhile to save it with storage.

two。 If you use this.globalData to save the data, the next time you enter the foreground from the background, will the value be empty?

Fail () {wx.login ()

}

})

The above is about the content of this article on "how to judge whether the login is invalid or not". I believe we all have a certain understanding. I hope the content shared by the editor will be helpful to you. If you want to know more about the relevant knowledge, please pay attention to the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report