feat: 对接部分接口

This commit is contained in:
anonymous
2025-01-09 10:45:10 +08:00
parent 21d8f75f6a
commit e70ca852d8
17 changed files with 165 additions and 62 deletions
+30 -11
View File
@@ -39,13 +39,18 @@
<view class="flex items-center py-15">
<view class="text-gradient">验证码</view>
<input
v-model="formData.invitecode"
v-model="formData.captcha"
placeholder-class="text-#889BC6"
type="text"
class="text-right flex-1 text-14"
placeholder="请输入验证码"
/>
<image class="w-60 h-24 ml-15 bg-gray-400" mode="aspectFit" />
<image
:src="codeUrl"
class="w-100 h-30 ml-15 bg-gray-400"
mode="widthFix"
@click="refreshCode"
/>
</view>
</view>
<!-- <view class="ml-auto mr-0 w-fit text-gradient text-14 p-15" @click="handleEditPassword">
@@ -76,12 +81,16 @@ const userStore = useUserStore()
const formData = ref({
account: '',
password: '',
captcha: '',
})
const { codeUrl, refreshCode } = useCaptcha()
let redirect = '/'
onLoad((options) => {
redirect = options.redirect ?? '/'
})
onShow(refreshCode)
const handleLogin = async () => {
if (!formData.value.account || !formData.value.password) {
@@ -90,15 +99,25 @@ const handleLogin = async () => {
icon: 'none',
})
}
const {
data: {
userinfo: { token },
},
} = await loginUserAPI(formData.value)
userStore.setToken(token)
uni.reLaunch({
url: redirect,
})
if (!formData.value.captcha) {
return uni.showToast({
title: '请输入验证码',
icon: 'none',
})
}
try {
const {
data: {
userinfo: { token },
},
} = await loginUserAPI(formData.value)
userStore.setToken(token)
uni.reLaunch({
url: redirect,
})
} catch (error) {
refreshCode()
}
}
const handleRegister = () => {