美化了样式
This commit is contained in:
@ -1,50 +1,47 @@
|
||||
const { baseUrl } = require('./request');
|
||||
function checkLogin() {
|
||||
const token = wx.getStorageSync('token');
|
||||
try {
|
||||
const user = wx.getStorageSync('usermessage');
|
||||
if (!user || (typeof user === 'object' && Object.keys(user).length === 0)) {
|
||||
wx.showToast({
|
||||
title: '您未登录请先登录',
|
||||
icon:'error',
|
||||
duration:2000
|
||||
})
|
||||
setTimeout(() => {
|
||||
wx.navigateTo({
|
||||
url: '/pages/logain/logain',
|
||||
if (!token) {
|
||||
wx.redirectTo({
|
||||
url: '/pages/welcome/homePage/homePage',
|
||||
});
|
||||
}, 2000);
|
||||
}
|
||||
} catch (e) {
|
||||
wx.navigateTo({
|
||||
url: '/pages/logain/logain',
|
||||
wx.redirectTo({
|
||||
url: '/pages/welcome/homePage/homePage',
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function checkLogin2() {
|
||||
try {
|
||||
const user = wx.getStorageSync('usermessage');
|
||||
if (!user || (typeof user === 'object' && Object.keys(user).length === 0)) {
|
||||
wx.showToast({
|
||||
title: '您未登录请先登录',
|
||||
icon:'error',
|
||||
duration:2000
|
||||
})
|
||||
setTimeout(() => {
|
||||
wx.navigateTo({
|
||||
url: '/pages/logain/logain',
|
||||
});
|
||||
}, 2000);
|
||||
}
|
||||
} catch (e) {
|
||||
wx.navigateTo({
|
||||
url: '/pages/logain/logain',
|
||||
wx.request({
|
||||
url: baseUrl + '/userInfo/verify/token',
|
||||
method: 'POST',
|
||||
header: {
|
||||
'Authorization': token
|
||||
},
|
||||
success: res => {
|
||||
console.log('登录校验=======>', res.data)
|
||||
if (res.data.code === 1) {
|
||||
wx.switchTab({
|
||||
url: '/pages/course/homepage/homepage'
|
||||
})
|
||||
} else {
|
||||
wx.redirectTo({
|
||||
url: '/pages/welcome/homePage/homePage',
|
||||
});
|
||||
}
|
||||
},
|
||||
fail: () => {
|
||||
wx.redirectTo({
|
||||
url: '/pages/welcome/homePage/homePage',
|
||||
});
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
module.exports = {
|
||||
checkLogin, checkLogin2
|
||||
checkLogin
|
||||
};
|
||||
|
Reference in New Issue
Block a user