zhb 1 month ago
parent
commit
9cf693175e

+ 6 - 6
App.vue

@@ -12,20 +12,20 @@ import {
 	updateRoute
 } from "@/hooks/useRoute";
 import useGlobalStore from "@/stores/use-global-store";
-import { useAppUpdate } from '@/hooks/useAppUpdate'
-const { checkUpdate } = useAppUpdate()
+// import { useAppUpdate } from '@/hooks/useAppUpdate'
+// const { checkUpdate } = useAppUpdate()
 const globalStore = useGlobalStore()
 onLoad((options) => {
 	updateRoute();
-	checkUpdate()
+	// checkUpdate()
 })
 onShow((options) => {
 	updateRoute();
-	checkUpdate()
+	// checkUpdate()
 })
 onLaunch((options) => {
 	// updateRoute();
-	checkUpdate()
+	// checkUpdate()
 })
 
 watch(locale, () => {
@@ -45,7 +45,7 @@ watch(locale, () => {
 
 onMounted(() => {
 	const sysInfo = uni.getSystemInfoSync();
-	globalStore.setBarHeight(sysInfo.statusBarHeight);
+	globalStore.setBarHeight(sysInfo.statusBarHeight || 60);
 
 	// ---------- 新增 H5 端专属初始化 ----------
 	// 仅在 H5 端执行(通过环境判断)

+ 12 - 12
components/cwg-page-wrapper.vue

@@ -1,11 +1,11 @@
 <template>
   <view :class="['page-wrapper', { dark: isDark }]">
     <cwg-match-media :max-width="991" v-if="!isLoginPage">
-      <cwg-pc-header @open-right-drawer="openRightDrawer" @open-left-drawer="openLeftDrawer" class="header-box"
+      <cwg-pc-header @open-right-drawer="openRightDrawer" @open-left-drawer="openLeftDrawer"
         :sidebarVisible="sidebarVisible" />
       <view class="sidebar-mask mask-visible" v-if="sidebarVisible" @click="openLeftDrawer">
       </view>
-      <view class="fixed"></view>
+      <view class="fixed" v-if=pageTitle></view>
       <cwg-header v-if=pageTitle class="custom-header" :title="pageTitle" />
     </cwg-match-media>
     <cwg-language style="width: 0;display: none;" />
@@ -36,7 +36,7 @@
               <slot />
             </view>
           </transition>
-          <cwg-custom-footer />
+          <cwg-custom-footer v-if=!pageTitle />
         </view>
       </view>
       <cwg-match-media :max-width="991">
@@ -197,17 +197,17 @@ onShow(() => {
 @import "@/uni.scss";
 
 .page-wrapper {
-  height: calc(100vh - 56px);
+  height: calc(100vh - (56px + var(--status-bar-height)));
 }
 
 .header-box {
   width: 100%;
-  height: 56px;
+  height: calc(56px + var(--status-bar-height));
 }
 
 .page-content {
   width: 100%;
-  height: calc(100vh - 56px);
+  height: calc(100vh - (56px + var(--status-bar-height)));
   overflow: hidden;
   display: flex;
   flex-direction: column;
@@ -215,7 +215,7 @@ onShow(() => {
   box-sizing: border-box;
 
   .content-info {
-    height: calc(100vh - 56px);
+    height: calc(100vh - (56px + var(--status-bar-height)));
     overflow: auto;
   }
 
@@ -238,7 +238,7 @@ onShow(() => {
   left: 0;
   top: 0;
   width: 100vw;
-  height: calc(100vh - 56px);
+  height: calc(100vh - (56px + var(--status-bar-height)));
   background-color: rgba(0, 0, 0, 0.2);
   z-index: 101;
 }
@@ -246,7 +246,7 @@ onShow(() => {
 .mask-visible {
   background-color: rgba(0, 0, 0, 0);
   width: 100vw;
-  height: 56px;
+  height: calc(56px + var(--status-bar-height));
 }
 
 .sidebar-visible {
@@ -262,7 +262,7 @@ onShow(() => {
   display: flex;
   flex-direction: column;
   justify-content: space-between;
-  min-height: calc(100vh - 56px);
+  min-height: calc(100vh - (56px + var(--status-bar-height)));
 }
 
 .chat-icon {
@@ -303,7 +303,7 @@ onShow(() => {
   // top: 0;
   // left: 0;
   width: 100%;
-  height: 56px;
+  height: calc(56px + var(--status-bar-height));
   background-color: var(--color-white);
   z-index: 9;
 }
@@ -312,7 +312,7 @@ onShow(() => {
   background-color: var(--color-white);
   padding: 0 px2rpx(15);
   position: fixed;
-  top: 56px;
+  top: calc(56px + var(--status-bar-height));
   left: 0;
 }
 

+ 23 - 19
components/cwg-pc-header.vue

@@ -1,18 +1,22 @@
 <template>
-	<header class="cwg-pc-header">
-		<div class="left">
-			<cwg-icon :name="!sidebarVisible ? 'crm-bars-staggered' : 'cwg-close'" color="#141d22"
-				@click="openLeftDrawer" />
-		</div>
-		<div class="left">
-			<image class="left-img" src="/static/images/logo.png" mode="widthFix" alt="logo" />
-		</div>
-		<div class="right">
-      <cwg-system />
-			<cwg-notice />
-			<cwg-right-drawer />
-		</div>
-	</header>
+	<uni-nav-bar :leftWidth="0" :rightWidth="0" :statusBar="true" :fixed="true" :height="55"
+		:backgroundColor="props.backgrounds || '#fff'" :border="false">
+		<view class="cwg-pc-header">
+			<div class="left">
+				<cwg-icon :name="!sidebarVisible ? 'crm-bars-staggered' : 'cwg-close'" color="#141d22"
+					@click="openLeftDrawer" />
+			</div>
+			<div class="left">
+				<image class="left-img" src="/static/images/logo.png" mode="widthFix" alt="logo" />
+			</div>
+			<div class="right">
+				<cwg-system />
+				<cwg-notice />
+				<cwg-right-drawer />
+			</div>
+		</view>
+	</uni-nav-bar>
+
 </template>
 
 <script setup lang="ts">
@@ -38,15 +42,15 @@ function openLeftDrawer() {
 	align-items: center;
 	justify-content: space-between;
 	width: 100vw;
-	height: px2rpx(55);
+	height: 55px;
 	background-color: rgba(255, 255, 255, 0.9);
 	border-bottom: 1px solid #f0f0f0;
 	padding: 0 px2rpx(16);
 	box-sizing: border-box;
-	position: fixed;
-	top: 0;
-	left: 0;
-	z-index: 101;
+	// position: fixed;
+	// top: 0;
+	// left: 0;
+	// z-index: 101;
 }
 
 .left {

+ 15 - 5
pages/common/chat.vue

@@ -3,7 +3,7 @@
     <view class="page-container">
       <!-- WebView 内容区(自动占满剩余空间,不遮挡导航栏) -->
       <view class="web-view-container">
-        <web-view :src="fileUrl" class="web-view" />
+        <web-view :src="fileUrl" class="web-view" :webview-styles="webviewStyles" />
       </view>
     </view>
   </cwg-page-wrapper>
@@ -12,14 +12,24 @@
 <script setup>
 import { ref, computed } from 'vue'
 import { onLoad } from '@dcloudio/uni-app'
+import useGlobalStore from '@/stores/use-global-store'
+const globalStore = useGlobalStore()
 import Config from '@/config/index'
 const { Host80 } = Config
 import getWebBase from '@/utils/webBase'
 const webBase = getWebBase()
-const fileUrl = ref('')
-onLoad((options) => {
-  fileUrl.value = `${Host80}${webBase}iframe/livechat.html`
-})
+const fileUrl = `${Host80}${webBase}iframe/livechat.html`
+const statusBarHeight = computed(() => globalStore.statusBarHeight)
+
+const webviewStyles = computed(() => ({
+  progress: {
+    color: '#ea002a'
+  },
+  bounce: 'none',
+  scrollIndicator: 'none',
+  top: statusBarHeight.value + 55 + 'px',
+  bottom: '0px'
+}))
 </script>
 
 <style scoped lang="scss">

+ 29 - 40
pages/common/webview.vue

@@ -3,7 +3,7 @@
     <view class="page-container">
       <!-- WebView 内容区(自动占满剩余空间,不遮挡导航栏) -->
       <view class="web-view-container">
-        <web-view :src="fileUrl" class="web-view" />
+        <web-view :src="fileUrl" class="web-view" :webview-styles="webviewStyles" />
       </view>
     </view>
   </cwg-page-wrapper>
@@ -18,61 +18,50 @@ import getWebBase from '@/utils/webBase'
 const webBase = getWebBase()
 import { useI18n } from 'vue-i18n'
 const { t } = useI18n()
+
 const fileUrl = ref('')
 const title = ref('')
-const pageTitle = computed(() => t(title.value))
+const pageTitle = computed(() => t(title.value || ''))
 const fileType = ref('')
+
+import useGlobalStore from '@/stores/use-global-store'
+const globalStore = useGlobalStore()
+const statusBarHeight = computed(() => globalStore.statusBarHeight || 0)
+
+// webview 样式(修复顶部安全区)
+const webviewStyles = computed(() => ({
+  progress: {
+    color: '#ea002a'
+  },
+  top: statusBarHeight.value + 105 + 'px',
+  bounce: 'none',
+  scrollIndicator: 'none'
+}))
+
 // 获取文件后缀
 const getFileExt = (name) => {
   if (!name) return ''
   return name.split('.').pop()?.toUpperCase()
 }
+
 onLoad((options) => {
+  console.log('webview 接收参数:', options)
+
   title.value = options.title || '文件预览'
-  fileType.value = getFileExt(options.url)
-  // PDF 跳转到你的预览页
+  const realUrl = options.url || ''
+  fileType.value = getFileExt(realUrl)
+
+  // ✅ 核心修复:PDF 只编码一次,不再二次编码
   if (fileType.value === 'PDF') {
-    fileUrl.value = `${Host80}${webBase}iframe/pdf.html?pdf=${encodeURIComponent(options.url)}`
+    fileUrl.value = `${Host80}${webBase}iframe/pdf.html?pdf=${realUrl}&title=${title.value}`
   } else {
-    fileUrl.value = options.url || ''
+    fileUrl.value = realUrl
   }
+
+  console.log('最终加载地址:', fileUrl.value)
 })
 </script>
 
 <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>

+ 1 - 1
pages/launch/index.vue

@@ -8,7 +8,7 @@ onLoad(() => {
         })
     } else {
         uni.reLaunch({
-            url: '/pages/mine/index'
+            url: '/pages/customer/index'
         })
     }
 })

+ 1 - 5
uni_modules/uni-nav-bar/components/uni-nav-bar/uni-nav-bar.vue

@@ -278,7 +278,6 @@ $nav-height: 44px;
 }
 
 .uni-navbar__header {
-	padding: 0 10px;
 	/* #ifndef APP-NVUE */
 	display: flex;
 	/* #endif */
@@ -329,8 +328,6 @@ $nav-height: 44px;
 	display: flex;
 	/* #endif */
 	flex: 1;
-	padding: 0 10px;
-	overflow: hidden;
 }
 
 .uni-navbar__header-container-inner {
@@ -342,7 +339,6 @@ $nav-height: 44px;
 	align-items: center;
 	justify-content: center;
 	font-size: 12px;
-	overflow: hidden;
 	// box-sizing: border-box;
 }
 
@@ -352,7 +348,7 @@ $nav-height: 44px;
 
 .uni-navbar--fixed {
 	position: fixed;
-	z-index: 998;
+	z-index: 1200;
 	/* #ifdef H5 */
 	left: var(--window-left);
 	right: var(--window-right);