|
|
@@ -61,12 +61,15 @@
|
|
|
import { useDictApi } from '/@/api/system/dict'
|
|
|
import { getDictLabel, formatAmountYuan } from '/@/utils/other'
|
|
|
import { useClaimApi } from '/@/api/fund/claim'
|
|
|
+ import { useLoginApi } from '/@/api/login'
|
|
|
+ import { Local, Session } from '/@/utils/storage'
|
|
|
const storesUseUserInfo = useUserInfo()
|
|
|
- const { userInfos } = storeToRefs(storesUseUserInfo)
|
|
|
+ const { userInfos, openId, unionId } = storeToRefs(storesUseUserInfo)
|
|
|
const route = useRoute()
|
|
|
const router = useRouter()
|
|
|
const configApi = useConfigApi()
|
|
|
const fundApi = useFundApi()
|
|
|
+ const loginApi = useLoginApi()
|
|
|
const dictApi = useDictApi()
|
|
|
const claimApi = useClaimApi()
|
|
|
const serviceList = ref([])
|
|
|
@@ -171,7 +174,30 @@
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
- onMounted(() => {
|
|
|
+ onMounted(async () => {
|
|
|
+ // 进行openId登录
|
|
|
+ const code: string = route.query.code ? route.query.code.toString() : ''
|
|
|
+ console.log('11111111111111111111111')
|
|
|
+ let param = {
|
|
|
+ code: code,
|
|
|
+ unionId: unionId.value,
|
|
|
+ user_name: userInfos.value?.userName,
|
|
|
+ tenant: Local.get('Tenant'),
|
|
|
+ }
|
|
|
+
|
|
|
+ if (code) {
|
|
|
+ console.log('2222222222222222222222')
|
|
|
+ const [err, res]: ToResponse = await to(loginApi.weChatLogin(param))
|
|
|
+ if (err) {
|
|
|
+ // 跳转到登录页面
|
|
|
+ Local.remove('token')
|
|
|
+ router.push('/login')
|
|
|
+ return
|
|
|
+ }
|
|
|
+ // 存储 token 到浏览器缓存
|
|
|
+ Local.set('token', res?.data?.token)
|
|
|
+ }
|
|
|
+
|
|
|
const id = route.query.id ? +route.query.id : 0
|
|
|
getDict()
|
|
|
getFundDetail(id)
|