lex-xin 4 月之前
父節點
當前提交
bf545becad
共有 3 個文件被更改,包括 13 次插入7 次删除
  1. 7 5
      miniprogram/components/service/service.ts
  2. 5 1
      miniprogram/pages/index/index.less
  3. 1 1
      miniprogram/pages/index/index.wxml

+ 7 - 5
miniprogram/components/service/service.ts

@@ -20,10 +20,12 @@ Component({
       // 获取屏幕宽高
       const systemInfo = wx.getWindowInfo();
       const isAndroid = systemInfo.platform === 'android'
-      const isDevtools = systemInfo.platform === 'devtools'
-      const barHeight = !isAndroid ? 
+      // const isDevtools = systemInfo.platform === 'devtools'
+      const barHeight = !isAndroid ? 44 : 48;
+
       const globalTop = app.globalData.top
       this.setData({
+        maxTop: barHeight + systemInfo.safeArea.top,
         windowWidth: systemInfo.windowWidth,
         windowHeight: systemInfo.windowHeight,
         top: globalTop
@@ -74,9 +76,9 @@ Component({
       const distanceTop = top;
       const moveHeight = top + elementHeight
       // 判断元素与顶部和底部的距离,选择最近的边界
-      if (distanceTop < 0) {
-        this.setData({ top: 0 }, () => {
-          app.globalData.top = 0
+      if (distanceTop < this.data.maxTop) {
+        this.setData({ top: this.data.maxTop }, () => {
+          app.globalData.top = this.data.maxTop
         }); // 吸附到顶部
       } else if(moveHeight >= windowHeight) {
         this.setData({ top: windowHeight - elementHeight }, () => {

+ 5 - 1
miniprogram/pages/index/index.less

@@ -164,7 +164,7 @@ page {
 
 .goodsInfo {
   display: flex;
-
+  position: relative;
   // align-items: center;
   .desc {
     display: flex;
@@ -199,6 +199,10 @@ page {
 
   .iconMore {
     position: absolute;
+    right: -24rpx;
+    bottom: 32rpx;
+    width: 20rpx;
+    height: 20rpx;
   }
 
   .goodsItem {

+ 1 - 1
miniprogram/pages/index/index.wxml

@@ -55,7 +55,7 @@
             </view>
           </view>
         </view>
-        <!-- <image class="iconMore" src="./images/icon-more.png"></image> -->
+        <image wx:if="{{ list.length > 3 }}" class="iconMore" src="./images/icon-more.png"></image>
       </view>
 
       <!-- 有选择商品的时候  -->