tarbar.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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: '../index/index?ind=0'
  38. })
  39. }
  40. if(index == 1) {
  41. wx.redirectTo({
  42. url: '../mistakes/mistakes?ind=1'
  43. })
  44. }
  45. if(index == 2) {
  46. wx.redirectTo({
  47. url: '../language/language?ind=2'
  48. })
  49. }
  50. if(index == 3) {
  51. wx.redirectTo({
  52. url: '../mathematics/mathematics?ind=3'
  53. })
  54. }
  55. if(index == 4) {
  56. wx.redirectTo({
  57. url: '../chinese/chinese?ind=4'
  58. })
  59. }
  60. if(index == 5) {
  61. wx.redirectTo({
  62. url: '../english/english?ind=5'
  63. })
  64. }
  65. if(index == 6) {
  66. wx.redirectTo({
  67. url: '../science/science?ind=6'
  68. })
  69. }
  70. if(index == 7) {
  71. wx.redirectTo({
  72. url: '../art/art?ind=7'
  73. })
  74. }
  75. }
  76. },
  77. ready() {
  78. let options = util.getUrl();
  79. //console.log(options)
  80. if(options.ind) {
  81. this.setData({ navBtnSelectIdx: options.ind});
  82. }
  83. if (options.ind <= 2) {
  84. this.setData({ left: 0 });
  85. }
  86. if(options.ind > 2){
  87. this.setData({left: 200 });
  88. }
  89. }
  90. })