zhb 1 hónapja
szülő
commit
9d08c7d2f8

+ 3 - 3
components/cwg-custom-footer.vue

@@ -19,7 +19,7 @@
         </view>
         <view class="footer-placeholder"></view>
         <view class="footer-links">
-            <view v-for="(item, index) in linkList" :key="index" class="link-item" @click="openLink(item.url)"
+            <view v-for="(item, index) in linkList" :key="index" class="link-item" @click="openLink(item)"
                 v-t="item.text" />
             <!-- <view class="copyright">© 2008 - 2026. Exness</view> -->
         </view>
@@ -34,8 +34,8 @@ const linkList = [
     { text: 'signup.agreemnet6', url: 'pdf/Privacy_Policy.pdf' },
     { text: 'news_add_field.OpenAccount.Des2', url: 'pdf/PrivacyPolicy2019_01.pdf' }
 ]
-const openLink = (url) => {
-    openLocalPdf(url)
+const openLink = ({url, text}) => {
+    openLocalPdf(url, text)
 }
 </script>
 

+ 15 - 0
components/cwg-page-wrapper.vue

@@ -5,10 +5,12 @@
         :sidebarVisible="sidebarVisible" />
       <!--      占位-->
       <view class="fixed"></view>
+      <cwg-header class="custom-header" :title="pageTitle" />
     </cwg-match-media>
     <LanguageDropdown style="width: 0;display: none;" />
     <cwg-progress />
     <cwg-confirm-popup />
+
     <view class="page-content" :style="{ backgroundColor: bgColor }">
       
       <cwg-match-media :max-width="991" v-if="!isLoginPage">
@@ -82,6 +84,11 @@ const props = defineProps({
     type: String,
     default: '',
   },
+  // 顶部导航栏标题
+  pageTitle: {
+    type: String,
+    default: '',
+  },
 })
 const isDark = computed(() => globalStore.theme === 'dark')
 const isTabBarPage = ref(false)
