index.js 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. const _Http = getApp().globalData.http;
  2. Page({
  3. /**
  4. * 页面的初始数据
  5. */
  6. data: {
  7. wusercenter: false, //个人中心权限
  8. userMsg: {},
  9. pathList: [], //功能权限
  10. },
  11. /**
  12. * 生命周期函数--监听页面加载
  13. */
  14. onLoad(options) {
  15. this.queryUserMsg();
  16. let auth = getApp().globalData.queryPer.query(wx.getStorageSync('userauth'), ['通用'], ['个人中心'])[0].apps;
  17. let wusercenter = false; //个人中心
  18. let pathList = [];
  19. auth.forEach(v => {
  20. if (v.name == 'wusercenter') {
  21. wusercenter = true;
  22. } else {
  23. switch (v.name) {
  24. case "teamManagement":
  25. pathList.push({
  26. name: "团队管理",
  27. icon: "icon-a-wodetuanduiguanli",
  28. color: "var(--assist)",
  29. path: `/${v.path}`
  30. })
  31. break;
  32. case "changePassword":
  33. pathList.push({
  34. name: "修改登录密码",
  35. icon: "icon-a-wodeguanyuyingyong",
  36. color: "var(--warning)",
  37. path: `/${v.path}`
  38. })
  39. break;
  40. case "wechatAgreement":
  41. pathList.push({
  42. name: "绑定微信",
  43. icon: "icon-a-wodebangdingweixin",
  44. color: "var(--success)"
  45. })
  46. break;
  47. }
  48. }
  49. });
  50. this.setData({
  51. wusercenter,
  52. pathList
  53. })
  54. },
  55. /* 查询用户信息 */
  56. queryUserMsg() {
  57. _Http.basic({
  58. "classname": "common.usercenter.usercenter",
  59. "method": "queryUserMsg",
  60. "content": {}
  61. }).then(res => {
  62. if (res.msg != '成功') return wx.showToast({
  63. title: res.data,
  64. icon: "none"
  65. })
  66. this.setData({
  67. userMsg: res.data
  68. })
  69. })
  70. },
  71. /**
  72. * 生命周期函数--监听页面初次渲染完成
  73. */
  74. onReady() {
  75. },
  76. /**
  77. * 生命周期函数--监听页面显示
  78. */
  79. onShow() {
  80. this.getTabBar().init();
  81. },
  82. /**
  83. * 生命周期函数--监听页面隐藏
  84. */
  85. onHide() {
  86. },
  87. /**
  88. * 生命周期函数--监听页面卸载
  89. */
  90. onUnload() {
  91. },
  92. /**
  93. * 页面相关事件处理函数--监听用户下拉动作
  94. */
  95. onPullDownRefresh() {
  96. },
  97. /**
  98. * 页面上拉触底事件的处理函数
  99. */
  100. onReachBottom() {
  101. },
  102. /**
  103. * 用户点击右上角分享
  104. */
  105. onShareAppMessage() {
  106. },
  107. /* 退出登录 */
  108. outLogin() {
  109. _Http.logout().then(res => {
  110. wx.showToast({
  111. title: '退出成功'
  112. });
  113. setTimeout(() => {
  114. wx.reLaunch({
  115. url: '/pages/login/phone',
  116. })
  117. }, 300)
  118. })
  119. },
  120. /* 去修改用户信息 */
  121. changeUserMsg() {
  122. let {
  123. name,
  124. phonenumber,
  125. attinfos
  126. } = this.data.userMsg;
  127. wx.navigateTo({
  128. url: `./userMsg/index?attinfos=${JSON.stringify(attinfos)}&name=${name}&phonenumber=${phonenumber}`
  129. })
  130. },
  131. listClick(e) {
  132. const {
  133. item
  134. } = e.currentTarget.dataset;
  135. const that = this;
  136. if (item.name == '绑定微信') return wx.showModal({
  137. title: "提示",
  138. content: "是否使用当前微信绑定此账号?",
  139. success: res => {
  140. if (res.confirm) {
  141. wx.login({
  142. success(res) {
  143. if (res.code) _Http.basic({
  144. "classname": "common.usercenter.usercenter",
  145. "method": "WechatBinding",
  146. "content": {
  147. "wechat_code": res.code,
  148. isbinging: 1 // 0解绑 1绑定
  149. }
  150. }).then(res => {
  151. console.log(res)
  152. if (res.code == 0) return wx.showToast({
  153. title: res.msg,
  154. icon: "none"
  155. });
  156. wx.showToast({
  157. title: '绑定成功',
  158. })
  159. that.setData({
  160. "userMsg.iswechatbinding": true
  161. })
  162. })
  163. }
  164. })
  165. }
  166. }
  167. });
  168. }
  169. })