1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- // compontents/tarbar/tarbar.js
- const util = require('../../utils/util.js');
- Component({
- /**
- * 组件的属性列表
- */
- 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: '../index/index?ind=0'
- })
- }
- if(index == 1) {
- wx.redirectTo({
- url: '../recommend/recommend?ind=1'
- })
- }
- if(index == 2) {
- wx.redirectTo({
- url: '../language/language?ind=2'
- })
- }
- if(index == 3) {
- wx.redirectTo({
- url: '../mathematics/mathematics?ind=3'
- })
- }
- if(index == 4) {
- wx.redirectTo({
- url: '../chinese/chinese?ind=4'
- })
- }
- if(index == 5) {
- wx.redirectTo({
- url: '../english/english?ind=5'
- })
- }
- if(index == 6) {
- wx.redirectTo({
- url: '../science/science?ind=6'
- })
- }
- if(index == 7) {
- wx.redirectTo({
- url: '../art/art?ind=7'
- })
- }
- }
- },
- ready() {
- let options = util.getUrl();
- console.log(options)
- if(options.ind) {
- this.setData({ navBtnSelectIdx: options.ind});
- }
- if (options.ind <= 2) {
- this.setData({ left: 0 });
- }
- if(options.ind > 2){
- this.setData({left: 200 });
- }
- }
- })
|