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