li.shaoyi 2 years ago
parent
commit
25dc82acc4
2 changed files with 11 additions and 2 deletions
  1. 7 1
      src/packages/mobile/App.vue
  2. 4 1
      src/packages/mobile/views/user/login/index.vue

+ 7 - 1
src/packages/mobile/App.vue

@@ -1,8 +1,9 @@
 <template>
-  <router-view />
+  <router-view v-if="isRouterAlive" />
 </template>
 
 <script lang="ts" setup>
+import { shallowRef, nextTick } from 'vue'
 import { useNavigation } from '@/hooks/navigation'
 import { dialog } from '@/utils/vant'
 import { useLogin } from '@/business/login'
@@ -10,9 +11,14 @@ import eventBus from '@/services/bus'
 
 const { userLogout } = useLogin()
 const { backHomePage } = useNavigation()
+const isRouterAlive = shallowRef(true) // 用于页面重新渲染
 
 const quit = (showLogin = false) => {
+  isRouterAlive.value = false
   backHomePage({ tabName: 'home', showLogin })
+  nextTick(() => {
+    isRouterAlive.value = true
+  })
 }
 
 // 接收用户登出通知

+ 4 - 1
src/packages/mobile/views/user/login/index.vue

@@ -40,9 +40,11 @@ import { fullloading } from '@/utils/vant'
 import { ClientType } from '@/constants/client'
 import { useLogin } from '@/business/login'
 import { useNavigation } from '@/hooks/navigation'
+import { themeStore } from '@/stores'
 import service from '@/services'
 import plus from '@/utils/h5plus'
 
+const { getClientAgent } = themeStore.actions
 const { routerBack, routerTo } = useNavigation()
 const { formData, userLogin } = useLogin()
 const checked = shallowRef(false) // 是否同意协议管理
@@ -63,7 +65,8 @@ const navigationTo = (name: string) => {
 const formSubmit = () => {
   if (checked.value) {
     fullloading((hideLoading) => {
-      userLogin(ClientType.Android).then(() => {
+      const client = getClientAgent()
+      userLogin(client.isiPhone ? ClientType.IOS : client.isAndroid ? ClientType.Android : ClientType.PCTrade).then(() => {
         hideLoading()
         routerBack()
         showSuccessToast('登录成功')