my.js 2.6 KB

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