2025-04-28 15:59:21 +08:00
|
|
|
const formatTime = date => {
|
|
|
|
const year = date.getFullYear()
|
|
|
|
const month = date.getMonth() + 1
|
|
|
|
const day = date.getDate()
|
|
|
|
const hour = date.getHours()
|
|
|
|
const minute = date.getMinutes()
|
|
|
|
const second = date.getSeconds()
|
|
|
|
|
|
|
|
return `${[year, month, day].map(formatNumber).join('/')} ${[hour, minute, second].map(formatNumber).join(':')}`
|
|
|
|
}
|
|
|
|
|
|
|
|
const formatNumber = n => {
|
|
|
|
n = n.toString()
|
|
|
|
return n[1] ? n : `0${n}`
|
|
|
|
}
|
|
|
|
|
2025-05-29 21:31:35 +08:00
|
|
|
const formatPassword = (pwd , currentPwd) => {
|
|
|
|
if (pwd === '') {
|
|
|
|
wx.showToast({
|
|
|
|
title: '密码不能为空',
|
|
|
|
icon: 'error'
|
|
|
|
})
|
2025-06-23 10:03:08 +08:00
|
|
|
return false;
|
2025-05-29 21:31:35 +08:00
|
|
|
}
|
2025-06-23 10:03:08 +08:00
|
|
|
if (pwd.length < 6 || pwd.length > 10) {
|
2025-05-29 21:31:35 +08:00
|
|
|
wx.showToast({
|
2025-06-23 10:03:08 +08:00
|
|
|
title: '密码长度必须在6-10位',
|
2025-05-29 21:31:35 +08:00
|
|
|
icon: 'error'
|
|
|
|
})
|
2025-06-23 10:03:08 +08:00
|
|
|
return false;
|
2025-05-29 21:31:35 +08:00
|
|
|
}
|
|
|
|
if (currentPwd === '') {
|
|
|
|
wx.showToast({
|
|
|
|
title: '请输入二次确认密码',
|
|
|
|
icon: 'error'
|
|
|
|
})
|
2025-06-23 10:03:08 +08:00
|
|
|
return false;
|
2025-05-29 21:31:35 +08:00
|
|
|
}
|
|
|
|
if (currentPwd !== pwd) {
|
|
|
|
wx.showToast({
|
|
|
|
title: '两次密码不一致',
|
|
|
|
icon: 'error'
|
|
|
|
})
|
2025-06-23 10:03:08 +08:00
|
|
|
return false;
|
2025-05-29 21:31:35 +08:00
|
|
|
}
|
2025-06-23 10:03:08 +08:00
|
|
|
// 纪文昊写的 密码必须包含字母和数字
|
|
|
|
const hasLetter = /[a-zA-z]/.test(pwd);
|
|
|
|
const hasNumber = /[0-9]/.test(pwd);
|
|
|
|
if (!hasLetter || !hasNumber) {
|
|
|
|
wx.showToast({
|
|
|
|
title: '密码必须包含字母和数字',
|
|
|
|
icon: 'none'
|
|
|
|
})
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
2025-05-29 21:31:35 +08:00
|
|
|
}
|
|
|
|
|
2025-04-28 15:59:21 +08:00
|
|
|
module.exports = {
|
2025-05-29 21:31:35 +08:00
|
|
|
formatTime,
|
|
|
|
formatPassword
|
2025-04-28 15:59:21 +08:00
|
|
|
}
|