feat: 接口对接完成
This commit is contained in:
+15
-11
@@ -19,7 +19,7 @@
|
||||
<image class="w-24 h-24" src="@/static/images/login/phone.png" mode="aspectFit" />
|
||||
<input
|
||||
type="text"
|
||||
v-model="formData.member_username"
|
||||
v-model="formData.account"
|
||||
placeholder-class="text-#889BC6"
|
||||
class="text-right flex-1 text-14"
|
||||
placeholder="请输入用户名"
|
||||
@@ -29,16 +29,16 @@
|
||||
<image class="w-24 h-24" src="@/static/images/login/password.png" mode="aspectFit" />
|
||||
<input
|
||||
placeholder-class="text-#889BC6"
|
||||
type="text"
|
||||
v-model="formData.member_password"
|
||||
type="password"
|
||||
v-model="formData.password"
|
||||
class="text-right flex-1 text-14"
|
||||
placeholder="请输入登录密码"
|
||||
/>
|
||||
</view>
|
||||
</view>
|
||||
<view class="ml-auto mr-0 w-fit text-gradient text-14 p-15" @click="handleEditPassword">
|
||||
<!-- <view class="ml-auto mr-0 w-fit text-gradient text-14 p-15" @click="handleEditPassword">
|
||||
忘记密码
|
||||
</view>
|
||||
</view> -->
|
||||
<view
|
||||
class="mt-30 text-center py-12 rounded-full mx-15 text-15 text-white btn-gradient"
|
||||
@click="handleLogin"
|
||||
@@ -57,12 +57,13 @@
|
||||
<script lang="ts" setup>
|
||||
import NavBar from '@/components/NavBar.vue'
|
||||
import { isLogged } from '@/interceptors/route'
|
||||
import { loginUserAPI } from '@/service'
|
||||
import { useUserStore } from '@/store/user'
|
||||
|
||||
const userStore = useUserStore()
|
||||
const formData = ref({
|
||||
member_username: '',
|
||||
member_password: '',
|
||||
account: '',
|
||||
password: '',
|
||||
})
|
||||
|
||||
let redirect = '/'
|
||||
@@ -71,15 +72,18 @@ onLoad((options) => {
|
||||
})
|
||||
|
||||
const handleLogin = async () => {
|
||||
if (!formData.value.member_username || !formData.value.member_password) {
|
||||
if (!formData.value.account || !formData.value.password) {
|
||||
return uni.showToast({
|
||||
title: '请输入用户名和密码',
|
||||
icon: 'none',
|
||||
})
|
||||
}
|
||||
userStore.setUserInfo({
|
||||
token: '123456',
|
||||
})
|
||||
const {
|
||||
data: {
|
||||
userinfo: { token },
|
||||
},
|
||||
} = await loginUserAPI(formData.value)
|
||||
userStore.setToken(token)
|
||||
uni.reLaunch({
|
||||
url: redirect,
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user