微信支付

This commit is contained in:
2025-09-03 14:20:40 +08:00
parent 34c74d9ad8
commit 376f701422
6 changed files with 136 additions and 122 deletions

View File

@@ -181,7 +181,7 @@ const handleLogin = async () => {
const valid = await loginFormRef.value.validate()
if (!valid) return
// // 验证验证码
// 验证验证码
// const captchaValid = await captchaRef.value.verifyCaptcha(loginForm.captcha)
// if (!captchaValid) {
// loginForm.captcha = ''
@@ -199,12 +199,40 @@ const handleLogin = async () => {
captchaText: captchaInfo.captchaText
}
const result = await userStore.login(loginData)
if (result.success) {
// 登录成功,跳转到目标页面或转账管理
const redirectPath = route.query.redirect || '/mainpage'
router.push(redirectPath)
console.log('开始调用登录接口');
try {
const result = await userStore.login(loginData)
console.log('登录接口调用完成');
console.log(result,'result');
if (result.success) {
// 登录成功,跳转到目标页面或转账管理
const redirectPath = route.query.redirect || '/transfers'
router.push(redirectPath)
} else if (result.needPayment) {
// 用户需要支付激活,直接跳转到支付页面
ElMessage.info('账户尚未激活,正在跳转到支付页面...')
router.push({
path: '/payment',
query: {
userId: result.userId,
from: 'login'
}
})
}
} catch (loginError) {
console.error('登录调用异常:', loginError)
// 如果是支付相关的错误,也要处理
if (loginError.needPayment) {
ElMessage.info('账户尚未激活,正在跳转到支付页面...')
router.push({
path: '/payment',
query: {
userId: loginError.userId,
from: 'login'
}
})
}
}
} catch (error) {
console.error('登录失败:', error)
@@ -216,21 +244,6 @@ const handleLogin = async () => {
}
}
// 快速登录(演示用)
const quickLogin = async (type) => {
if (type === 'admin') {
loginForm.username = 'admin'
loginForm.password = 'admin123'
} else {
loginForm.username = 'user'
loginForm.password = 'user123'
}
// 清空验证码,让用户手动输入
loginForm.captcha = ''
ElMessage.info('请输入验证码后登录')
}
// 忘记密码
const showForgotPassword = () => {
ElMessageBox.alert(