当前位置:网站首页>微信小程序 登录失效后处理
微信小程序 登录失效后处理
2022-06-09 10:28:00 【一个假的前端男】
方法一、模态框
方法二、无痕登录
还是根据方法一的请求并发处理更改 直接修改
function success(res) {
console.log(res, '我成功了')
if (res.success) {
return res
} else {
if (!res.success && res.errCode == "USER50001") {
wx.removeStorage({
key: 'Authorization',
})
wx.removeStorage({
key: 'Cookie',
})
if (!getApp().globalData.isShowModel) {
getApp().globalData.isShowModel = true
// 过期方案一 模态框
// wx.showModal({
// title: "提示",
// content: '登录已过期,请重新登录!',
// success: function (res) {
// if (res.confirm) {
// wx.reLaunch({
// url: '/pages/login/index',
// })
// getApp().globalData.isShowModel = true
// } else if (res.cancel) {
// // console.log('用户点击取消');
// wx.reLaunch({
// url: '/pages/login/index',
// })
// getApp().globalData.isShowModel = true
// }
// }
// })
// 方案二 无痕登录
wx.login({
success: res => {
isLogin(res.code)
}
})
}
} else {
wx.showToast({
icon: 'none',
title: res.msg,
})
}
}
}
function isLogin(code) {
wx.request({
url: '', // 线上
method: 'post',
data: {
password: '',
isAutoLogin: false,
login_type: 'WECHAT_MINIAPP',
grant_type: 'password',
appId: "appid",
code: code,
username: '',
},
header: {
"Content-Type": "application/x-www-form-urlencoded",
'Cookie': '__wpkreporterwid_=20c31724-aeb1-4d85-0fa3-67166e6379cf; token=null',
'Authorization': 'Basic eXVuc2E6eXVuc2E='
},
success: function (res) {
if (res.data.success) {
// 直接保存 token
wx.setStorageSync('TaoLouToken', res.data.data.accessToken)
// 获取当前页
var page = getCurrentPages().pop();
if (page == undefined || page == null) return;
// 调用当前页的onload 进行刷新
page.onLoad(page.options)
// 延时 防止 多次请求
setTimeout(() => {
getApp().globalData.isShowModel = false
}, 60000)
}
},
fail: function (err) {
console.log(err)
}
})
}
边栏推荐
- 啥是腾讯PBD ,看我给讲讲
- 基于C语言实现的网络嗅探器设计课程设计
- 最新Camtasia 2022免费版电脑录屏工具
- Float float simulates double precision computation on CPU and GPU
- 论文阅读 (54):DeepFool: A Simple and Accurate Method to Fool Deep Neural Networks
- 【 tgcalls】 suivi et débogage des gestionnaires d'appels 2
- Qt-Char实现动态波形显示
- 三拾壹- NodeJS簡單代理池(合) 之 MongoDB 鏈接數爆炸了
- 论文阅读 (53):Universal Adversarial Perturbations
- One question per day -1200 Minimum absolute difference
猜你喜欢
[email protected]负载5-氟尿嘧啶|[email protected]装载5"/>[email protected]负载5-氟尿嘧啶|[email protected]装载5

肆拾伍- 正则表达式 (?=pattern) 以及 (?!pattern)

MOF-53NPs负载抗菌药物分子万古霉素(MOF金属有机骨架负载蛋白多肽类药物)

你知道多少,深度解析,值得收藏

哐哐英雄Clunky Hero v0.96中文版

Mof-53nps loaded antibacterial molecule vancomycin (MOF metal organic framework loaded protein polypeptide drugs)

Cyclodextrin metal organic framework( β- Cd-mof) loaded with dimercaptosuccinic acid( β- CD-MOF/DMSA) β- Drug loading mechanism of cyclodextrin metal organic framework

excel条件格式使用详细步骤

Forty five - regular expressions (? =pattern) and (?! pattern)

论文阅读 (54):DeepFool: A Simple and Accurate Method to Fool Deep Neural Networks
随机推荐
[go]实验包exp简介
C# 图片验证码简单例子
Openkruise v1.2: add persistentpodstate to realize stateful pod topology fixation and IP reuse
error NU1202: Package Volo.Abp.Cli 5.2.1 is not compatible with netcoreapp3.1
叁拾捌- JS 在 Canvas 上尝试分形图形 (二) 尝试造山画山 以及 角度几何基础
李宁抄底Clarks
三拾壹- NodeJS簡單代理池(合) 之 MongoDB 鏈接數爆炸了
Camtasia 2022最新版新增功能
[机缘参悟-20]:鬼谷子-反应篇-动静之术、说听结合、沉默是金
自己建设网站需要做哪些准备
中金财富开户安全吗
IDEA插件推荐:文件树增强,显示类注释
Learning fuzzy from SQL injection to bypass the latest safe dog WAF
【Pyhton 实战】---- 批量【端午节】海报下载
叁拾壹- NodeJS简单代理池(合) 之 MongoDB 链接数爆炸了
More than observation | Alibaba cloud observable Technology Summit officially launched
多线程系列之基本概念
EasyRecovery15免费版本数据恢复软件
How to realize face verification quickly and accurately?
Recursive and non recursive implementation of quick sorting of interview questions