微信支付
This commit is contained in:
@@ -173,22 +173,40 @@ const handleLogin = async () => {
|
||||
captchaText: captchaInfo.captchaText
|
||||
}
|
||||
|
||||
const result = await userStore.login(loginData)
|
||||
|
||||
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'
|
||||
}
|
||||
})
|
||||
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)
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -7,14 +7,6 @@
|
||||
</div>
|
||||
|
||||
<div class="payment-info">
|
||||
<div class="info-item">
|
||||
<span class="label">用户名:</span>
|
||||
<span class="value">{{ userInfo.username }}</span>
|
||||
</div>
|
||||
<div class="info-item">
|
||||
<span class="label">手机号:</span>
|
||||
<span class="value">{{ userInfo.phone }}</span>
|
||||
</div>
|
||||
<div class="info-item">
|
||||
<span class="label">支付金额:</span>
|
||||
<span class="value price">¥{{ paymentAmount }}</span>
|
||||
@@ -78,8 +70,7 @@ const paymentLoading = ref(false)
|
||||
const paymentStatus = ref('')
|
||||
const paymentAmount = ref(99) // 注册费用
|
||||
const userInfo = reactive({
|
||||
username: '',
|
||||
phone: ''
|
||||
userId: '',
|
||||
})
|
||||
|
||||
// 获取用户信息
|
||||
@@ -91,31 +82,6 @@ const getUserInfo = async () => {
|
||||
userInfo.phone = userStore.user.phone
|
||||
return
|
||||
}
|
||||
|
||||
// 如果store中没有用户信息,尝试从URL参数获取
|
||||
const token = route.query.token
|
||||
const userId = route.query.userId
|
||||
|
||||
if (token && userId) {
|
||||
// 设置临时token以获取用户信息
|
||||
const response = await api.get(`/users/${userId}`, {
|
||||
headers: {
|
||||
Authorization: `Bearer ${token}`
|
||||
}
|
||||
})
|
||||
|
||||
if (response.data.success) {
|
||||
userInfo.username = response.data.user.username
|
||||
userInfo.phone = response.data.user.phone
|
||||
}
|
||||
} else {
|
||||
// 如果没有URL参数,尝试获取当前用户信息
|
||||
const response = await api.get('/auth/me')
|
||||
if (response.data.success) {
|
||||
userInfo.username = response.data.user.username
|
||||
userInfo.phone = response.data.user.phone
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取用户信息失败:', error)
|
||||
ElMessage.error('获取用户信息失败')
|
||||
|
||||
Reference in New Issue
Block a user