完善登录、收藏、分享
This commit is contained in:
@ -178,10 +178,11 @@
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import {OrderStatus} from '@/utils/order'
|
||||
import {toast} from '@/utils/toast'
|
||||
import { OrderStatus } from '@/utils/order'
|
||||
import { toast } from '@/utils/toast'
|
||||
import { useUserStore } from '@/store'
|
||||
import {snsapiBaseAuthorize} from '@/hooks/useWeiXin'
|
||||
import { getUrlCode, snsapiBaseAuthorize } from '@/hooks/useWeiXin'
|
||||
import { jump, NAVIGATE_TO } from '@/utils/tools'
|
||||
|
||||
const OSS = inject('OSS')
|
||||
const navbarHeight = inject('navbarHeight')
|
||||
@ -212,15 +213,33 @@
|
||||
const isClaimCoupon = ref<boolean>(false)
|
||||
|
||||
onShow(() => {
|
||||
const code = getUrlCode().code // 截取code
|
||||
const userStore = useUserStore()
|
||||
console.log("🚀 ~ userStore:", userStore.userInfo)
|
||||
if (userStore.userInfo.mobile) {
|
||||
userInfo.value = userStore.userInfo
|
||||
isLogin.value = true
|
||||
} else if (code && !userStore.userInfo.token) {
|
||||
// 这里是微信授权之后跳转回到本页面获取到code但是没有登录状态的话需要进行登录操作
|
||||
snsapiBaseAuthorize()
|
||||
}
|
||||
})
|
||||
|
||||
onLoad(() => {
|
||||
uni.$on('loginSuccess', () => {
|
||||
// 刷新用户信息
|
||||
console.log("🚀 ~ 刷新用户信息:")
|
||||
const userStore = useUserStore()
|
||||
if (userStore.userInfo.mobile) {
|
||||
userInfo.value = userStore.userInfo
|
||||
isLogin.value = true
|
||||
}
|
||||
// 你可以在这里做跳转或弹窗提示
|
||||
})
|
||||
})
|
||||
|
||||
onUnload(() => {
|
||||
uni.$off('loginSuccess')
|
||||
})
|
||||
|
||||
const My = {
|
||||
@ -254,16 +273,13 @@
|
||||
},
|
||||
|
||||
// 跳转到个人信息
|
||||
handleToProfile: () => {
|
||||
handleToProfile: async () => {
|
||||
if (isLogin.value) {
|
||||
uni.navigateTo({
|
||||
url: '/bundle/profile/profile'
|
||||
})
|
||||
} else {
|
||||
// 登录操作
|
||||
uni.navigateTo({
|
||||
url: '/bundle/vip/benefits'
|
||||
})
|
||||
await snsapiBaseAuthorize()
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user