feat: 接口对接完成

This commit is contained in:
anonymous
2025-01-03 16:44:05 +08:00
parent 0889d068a8
commit 2d19bbce4c
37 changed files with 1220 additions and 398 deletions
+96 -46
View File
@@ -1,4 +1,4 @@
<route lang="json5">
<route lang="json5" type="page">
{
style: {
navigationBarTitleText: '注册',
@@ -7,6 +7,94 @@
notNeedLogin: false,
}
</route>
<script lang="ts" setup>
import NavBar from '@/components/NavBar.vue'
import { isLogged } from '@/interceptors/route'
import { registerUserAPI } from '@/service'
import { useUserStore } from '@/store/user'
import { mergeStep } from '@/utils'
const userStore = useUserStore()
const form = ref({
username: '',
// member_nickname: '',
password: '',
retpassword: '',
invitecode: '',
tpassword: '',
rettpassword: '',
})
let redirect = '/'
onLoad((options) => {
redirect = options.redirect ?? '/'
form.value.invitecode = options.invitecode ?? ''
})
const handleRegister = mergeStep(async () => {
if (!form.value.username) {
uni.showToast({
title: '请输入用户名',
icon: 'none',
})
return
}
if (!form.value.password) {
uni.showToast({
title: '请输入登录密码',
icon: 'none',
})
return
}
if (form.value.password !== form.value.retpassword) {
uni.showToast({
title: '两次输入的密码不一致',
icon: 'none',
})
return
}
if (!form.value.tpassword) {
uni.showToast({
title: '请输入支付密码',
icon: 'none',
})
return
}
if (form.value.tpassword !== form.value.rettpassword) {
uni.showToast({
title: '两次输入的支付密码不一致',
icon: 'none',
})
return
}
// if (!form.value.invitecode) {
// uni.showToast({
// title: '请输入邀请码',
// icon: 'none',
// })
// return
// }
const {
data: {
userinfo: { token },
},
} = await registerUserAPI(form.value)
userStore.setToken(token)
uni.reLaunch({
url: redirect,
})
})
onLoad(async (options) => {
if (isLogged()) {
uni.reLaunch({
url: redirect,
})
}
form.value.invitecode = options.invite ?? ''
})
</script>
<template>
<view class="login-container relative">
<NavBar />
@@ -15,30 +103,17 @@
<view class="flex items-center py-15">
<image class="w-24 h-24" src="@/static/images/login/phone.png" mode="aspectFit" />
<input
v-model="form.username"
type="text"
placeholder-class="text-#889BC6"
class="text-right flex-1 text-14"
placeholder="请输入用户名"
/>
</view>
<view class="flex items-center py-15">
<image class="w-24 h-24" src="@/static/images/login/message.png" mode="aspectFit" />
<input
type="text"
placeholder-class="text-#889BC6"
class="text-right flex-1 text-14"
placeholder="请输入短信验证码"
/>
<view
class="py-6 rounded-full ml-15 px-15 text-12 text-white btn-gradient text-14 text-#889BC6"
@click="handleGetCode"
>
获取验证码
</view>
</view>
<view class="flex items-center py-15">
<image class="w-24 h-24" src="@/static/images/login/password.png" mode="aspectFit" />
<input
v-model="form.password"
placeholder-class="text-#889BC6"
type="password"
class="text-right flex-1 text-14"
@@ -48,6 +123,7 @@
<view class="flex items-center py-15">
<image class="w-24 h-24" src="@/static/images/login/password.png" mode="aspectFit" />
<input
v-model="form.retpassword"
placeholder-class="text-#889BC6"
type="password"
class="text-right flex-1 text-14"
@@ -57,6 +133,7 @@
<view class="flex items-center py-15">
<image class="w-24 h-24" src="@/static/images/login/password.png" mode="aspectFit" />
<input
v-model="form.tpassword"
placeholder-class="text-#889BC6"
type="password"
class="text-right flex-1 text-14"
@@ -66,6 +143,7 @@
<view class="flex items-center py-15">
<image class="w-24 h-24" src="@/static/images/login/password.png" mode="aspectFit" />
<input
v-model="form.rettpassword"
placeholder-class="text-#889BC6"
type="password"
class="text-right flex-1 text-14"
@@ -75,8 +153,9 @@
<view class="flex items-center py-15">
<image class="w-24 h-24" src="@/static/images/login/invite.png" mode="aspectFit" />
<input
v-model="form.invitecode"
placeholder-class="text-#889BC6"
type="password"
type="text"
class="text-right flex-1 text-14"
placeholder="请输入邀请码"
/>
@@ -92,35 +171,6 @@
</view>
</template>
<script lang="ts" setup>
import NavBar from '@/components/NavBar.vue'
import { isLogged } from '@/interceptors/route'
import { useUserStore } from '@/store/user'
const userStore = useUserStore()
let redirect = '/'
onLoad((options) => {
redirect = options.redirect ?? '/'
})
const handleRegister = () => {
userStore.setUserInfo({
token: '123456',
})
uni.reLaunch({
url: redirect,
})
}
onLoad(() => {
if (isLogged()) {
uni.reLaunch({
url: redirect,
})
}
})
</script>
<style lang="scss">
.login-container {
box-sizing: border-box;