feat: 对接部分接口
This commit is contained in:
+30
-11
@@ -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 = () => {
|
||||
|
||||
Reference in New Issue
Block a user