mall-app-t/pages/index/redirect.vue

31 lines
672 B
Vue

<template>
<view>页面重定向</view>
</template>
<script setup>
import { onLoad } from '@dcloudio/uni-app'
import peach from '@/peach'
async function redirectFn() {
const userStore = peach.$store('user')
// 判断是否登录
if (!userStore.isLogin) {
userStore.logOut()
peach.$router.redirect('/pages/index/login')
} else {
await userStore.loginAfter()
if (userStore.lastRoutePage) {
peach.$router.redirect(userStore.lastRoutePage)
} else {
peach.$router.redirect('/pages/index/index')
}
}
}
onLoad(() => {
redirectFn()
})
</script>