index.js 3.4 KB

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