my.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. import login from '../../utils/login'
  2. import { VueLikePage } from '../../utils/page'
  3. import Router from '../../utils/routes'
  4. import { autoSubcrebe, subcrebe } from '../../utils/utils'
  5. const app = getApp();
  6. VueLikePage([], {
  7. options: {
  8. addGlobalClass: true,
  9. },
  10. data: {
  11. cu_items: [{
  12. title: '名片夹',
  13. icon: 'my_contacts',
  14. value: 'businessCard',
  15. needLogin: true
  16. },
  17. {
  18. title: '已收藏产品',
  19. icon: 'my_product',
  20. value: 'collectGoods',
  21. needLogin: true
  22. },
  23. // {
  24. // title: '已收藏参展商',
  25. // icon: 'my_enterprise',
  26. // value: 'collectEnterprise',
  27. // },
  28. // {
  29. // title: '数据报表',
  30. // icon: 'my_reportform',
  31. // value: 'dataReport',
  32. // needLogin: true
  33. // },
  34. {
  35. title: '账号设置',
  36. icon: 'my_set',
  37. value: 'logout',
  38. needLogin: true
  39. },
  40. {
  41. title: '开启消息订阅',
  42. icon: 'cus_msg',
  43. value: 'message',
  44. needLogin: true,
  45. hiddenKey: 'isCustomer',
  46. hidden: getApp().globalData.userinfo ? getApp().globalData.userinfo.type==='guide' : false
  47. },
  48. ],
  49. user_code: '',
  50. isLogined: app.globalData.token ? true : false,
  51. userinfo: app.globalData.userinfo
  52. },
  53. methods: {
  54. Navigator_to(e) {
  55. const { value } = e.currentTarget.dataset
  56. const item = this.data.cu_items.find(item => item.value === value)
  57. if (item.needLogin && !getApp().globalData.token) {
  58. Router.push('login')
  59. return
  60. }
  61. Router.push(value)
  62. },
  63. toModifyUser() {
  64. if (!this.data.isLogined) {
  65. return
  66. }
  67. wx.navigateTo({
  68. url: '/pages/user-info/user-info',
  69. })
  70. },
  71. /**
  72. * 生命周期函数--监听页面加载
  73. */
  74. onLoad: function (e) {
  75. wx.login({
  76. success: (res) => {
  77. this.setData({
  78. user_code: res.code
  79. })
  80. }
  81. })
  82. },
  83. onShow: function () {
  84. let cu_items = this.data.cu_items
  85. this.isCustomer = app.globalData.userinfo ? app.globalData.userinfo.type !== 'guide' : false
  86. cu_items.forEach(item => {
  87. if (item.hiddenKey) {
  88. item.hidden = this[item.hiddenKey]
  89. }
  90. })
  91. this.setData({
  92. cu_items,
  93. isLogined: app.globalData.token ? true : false,
  94. userinfo: app.globalData.userinfo
  95. });
  96. },
  97. bindgetphonenumber(e) {
  98. login(e, this.data.user_code).then(res => {
  99. this.setData({
  100. isLogined: app.globalData.token ? true : false,
  101. userinfo: app.globalData.userinfo
  102. })
  103. })
  104. },
  105. toLogin () {
  106. Router.push('login')
  107. }
  108. }
  109. })