Selaa lähdekoodia

h5页面适配修改

Zhangbw 2 kuukautta sitten
vanhempi
sitoutus
d944bab7dc

+ 10 - 0
.idea/.gitignore

@@ -0,0 +1,10 @@
+# 默认忽略的文件
+/shelf/
+/workspace.xml
+# 已忽略包含查询文件的默认文件夹
+/queries/
+# Datasource local storage ignored files
+/dataSources/
+/dataSources.local.xml
+# 基于编辑器的 HTTP 客户端请求
+/httpRequests/

+ 8 - 0
.idea/compiler.xml

@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="CompilerConfiguration">
+    <annotationProcessing>
+      <profile default="true" name="Default" enabled="true" />
+    </annotationProcessing>
+  </component>
+</project>

+ 9 - 0
.idea/gupiao-wx.iml

@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module type="JAVA_MODULE" version="4">
+  <component name="NewModuleRootManager" inherit-compiler-output="true">
+    <exclude-output />
+    <content url="file://$MODULE_DIR$" />
+    <orderEntry type="inheritedJdk" />
+    <orderEntry type="sourceFolder" forTests="false" />
+  </component>
+</module>

+ 9 - 0
.idea/misc.xml

@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="MavenRunner">
+    <option name="jreName" value="17" />
+  </component>
+  <component name="ProjectRootManager" version="2" languageLevel="JDK_22" default="true" project-jdk-name="22" project-jdk-type="JavaSDK">
+    <output url="file://$PROJECT_DIR$/out" />
+  </component>
+</project>

+ 8 - 0
.idea/modules.xml

@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="ProjectModuleManager">
+    <modules>
+      <module fileurl="file://$PROJECT_DIR$/.idea/gupiao-wx.iml" filepath="$PROJECT_DIR$/.idea/gupiao-wx.iml" />
+    </modules>
+  </component>
+</project>

+ 6 - 0
.idea/vcs.xml

@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="VcsDirectoryMappings">
+    <mapping directory="" vcs="Git" />
+  </component>
+</project>

+ 59 - 0
src/App.vue

@@ -54,6 +54,46 @@ export default {
 
     }
 
+    // #ifdef H5
+    let baseLayoutHeight = window.innerHeight || document.documentElement.clientHeight || 0
+
+    const setKeyboardOffset = () => {
+      const vv = window.visualViewport
+      if (!vv) {
+        document.documentElement.style.setProperty('--keyboard-offset', '0px')
+        return
+      }
+
+      const currentLayoutHeight = window.innerHeight || document.documentElement.clientHeight || 0
+      baseLayoutHeight = Math.max(baseLayoutHeight, currentLayoutHeight)
+
+      const vvHeight = vv.height
+      const offsetTop = vv.offsetTop || 0
+      const keyboardHeight = Math.max(0, baseLayoutHeight - vvHeight - offsetTop)
+      document.documentElement.style.setProperty('--keyboard-offset', `${keyboardHeight}px`)
+    }
+
+    this.__keyboardOffsetHandler = setKeyboardOffset
+
+    if (window.visualViewport) {
+      window.visualViewport.addEventListener('resize', setKeyboardOffset)
+      window.visualViewport.addEventListener('scroll', setKeyboardOffset)
+    }
+
+    window.addEventListener('resize', () => {
+      const h = window.innerHeight || document.documentElement.clientHeight || 0
+      baseLayoutHeight = Math.max(baseLayoutHeight, h)
+      setKeyboardOffset()
+    })
+
+    window.addEventListener('focusin', setKeyboardOffset)
+    window.addEventListener('focusout', () => {
+      document.documentElement.style.setProperty('--keyboard-offset', '0px')
+    })
+
+    setKeyboardOffset()
+    // #endif
+
   },
 
   onShow: function() {
@@ -107,6 +147,25 @@ page {
 
 }
 
+/* H5环境下固定底部tabBar位置 */
+/* #ifdef H5 */
+uni-tabbar,
+.uni-tabbar,
+.uni-tabbar__container,
+.uni-tabbar-bottom {
+  position: fixed !important;
+  bottom: 0 !important;
+  left: 0 !important;
+  right: 0 !important;
+  z-index: 999 !important;
+  transform: translateY(var(--keyboard-offset, 0px)) !important;
+}
+
+body {
+  padding-bottom: constant(safe-area-inset-bottom) !important;
+  padding-bottom: env(safe-area-inset-bottom) !important;
+}
+/* #endif */
 
 
 .container {

+ 7 - 1
src/manifest.json

@@ -51,7 +51,13 @@
     "h5": {
         "router": {
             "mode": "hash"
-        }
+        },
+        "optimization": {
+            "treeShaking": {
+                "enable": true
+            }
+        },
+        "template": "index.html"
     },
     "vueVersion": "3"
 }

