diff --git a/app.js b/app.js index ee69f55..da4a484 100644 --- a/app.js +++ b/app.js @@ -178,7 +178,7 @@ App({ }, globalData:{ userInfo:null, - apiurl:"https://g.hnyhua.cn", //https://g.hnyhua.cn + apiurl:"http://localhost:24382", //https://g.hnyhua.cn IFRefreshCart:0, IFRefreshsell:0, IFRefreshsell0:0, @@ -201,6 +201,66 @@ App({ selladdress0:{}, IFYGM:0, IFwxLogin:0,//是否点击微信一键登录1还是扫码自动登录0 - servermsg:"" + servermsg:"", + // 全局菜单配置 + tabBarList: [ + { + "pagePath": "/pages/index/index", + "text": "首页", + "iconPath": "/images/footer-icon-01.png", + "selectedIconPath": "/images/footer-icon-01-active.png" + }, + { + "pagePath": "/pages/news/index", + "iconPath": "/images/footer-icon-05.png", + "selectedIconPath": "/images/footer-icon-05-active.png", + "text": "资讯" + }, + { + "pagePath": "/pages/shop/index", + "iconPath": "/images/footer-icon-07.png", + "selectedIconPath": "/images/footer-icon-07-active.png", + "text": "商城" + }, + { + "pagePath": "/pages/business/index", + "iconPath": "/images/footer-icon-02.png", + "selectedIconPath": "/images/footer-icon-02-active.png", + "text": "门店" + }, + { + "pagePath": "/pages/my/index", + "text": "我的", + "iconPath": "/images/footer-icon-04.png", + "selectedIconPath": "/images/footer-icon-04-active.png" + } + ], + // 特殊权限菜单配置(bdshEnable=1) + tabBarListBdsh: [ + { + "pagePath": "/pages/index/index", + "text": "首页", + "iconPath": "/images/footer-icon-01.png", + "selectedIconPath": "/images/footer-icon-01-active.png" + }, + { + "pagePath": "/pages/news/index", + "iconPath": "/images/footer-icon-05.png", + "selectedIconPath": "/images/footer-icon-05-active.png", + "text": "资讯" + }, + { + "pagePath": "/pages/shop/index", + "iconPath": "/images/footer-icon-07.png", + "selectedIconPath": "/images/footer-icon-07-active.png", + "text": "商城" + }, + { + "pagePath": "/pages/my/index", + "text": "我的", + "iconPath": "/images/footer-icon-04.png", + "selectedIconPath": "/images/footer-icon-04-active.png" + } + ] } }) \ No newline at end of file diff --git a/app.json b/app.json index 846c40c..265b836 100644 --- a/app.json +++ b/app.json @@ -66,7 +66,7 @@ "window": { "backgroundTextStyle": "light", "navigationBarTextStyle": "white", - "navigationBarTitleText": "银花优选", + "navigationBarTitleText": "仁E森命", "navigationBarBackgroundColor": "#1E88E5", "backgroundColor": "#F2f2f2", "enablePullDownRefresh": true @@ -89,6 +89,12 @@ "selectedIconPath": "images/footer-icon-05-active.png", "text": "资讯" }, + { + "pagePath": "pages/shop/index", + "iconPath": "images/footer-icon-07.png", + "selectedIconPath": "images/footer-icon-07-active.png", + "text": "商城" + }, { "pagePath": "pages/business/index", "iconPath": "images/footer-icon-02.png", diff --git a/custom-tab-bar/index.js b/custom-tab-bar/index.js index 4506a6d..6a3d739 100644 --- a/custom-tab-bar/index.js +++ b/custom-tab-bar/index.js @@ -2,36 +2,24 @@ Component({ data: { selected: 0, color: "#6e6d6b", - selectedColor: "#00B050", - "list": [ - { - "pagePath": "/pages/index/index", - "text": "首页", - "iconPath": "/images/footer-icon-01.png", - "selectedIconPath": "/images/footer-icon-01-active.png" - }, - { - "pagePath": "/pages/news/index", - "iconPath": "/images/footer-icon-05.png", - "selectedIconPath": "/images/footer-icon-05-active.png", - "text": "资讯" - }, - { - "pagePath": "/pages/business/index", - "iconPath": "/images/footer-icon-02.png", - "selectedIconPath": "/images/footer-icon-02-active.png", - "text": "门店" - }, - - { - "pagePath": "/pages/my/index", - "text": "我的", - "iconPath": "/images/footer-icon-04.png", - "selectedIconPath": "/images/footer-icon-04-active.png" - } - ] + selectedColor: "#1E88E5", + "list": [] }, attached() { + const app = getApp(); + const userId = wx.getStorageSync("userId"); + const userInfodata = wx.getStorageSync("userInfo"); + let ifsel = 0; + + if (userId && userInfodata) { + const userInfo = JSON.parse(userInfodata); + ifsel = userInfo.bdshEnable; + } + + // 从全局配置获取菜单列表 + this.setData({ + list: ifsel == 1 ? app.globalData.tabBarListBdsh : app.globalData.tabBarList + }); }, methods: { switchTab(e) { diff --git a/pages/business/index.js b/pages/business/index.js index d25423f..d34c10c 100644 --- a/pages/business/index.js +++ b/pages/business/index.js @@ -23,75 +23,24 @@ Page( { keyword:"", },onShow: function () { if (typeof this.getTabBar === 'function' && this.getTabBar()) { - that0=this; - var userId = wx.getStorageSync("userId") - var userInfodata = wx.getStorageSync("userInfo") - var sel=2; - var ifsel=0; - if(userId&&userInfodata){ - var userInfo = JSON.parse(userInfodata) - - ifsel=userInfo.bdshEnable; + const userId = wx.getStorageSync("userId") + const userInfodata = wx.getStorageSync("userInfo") + let sel = 3; + + // 根据用户权限调整选中索引 + if (userId && userInfodata) { + const userInfo = JSON.parse(userInfodata); + if (userInfo.bdshEnable == 1) { + sel = 3; // 在特殊权限菜单中,"门店"选项不存在,"我的"选项索引为3 + } else { + sel = 3; // 在普通菜单中,"门店"选项索引为3 } - - if(ifsel==1){ - that0.getTabBar().setData({ - "list": [ - { - "pagePath": "/pages/index/index", - "text": "首页", - "iconPath": "/images/footer-icon-01.png", - "selectedIconPath": "/images/footer-icon-01-active.png" - }, - { - "pagePath": "/pages/news/index", - "iconPath": "/images/footer-icon-05.png", - "selectedIconPath": "/images/footer-icon-05-active.png", - "text": "资讯" - }, - - { - "pagePath": "/pages/my/index", - "text": "我的", - "iconPath": "/images/footer-icon-04.png", - "selectedIconPath": "/images/footer-icon-04-active.png" - } - ] - }) - }else{ - that0.getTabBar().setData({ - "list": [ - { - "pagePath": "/pages/index/index", - "text": "首页", - "iconPath": "/images/footer-icon-01.png", - "selectedIconPath": "/images/footer-icon-01-active.png" - }, - { - "pagePath": "/pages/news/index", - "iconPath": "/images/footer-icon-05.png", - "selectedIconPath": "/images/footer-icon-05-active.png", - "text": "资讯" - }, - { - "pagePath": "/pages/business/index", - "iconPath": "/images/footer-icon-02.png", - "selectedIconPath": "/images/footer-icon-02-active.png", - "text": "门店" - }, - - { - "pagePath": "/pages/my/index", - "text": "我的", - "iconPath": "/images/footer-icon-04.png", - "selectedIconPath": "/images/footer-icon-04-active.png" - } - ] - }) - } - that0.getTabBar().setData({ - selected: sel - }) + } + + // 只设置选中状态,菜单列表由全局配置管理 + this.getTabBar().setData({ + selected: sel + }) } }, diff --git a/pages/index/index.js b/pages/index/index.js index 0b41967..ae53b75 100644 --- a/pages/index/index.js +++ b/pages/index/index.js @@ -1,4 +1,4 @@ -var WxParse = null; +var WxParse = null; //获取应用实例 var app = getApp() var sopenFrame = null @@ -124,70 +124,9 @@ Page({ }, onShow: function () { if (typeof this.getTabBar === 'function' && this.getTabBar()) { - that0 = this; - var userId = wx.getStorageSync("userId") - var userInfodata = wx.getStorageSync("userInfo") - var sel = 0; - var ifsel = 0; - if (userId && userInfodata) { - var userInfo = JSON.parse(userInfodata) - - ifsel = userInfo.bdshEnable; - } - - if (ifsel == 1) { - that0.getTabBar().setData({ - "list": [{ - "pagePath": "/pages/index/index", - "text": "首页", - "iconPath": "/images/footer-icon-01.png", - "selectedIconPath": "/images/footer-icon-01-active.png" - }, - { - "pagePath": "/pages/news/index", - "iconPath": "/images/footer-icon-05.png", - "selectedIconPath": "/images/footer-icon-05-active.png", - "text": "资讯" - }, - { - "pagePath": "/pages/my/index", - "text": "我的", - "iconPath": "/images/footer-icon-04.png", - "selectedIconPath": "/images/footer-icon-04-active.png" - } - ] - }) - } else { - that0.getTabBar().setData({ - "list": [{ - "pagePath": "/pages/index/index", - "text": "首页", - "iconPath": "/images/footer-icon-01.png", - "selectedIconPath": "/images/footer-icon-01-active.png" - }, - { - "pagePath": "/pages/news/index", - "iconPath": "/images/footer-icon-05.png", - "selectedIconPath": "/images/footer-icon-05-active.png", - "text": "资讯" - }, - { - "pagePath": "/pages/business/index", - "iconPath": "/images/footer-icon-02.png", - "selectedIconPath": "/images/footer-icon-02-active.png", - "text": "门店" - }, - { - "pagePath": "/pages/my/index", - "text": "我的", - "iconPath": "/images/footer-icon-04.png", - "selectedIconPath": "/images/footer-icon-04-active.png" - } - ] - }) - } - that0.getTabBar().setData({ - selected: sel + // 只设置选中状态,菜单列表由全局配置管理 + this.getTabBar().setData({ + selected: 0 }) } }, diff --git a/pages/index/index.wxml b/pages/index/index.wxml index 8cb5a18..0c5abc0 100644 --- a/pages/index/index.wxml +++ b/pages/index/index.wxml @@ -128,7 +128,7 @@ {{cell.name}} 零售价:¥{{cell.scje}} 会员价:¥{{cell.hyje}} - + 立即购买 @@ -160,7 +160,7 @@ {{cell.name}} 兑换券:{{cell.hyje}} - + 立即购买 diff --git a/pages/my/index.js b/pages/my/index.js index 0f7f12d..eff06b0 100644 --- a/pages/my/index.js +++ b/pages/my/index.js @@ -46,66 +46,23 @@ Page({ that0 = this; var userId = wx.getStorageSync("userId") var userInfodata = wx.getStorageSync("userInfo") - var sel = 3; + var sel = 4; var ifsel = 0; + if (userId && userInfodata) { var userInfo = JSON.parse(userInfodata) ifsel = userInfo.bdshEnable; that0.GetSignInfo(); } + // 根据用户权限调整选中索引 if (ifsel == 1) { - sel = 3; - that0.getTabBar().setData({ - "list": [{ - "pagePath": "/pages/index/index", - "text": "首页", - "iconPath": "/images/footer-icon-01.png", - "selectedIconPath": "/images/footer-icon-01-active.png" - }, - { - "pagePath": "/pages/news/index", - "iconPath": "/images/footer-icon-05.png", - "selectedIconPath": "/images/footer-icon-05-active.png", - "text": "资讯" - }, - { - "pagePath": "/pages/my/index", - "text": "我的", - "iconPath": "/images/footer-icon-04.png", - "selectedIconPath": "/images/footer-icon-04-active.png" - } - ] - }) + sel = 3; // 在特殊权限菜单中,"我的"选项索引为3 } else { - that0.getTabBar().setData({ - "list": [{ - "pagePath": "/pages/index/index", - "text": "首页", - "iconPath": "/images/footer-icon-01.png", - "selectedIconPath": "/images/footer-icon-01-active.png" - }, - { - "pagePath": "/pages/news/index", - "iconPath": "/images/footer-icon-05.png", - "selectedIconPath": "/images/footer-icon-05-active.png", - "text": "资讯" - }, - { - "pagePath": "/pages/business/index", - "iconPath": "/images/footer-icon-02.png", - "selectedIconPath": "/images/footer-icon-02-active.png", - "text": "门店" - }, - { - "pagePath": "/pages/my/index", - "text": "我的", - "iconPath": "/images/footer-icon-04.png", - "selectedIconPath": "/images/footer-icon-04-active.png" - } - ] - }) + sel = 4; // 在普通菜单中,"我的"选项索引为4 } + + // 只设置选中状态,菜单列表由全局配置管理 that0.getTabBar().setData({ selected: sel }) diff --git a/pages/register/index.wxml b/pages/register/index.wxml index ad5e119..0c56ce0 100644 --- a/pages/register/index.wxml +++ b/pages/register/index.wxml @@ -53,7 +53,7 @@ - 本人已阅读并同意银花优选 + 本人已阅读并同意仁E森命 《用户服务协议》 diff --git a/pages/shop/index.wxml b/pages/shop/index.wxml index 7e1e180..c964999 100644 --- a/pages/shop/index.wxml +++ b/pages/shop/index.wxml @@ -52,7 +52,7 @@ - +