Преглед на файлове

更新开票信息确认页面,删除冗余提示文本,优化用户体验

yuanmingze преди 1 месец
родител
ревизия
9a060f26e2
променени са 2 файла, в които са добавени 25 реда и са изтрити 23 реда
  1. 25 13
      src/pages/index/index.vue
  2. 0 10
      src/pages/invoice-entry/index.vue

+ 25 - 13
src/pages/index/index.vue

@@ -1,17 +1,18 @@
 <template>
-  <view>
-    <web-view v-if="url" :src="url" />
+  <view class="webview-page">
+    <web-view v-if="url" :key="webviewKey" :src="url" />
   </view>
 </template>
 
 <script setup lang="ts">
 import { ref } from 'vue'
-import { onLoad } from '@dcloudio/uni-app'
+import { onLoad, onShow } from '@dcloudio/uni-app'
 
 const FALLBACK_PAGE = '/pages/invoice-entry/index'
 const MAX_DECODE_TIMES = 3
 
 const url = ref('')
+const webviewKey = ref('')
 
 const redirectToFallback = (): void => {
   uni.redirectTo({
@@ -29,11 +30,9 @@ const safeDecode = (value: string, maxTimes = MAX_DECODE_TIMES): string => {
   for (let i = 0; i < maxTimes; i += 1) {
     try {
       const decoded = decodeURIComponent(result)
-
       if (decoded === result) {
         break
       }
-
       result = decoded
     } catch (error) {
       console.error('decode redirect failed:', error)
@@ -44,9 +43,7 @@ const safeDecode = (value: string, maxTimes = MAX_DECODE_TIMES): string => {
   return result
 }
 
-const isHttpUrl = (value: string): boolean => {
-  return /^https?:\/\//i.test(value)
-}
+const isHttpUrl = (value: string): boolean => /^https?:\/\//i.test(value)
 
 const resolveRedirectUrl = (query: Record<string, unknown>): string => {
   const redirectRaw = getRedirectFromQuery(query)
@@ -65,12 +62,14 @@ const resolveRedirectUrl = (query: Record<string, unknown>): string => {
     return ''
   }
 
-  console.log('redirectRaw:', redirectRaw)
-  console.log('redirectUrl:', redirectUrl)
-
   return redirectUrl
 }
 
+const setWebviewUrl = (nextUrl: string): void => {
+  url.value = nextUrl
+  webviewKey.value = `${nextUrl}__${Date.now()}`
+}
+
 onLoad((query) => {
   const redirectUrl = resolveRedirectUrl(query as Record<string, unknown>)
 
@@ -79,11 +78,24 @@ onLoad((query) => {
       title: '链接参数错误',
       icon: 'none',
     })
-
     redirectToFallback()
     return
   }
 
-  url.value = redirectUrl
+  setWebviewUrl(redirectUrl)
+})
+
+onShow(() => {
+  // 某些机型/场景下,页面返回后强制触发一次视图重建更稳
+  if (url.value && !webviewKey.value) {
+    webviewKey.value = `${url.value}__${Date.now()}`
+  }
 })
 </script>
+
+<style scoped>
+.webview-page {
+  width: 100%;
+  height: 100vh;
+}
+</style>

+ 0 - 10
src/pages/invoice-entry/index.vue

@@ -25,8 +25,6 @@
         <view class="intro-title">开票信息确认</view>
         <view class="intro-text"> 请通过收到的开票确认短信中链接进入,完成相关信息确认流程 </view>
       </view>
-
-      <view class="footer-tip"> 点击开票确认短信中链接即可进入 </view>
     </view>
   </view>
 </template>
@@ -181,13 +179,5 @@
       color: rgba(255, 255, 255, 0.72);
     }
   }
-
-  .footer-tip {
-    margin-top: 120rpx;
-    font-size: 34rpx;
-    line-height: 1.6;
-    color: rgba(255, 255, 255, 0.66);
-    text-align: center;
-  }
 }
 </style>