index.js 3.3 KB

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