index.js 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  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. } else if (name == '商户管理') {
  50. wx.navigateTo({
  51. url: '/pages/storeMessage/index'
  52. })
  53. }
  54. },
  55. /* 跳转用户信息 */
  56. toUserCenter() {
  57. const data = JSON.stringify(this.data.userMessage)
  58. wx.navigateTo({
  59. url: '/pages/userCenter/index?data=' + data,
  60. })
  61. },
  62. /* 退出登录 */
  63. userLogout() {
  64. _Http.logout({
  65. "accesstoken": wx.getStorageSync('userData').token
  66. }).then(res => {
  67. if (res.status == "ok") {
  68. wx.showToast({
  69. title: '退出成功',
  70. })
  71. wx.setStorageSync('userData', {}) //清空用户数据
  72. setTimeout(() => {
  73. wx.reLaunch({
  74. url: '/pages/login/index',
  75. })
  76. }, 500)
  77. }
  78. })
  79. },
  80. /**
  81. * 生命周期函数--监听页面初次渲染完成
  82. */
  83. onReady: function () {
  84. },
  85. /**
  86. * 生命周期函数--监听页面显示
  87. */
  88. onShow: function () {
  89. this.getTabBar().init();
  90. // 获取用户信息
  91. _Http.basic({
  92. "accesstoken": wx.getStorageSync('userData').token,
  93. "classname": "customer.usercenter.usermsg.usermsg",
  94. "method": "query_usermsg",
  95. "content": {}
  96. }).then(res => {
  97. if (res.msg == '成功') return this.setData({
  98. userMessage: res.data[0]
  99. })
  100. })
  101. },
  102. /**
  103. * 生命周期函数--监听页面隐藏
  104. */
  105. onHide: function () {
  106. },
  107. /**
  108. * 生命周期函数--监听页面卸载
  109. */
  110. onUnload: function () {
  111. },
  112. /**
  113. * 页面相关事件处理函数--监听用户下拉动作
  114. */
  115. onPullDownRefresh: function () {
  116. },
  117. /**
  118. * 页面上拉触底事件的处理函数
  119. */
  120. onReachBottom: function () {
  121. },
  122. /**
  123. * 用户点击右上角分享
  124. */
  125. onShareAppMessage: function () {
  126. }
  127. })