index.js 4.9 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/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. /* 查询商户信息,有跳转到商户信息 没有跳转商户入口选择 */
  51. _Http.basic({
  52. "accesstoken": wx.getStorageSync('userData').token,
  53. "classname": "customer.tagents.tagents",
  54. "method": "query_enterpriseAgentsMain",
  55. "content": {}
  56. }).then(res => {
  57. console.log(res)
  58. if (res.msg != '成功') return;
  59. const data = res.data[0];
  60. console.log(data.fintroduction)
  61. const fintroduction = encodeURIComponent(data.fintroduction);
  62. data.fintroduction = "";
  63. //商户
  64. if (data.ftype != '个人') return wx.navigateTo({
  65. url: '/pages/storeMessage/index?data=' + JSON.stringify(data) + "&fintroduction=" + fintroduction,
  66. });
  67. if (data.fisauthenticating == 1) {
  68. //正在审核中
  69. return wx.showModal({
  70. title: "提示",
  71. content: '商户信息正在审核中'
  72. })
  73. } else {
  74. //无商户信息子账号
  75. if (wx.getStorageSync('userData').fisadministrator == 0) return wx.showToast({
  76. title: '暂无商户信息',
  77. icon: "none"
  78. })
  79. //未认证
  80. wx.navigateTo({
  81. url: '/pages/storeMessage/select',
  82. })
  83. }
  84. })
  85. } else if (name == '合作商家') {
  86. wx.navigateTo({
  87. url: '/pages/businessPartner/index'
  88. })
  89. }
  90. },
  91. /* 跳转用户信息 */
  92. toUserCenter() {
  93. const data = JSON.stringify(this.data.userMessage)
  94. wx.navigateTo({
  95. url: '/pages/userCenter/index?data=' + data,
  96. })
  97. },
  98. /* 退出登录 */
  99. userLogout() {
  100. _Http.logout({
  101. "accesstoken": wx.getStorageSync('userData').token
  102. }).then(res => {
  103. if (res.status == "ok") {
  104. wx.showToast({
  105. title: '退出成功',
  106. })
  107. wx.setStorageSync('userData', {}) //清空用户数据
  108. setTimeout(() => {
  109. wx.reLaunch({
  110. url: '/pages/login/index',
  111. })
  112. }, 500)
  113. }
  114. })
  115. },
  116. /**
  117. * 生命周期函数--监听页面初次渲染完成
  118. */
  119. onReady: function () {
  120. },
  121. /**
  122. * 生命周期函数--监听页面显示
  123. */
  124. onShow: function () {
  125. this.getTabBar().init();
  126. // 获取用户信息
  127. _Http.basic({
  128. "accesstoken": wx.getStorageSync('userData').token,
  129. "classname": "customer.usercenter.usermsg.usermsg",
  130. "method": "query_usermsg",
  131. "content": {}
  132. }).then(res => {
  133. if (res.msg == '成功') return this.setData({
  134. userMessage: res.data[0]
  135. })
  136. })
  137. },
  138. /**
  139. * 生命周期函数--监听页面隐藏
  140. */
  141. onHide: function () {
  142. },
  143. /**
  144. * 生命周期函数--监听页面卸载
  145. */
  146. onUnload: function () {
  147. },
  148. /**
  149. * 页面相关事件处理函数--监听用户下拉动作
  150. */
  151. onPullDownRefresh: function () {
  152. },
  153. /**
  154. * 页面上拉触底事件的处理函数
  155. */
  156. onReachBottom: function () {
  157. },
  158. /**
  159. * 用户点击右上角分享
  160. */
  161. onShareAppMessage: function () {
  162. }
  163. })