guhongwei 2 年之前
父節點
當前提交
0570d0b7f3

+ 31 - 11
commpents/mobile-frame/foot.js

@@ -1,5 +1,6 @@
 // commpents/mobile-frame/mobile-main.js
-const app = getApp()
+const app = getApp();
+import { system } from "../../utils/dict";
 Component({
   /**
    * 组件的属性列表
@@ -22,24 +23,43 @@ Component({
    * 组件的初始数据
    */
   data: {
-    active: '0'
+    // 当前选中菜单
+    active: 0,
+    // 菜单列表
+    menuList: []
   },
   /**
    * 组件的方法列表
    */
   methods: {
-    // 返回上一级
+    // 跳转
     tabPath(e) {
-      this.triggerEvent('tabPath', { index: e.detail })
+      const that = this;
+      that.setData({ active: e.detail });
+      let route = that.data.menuList[e.detail];
+      if (route) that.triggerEvent('tabPath', route)
     },
     search() {
-      let pages = getCurrentPages();
-      let currentPage = pages[pages.length - 1];
-      if (currentPage.route == 'pages/market/index') {
-        this.setData({ active: 0 })
-      } else {
-        this.setData({ active: 1 })
-      }
+      const that = this;
+      // 监听用户是否登录
+      wx.getStorage({
+        key: 'token',
+        success: res => {
+          // 获取当前路由地址
+          let pages = getCurrentPages();
+          let currentPage = pages[pages.length - 1];
+          let menu = system.filter((i) => i.type.includes(res.data.type));
+          if (menu) {
+            that.setData({ menuList: menu });
+            let index = menu.findIndex((i) => i.route == currentPage.route);
+            if (index) that.setData({ active: index });
+          }
+        },
+        fail: res => {
+          return wx.redirectTo({ url: '/pages/login/index', })
+        }
+      })
     }
   }
 })
+

+ 5 - 2
commpents/mobile-frame/foot.wxml

@@ -1,6 +1,9 @@
 <view class="foot">
   <van-tabbar active="{{ active }}" bind:change="tabPath">
-    <van-tabbar-item icon="cart-o">采购</van-tabbar-item>
-    <van-tabbar-item icon="manager-o">个人中心</van-tabbar-item>
+    <van-tabbar-item wx:for="{{menuList}}" wx:key="item">
+      <image slot="icon" src="{{ item.normal }}" mode="aspectFit" style="width: 24px; height: 26px;" />
+      <image slot="icon-active" src="{{ item.active }}" mode="aspectFit" style="width: 24px; height: 26px;" />
+      {{item.title}}
+    </van-tabbar-item>
   </van-tabbar>
 </view>

+ 4 - 2
commpents/mobile-frame/foot.wxss

@@ -1,6 +1,8 @@
 .foot {
   float: left;
   width: 100%;
-  height: 48px;
-  border-top: 1px solid #666;
+}
+
+.iocn {
+  text-align: center;
 }

+ 7 - 6
commpents/mobile-frame/mobile-main.js

@@ -31,19 +31,20 @@ Component({
   methods: {
     // 返回上一级
     back() {
-      this.triggerEvent('back',)
+      this.triggerEvent('back', '1')
     },
     tabPath(e) {
       this.triggerEvent('tabPath', e)
     },
     searchHeight() {
-      let frameStyle = this.properties.frameStyle;
+      let frameStyle = this.data.frameStyle;
       let client = app.globalData.client;
-      // 减去状态栏
-      let infoHeight = client.windowHeight - (client.statusBarHeight + client.getMenu.height + (client.getMenu.top - client.statusBarHeight) * 2);
-      // 是否减去底部菜单
+      let infoHeight = client.windowHeight;
+      // 减去状态栏
+      if (frameStyle.useTop) infoHeight = infoHeight - (client.statusBarHeight + client.getMenu.height + (client.getMenu.top - client.statusBarHeight) * 2);
+      // 减去菜单栏
       if (frameStyle.useBar) infoHeight = infoHeight - 50;
-      if (infoHeight) this.setData({ infoHeight: infoHeight })
+      this.setData({ infoHeight: infoHeight })
     }
   }
 })

+ 1 - 0
commpents/mobile-frame/mobile-main.wxss

@@ -1,6 +1,7 @@
 .main {
   float: left;
   width: 100%;
+  background-color: #f1f1f1;
 }
 
 .main .one {

+ 2 - 2
commpents/mobile-frame/top.wxss

@@ -1,7 +1,7 @@
 .top {
   float: left;
   width: 100%;
-  background-color: #409eff9f;
+  background-color: #ffffff;
 }
 
 .top .left {
@@ -25,7 +25,7 @@
   width: 70%;
   text-align: center;
   font-size: 36rpx;
-  color: #ffffff;
+  color: #000000;
   font-weight: 600;
 }