index.js 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. androidMask: 'androidMaskFun'
  14. },
  15. },
  16. /**
  17. * 组件的属性列表
  18. */
  19. properties: {},
  20. /**
  21. * 组件的初始数据
  22. */
  23. data: {
  24. selected: 2,
  25. color: "#999999",
  26. selectedColor: "#32CA69",
  27. mask: false,
  28. show: true,
  29. listTab: [{
  30. "pagePath": "/pages/activity/index",
  31. "text": "排行榜",
  32. "iconPath": "/static/ranking.png",
  33. "selectedIconPath": "/static/ranking2.png"
  34. }, {
  35. "pagePath": "/pages/works/index",
  36. "text": "作品",
  37. "iconPath": "/static/zp.png",
  38. "selectedIconPath": "/static/zp2.png"
  39. }, {
  40. "pagePath": "/pages/index/index",
  41. "text": "推荐",
  42. "iconPath": "/static/tj.png",
  43. "selectedIconPath": "/static/tj2.png"
  44. }, {
  45. "pagePath": "/pages/message/index",
  46. "text": "消息",
  47. "iconPath": "/static/message.png",
  48. "selectedIconPath": "/static/message2.png"
  49. }, {
  50. "pagePath": "/pages/my/index",
  51. "text": "我的",
  52. "iconPath": "/static/my.png",
  53. "selectedIconPath": "/static/my2.png"
  54. }]
  55. },
  56. /**
  57. * 组件的方法列表
  58. */
  59. methods: {
  60. switchTab(e) {
  61. if (e.currentTarget.dataset.index != this.data.selected) {
  62. const data = e.currentTarget.dataset;
  63. const url = data.path;
  64. // 作品页面跳转时销毁
  65. if (this.data.selected == '1') {
  66. wx.reLaunch({
  67. url
  68. });
  69. } else {
  70. wx.switchTab({
  71. url
  72. });
  73. }
  74. this.setData({
  75. selected: ''
  76. })
  77. }
  78. },
  79. toAndroidLogin() {
  80. wx.redirectTo({
  81. url: '/pages/donutLogin/index',
  82. })
  83. }
  84. }
  85. })