| | |
| | | export function useUser() { |
| | | const userStore = useUserStore(); |
| | | |
| | | const { userDetail, userInfo, locationCity } = storeToRefs(userStore); |
| | | const { userDetail, userInfo, locationCity, virtualUserId } = storeToRefs(userStore); |
| | | |
| | | function updateUserInfo() { |
| | | return userStore.getCurrentUserInfo(); |
| | |
| | | userDetail: userDetail, |
| | | updateUserInfo, |
| | | locationCity, |
| | | virtualUserId, |
| | | }; |
| | | } |
| | | |
| | | export function useIsLogin() { |
| | | const { user, userDetail } = useUser(); |
| | | return computed(() => !!user.value); |
| | | // return user?.isPersonal ? !!user : !!user && !!enterpriseInfo; |
| | | const { virtualUserId } = useUser(); |
| | | // return computed(() => !!user.value); |
| | | return computed(() => !!virtualUserId.value); |
| | | } |
| | | |
| | | type UseAuthOptions = { |
| | |
| | | |
| | | Taro.useReady(async () => { |
| | | if (isLogin.value && userStore.firstGetUserDetail) { |
| | | userStore.getCurrentUserInfo(); |
| | | // userStore.getCurrentUserInfo(); |
| | | } |
| | | if (needAuth && !isLogin.value) { |
| | | Taro.navigateTo({ |