// compontents/tarbar/tarbar.js const util = require('../../utils/util.js'); Component({ /** * 组件的属性列表 * 第一次进入课程的nav */ properties: { }, /** * 组件的初始数据 */ data: { motto: ['我的','错题本','语文','数学','中文','英语','科学','艺术'], navBtnSelectIdx: 0, left: 0 }, /** * 组件的方法列表 */ methods: { navItemTap: function (e) { //更改navBtnSelectIdx加class let index = e.target.dataset.index; if (index != this.navBtnSelectIdx) { this.setData({ navBtnSelectIdx: index}); } //移动nav if (index <= 2) { this.setData({ left: 0 }); } if(index > 2){ this.setData({left: 200 }); } if(index == 0) { wx.redirectTo({ url: '../my/my?ind=0&type=noTV' }) } if(index == 1) { wx.redirectTo({ url: '../mistakes/mistakes?ind=1&type=noTV' }) } if(index == 2) { wx.redirectTo({ url: '../language/language?ind=2&type=noTV' }) } if(index == 3) { wx.redirectTo({ url: '../mathematics/mathematics?ind=3&type=noTV' }) } if(index == 4) { wx.redirectTo({ url: '../chinese/chinese?ind=4&type=noTV' }) } if(index == 5) { wx.redirectTo({ url: '../english/english?ind=5&type=noTV' }) } if(index == 6) { wx.redirectTo({ url: '../science/science?ind=6&type=noTV' }) } if(index == 7) { wx.redirectTo({ url: '../art/art?ind=7&type=noTV' }) } } }, ready() { let options = util.getUrl(); const ind = options.ind || util.convertObject(decodeURIComponent(options.scene)).ind || util.convertObject(decodeURIComponent(options.scene)).a; const noTv = options.type || ''; // wx.setStorage({ // key: "type", // data: noTv // }) // console.log(wx.getStorageSync('type')) if(ind) { this.setData({ navBtnSelectIdx: ind}); } if (ind <= 2) { this.setData({ left: 0 }); } if(ind > 2){ this.setData({left: 200 }); } } })