index.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. import {
  2. ApiModel
  3. } from "../../../utils/api";
  4. const _Http = new ApiModel();
  5. Page({
  6. /**
  7. * 页面的初始数据
  8. */
  9. data: {
  10. /* 宫格列表 */
  11. gridList: [{
  12. id: '001',
  13. text: '商户管理',
  14. icon: '/static/login/Phone.png'
  15. }, {
  16. id: '002',
  17. text: '产品管理',
  18. icon: '/static/login/identity.png'
  19. }, {
  20. id: '003',
  21. text: '合作商家',
  22. icon: '/static/login/username.png'
  23. }, {
  24. id: '004',
  25. text: '团队管理',
  26. icon: '/static/login/verificationcode.png'
  27. }],
  28. userMessage: {}, //用户信息
  29. },
  30. /**
  31. * 生命周期函数--监听页面加载
  32. */
  33. onLoad: function (options) {
  34. },
  35. /* 宫格展示区跳转 */
  36. gridJumpPage(e) {
  37. const {
  38. name
  39. } = e.target.dataset
  40. console.log(name)
  41. if (name == "团队管理") {
  42. wx.navigateTo({
  43. url: '/pages/teamManagement/index',
  44. })
  45. } else if (name == '产品管理') {
  46. wx.navigateTo({
  47. url: '/pages/productManagement/index'
  48. })
  49. }
  50. },
  51. /* 跳转用户信息 */
  52. toUserCenter() {
  53. const data = JSON.stringify(this.data.userMessage)
  54. wx.navigateTo({
  55. url: '/pages/userCenter/index?data=' + data,
  56. })
  57. },
  58. /* 退出登录 */
  59. userLogout() {
  60. _Http.logout({
  61. "accesstoken": wx.getStorageSync('userData').token
  62. }).then(res => {
  63. if (res.status == "ok") {
  64. wx.showToast({
  65. title: '退出成功',
  66. })
  67. wx.setStorageSync('userData', {}) //清空用户数据
  68. setTimeout(() => {
  69. wx.reLaunch({
  70. url: '/pages/login/index',
  71. })
  72. }, 500)
  73. }
  74. })
  75. },
  76. /**
  77. * 生命周期函数--监听页面初次渲染完成
  78. */
  79. onReady: function () {
  80. },
  81. /**
  82. * 生命周期函数--监听页面显示
  83. */
  84. onShow: function () {
  85. // 获取用户信息
  86. _Http.basic({
  87. "accesstoken": wx.getStorageSync('userData').token,
  88. "classname": "customer.usercenter.usermsg.usermsg",
  89. "method": "query_usermsg",
  90. "content": {}
  91. }).then(res => {
  92. if (res.msg == '成功') return this.setData({
  93. userMessage: res.data[0]
  94. })
  95. })
  96. },
  97. /**
  98. * 生命周期函数--监听页面隐藏
  99. */
  100. onHide: function () {
  101. },
  102. /**
  103. * 生命周期函数--监听页面卸载
  104. */
  105. onUnload: function () {
  106. },
  107. /**
  108. * 页面相关事件处理函数--监听用户下拉动作
  109. */
  110. onPullDownRefresh: function () {
  111. },
  112. /**
  113. * 页面上拉触底事件的处理函数
  114. */
  115. onReachBottom: function () {
  116. },
  117. /**
  118. * 用户点击右上角分享
  119. */
  120. onShareAppMessage: function () {
  121. }
  122. })