+ 3 - 3
src/pages.json

@@ -45,13 +45,13 @@
     {
       "path": "pages/order/order",
       "style": {
-        "navigationStyle": "custom"
+        "navigationBarTitleText": "我的订单"
       }
     },
     {
       "path": "pages/admin/shortPool",
       "style": {
-        "navigationStyle": "custom"
+        "navigationBarTitleText": "超短池管理"
       }
     },
     {
@@ -63,7 +63,7 @@
     {
       "path": "pages/history/history",
       "style": {
-        "navigationStyle": "custom"
+        "navigationBarTitleText": "历史标的池回顾"
       }
     },
     {

+ 1 - 17
src/pages/admin/shortPool.vue

@@ -1,16 +1,5 @@
 <template>
   <view class="page-container">
-    <!-- 顶部导航栏 -->
-    <view class="custom-navbar">
-      <view class="navbar-back" @click="handleBack">
-        <text class="back-icon">←</text>
-      </view>
-      <view class="navbar-title">
-        <text class="title-text">超短池管理</text>
-      </view>
-      <view class="navbar-placeholder"></view>
-    </view>
-
     <scroll-view class="scroll-view" scroll-y>
       <view class="content-wrapper">
         <!-- 搜索添加区域 -->
@@ -153,11 +142,6 @@ const request = (options) => {
   })
 }
 
-const handleBack = () => {
-  const pages = getCurrentPages()
-  pages.length > 1 ? uni.navigateBack() : uni.switchTab({ url: '/pages/mine/mine' })
-}
-
 onShow(() => {
   checkAdminPermission()
   loadStockList()
@@ -341,7 +325,7 @@ const handleDeleteStock = (item) => {
 .title-text {
   font-size: 36rpx;
   font-weight: 600;
-  color: #222222;
+  color: #3F51F7;
 }
 
 .navbar-placeholder {

+ 1 - 16
src/pages/history/history.vue

@@ -1,14 +1,5 @@
 <template>
   <view class="page-container">
-    <!-- 自定义导航栏 -->
-    <view class="nav-bar">
-      <view class="nav-back" @click="goBack">
-        <text class="back-icon">←</text>
-      </view>
-      <text class="nav-title">历史标的池回顾</text>
-      <view class="nav-placeholder"></view>
-    </view>
-    
     <scroll-view class="scroll-view" scroll-y @scrolltolower="loadMore">
       <view class="content-wrapper">
         <!-- 查询条件显示 -->
@@ -147,12 +138,6 @@ const formatTrend = (trend) => {
   return `${prefix}${trend.toFixed(2)}%`
 }
 
-// 返回上一页
-const goBack = () => {
-  const pages = getCurrentPages()
-  pages.length > 1 ? uni.navigateBack() : uni.switchTab({ url: '/pages/index/index' })
-}
-
 // 加载历史数据
 const loadHistoryData = async () => {
   if (loading.value) return
@@ -243,7 +228,7 @@ onLoad((options) => {
 .nav-title {
   font-size: 32rpx;
   font-weight: 600;
-  color: #222222;
+  color: #3F51F7;
 }
 
 .nav-placeholder {

+ 1 - 0
src/pages/index/index.vue

@@ -18,6 +18,7 @@
               @input="onKeywordChange"
               @confirm="handleSearchClick"
               @focus="showDropdown = true"
+              :adjust-position="false"
             />
             <!-- 搜索按钮(统一处理登录检查) -->
             <view class="search-button" @click="handleSearchClick">

+ 1 - 17
src/pages/order/order.vue

@@ -1,16 +1,5 @@
 <template>
   <view class="page-container">
-    <!-- 顶部导航栏 -->
-    <view class="custom-navbar">
-      <view class="navbar-back" @click="handleBack">
-        <text class="back-icon">‹</text>
-      </view>
-      <view class="navbar-title">
-        <text class="title-text">我的订单</text>
-      </view>
-      <view class="navbar-placeholder"></view>
-    </view>
-
     <scroll-view class="scroll-view" scroll-y>
       <view class="content-wrapper">
         <!-- 主卡片容器 -->
@@ -118,11 +107,6 @@ const checkLogin = () => {
   isLoggedIn.value = checkLoginStatus()
 }
 
-const handleBack = () => {
-  const pages = getCurrentPages()
-  pages.length > 1 ? uni.navigateBack() : uni.switchTab({ url: '/pages/mine/mine' })
-}
-
 const loadOrders = async () => {
   if (!isLoggedIn.value) return
   loading.value = true
@@ -257,7 +241,7 @@ onUnmounted(() => {
 .title-text {
   font-size: 34rpx;
   font-weight: 600;
-  color: #1F2937;
+  color: #3F51F7;
 }
 
 .navbar-placeholder {