Browse Source

导航栏调整

Xiao_123 1 month ago
parent
commit
2c28cb95d6
4 changed files with 57 additions and 17 deletions
  1. 17 10
      components/Navbar/index.vue
  2. 19 2
      pages/index/position.vue
  3. 1 1
      pagesA/collect/company.vue
  4. 20 4
      pagesB/positionDetail/index.vue

+ 17 - 10
components/Navbar/index.vue

@@ -3,8 +3,8 @@
     class="navbar"
     :class="{'gradientBgc': !noBgColor}"
     :style="{
-      'height': (navbarHeight < defaultLogoHeight ? (defaultLogoHeight + 10) : navbarHeight + 10) + 'px',
-      'line-height': (navbarHeight < defaultLogoHeight ? (defaultLogoHeight + 10) : navbarHeight + 10) + 'px',
+      'height': height + 'px',
+      'line-height': height + 'px',
     }"
   >
     <view class="navbar-box" :style="{'paddingTop': statusBarHeight + 'px'}">
@@ -14,8 +14,8 @@
         class="navbar-box-logo" 
         :style="{'height': defaultLogoHeight + 'px'}"
       ></image>
-      <view v-else class="nav-box-title">
-        <uni-icons type="left" size="25" class="ss-m-l-20" color="#0E100F" @tap="goBack"></uni-icons>
+      <view v-else class="nav-box-title" :style="{'height': height ? (height - statusBarHeight) + 'px' : '100%'}">
+        <uni-icons v-if="!textLeft" type="left" size="25" class="ss-m-l-20" color="#0E100F" @tap="goBack"></uni-icons>
         <view class="title-text" :class="[{'text-left': textLeft}, {'text-center': !textLeft}]">{{ title }}</view>
       </view>
     </view>
@@ -50,8 +50,9 @@ defineProps({
 const defaultLogoHeight = 40
 const navbarHeight = ref(0)
 const statusBarHeight = ref(0)
+const height = ref(0)
 
-onLoad(() => {
+onLoad(async () => {
   try {
     const systemInfo = uni.getSystemInfoSync()
     statusBarHeight.value = systemInfo.statusBarHeight
@@ -65,18 +66,25 @@ onLoad(() => {
       navbarHeight.value = defaultLogoHeight + 10
     }
 
-    // 将 navbarHeight 存入本地缓存
-    const height = navbarHeight.value < defaultLogoHeight ? (defaultLogoHeight + 10) : navbarHeight.value + 10
-    uni.setStorageSync('navbarHeight', height)
+    height.value = navbarHeight.value < defaultLogoHeight ? (defaultLogoHeight + 10) : navbarHeight.value + 10
+	  await new Promise((resolve, reject) => {
+	    uni.setStorage({
+	      key: 'navbarHeight',
+	      data: height.value,
+	      success: resolve,
+	      fail: reject
+	    })
+	  })
   } catch (error) {
     console.error('获取系统信息或菜单按钮信息时出错:', error)
   }
 })
 
+// 返回上一页
 const goBack = () => {
   uni.navigateBack({
     delta: 1
-  });
+  })
 }
 </script>
 
@@ -104,7 +112,6 @@ const goBack = () => {
 .nav-box-title {
   position: relative;
   width: 100%;
-  height: 100%;
   display: flex;
   align-items: center;
   .title-text {

+ 19 - 2
pages/index/position.vue

@@ -53,7 +53,7 @@
 </template>
 
 <script setup>
-import { ref, reactive, nextTick } from 'vue'
+import { ref, reactive, nextTick, onMounted } from 'vue'
 import SwiperAd from '@/components/SwiperAd'
 import FilterList from '@/components/FilterList'
 import PositionList from '@/components/PositionList'
@@ -66,7 +66,24 @@ import { getRewardEventList } from '@/utils/eventList'
 import { getMorningNewsArticle } from '@/api/content'
 import { getWebContent } from '@/api/common'
 
-const navbarHeight = ref(uni.getStorageSync('navbarHeight'))
+const navbarHeight = ref(0)
+
+onMounted(async () => {
+  try {
+    const res = await new Promise((resolve, reject) => {
+      uni.getStorage({
+        key: 'navbarHeight',
+        success: (result) => resolve(result),
+        fail: (err) => reject(err)
+      })
+    })
+    navbarHeight.value = res.data
+	  console.log(navbarHeight.value, '职位列表-导航栏高度')
+  } catch (error) {
+    console.error('读取本地缓存出错:', error)
+  }
+})
+
 onLoad(() => {
   wx.showShareMenu({
     withShareTicket: true,

+ 1 - 1
pagesA/collect/company.vue

@@ -5,7 +5,7 @@
         <view v-for="(item, index) in items" :key="index" class="list-item default-border defaultBgc" @click="jumpToEnterpriseDetail(item.id)">
           <view class="d-flex align-center">
             <view class="enterAvatar default-radius default-border">
-              <image class="enterAvatar default-radius default-border" :src="item.logoUrl || 'https://minio.citupro.com/dev/menduner/company-avatar.png'"></image>
+              <image class="enterAvatar default-radius" :src="item.logoUrl || 'https://minio.citupro.com/dev/menduner/company-avatar.png'"></image>
             </view>
             <view style="flex: 1;" class="ss-m-l-30">
               <view class="enterprise-name ellipsis MiSans-Semibold default-text-color">{{ formatName(item.anotherName || item.name) }}</view>

+ 20 - 4
pagesB/positionDetail/index.vue

@@ -62,11 +62,11 @@
                   </view>
                   <view>
                     <view class="contact-name MiSans-Medium default-text-color">{{ info.contact?.name }}</view>
-                    <view class="contact-info MiSans-Normal color-666">
+                    <view class="contact-info MiSans-Normal color-666 font-size-13">
                       {{ formatName(info.enterprise?.anotherName || info.enterprise?.name) }} {{ info.contact?.postNameCn ? '· ' + info.contact?.postNameCn : '' }}
                     </view>
                   </view>
-                  <view class="d-flex align-center">
+                  <view class="d-flex align-center ss-m-l-10">
                     <uni-icons type="right" size="20" color="#666"></uni-icons>
                   </view>
                 </view>
@@ -246,7 +246,7 @@ import { preview } from '@/utils/preview'
 import { uploadFile } from '@/api/file'
 import layoutPage from '@/layout'
 import Navbar from '@/components/Navbar'
-import { ref, watch, computed } from 'vue';
+import { ref, watch, computed, onMounted } from 'vue';
 import {
   jobCvRelSend,
   getPositionDetails,
@@ -268,7 +268,23 @@ import { formatName } from '@/utils/getText'
 import studentDeliveryForm from '@/components/studentDeliveryForm'
 // import { getShareQueryById } from '@/api/jobFair.js'
 
-const navbarHeight = ref(uni.getStorageSync('navbarHeight'))
+const navbarHeight = ref(0)
+
+onMounted(async () => {
+  try {
+    const res = await new Promise((resolve, reject) => {
+      uni.getStorage({
+        key: 'navbarHeight',
+        success: (result) => resolve(result),
+        fail: (err) => reject(err)
+      })
+    })
+    navbarHeight.value = res.data
+	  console.log(navbarHeight.value, '职位详情-导航栏高度')
+  } catch (error) {
+    console.error('读取本地缓存出错:', error)
+  }
+})
 
 const useUserStore = userStore()
 const sharePopup = ref()