index.js 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  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/userCenter/icon-04.png'
  16. }, {
  17. id: '002',
  18. text: '产品管理',
  19. icon: '/static/userCenter/icon-03.png'
  20. }, {
  21. id: '003',
  22. text: '合作商家',
  23. icon: '/static/userCenter/icon-02.png'
  24. }, {
  25. id: '004',
  26. text: '团队管理',
  27. icon: '/static/userCenter/icon-01.png'
  28. }],
  29. userMessage: {}, //用户信息
  30. },
  31. /**
  32. * 生命周期函数--监听页面加载
  33. */
  34. onLoad: function (options) {},
  35. /* 宫格展示区跳转 */
  36. gridJumpPage(e) {
  37. const {
  38. name
  39. } = e.target.dataset;
  40. if (name == "团队管理") {
  41. wx.navigateTo({
  42. url: '/pages/teamManagement/index',
  43. })
  44. } else if (name == '产品管理') {
  45. wx.navigateTo({
  46. url: '/pages/productManagement/index'
  47. })
  48. } else if (name == '商户管理') {
  49. /* 查询商户信息,有跳转到商户信息 没有跳转商户入口选择 */
  50. _Http.basic({
  51. "accesstoken": wx.getStorageSync('userData').token,
  52. "classname": "customer.tagents.tagents",
  53. "method": "query_enterpriseAgentsMain",
  54. "content": {}
  55. }).then(res => {
  56. if (res.msg != '成功') return;
  57. const data = res.data[0];
  58. const fintroduction = encodeURIComponent(data.fintroduction);
  59. data.fintroduction = fintroduction;
  60. //商户
  61. if (data.ftype != '个人') return wx.navigateTo({
  62. url: '/pages/storeMessage/index?data=' + JSON.stringify(data),
  63. });
  64. if (data.fisauthenticating == 1) {
  65. //正在审核中
  66. return wx.showModal({
  67. title: "提示",
  68. content: '商户信息正在审核中',
  69. showCancel: false
  70. })
  71. } else {
  72. //无商户信息子账号
  73. if (wx.getStorageSync('userData').fisadministrator == 0) return wx.showToast({
  74. title: '暂无商户信息',
  75. icon: "none"
  76. })
  77. //未认证
  78. wx.navigateTo({
  79. url: '/pages/storeMessage/select',
  80. })
  81. }
  82. })
  83. } else if (name == '合作商家') {
  84. wx.navigateTo({
  85. url: '/pages/businessPartner/index'
  86. })
  87. }
  88. },
  89. /* 跳转用户信息 */
  90. toUserCenter() {
  91. const data = JSON.stringify(this.data.userMessage)
  92. wx.navigateTo({
  93. url: '/pages/userCenter/index?data=' + data,
  94. })
  95. },
  96. /* 退出登录 */
  97. userLogout() {
  98. _Http.logout({
  99. "accesstoken": wx.getStorageSync('userData').token
  100. }).then(res => {
  101. if (res.status == "ok") {
  102. wx.showToast({
  103. title: '退出成功',
  104. })
  105. wx.setStorageSync('userData', {}) //清空用户数据
  106. setTimeout(() => {
  107. wx.reLaunch({
  108. url: '/pages/login/index',
  109. })
  110. }, 500)
  111. }
  112. })
  113. },
  114. /**
  115. * 生命周期函数--监听页面初次渲染完成
  116. */
  117. onReady: function () {
  118. },
  119. /**
  120. * 生命周期函数--监听页面显示
  121. */
  122. onShow: function () {
  123. this.getTabBar().init();
  124. // 获取用户信息
  125. _Http.basic({
  126. "accesstoken": wx.getStorageSync('userData').token,
  127. "classname": "customer.usercenter.usermsg.usermsg",
  128. "method": "query_usermsg",
  129. "content": {}
  130. }).then(res => {
  131. if (res.msg == '成功') return this.setData({
  132. userMessage: res.data[0]
  133. })
  134. });
  135. this.getTabBar().setData({
  136. 'tabbarList[3].fcount': getApp().globalData.msgFcount
  137. })
  138. },
  139. /**
  140. * 生命周期函数--监听页面隐藏
  141. */
  142. onHide: function () {
  143. },
  144. /**
  145. * 生命周期函数--监听页面卸载
  146. */
  147. onUnload: function () {
  148. },
  149. /**
  150. * 页面相关事件处理函数--监听用户下拉动作
  151. */
  152. onPullDownRefresh: function () {
  153. },
  154. /**
  155. * 页面上拉触底事件的处理函数
  156. */
  157. onReachBottom: function () {
  158. },
  159. /**
  160. * 用户点击右上角分享
  161. */
  162. onShareAppMessage: function () {
  163. }
  164. })