1
0

5 Ревизии d43a7c0335 ... d371bec717

Автор SHA1 Съобщение Дата
  yuanmingze d371bec717 移除不必要的代码,优化页面加载逻辑,禁止外层滚动 преди 1 месец
  yuanmingze 3adfa194ea 修改小程序链接参数,统一环境版本为 'release' преди 1 месец
  yuanmingze 2a1d7e233c 新增提示信息和弹窗,优化电脑用户访问体验 преди 1 месец
  yuanmingze c994595bfd 修改微信跳转路由路径,从 '/wechat-redirect' 更改为 '/wxr' преди 1 месец
  yuanmingze cbe245676f 新增手机访问提示弹窗,优化非手机用户的跳转体验 преди 1 месец
променени са 3 файла, в които са добавени 37 реда и са изтрити 24 реда
  1. 1 1
      src/router/routes.ts
  2. 1 16
      src/views/register/index.vue
  3. 35 7
      src/views/wechat-redirect/index.vue

+ 1 - 1
src/router/routes.ts

@@ -67,7 +67,7 @@ export const routes: RouteRecordRaw[] = [
     meta: { title: '获取认证状态', requiresAuth: true },
   },
   {
-    path: '/wechat-redirect',
+    path: '/wxr',
     name: 'WechatRedirect',
     component: () => import('@/views/wechat-redirect/index.vue'),
     meta: { title: '路由跳转中', requiresAuth: false },

+ 1 - 16
src/views/register/index.vue

@@ -29,7 +29,7 @@
 </template>
 
 <script setup lang="ts">
-import { ref, onMounted, onUnmounted } from 'vue'
+import { ref, onMounted } from 'vue'
 import { useRouter } from 'vue-router'
 import { showFailToast } from 'vant'
 import { REGISTER_URL_KEY } from '@/constants/storage'
@@ -54,9 +54,6 @@ const onLoad = () => {
 }
 
 onMounted(() => {
-  // 禁止外层滚动,避免出现页面滚动条
-  document.body.style.overflow = 'hidden'
-
   if (props.src) {
     realSrc.value = props.src
     return
@@ -70,10 +67,6 @@ onMounted(() => {
     router.back()
   }
 })
-
-onUnmounted(() => {
-  document.body.style.overflow = ''
-})
 </script>
 
 <style lang="scss" scoped>
@@ -118,12 +111,4 @@ onUnmounted(() => {
     color: #999;
   }
 }
-
-/* 站点级兜底:去掉默认间距并禁掉页面滚动(scoped 下需 :global) */
-:global(html, body) {
-  margin: 0;
-  padding: 0;
-  overflow: hidden;
-  overscroll-behavior: none;
-}
 </style>

+ 35 - 7
src/views/wechat-redirect/index.vue

@@ -56,10 +56,18 @@
         <p>若长时间未跳转,请稍后重试</p>
       </div>
     </div>
+    <!-- 修改密码弹窗 -->
+    <ModernDialog
+      :closeOnClickOverlay="false"
+      v-model:show="showDialog"
+      title="提示"
+      :message="message"
+    />
   </div>
 </template>
 
 <script setup lang="ts">
+import ModernDialog from '@/components/ModernDialog.vue'
 import { computed, onBeforeUnmount, onMounted, ref } from 'vue'
 import { useRoute } from 'vue-router'
 import { showToast } from 'vant'
@@ -69,6 +77,8 @@ const route = useRoute()
 
 const progress = ref(10)
 
+const message = ref('')
+
 const getPushRecordId = (): string => {
   const { pushRecordId } = route.query
 
@@ -96,7 +106,7 @@ const getMiniappLinkParams = (redirectUrl: string) => {
   return {
     path: 'pages/index/index',
     query: `redirect=${encodeURIComponent(redirectUrl)}`,
-    envVersion: import.meta.env.VITE_APP_ENV === 'prod' ? 'release' : 'trial',
+    envVersion: 'release',
   } as const
 }
 
@@ -104,7 +114,8 @@ const redirectToMiniapp = async (): Promise<void> => {
   const pushRecordId = getPushRecordId()
 
   if (!pushRecordId) {
-    showToast('链接不完整或参数错误')
+    message.value = '链接不完整或参数错误'
+    showDialog.value = true
     return
   }
 
@@ -117,8 +128,8 @@ const redirectToMiniapp = async (): Promise<void> => {
       showToast(res.msg || '跳转链接生成失败')
       return
     }
-
-    window.location.href = res.data
+    // 跳转
+    window.location.replace(res.data)
   } catch (error) {
     console.error('[redirectToMiniapp] failed:', error)
     showToast('页面跳转失败,请稍后重试')
@@ -170,11 +181,28 @@ const startProgress = (): void => {
   }, 300)
 }
 
-onMounted(() => {
+const showDialog = ref(false)
+
+const isMobile = (): boolean => {
+  const ua = navigator.userAgent.toLowerCase()
+  return /android|iphone|ipad|ipod|mobile|wechat|micromessenger/i.test(ua)
+}
+
+const init = async (): Promise<void> => {
+  if (!isMobile()) {
+    message.value =
+      '电脑无法访问本链接,请使用手机访问。如您已使用手机访问,请将您的默认浏览器的浏览器标识设置为“手机版”'
+    showDialog.value = true
+    return
+  }
+
   startProgress()
-  redirectToMiniapp()
-})
+  await redirectToMiniapp()
+}
 
+onMounted(() => {
+  init()
+})
 onBeforeUnmount(() => {
   clearTimer()
 })