feat(登录): 添加userid参数以支持用户登录验证
在登录流程中,新增userid参数以增强用户验证功能。修改了相关API和页面逻辑,确保在登录时能够正确传递和处理userid,提升系统的安全性和用户体验。
This commit is contained in:
parent
c4562333c0
commit
76f59685bd
14
src/App.vue
14
src/App.vue
|
@ -41,17 +41,23 @@ onMounted(() => {
|
||||||
if (token) {
|
if (token) {
|
||||||
ab98UserStore.setTokenLogin(token);
|
ab98UserStore.setTokenLogin(token);
|
||||||
|
|
||||||
tokenLogin(token).then(res => {
|
watch(
|
||||||
if (res && res.code == 0) {
|
() => wxStore.userid,
|
||||||
if (res.data.success) {
|
(newVal) => {
|
||||||
|
if (newVal && !ab98UserStore.isLogin) {
|
||||||
|
tokenLogin(ab98UserStore.tokenLogin, newVal).then(res => {
|
||||||
|
if (res?.code === 0 && res.data?.success) {
|
||||||
ab98UserStore.setTel(res.data.tel)
|
ab98UserStore.setTel(res.data.tel)
|
||||||
ab98UserStore.setUserInfo(res.data)
|
ab98UserStore.setUserInfo(res.data)
|
||||||
ab98UserStore.setIsLogin(true)
|
ab98UserStore.setIsLogin(true)
|
||||||
router.push('/')
|
router.push('/')
|
||||||
}
|
}
|
||||||
}
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
{ immediate: true }
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isAdmin == '1') {
|
if (isAdmin == '1') {
|
||||||
|
|
|
@ -55,10 +55,10 @@ export function logoutApi(token: string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** ab98Token登录 */
|
/** ab98Token登录 */
|
||||||
export function tokenLogin(token: string) {
|
export function tokenLogin(token: string, userid: string) {
|
||||||
return request<ApiResponseData<LoginData>>({
|
return request<ApiResponseData<LoginData>>({
|
||||||
url: '/wx/login/tokenLogin',
|
url: '/wx/login/tokenLogin',
|
||||||
method: 'get',
|
method: 'get',
|
||||||
params: { token }
|
params: { token, userid }
|
||||||
})
|
})
|
||||||
}
|
}
|
|
@ -56,4 +56,5 @@ export type VerifySmsParams = {
|
||||||
tel: string
|
tel: string
|
||||||
/** 验证码 */
|
/** 验证码 */
|
||||||
vcode: string
|
vcode: string
|
||||||
|
userid: string
|
||||||
}
|
}
|
|
@ -40,13 +40,15 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, onMounted } from 'vue'
|
import { ref, onMounted } from 'vue';
|
||||||
import { useRouter } from 'vue-router'
|
import { useRouter } from 'vue-router';
|
||||||
import { showSuccessToast, showFailToast } from 'vant'
|
import { showSuccessToast, showFailToast } from 'vant';
|
||||||
import { getTokenApi, sendSmsApi, verifySmsApi } from '@/common/apis/ab98'
|
import { getTokenApi, sendSmsApi, verifySmsApi } from '@/common/apis/ab98';
|
||||||
import { useAb98UserStore } from '@/pinia/stores/ab98-user'
|
import { useAb98UserStore } from '@/pinia/stores/ab98-user';
|
||||||
|
import { useWxStore } from '@/pinia/stores/wx';
|
||||||
|
|
||||||
const userStore = useAb98UserStore()
|
const userStore = useAb98UserStore();
|
||||||
|
const wxStore = useWxStore();
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
|
|
||||||
const form = ref({
|
const form = ref({
|
||||||
|
@ -108,7 +110,8 @@ const handleSubmit = async () => {
|
||||||
const { data } = await verifySmsApi({
|
const { data } = await verifySmsApi({
|
||||||
token: userStore.token,
|
token: userStore.token,
|
||||||
tel: form.value.tel,
|
tel: form.value.tel,
|
||||||
vcode: form.value.vcode
|
vcode: form.value.vcode,
|
||||||
|
userid: wxStore.userid
|
||||||
})
|
})
|
||||||
|
|
||||||
if (data.success) {
|
if (data.success) {
|
||||||
|
|
Loading…
Reference in New Issue