const app = getApp(); const titleMap = ["实训项目", "实践课程","教学课堂"] const typeMap = { shixun:0, path:1, course:2 } Page({ data: { statusBarHeight: 20, current: 0, show: [1], showSearch:1, title:"实训项目", list: [ { text: "实训", type:"shixun"}, { text: "课程", type:"path"}, //{ text: "课堂", type:"course"} ] }, enterSearch() { let type = this.data.list[this.data.current].type || ''; app.navigateTo({ url: `{search}?type=${type}`}); }, onLoad: function (options) { wx.getSystemInfo({ success: res => { let { statusBarHeight } = res; this.setData({ statusBarHeight }); }, }) }, switch({current}){ let title = titleMap[current]; this.setData({ ['show[' + current + ']']: 1,current, title}); }, switchNav({ target: { dataset: { current } } }) { this.switch({current}); }, switchTab({ detail: { current, source, value } }) { if (source == "touch") { this.switch({current}); } }, onShareAppMessage: function () { let {list, current} = this.data; return app.shareApp({ path:"/"+this.route+"?type="+list[current].type }) } })