小程序检测用户是否授权过
isLogin() {
uni.login({
provider: "weixin",
success: (res) => {
this.$require({
url: "xxxxxxx",
data: {
code: res.code,
},
}).then((res) => {
if (res.code == 2 || res.code == 0) {
getApp().globalData.isLogin = false;
uni.setStorageSync("isLogin", "false"); //appid
} else {
getApp().globalData.isLogin = true;
uni.setStorageSync("userId", res.data.userId); //appid
uni.setStorageSync("username", res.data.nickName); //appid
uni.setStorageSync("userImg", res.data.avatarUrl); //appid
uni.setStorageSync("isLogin", "true"); //appid
}
});
},
});
},
本文来自博客园,作者:小万子呀,转载请注明原文链接:https://www.cnblogs.com/newBugs/p/16115324.html

浙公网安备 33010602011771号