Quellcode durchsuchen

Merge branch 'master' of http://git.cc-lotus.info/ball-court/court-mobile

YY vor 3 Jahren
Ursprung
Commit
6c05b7a5f6

+ 28 - 37
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,27 +23,10 @@ Component({
    * 组件的初始数据
    */
   data: {
+    // 当前选中菜单
     active: 0,
-    one: {
-      normal: '/image/shouye.png',
-      active: '/image/shouye-01.png',
-    },
-    two: {
-      normal: '/image/saishi.png',
-      active: '/image/saishi-01.png',
-    },
-    three: {
-      normal: '/image/miaobiao.png',
-      active: '/image/miaobiao-01.png',
-    },
-    four: {
-      normal: '/image/duiwu.png',
-      active: '/image/duiwu-01.png',
-    },
-    five: {
-      normal: '/image/wodexiao.png',
-      active: '/image/wodexiao-01.png',
-    },
+    // 菜单列表
+    menuList: []
   },
   /**
    * 组件的方法列表
@@ -50,24 +34,31 @@ Component({
   methods: {
     // 跳转
     tabPath(e) {
-      this.setData({ active: e.detail })
-      let route = e.detail == 0 ? 'home' : e.detail == 1 ? 'search' : e.detail == '2' ? 'administration' : e.detail == '3' ? 'team' : e.detail == '4' ? 'me' : '';
-      this.triggerEvent('tabPath', route)
+      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/home/index') {
-        this.setData({ active: 0 })
-      } else if (currentPage.route == 'pages/search/index') {
-        this.setData({ active: 1 })
-      } else if (currentPage.route == 'pages/administration/index') {
-        this.setData({ active: 2 })
-      } else if (currentPage.route == 'pages/team/index') {
-        this.setData({ active: 3 })
-      } else if (currentPage.route == 'pages/me/index') {
-        this.setData({ active: 4 })
-      }
+      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', })
+        }
+      })
     }
   }
 })

+ 4 - 24
commpents/mobile-frame/foot.wxml

@@ -1,29 +1,9 @@
 <view class="foot">
   <van-tabbar active="{{ active }}" bind:change="tabPath">
-    <van-tabbar-item>
-      <image slot="icon" src="{{ one.normal }}" mode="aspectFit" style="width: 24px; height: 26px;" />
-      <image slot="icon-active" src="{{ one.active }}" mode="aspectFit" style="width: 24px; height: 26px;" />
-      首页
-    </van-tabbar-item>
-    <van-tabbar-item>
-      <image slot="icon" src="{{ two.normal }}" mode="aspectFit" style="width: 24px; height: 26px;" />
-      <image slot="icon-active" src="{{ two.active }}" mode="aspectFit" style="width: 24px; height: 26px;" />
-      查询比赛
-    </van-tabbar-item>
-    <van-tabbar-item>
-      <image slot="icon" src="{{ three.normal }}" mode="aspectFit" style="width: 24px; height: 26px;" />
-      <image slot="icon-active" src="{{ three.active }}" mode="aspectFit" style="width: 24px; height: 26px;" />
-      比赛管理
-    </van-tabbar-item>
-    <van-tabbar-item>
-      <image slot="icon" src="{{ four.normal }}" mode="aspectFit" style="width: 24px; height: 26px;" />
-      <image slot="icon-active" src="{{ four.active }}" mode="aspectFit" style="width: 24px; height: 26px;" />
-      查找团队
-    </van-tabbar-item>
-    <van-tabbar-item>
-      <image slot="icon" src="{{ five.normal }}" mode="aspectFit" style="width: 24px; height: 26px;" />
-      <image slot="icon-active" src="{{ five.active }}" mode="aspectFit" style="width: 24px; height: 26px;" />
-      我的
+    <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>

+ 3 - 2
pages/administration/index.js

@@ -18,9 +18,10 @@ Page({
     nostart: [],
     complete: [],
   },
+  // 跳转菜单
   tabPath(e) {
-    let query = e.detail.detail;
-    if (query) wx.redirectTo({ url: `/pages/${query}/index` })
+    let { route } = e.detail.detail;
+    if (route) wx.redirectTo({ url: `/${route}` })
   },
   //跳转详情页
   tiao: function (e) {

+ 2 - 2
pages/home/index.js

@@ -14,8 +14,8 @@ Page({
   },
   // 跳转菜单
   tabPath(e) {
-    let query = e.detail.detail;
-    if (query) wx.redirectTo({ url: `/pages/${query}/index` })
+    let { route } = e.detail.detail;
+    if (route) wx.redirectTo({ url: `/${route}` })
   },
   //跳转详情
   tiao: function (e) {

+ 3 - 2
pages/me/index.js

@@ -30,9 +30,10 @@ Page({
     icon: '',
     showModal: false,
   },
+  // 跳转菜单
   tabPath(e) {
-    let query = e.detail.detail;
-    if (query) wx.redirectTo({ url: `/pages/${query}/index` })
+    let { route } = e.detail.detail;
+    if (route) wx.redirectTo({ url: `/${route}` })
   },
   //展开
   listToggle: function () {

+ 6 - 4
pages/search/index.js

@@ -13,6 +13,11 @@ Page({
     infoHeight: '',
     list: [],
     listend: [],
+  },
+   // 跳转菜单
+   tabPath(e) {
+    let { route } = e.detail.detail;
+    if (route) wx.redirectTo({ url: `/${route}` })
   },
   //跳转详情
   tiao: function (e) {
@@ -21,10 +26,7 @@ Page({
       url: '/pages/list/index?id=' + id,
     })
   },
-  tabPath(e) {
-    let query = e.detail.detail;
-    if (query) wx.redirectTo({ url: `/pages/${query}/index` })
-  },
+
   /**
    * 生命周期函数--监听页面加载
    */

+ 3 - 2
pages/team/index.js

@@ -14,9 +14,10 @@ Page({
     infoHeight: '',
     teamlist: [],
   },
+  // 跳转菜单
   tabPath(e) {
-    let query = e.detail.detail;
-    if (query) wx.redirectTo({ url: `/pages/${query}/index` })
+    let { route } = e.detail.detail;
+    if (route) wx.redirectTo({ url: `/${route}` })
   },
   //跳转查看
   tiao: function (e) {