index.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. import {
  2. storeBindingsBehavior
  3. } from 'mobx-miniprogram-bindings'
  4. import {
  5. store
  6. } from '~/store/index'
  7. Component({
  8. behaviors: [storeBindingsBehavior],
  9. storeBindings: {
  10. store,
  11. fields: {
  12. userInfo: 'userInfo'
  13. },
  14. },
  15. /**
  16. * 组件的属性列表
  17. */
  18. properties: {},
  19. /**
  20. * 组件的初始数据
  21. */
  22. data: {
  23. selected: 2,
  24. color: "#999999",
  25. selectedColor: "#32CA69",
  26. mask: false,
  27. listTab: [{
  28. "pagePath": "/pages/activity/index",
  29. "text": "活动",
  30. "iconPath": "/static/activity.png",
  31. "selectedIconPath": "/static/activity2.png"
  32. }, {
  33. "pagePath": "/pages/works/index",
  34. "text": "作品",
  35. "iconPath": "/static/zp.png",
  36. "selectedIconPath": "/static/zp2.png"
  37. }, {
  38. "pagePath": "/pages/index/index",
  39. "text": "推荐",
  40. "iconPath": "/static/tj.png",
  41. "selectedIconPath": "/static/tj2.png"
  42. }, {
  43. "pagePath": "/pages/message/index",
  44. "text": "消息",
  45. "iconPath": "/static/message.png",
  46. "selectedIconPath": "/static/message2.png"
  47. }, {
  48. "pagePath": "/pages/my/index",
  49. "text": "我的",
  50. "iconPath": "/static/my.png",
  51. "selectedIconPath": "/static/my2.png"
  52. }]
  53. },
  54. /**
  55. * 组件的方法列表
  56. */
  57. methods: {
  58. switchTab(e) {
  59. if (e.currentTarget.dataset.index != this.data.selected) {
  60. this.setData({
  61. selected: ''
  62. })
  63. const data = e.currentTarget.dataset;
  64. const url = data.path;
  65. wx.switchTab({
  66. url
  67. });
  68. }
  69. }
  70. }
  71. })