// components/tabBar/tabBar.js const app = getApp() Component({ // 纯数据字段规则 options: { pureDataPattern: /^_/ }, // 组件的属性列表 properties: { _tabBarInd: { type: Number, value: 0 } }, /** * 组件的初始数据 */ data: { isFullscreen: false, navList: [{ name: "首页", //文本 current: 0, //是否是当前页,0不是 1是 style: 0, //样式 typea: "https://api.zhumi.tech/MiniProgram/image/home.png", //不同图标 typec: "https://api.zhumi.tech/MiniProgram/image/homec.png", fn: 'index' }, { name: "课程", current: 0, style: 0, typea: "https://api.zhumi.tech/MiniProgram/image/course.png", //不同图标 typec: "https://api.zhumi.tech/MiniProgram/image/coursec.png", fn: 'packages' }, { // name: "超人妈妈学院", current: 0, style: 2, ico: '', fn: 'supermama' }, { name: "活动", current: 0, style: 0, typea: "https://api.zhumi.tech/MiniProgram/image/promotion.png", //不同图标 typec: "https://api.zhumi.tech/MiniProgram/image/promotionc.png", fn: 'promotion' }, { name: "我的", current: 0, style: 0, typea: "https://api.zhumi.tech/MiniProgram/image/mine.png", //不同图标 typec: "https://api.zhumi.tech/MiniProgram/image/minec.png", fn: 'mine' } ] }, lifetimes: { attached: function() { this.SetNavList() } }, // 旧式的定义方式,可以保持对 <2.2.3 版本基础库的兼容 attached: function() { this.SetNavList() }, ready:function() { let full = wx.getStorageSync('isFullscreen'); // console.log(full) this.setData({ isFullscreen: full }) }, methods: { // 设置tabbar数据 SetNavList: function() { let index = this.data._tabBarInd let deletedtodo = 'navList[' + index + ']' this.setData({ [deletedtodo + '.current']: 1, [deletedtodo + '.style']: index != 2 ? 1 : 2, [deletedtodo + '.fn']: '' }) }, // tabbar跳转页面 gotoPage: function(event) { let str = event.currentTarget.dataset.fn let url = `/pages/${str}/${str}` app.gopage(url) } } })