美化了样式

This commit is contained in:
2025-08-15 00:36:04 +08:00
parent 5fc1378051
commit 1b4d3e310b
63 changed files with 2735 additions and 2411 deletions

View File

@ -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
};

View File

@ -25,7 +25,7 @@ const formatPassword = (pwd , currentPwd) => {
if (pwd.length < 6 || pwd.length > 10) {
wx.showToast({
title: '密码长度必须在6-10位',
icon: 'error'
icon: 'none'
})
return false;
}
@ -44,19 +44,38 @@ const formatPassword = (pwd , currentPwd) => {
return false;
}
// 纪文昊写的 密码必须包含字母和数字
const hasLetter = /[a-zA-z]/.test(pwd);
const hasNumber = /[0-9]/.test(pwd);
if (!hasLetter || !hasNumber) {
const isValid = /^[A-Za-z0-9]+$/.test(pwd); // 只能是数字和字母
if (!isValid) {
wx.showToast({
title: '密码必须包含字母和数字',
title: '密码只能包含字母和数字',
icon: 'none'
})
});
return false;
}
return true;
}
const notLogin = (msg) => {
if (msg === '无权限' || msg === 'token为空' || msg === 'token已过期' || msg === '用户不存在') {
wx.showToast({
title: '未登录',
icon: 'none'
})
setTimeout(() => {
wx.redirectTo({
url: '/pages/welcome/homePage/homePage',
})
}, 1000)
} else {
wx.showToast({
title: msg,
icon: 'none'
});
}
}
module.exports = {
formatTime,
formatPassword
formatPassword,
notLogin
}