bobo 3 vuotta sitten
vanhempi
commit
121fe25f3e
5 muutettua tiedostoa jossa 78 lisäystä ja 0 poistoa
  1. 51 0
      components/topbar.js
  2. 4 0
      components/topbar.json
  3. 6 0
      components/topbar.wxml
  4. 17 0
      components/topbar.wxss
  5. BIN
      images/back.png

+ 51 - 0
components/topbar.js

@@ -0,0 +1,51 @@
+// components/topbar.js
+Component({
+    /**
+     * 组件的属性列表
+     */
+    properties: {
+
+    },
+
+    /**
+     * 组件的初始数据
+     */
+    data: {
+
+    },
+
+    attached: function() {
+        var url =getCurrentPages()[getCurrentPages().length-1].route
+
+        let dwObj = wx.getMenuButtonBoundingClientRect()
+        let navHeight_ = (dwObj.top + dwObj.height)
+        let capsuleTop_ = dwObj.top
+        let windowHeight = wx.getSystemInfoSync().windowHeight
+
+        this.setData({
+            navHeight: navHeight_,
+            capsuleTop:capsuleTop_, 
+            capHeight: dwObj.height,
+            bodyHeight: windowHeight - navHeight_,
+        });
+    },
+
+    /**
+     * 组件的方法列表
+     */
+    methods: {
+        handleBack() {
+            let routeLen = getCurrentPages().length;
+            if (routeLen == 1) {
+                wx.reLaunch({
+                  url: '/pages/welfareMall/index/index',
+                })
+                return
+            }
+            const url =getCurrentPages()[getCurrentPages().length-2].route
+            wx.switchTab({
+              url: "/" + url,
+            })
+        }
+    }
+})

+ 4 - 0
components/topbar.json

@@ -0,0 +1,4 @@
+{
+    "component": true,
+    "usingComponents": {}
+}

+ 6 - 0
components/topbar.wxml

@@ -0,0 +1,6 @@
+<!--components/topbar.wxml-->
+<view class="topbar" style="top:{{capsuleTop + 3}}px; left: 28rpx;">
+   <view class="back" catchtap="handleBack">
+      <image src="/images/back.png" />
+   </view>
+</view>

+ 17 - 0
components/topbar.wxss

@@ -0,0 +1,17 @@
+/* components/topbar.wxss */
+
+.topbar {
+    position: fixed;
+    top: 0;
+    left: 0;
+    z-index: 999;
+}
+
+.topbar .back {
+    width: 36rpx;
+    height: 36rpx;
+}
+.topbar .back image {
+    width: 20rpx;
+    height: 36rpx;
+}

BIN
images/back.png