@@ -231,6 +238,14 @@ onShow(() => {
   z-index: 9;
 }
 
+.custom-header {
+  background-color: var(--color-white);
+  padding: 0 px2rpx(15);
+  position: fixed;
+  top: 56px;
+  left: 0;
+}
+
 @media screen and (max-width: 1504px) {
   .content-wrapper-padding {
     padding:  px2rpx(16) px2rpx(16) 0 px2rpx(16);

+ 1 - 0
main.js

@@ -8,6 +8,7 @@ import vEllipsis from './directives/v-ellipsis'
 import { createI18n } from "vue-i18n";
 import { routeInterceptor } from '@/utils/routeInterceptor.js'
 import { lang } from '@/composables/config'
+// import './static/js/jsvm_all.js'
 import { watch } from "vue";
 import vT from './directives/v-t'
 export const i18n = createI18n({

+ 1 - 1
manifest.json

@@ -185,7 +185,7 @@
         "template" : "template.h5.html",
         "router" : {
             "mode" : "hash",
-            "base" : ""
+            "base" : "/web4/"
         },
         "sdkConfigs" : {
             "maps" : {

+ 65 - 16
pages/common/webview.vue

@@ -1,29 +1,78 @@
 <template>
-  <view class="container">
-    <web-view :src="fileUrl" :title="pageTitle"></web-view>
-  </view>
+  <cwg-page-wrapper class="webview-page" :pageTitle="pageTitle">
+    <view class="page-container">
+      <!-- WebView 内容区(自动占满剩余空间,不遮挡导航栏) -->
+      <view class="web-view-container">
+        <web-view :src="fileUrl" class="web-view" />
+      </view>
+    </view>
+  </cwg-page-wrapper>
 </template>
 
 <script setup>
-import { ref } from 'vue'
- import { onLoad } from '@dcloudio/uni-app'
+import { ref, computed } from 'vue'
+import { onLoad } from '@dcloudio/uni-app'
+import Config from '@/config/index'
+const { Host80 } = Config
+import getWebBase from '@/utils/webBase'
+const webBase = getWebBase()
+import { useI18n } from 'vue-i18n'
+const { t } = useI18n()
 const fileUrl = ref('')
-const pageTitle = ref('文件预览')
-
+const title = ref('')
+const pageTitle = computed(() => t(title.value))
+const fileType = ref('')
+// 获取文件后缀
+const getFileExt = (name) => {
+  if (!name) return ''
+  return name.split('.').pop()?.toUpperCase()
+}
 onLoad((options) => {
-  fileUrl.value = options.url || ''
-  pageTitle.value = options.title || '文件预览'
-  
-  // 设置导航栏标题
-  uni.setNavigationBarTitle({
-    title: pageTitle.value
-  })
+  title.value = options.title || '文件预览'
+  fileType.value = getFileExt(options.url)
+  // PDF 跳转到你的预览页
+  if (fileType.value === 'PDF') {
+    fileUrl.value = `${Host80}${webBase}pdf/index.html?pdf=${encodeURIComponent(options.url)}`
+  } else {
+    fileUrl.value = options.url || ''
+  }
 })
 </script>
 
-<style scoped>
-.container {
+<style scoped lang="scss">
+@import "@/uni.scss";
+
+.webview-page {
+  :deep(.content-wrapper) {
+    padding: 0 !important;
+  }
+
+  :deep(.page-content) {
+    height: calc(100vh - 112px);
+  }
+
+  :deep(.fixed) {
+    height: 112px;
+  }
+}
+
+/* 页面根容器:弹性布局,完美分配导航栏和web-view高度 */
+.page-container {
+  display: flex;
+  flex-direction: column;
   width: 100%;
   height: 100vh;
 }
+
+/* 顶部导航栏:正确适配安全区,高度计算正确 */
+.web-view-container {
+  flex: 1;
+  width: 100%;
+  overflow: hidden;
+}
+
+.web-view {
+  width: 100%;
+  height: 100%;
+}
 </style>

+ 2 - 2
pages/customer/create-account.vue

@@ -572,14 +572,14 @@ const handleBalanceChange = () => {
 // 打开链接
 const openLink = (path) => {
     uni.navigateTo({
-        url: `/pages/webview/index?url=https://www.${ho.value}.com/${path}`
+        url: `/pages/common/webview?url=https://www.${ho.value}.com/${path}`
     });
 };
 
 // 打开PDF
 const openPdf = (path) => {
     uni.navigateTo({
-        url: `/pages/webview/index?url=/pdf/${path}`
+        url: `/pages/common/webview?url=/pdf/${path}`
     });
 };
 

+ 0 - 7
utils/openExternalUrl.js

@@ -10,11 +10,4 @@ export function openExternalUrl(url) {
     // #ifdef H5
     window.open(url, '_blank');
     // #endif
-
-    // #ifdef MP-WEIXIN
-    // 小程序只能使用 web-view 组件,这里可以跳转到一个内嵌 web-view 的页面
-    uni.navigateTo({
-        url: `/pages/webview/webview?url=${encodeURIComponent(url)}`
-    });
-    // #endif
 }

+ 8 - 16
utils/pdf.js

@@ -1,26 +1,18 @@
+import Config from '@/config/index'
+const { Host80 } = Config
+import getWebBase from '@/utils/webBase'
+const webBase = getWebBase()
 // utils/pdf.js 或直接在组件 methods 中定义
-export function openLocalPdf(fileName) {
+export function openLocalPdf(fileName, title) {
   // #ifdef H5
   // H5 端直接打开相对路径,会被浏览器渲染或下载(取决于浏览器配置)
-  window.open(`/static/${fileName}`);
+  window.open(`${Host80}${webBase}static/${fileName}`);
   // #endif
 
   // #ifdef APP-PLUS
   // App 端:将静态资源路径转为系统绝对路径,再用 uni.openDocument 调用系统阅读器打开
-  const localPath = `_www/static/${fileName}`;
-  const absolutePath = plus.io.convertLocalFileSystemURL(localPath);
-  uni.openDocument({
-    filePath: absolutePath,
-    success: () => {
-      console.log('PDF 打开成功');
-    },
-    fail: err => {
-      console.error('打开失败', err);
-      uni.showToast({
-        title: '无法打开文件,请检查文件是否存在',
-        icon: 'none'
-      });
-    }
+  uni.navigateTo({
+    url: `/pages/common/webview?url=${encodeURIComponent(`${Host80}${webBase}static/${fileName}`)}&title=${title}`  
   });
   // #endif
 }

+ 5 - 0
utils/webBase.js

@@ -0,0 +1,5 @@
+import manifest from '../manifest.json'
+export default function getWebBase() {
+    const webBase = manifest.h5?.router?.base
+    return webBase
+}