diff --git a/custom-tab-bar/index.js b/custom-tab-bar/index.js index 93329d3..099c9f5 100644 --- a/custom-tab-bar/index.js +++ b/custom-tab-bar/index.js @@ -1,6 +1,6 @@ Component({ data: { - selected: 0, //当前选中的tab下标 + selected: null, //当前选中的tab下标 color: "#1E1E1E", selectedColor: "#646464", //tabbar选中字体颜色 list: [{ @@ -40,13 +40,19 @@ Component({ switchTab(e) { const data = e.currentTarget.dataset; const url = data.path - console.log(url) - this.setData({ - selected: data.index - }) + // this.setData({ + // selected: data.index + // }) wx.switchTab({ url: "/" + url }) - } + }, + init() { + const page = getCurrentPages().pop(); + let n = this.data.list.findIndex(item => item.pagePath === `${page.route}`); + this.setData({ + selected: n + }); + } }, }) \ No newline at end of file diff --git a/pages/brandSearch/index.js b/pages/brandSearch/index.js index e7381ce..6cc3c52 100644 --- a/pages/brandSearch/index.js +++ b/pages/brandSearch/index.js @@ -2,5 +2,8 @@ Page({ data: { - } + }, + onShow() { + this.getTabBar().init(); + }, }); diff --git a/pages/index/index.js b/pages/index/index.js index 6540b4d..d6feef8 100644 --- a/pages/index/index.js +++ b/pages/index/index.js @@ -4,10 +4,9 @@ const app = getApp() Page({ data: { - tabbar:{}, - condition: ['二十四小时','最近七天','最近三十天','自定义'], - toplist: [ - { + tabbar: {}, + condition: ['二十四小时', '最近七天', '最近三十天', '自定义'], + toplist: [{ url: '', title: '入库数据总量', num: '0' @@ -46,10 +45,13 @@ Page({ num: '0' }, ], - + + }, + onShow() { + this.getTabBar().init(); }, onLoad: function (options) { - + }, -}) +}) \ No newline at end of file diff --git a/pages/insight/index.js b/pages/insight/index.js index e7381ce..6cc3c52 100644 --- a/pages/insight/index.js +++ b/pages/insight/index.js @@ -2,5 +2,8 @@ Page({ data: { - } + }, + onShow() { + this.getTabBar().init(); + }, }); diff --git a/pages/mine/index.js b/pages/mine/index.js index e7381ce..6cc3c52 100644 --- a/pages/mine/index.js +++ b/pages/mine/index.js @@ -2,5 +2,8 @@ Page({ data: { - } + }, + onShow() { + this.getTabBar().init(); + }, }); diff --git a/pages/varComm/index.js b/pages/varComm/index.js index e7381ce..6cc3c52 100644 --- a/pages/varComm/index.js +++ b/pages/varComm/index.js @@ -2,5 +2,8 @@ Page({ data: { - } + }, + onShow() { + this.getTabBar().init(); + }, }); diff --git a/project.config.json b/project.config.json index d956b7f..1750650 100644 --- a/project.config.json +++ b/project.config.json @@ -51,13 +51,13 @@ "ignoreUploadUnusedFiles": true }, "compileType": "miniprogram", - "libVersion": "2.19.4", + "libVersion": "2.24.7", "appid": "wxc7ec43a0959453fb", "projectname": "miniprogram-92", - "condition": {}, "editorSetting": { "tabIndent": "insertSpaces", "tabSize": 4 }, - "simulatorPluginLibVersion": {} + "simulatorPluginLibVersion": {}, + "condition": {} } \ No newline at end of file