diff --git a/app.js b/app.js index 9592b27..4f54ee8 100644 --- a/app.js +++ b/app.js @@ -5,29 +5,87 @@ var api = require("./api/api.js") //公共方法和变量 App({ - globalData: { - setting: t, - wechatUser: null, - userInfo: null, - config: null, //门店参数 - config2: null, //门店配置 - code: null, - heigth:0, - user_id:null,// 3674923,// 4379287,// null,// 5682068, - buy_now:null, - picklist:null, //门店列表 - wuliuprice: null, //物流价格表 - wuliu: null, //物流公司 - baddr:null, - mobile: null, //记录手机 - getu:null, //记录会员信息 - sessionKey: null,//记录会员信息 - openid: null, //记录会员信息 + editTabBar: function () { + //使用getCurrentPages可以获取当前加载中所有的页面对象的一个数组,数组最后一个就是当前页面。 - to_group:null, //参团传递的数据 - wxapp_buy_obj:null, //微信小程序购买的Object - pk_store:null, //选择的门店 + var curPageArr = getCurrentPages(); //获取加载的页面 + var curPage = curPageArr[curPageArr.length - 1]; //获取当前页面的对象 + var pagePath = curPage.route; //当前页面url + if (pagePath.indexOf('/') != 0) { + pagePath = '/' + pagePath; + } + console.log("获取加载的页面:="+curPageArr) + console.log("获取当前页面的对象:="+curPage) + console.log("当前页面url:="+pagePath) + var tabBar = this.globalData.tabBar; + for (var i = 0; i < tabBar.list.length; i++) { + tabBar.list[i].active = false; + if (tabBar.list[i].weappurl == pagePath) { + tabBar.list[i].active = true; //根据页面地址设置当前页面状态 + } + } + curPage.setData({ + tabBar: tabBar + }); + }, + + globalData: { + tabBar: { + "color": "#6e6d6b",//文字未选择color + "selectedColor": "#f23030",//文字被选择后color + "borderStyle": "white",// + "backgroundColor": "#ffffff",//背景color + "iscustom":'', + "list": [ + { + "weappurl": "/pages/index/index/index", + "nav_name": "首页", + "src": "/images/bar/index.png", + "src_sele": "/images/bar/index_on.png" + }, + { + "weappurl": "/pages/goods/categoryList/categoryList", + "nav_name": "分类", + "src": "/images/bar/fl.png", + "src_sele": "/images/bar/fl_on.png" + }, + { + "weappurl": "/pages/cart/cart/cart", + "nav_name": "购物车", + "src": "/images/bar/car.png", + "src_sele": "/images/bar/car_on.png" + }, + { + "weappurl": "/pages/user/index/index", + "nav_name": "我的", + "src": "/images/bar/user.png", + "src_sele": "/images/bar/user_on.png" + } + ] }, + isTabBar:false, + setting: t, + wechatUser: null, + userInfo: null, + config: null, //门店参数 + config2: null, //门店配置 + code: null, + heigth:0, + user_id:null,// 3674923,// 4379287,// null,// 5682068, + buy_now:null, + picklist:null, //门店列表 + wuliuprice: null, //物流价格表 + wuliu: null, //物流公司 + baddr:null, + mobile: null, //记录手机 + getu:null, //记录会员信息 + sessionKey: null,//记录会员信息 + openid: null, //记录会员信息 + + to_group:null, //参团传递的数据 + wxapp_buy_obj:null, //微信小程序购买的Object + pk_store:null, //选择的门店 + }, auth: o, request: a, onLaunch: function() { diff --git a/app.json b/app.json index 7b1d17e..c570bab 100644 --- a/app.json +++ b/app.json @@ -111,38 +111,7 @@ "backgroundColor": "#ffffff", "enablePullDownRefresh": true }, - "tabBar": { - "color": "#6e6d6b", - "selectedColor": "#f23030", - "borderStyle": "white", - "backgroundColor": "#ffffff", - "list": [ - { - "pagePath": "pages/index/index/index", - "text": "首页", - "iconPath": "packageA/images/bar/index.png", - "selectedIconPath": "packageA/images/bar/index_on.png" - }, - { - "pagePath": "pages/goods/categoryList/categoryList", - "text": "分类", - "iconPath": "packageA/images/bar/fl.png", - "selectedIconPath": "packageA/images/bar/fl_on.png" - }, - { - "pagePath": "pages/cart/cart/cart", - "text": "购物车", - "iconPath": "packageA/images/bar/car.png", - "selectedIconPath": "packageA/images/bar/car_on.png" - }, - { - "pagePath": "pages/user/index/index", - "text": "我的", - "iconPath": "packageA/images/bar/user.png", - "selectedIconPath": "packageA/images/bar/user_on.png" - } - ] - }, + "debug": false, "sitemapLocation": "sitemap.json" } \ No newline at end of file diff --git a/pages/cart/cart/cart.js b/pages/cart/cart/cart.js index 73a41f7..0e836d6 100644 --- a/pages/cart/cart/cart.js +++ b/pages/cart/cart/cart.js @@ -55,6 +55,11 @@ Page({ }, onShow: function() { var th = this; + th.setData({ + isTabBar: getApp().globalData.isTabBar, + }); + + t.editTabBar(); //显示自定义的底部导航 this.getCardList(); if(getApp().globalData.user_id) getApp().requestCardNum(); //--获取是否又秒杀活动-- @@ -73,6 +78,7 @@ Page({ }) } }); + isTabBar }, diff --git a/pages/cart/cart/cart.wxml b/pages/cart/cart/cart.wxml index c820f5a..e6e30ec 100644 --- a/pages/cart/cart/cart.wxml +++ b/pages/cart/cart/cart.wxml @@ -147,7 +147,7 @@ - + @@ -182,4 +182,8 @@ - \ No newline at end of file + + + +