手机号格式错误视为登录不存在将会提示并重新跳转登录页面

main
Frontend-徐志烘 1 year ago
parent 6c81ac1f80
commit 9776537e59

@ -8,15 +8,25 @@ list.forEach((item) => {
invoke(e) {
const phonePattern = /^1[3456789]\d{9}$/;
let token;
if (phonePattern.test(common_vendor.index.getStorageSync("phoneNumber"))) {
token = common_vendor.index.getStorageSync("phoneNumber");
} else {
if (!phonePattern.test(common_vendor.index.getStorageSync("phoneNumber"))) {
common_vendor.index.showToast({
icon: "none",
title: "登录失败,请重新登录",
duration: 1e3
title: "登录不存在,请重新登录",
duration: 1e3,
success: () => {
setTimeout(() => {
common_vendor.index.showToast({
icon: "none",
title: "登录不存在,请重新登录",
duration: 800
});
}, 1e3);
}
});
}
if (phonePattern.test(common_vendor.index.getStorageSync("phoneNumber"))) {
token = common_vendor.index.getStorageSync("phoneNumber");
}
const url = e.url.split("?")[0];
if (!needLogin.includes(url) && !token) {
common_vendor.index.navigateTo({

@ -11,15 +11,24 @@ let needLogin = ['/pages/index/index','/pages/handle/handle','/pages/login/login
// 暂时将token验证替换手机号
const phonePattern = /^1[3456789]\d{9}$/;
let token
if(phonePattern.test(uni.getStorageSync('phoneNumber'))){
token=uni.getStorageSync('phoneNumber')
}else{
if(!phonePattern.test(uni.getStorageSync('phoneNumber'))){
uni.showToast({
icon:"none",
title:"登录失败,请重新登录",
duration:1000
title:"登录不存在,请重新登录",
duration:1000,
success: () => {
setTimeout(()=>{
uni.showToast({
icon:"none",
title:"登录不存在,请重新登录",
duration:800,})
},1000)
}
})
}
if(phonePattern.test(uni.getStorageSync('phoneNumber'))){
token=uni.getStorageSync('phoneNumber')
}
//获取当前页面路径即url去掉"?"和"?"后的参数)
// console.log(token,'router index token')

Loading…
Cancel
Save