| | |
| | | import Taro from '@tarojs/taro'; |
| | | import { object2query, LocationUtils } from '@12333/utils'; |
| | | import { ParkOrHRStatus, UserCertificationFrontStatus } from '@12333/constants'; |
| | | import * as userServices from '@12333/services/api/User'; |
| | | import { useQuery } from '@tanstack/vue-query'; |
| | | import { useQuery, useQueryClient } from '@tanstack/vue-query'; |
| | | import { MaybeRef } from 'vue'; |
| | | import { useRefeshDidShow } from '@12333/hooks/infiniteLoading'; |
| | | import * as userResumeServices from '@12333/services/apiV2/userResume'; |
| | | |
| | | export function useUser() { |
| | | const userStore = useUserStore(); |
| | | |
| | | const { userDetail, userInfo, locationCity } = storeToRefs(userStore); |
| | | const { userDetail, userInfo, locationCity, userId } = storeToRefs(userStore); |
| | | |
| | | function updateUserInfo() { |
| | | return userStore.getCurrentUserInfo(); |
| | |
| | | isCompanyAudited, |
| | | isCertified, |
| | | locationCity, |
| | | userId, |
| | | }; |
| | | } |
| | | |
| | |
| | | const router = Taro.useRouter(); |
| | | |
| | | Taro.useReady(async () => { |
| | | let res; |
| | | try { |
| | | res = await LocationUtils.getLocation(); |
| | | } catch (error) {} |
| | | if (isLogin.value && userStore.firstGetUserDetail) { |
| | | userStore.firstGetUserDetail = false; |
| | | if (LocationUtils.isProvinceChange(userStore.locationProvince)) { |
| | | userStore.resetState(); |
| | | } else { |
| | | userStore.getCurrentUserInfo(); |
| | | } |
| | | } |
| | | if (res?.result?.ad_info?.city && userStore.firstSetLocation) { |
| | | userStore.setLocationCity(res.result.ad_info.city, res.result.ad_info.province); |
| | | userStore.getCurrentUserInfo(); |
| | | } |
| | | if (needAuth && !isLogin.value) { |
| | | Taro.navigateTo({ |
| | |
| | | goLoginFn, |
| | | }; |
| | | } |
| | | |
| | | export function useUserResume() { |
| | | const { userId } = useUser(); |
| | | |
| | | const { data, refetch } = useQuery({ |
| | | queryKey: ['userResumeServices/getUserResume', userId], |
| | | queryFn: async () => { |
| | | return await userResumeServices.getUserResume( |
| | | { userId: userId.value }, |
| | | { |
| | | showLoading: false, |
| | | } |
| | | ); |
| | | }, |
| | | placeholderData: () => ({} as API.GetUserResumeQueryResult), |
| | | enabled: computed(() => !!userId.value), |
| | | }); |
| | | |
| | | return { |
| | | userResumeInfo: data, |
| | | refetch, |
| | | }; |
| | | } |
| | | |
| | | export function useUpdateResume() { |
| | | const queryClient = useQueryClient(); |
| | | |
| | | const updateUserResumeCredentials = () => { |
| | | return queryClient.invalidateQueries(['userResumeServices/getUserResumeCredentials']); |
| | | }; |
| | | |
| | | const updateUserResume = () => { |
| | | return queryClient.invalidateQueries(['userResumeServices/getUserResume']); |
| | | }; |
| | | |
| | | return { |
| | | updateUserResumeCredentials, |
| | | updateUserResume, |
| | | }; |
| | | } |