更新:增加登录失败提示反馈问题;修改样式问题
This commit is contained in:
16
App.vue
16
App.vue
@@ -14,11 +14,15 @@
|
||||
|
||||
<style>
|
||||
@import "@/static/tailwind.css";
|
||||
.container {
|
||||
padding: 15px;
|
||||
}
|
||||
/* 覆盖 Tailwind 的默认 block 样式 */
|
||||
img, svg, video, canvas, audio, iframe, embed, object {
|
||||
display: inline-block;
|
||||
}
|
||||
.container {
|
||||
padding: 15px;
|
||||
}
|
||||
|
||||
button {
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
button {
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -99,6 +99,10 @@
|
||||
</button>
|
||||
</view>
|
||||
|
||||
<view class="loginHelp" v-if="submitClickNum > 0">
|
||||
<text>登录遇到问题?</text><text class="link" @click="onPageJump('/pages/user/workOrder?name=login')">去反馈</text>
|
||||
</view>
|
||||
|
||||
<!-- 切换登录方式 -->
|
||||
<view class="qie-huan">
|
||||
<view v-if="loginType === 2000" @click="changeLoginType(1000)">
|
||||
@@ -142,6 +146,7 @@ import { useUserStore } from '@/stores/user'
|
||||
import { loginWithCode, loginWithPassword } from '@/api/modules/auth'
|
||||
import { commonApi } from '@/api/modules/common'
|
||||
import { validateEmail } from '@/utils/validator'
|
||||
import { onPageJump } from '@/utils'
|
||||
|
||||
import { useI18n } from 'vue-i18n'
|
||||
const { t } = useI18n()
|
||||
@@ -178,6 +183,9 @@ const yszcText = ref<any>({
|
||||
|
||||
let codeTimer: any = null
|
||||
|
||||
// 提交点击次数
|
||||
const submitClickNum = ref(0)
|
||||
|
||||
/**
|
||||
* 切换登录方式
|
||||
* @param type 1000-密码登录,2000-验证码登录
|
||||
@@ -278,9 +286,13 @@ const verifyCodeLogin = async () => {
|
||||
|
||||
if (!isCodeEmpty()) return false
|
||||
|
||||
const res = await loginWithCode(email.value, code.value)
|
||||
|
||||
return res
|
||||
try {
|
||||
const res = await loginWithCode(email.value, code.value)
|
||||
return res
|
||||
} catch (error) {
|
||||
console.error('验证码登录失败:', error)
|
||||
return null
|
||||
}
|
||||
}
|
||||
// 密码登录
|
||||
const passwordLogin = async () => {
|
||||
@@ -288,11 +300,15 @@ const passwordLogin = async () => {
|
||||
|
||||
if (!isEmailVerified(phoneEmail.value)) return false
|
||||
|
||||
if (!isPasswordEmpty) return false
|
||||
if (!isPasswordEmpty()) return false
|
||||
|
||||
const res = await loginWithPassword(phoneEmail.value, password.value)
|
||||
|
||||
return res
|
||||
try {
|
||||
const res = await loginWithPassword(phoneEmail.value, password.value)
|
||||
return res
|
||||
} catch (error) {
|
||||
console.error('密码登录失败:', error)
|
||||
return null
|
||||
}
|
||||
}
|
||||
// 提交登录
|
||||
const onSubmit = async () => {
|
||||
@@ -309,11 +325,8 @@ const onSubmit = async () => {
|
||||
break
|
||||
}
|
||||
|
||||
console.log('res', res)
|
||||
|
||||
if (res && res.userInfo && res.token) {
|
||||
res.userInfo.token = res.token.token
|
||||
console.log('设置用户信息login', res.userInfo)
|
||||
userStore.setUserInfo(res.userInfo)
|
||||
uni.showToast({
|
||||
title: t('login.loginSuccess'),
|
||||
@@ -324,6 +337,9 @@ const onSubmit = async () => {
|
||||
url: '/pages/index/index'
|
||||
})
|
||||
}, 600)
|
||||
} else {
|
||||
// 登录失败时增加提交点击次数
|
||||
submitClickNum.value++
|
||||
}
|
||||
}
|
||||
|
||||
@@ -352,6 +368,7 @@ const onSetCode = async () => {
|
||||
getCodeState()
|
||||
} catch (error) {
|
||||
uni.hideLoading()
|
||||
submitClickNum.value++ // 发送验证码失败时增加提交点击次数
|
||||
console.error('Send code error:', error)
|
||||
}
|
||||
}
|
||||
@@ -664,4 +681,16 @@ onMounted(() => {
|
||||
line-height: 45rpx;
|
||||
}
|
||||
}
|
||||
.loginHelp{
|
||||
border: 1px solid #f5dab1;
|
||||
margin-top: 16rpx;
|
||||
font-size: 26rpx;
|
||||
text-align: center;
|
||||
padding: 10rpx;
|
||||
background-color: #fdf6ec;
|
||||
border-radius: 15rpx;
|
||||
.link{
|
||||
color: #e6a23c;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
--font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono",
|
||||
"Courier New", monospace;
|
||||
--color-red-500: oklch(63.7% 0.237 25.331);
|
||||
--color-emerald-600: oklch(59.6% 0.145 163.225);
|
||||
--ease-out: cubic-bezier(0, 0, 0.2, 1);
|
||||
--ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);
|
||||
--default-transition-duration: 150ms;
|
||||
|
||||
5
utils/index.ts
Normal file
5
utils/index.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
export const onPageJump = (path: string) => {
|
||||
uni.navigateTo({
|
||||
url: path
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user