In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces how Mini Program failed to get user information, the article is very detailed, has a certain reference value, interested friends must read it!
When using Mini Program, many people fail to authorize the license, but Mini Program does not launch the authorization information pop-up layer for the second time. In this case, we need to deal with it in this way for the sake of user experience:
Whether the function isEmptyObject (e) {/ / object is empty To determine whether it is the first authorization, remind var t; for (tin e) return! 1; return! 0} function checkSettingStatu (cb) {/ / Authorization processing var that = this; / / determine whether it is the first authorization, if the authorization fails, remind wx.getSetting ({success: function success (res) {var authSetting = res.authSetting) If (isEmptyObject (authSetting)) {/ / console.log ('first license');} else {/ / console.log ('not first license', authSetting) / / Notification if without authorization (authSetting ['scope.userInfo'] = false) {wx.showModal ({title:' user is not authorized', content:'if you need to use this Mini Program feature normally Please press OK and authorize user information on the settings page', showCancel: false, success: function (res) {/ / here in order to distinguish between clicking the mask to close or clicking the cancel button to close for the Android system, res.confirm is omitted. Res.cancel determines / / Click the mask layer to also trigger the opening setting wx.openSetting ({success: function success (res) {if (res.authSetting ['scope.userInfo'] = false) {checkSettingStatu (cb)) } else {userinfor ();}})});} function userinfor () {/ / get user information wx.login ({success: function (res) {var code = res.code) If (res.code) {wx.getUserInfo ({fail: function (res) {checkSettingStatu ();}, success: function (data) {var encryptedData = data.encryptedData; var iv = data.iv Wx.request ({url: 'XXXX', data: {"json": JSON.stringify ({"type": "small_wechat_new", "code": code, "encryptedData": encryptedData "iv": iv})}, method: 'POST', header: {' content-type': 'application/x-www-form-urlencoded'} Success: function (res) {/ / wx.setStorageSync ('user_id', res.data.data.user_id) / / wx.setStorageSync ('token', res.data.data.token); / / wx.setStorageSync (' avatar', res.data.data.avatar); / / wx.setStorageSync ('nickname', res.data.data.nickname) }})}})})} module.exports = {checkSettingStatu: checkSettingStatu, userinfor: userinfor} above is all the content of the article "how Mini Program failed to get user information". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow 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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.