shish 2 месяцев назад
Родитель
Сommit
5616caed8a
1 измененных файлов с 54 добавлено и 31 удалено
  1. 54 31
      hdApp/src/admin/home/me.vue

+ 54 - 31
hdApp/src/admin/home/me.vue

@@ -1,8 +1,8 @@
 <template>
-  <view class="me-page app-content">
+  <view class="me-page app-content" :class="{ 'me-page--app': isAppRuntime }">
     <block v-if="isLoggedIn">
       <view class="page-hero">
-        <view class="status-space" :style="{ height: safeTopHeight + 'px' }"></view>
+        <view class="status-space" :style="statusSpaceStyle"></view>
 
         <view class="hero-panel">
           <view class="profile-card">
@@ -97,7 +97,7 @@
     <block v-else>
       <view class="guest-page">
         <view class="guest-hero">
-          <view class="status-space" :style="{ height: safeTopHeight + 'px' }"></view>
+          <view class="status-space" :style="statusSpaceStyle"></view>
           <view class="guest-hero-inner">
             <text class="guest-hero-title">我的</text>
             <text class="guest-hero-desc">登录后管理门店</text>
@@ -254,15 +254,45 @@ export default {
       return `/admin/shop/add?id=${id}`;
     },
     safeTopHeight () {
+      if (this.isAppRuntime) {
+        const gap = this.appTopExtraPx > 0 ? this.appTopExtraPx : uni.upx2px(23);
+        return (this.statusBarHeight || 0) + gap;
+      }
       return this.heroTopOffset > 0 ? this.heroTopOffset : this.statusBarHeight;
     },
+    statusSpaceStyle () {
+      const h = this.safeTopHeight;
+      return {
+        height: h + "px",
+        minHeight: h + "px",
+        width: "100%",
+        flexShrink: 0
+      };
+    },
+    /** 运行到 App / 正式包均为 true;微信小程序为 false */
+    isAppRuntime () {
+      try {
+        const info = uni.getSystemInfoSync();
+        const p = String(info.uniPlatform || "").toLowerCase();
+        if (p === "app" || p === "app-plus" || p === "app_android" || p === "app_ios") {
+          return true;
+        }
+      } catch (e) { /* ignore */ }
+      // #ifdef APP-PLUS
+      return true;
+      // #endif
+      try {
+        return typeof plus !== "undefined" && !!plus.runtime;
+      } catch (e2) {
+        return false;
+      }
+    },
     profileHeaderStyle () {
+      const style = {};
       if (this.capsuleSafeRight > 0) {
-        return {
-          paddingRight: this.capsuleSafeRight + "px"
-        };
+        style.paddingRight = this.capsuleSafeRight + "px";
       }
-      return {};
+      return style;
     }
   },
   data () {
@@ -271,6 +301,8 @@ export default {
       statusBarHeight: 0,
       heroTopOffset: 0,
       capsuleSafeRight: 0,
+      /** App:状态栏下额外下移(px),onShow 里 uni.upx2px 写入 */
+      appTopExtraPx: 0,
       myInfo: {},
       version: "1.0.0",
       lookMoney: 0,
@@ -352,29 +384,18 @@ export default {
           this.capsuleSafeRight = systemInfo.windowWidth - menuButton.left + 8;
         }
         // #endif
-        // #ifdef APP-PLUS
-        const appTopLift = uni.upx2px(20);
-        const liftAppTop = (px) => Math.max(this.statusBarHeight, px - appTopLift);
-        const statusBar = this.statusBarHeight;
-        const safeInsetTop =
-          (systemInfo.safeAreaInsets && systemInfo.safeAreaInsets.top) ||
-          (systemInfo.safeArea && systemInfo.safeArea.top) ||
-          0;
-        const topInset = Math.max(statusBar, safeInsetTop);
-        const isIos =
-          systemInfo.platform === "ios" || (systemInfo.osName && systemInfo.osName.toLowerCase() === "ios");
-        if (isIos) {
-          // iOS 刘海屏 safeArea.top 已含状态栏,仅补内容与顶部的间距
-          this.heroTopOffset = liftAppTop(topInset + 12);
+        if (this.isAppRuntime) {
+          // App 自定义导航:仅占状态栏 + 可调下移量(8+15=23upx,用 px 写入 data 保证运行到 App 可见)
+          this.heroTopOffset = 0;
+          this.appTopExtraPx = uni.upx2px(23);
         } else {
-          // Android 自定义导航:状态栏 + 约 44px 标题区(与微信胶囊下边距接近)
-          this.heroTopOffset = liftAppTop(topInset + 44 + 12);
+          this.appTopExtraPx = 0;
         }
-        // #endif
       } catch (e) {
         this.statusBarHeight = 0;
         this.heroTopOffset = 0;
         this.capsuleSafeRight = 0;
+        this.appTopExtraPx = 0;
       }
     },
     resetGuestState () {
@@ -604,10 +625,14 @@ export default {
   padding: 20upx 0 0;
 }
 
+.me-page--app .profile-card {
+  padding-top: 8upx;
+}
+
 .profile-header-row {
   display: flex;
   flex-direction: row;
-  align-items: flex-start;
+  align-items: center;
   justify-content: space-between;
 }
 
@@ -618,14 +643,11 @@ export default {
   flex: 1;
   min-width: 0;
   margin-right: 16upx;
-  margin-top: -24upx;
 }
 
-/* #ifdef APP-PLUS */
-.profile-main {
-  margin-top: 0;
+.me-page--app .guest-hero-inner {
+  padding-top: 16upx;
 }
-/* #endif */
 
 .shop-avatar,
 .avatar-placeholder {
@@ -685,10 +707,11 @@ export default {
 .quick-actions {
   display: flex;
   flex-direction: row;
-  align-items: flex-start;
+  align-items: center;
   flex-shrink: 0;
   padding: 0;
   background: transparent;
+  align-self: center;
 }
 
 .quick-action {