修改商城

This commit is contained in:
szz
2025-07-28 12:22:11 +08:00
parent 6da8ea34cb
commit 05639f3e5b
42 changed files with 628 additions and 368 deletions

View File

@@ -34,7 +34,8 @@
/>
</el-form-item>
<el-form-item prop="smsCode">
<!-- 短信验证码组件 - 已注释 -->
<!-- <el-form-item prop="smsCode">
<div class="sms-code-group">
<el-input
v-model="registerForm.smsCode"
@@ -55,7 +56,7 @@
{{ smsCountdown > 0 ? `${smsCountdown}s后重发` : '发送验证码' }}
</el-button>
</div>
</el-form-item>
</el-form-item> -->
<el-form-item prop="registrationCode">
<el-input
@@ -191,17 +192,17 @@ const registerForm = reactive({
password: '',
confirmPassword: '',
captcha: '',
smsCode: '',
// smsCode: '', // 短信验证码字段 - 已注释
agreement: false
})
// 短信验证码相关状态
const sendingSMS = ref(false)
const smsCountdown = ref(0)
const canSendSMS = computed(() => {
const phoneRegex = /^1[3-9]\d{9}$/
return phoneRegex.test(registerForm.phone)
})
// 短信验证码相关状态 - 已注释
// const sendingSMS = ref(false)
// const smsCountdown = ref(0)
// const canSendSMS = computed(() => {
// const phoneRegex = /^1[3-9]\d{9}$/
// return phoneRegex.test(registerForm.phone)
// })
// 自定义验证函数
const validateUsername = (rule, value, callback) => {
@@ -263,12 +264,14 @@ const registerRules = {
],
registrationCode: [
{ required: true, message: '请输入激活码', trigger: 'blur' },
{ min: 6, message: '激活码长度不能少于6位', trigger: 'blur' }
],
smsCode: [
{ required: true, message: '请输入短信验证码', trigger: 'blur' },
{ pattern: /^\d{6}$/, message: '短信验证码为6位数字', trigger: 'blur' }
{ len: 6, message: '激活码长度6位', trigger: 'blur' },
{ pattern: /^[A-Z0-9]{6}$/, message: '激活码只能包含大写字母和数字', trigger: 'blur' }
],
// 短信验证码验证规则 - 已注释
// smsCode: [
// { required: true, message: '请输入短信验证码', trigger: 'blur' },
// { pattern: /^\d{6}$/, message: '短信验证码为6位数字', trigger: 'blur' }
// ],
password: [{ validator: validatePassword, trigger: 'blur' }],
confirmPassword: [{ validator: validateConfirmPassword, trigger: 'blur' }],
@@ -279,52 +282,52 @@ const registerRules = {
agreement: [{ validator: validateAgreement, trigger: 'change' }]
}
// 发送短信验证码
const sendSMSCode = async () => {
if (!canSendSMS.value || sendingSMS.value || smsCountdown.value > 0) {
return
}
try {
sendingSMS.value = true
const response = await fetch('/api/sms/send', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
phone: registerForm.phone
})
})
const result = await response.json()
if (result.success) {
ElMessage.success('验证码发送成功,请查收短信')
// 开始倒计时
startCountdown()
} else {
ElMessage.error(result.message || '发送失败,请重试')
}
} catch (error) {
console.error('发送短信验证码失败:', error)
ElMessage.error('发送失败,请检查网络连接')
} finally {
sendingSMS.value = false
}
}
// 发送短信验证码 - 已注释
// const sendSMSCode = async () => {
// if (!canSendSMS.value || sendingSMS.value || smsCountdown.value > 0) {
// return
// }
//
// try {
// sendingSMS.value = true
//
// const response = await fetch('/api/sms/send', {
// method: 'POST',
// headers: {
// 'Content-Type': 'application/json'
// },
// body: JSON.stringify({
// phone: registerForm.phone
// })
// })
//
// const result = await response.json()
//
// if (result.success) {
// ElMessage.success('验证码发送成功,请查收短信')
// // 开始倒计时
// startCountdown()
// } else {
// ElMessage.error(result.message || '发送失败,请重试')
// }
// } catch (error) {
// console.error('发送短信验证码失败:', error)
// ElMessage.error('发送失败,请检查网络连接')
// } finally {
// sendingSMS.value = false
// }
// }
// 开始倒计时
const startCountdown = () => {
smsCountdown.value = 60
const timer = setInterval(() => {
smsCountdown.value--
if (smsCountdown.value <= 0) {
clearInterval(timer)
}
}, 1000)
}
// 开始倒计时 - 已注释
// const startCountdown = () => {
// smsCountdown.value = 60
// const timer = setInterval(() => {
// smsCountdown.value--
// if (smsCountdown.value <= 0) {
// clearInterval(timer)
// }
// }, 1000)
// }
// 处理注册
const handleRegister = async () => {
@@ -351,7 +354,7 @@ const handleRegister = async () => {
phone: registerForm.phone,
registrationCode: registerForm.registrationCode,
password: registerForm.password,
smsCode: registerForm.smsCode,
// smsCode: registerForm.smsCode, // 短信验证码 - 已注释
captchaId: captchaInfo.captchaId,
captchaText: captchaInfo.captchaText
}