index.js 2.8 KB

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