tarbar.js 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. // compontents/tarbar/tarbar.js
  2. const util = require('../../utils/util.js');
  3. Component({
  4. /**
  5. * 组件的属性列表
  6. * 第一次进入课程的nav
  7. */
  8. properties: {
  9. },
  10. /**
  11. * 组件的初始数据
  12. */
  13. data: {
  14. motto: ['我的','错题本','语文','数学','中文','英语','科学','艺术'],
  15. navBtnSelectIdx: 0,
  16. left: 0
  17. },
  18. /**
  19. * 组件的方法列表
  20. */
  21. methods: {
  22. navItemTap: function (e) {
  23. //更改navBtnSelectIdx加class
  24. let index = e.target.dataset.index;
  25. if (index != this.navBtnSelectIdx) {
  26. this.setData({ navBtnSelectIdx: index});
  27. }
  28. //移动nav
  29. if (index <= 2) {
  30. this.setData({ left: 0 });
  31. }
  32. if(index > 2){
  33. this.setData({left: 200 });
  34. }
  35. if(index == 0) {
  36. wx.redirectTo({
  37. url: '../my/my?ind=0&type=noTV'
  38. })
  39. }
  40. if(index == 1) {
  41. wx.redirectTo({
  42. url: '../mistakes/mistakes?ind=1&type=noTV'
  43. })
  44. }
  45. if(index == 2) {
  46. wx.redirectTo({
  47. url: '../language/language?ind=2&type=noTV'
  48. })
  49. }
  50. if(index == 3) {
  51. wx.redirectTo({
  52. url: '../mathematics/mathematics?ind=3&type=noTV'
  53. })
  54. }
  55. if(index == 4) {
  56. wx.redirectTo({
  57. url: '../chinese/chinese?ind=4&type=noTV'
  58. })
  59. }
  60. if(index == 5) {
  61. wx.redirectTo({
  62. url: '../english/english?ind=5&type=noTV'
  63. })
  64. }
  65. if(index == 6) {
  66. wx.redirectTo({
  67. url: '../science/science?ind=6&type=noTV'
  68. })
  69. }
  70. if(index == 7) {
  71. wx.redirectTo({
  72. url: '../art/art?ind=7&type=noTV'
  73. })
  74. }
  75. }
  76. },
  77. ready() {
  78. let options = util.getUrl();
  79. const ind = options.ind || util.convertObject(decodeURIComponent(options.scene)).ind || util.convertObject(decodeURIComponent(options.scene)).a;
  80. const noTv = options.type || '';
  81. // wx.setStorage({
  82. // key: "type",
  83. // data: noTv
  84. // })
  85. // console.log(wx.getStorageSync('type'))
  86. if(ind) {
  87. this.setData({ navBtnSelectIdx: ind});
  88. }
  89. if (ind <= 2) {
  90. this.setData({ left: 0 });
  91. }
  92. if(ind > 2){
  93. this.setData({left: 200 });
  94. }
  95. }
  96. })