index.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. const _Http = getApp().globalData.http;
  2. let downCount = null;
  3. Page({
  4. data: {
  5. userMsg: {},
  6. pathList: [], //功能权限
  7. teamAuth: '', //团队管理权限列表 JSON字符串 用于传递
  8. },
  9. onLoad(options) {
  10. this.queryUserMsg();
  11. let authlist = getApp().globalData.queryPer.query(wx.getStorageSync('userauth'), ['通用'], ['个人中心']);
  12. let pathList = [{
  13. name: "修改登录密码",
  14. icon: "icon-a-wodeguanyuyingyong",
  15. color: "var(--warning)",
  16. path: `/pages/tabbar/mine/changePassword/index`
  17. }]
  18. if (authlist.length != 0) authlist[0].apps.forEach(v => {
  19. switch (v.name) {
  20. case "teamManagement":
  21. console.log(v)
  22. pathList.unshift({
  23. name: "团队管理",
  24. icon: "icon-a-wodetuanduiguanli",
  25. color: "var(--assist)",
  26. path: `/${v.path}`
  27. })
  28. this.setData({
  29. teamAuth: JSON.stringify(v.meta.auth)
  30. })
  31. break;
  32. }
  33. });
  34. this.setData({
  35. pathList
  36. })
  37. },
  38. /* 查询用户信息 */
  39. queryUserMsg() {
  40. _Http.basic({
  41. "classname": "common.usercenter.usercenter",
  42. "method": "queryUserMsg",
  43. "content": {
  44. "nocache": true
  45. }
  46. }).then(res => {
  47. if (res.msg != '成功') return wx.showToast({
  48. title: res.msg,
  49. icon: "none"
  50. })
  51. this.setData({
  52. userMsg: res.data
  53. })
  54. })
  55. },
  56. onShow() {
  57. this.getTabBar().init();
  58. },
  59. /* 退出登录 */
  60. outLogin() {
  61. clearTimeout(downCount);
  62. wx.showLoading({
  63. title: '正在退出...',
  64. })
  65. downCount = setTimeout(() => {
  66. _Http.logout().then(res => {
  67. wx.showToast({
  68. title: '退出成功'
  69. });
  70. let loginMsg = wx.getStorageSync("loginMsg");
  71. wx.clearStorageSync();
  72. wx.setStorageSync('loginMsg', loginMsg)
  73. wx.setStorageSync('isAgree', true)
  74. setTimeout(() => {
  75. wx.reLaunch({
  76. url: '/pages/login/phone',
  77. })
  78. }, 300)
  79. })
  80. }, 300);
  81. },
  82. /* 去修改用户信息 */
  83. changeUserMsg() {
  84. let {
  85. name,
  86. phonenumber,
  87. attinfos,
  88. hr
  89. } = this.data.userMsg;
  90. wx.navigateTo({
  91. url: `./userMsg/index?attinfos=${JSON.stringify(attinfos)}&name=${name}&phonenumber=${phonenumber}&email=${hr.email}`
  92. })
  93. },
  94. /* 绑定或解绑微信 */
  95. bindingWechat(e) {
  96. if (this.data.userMsg.iswechatbinding) {
  97. let that = this;
  98. wx.showModal({
  99. title: "提示",
  100. content: "是否解除绑定",
  101. success: (res) => {
  102. if (res.confirm) that.handleBDWechat(0);
  103. }
  104. })
  105. } else {
  106. this.handleBDWechat(1);
  107. }
  108. },
  109. handleBDWechat(isbinging) {
  110. let that = this;
  111. wx.getUserProfile({
  112. desc: '用于完善用户资料',
  113. success: ({
  114. userInfo
  115. }) => {
  116. wx.login({
  117. success(res) {
  118. if (res.code) _Http.basic({
  119. "classname": "common.usercenter.usercenter",
  120. "method": "WechatBinding",
  121. content: {
  122. "wechat_code": res.code,
  123. isbinging, // 0解绑 1绑定
  124. wechatuserinfo: userInfo,
  125. appid: "wxc1b6ae925ac1d06a"
  126. }
  127. }).then(s => {
  128. if (s.msg != '成功') return wx.showToast({
  129. title: s.data,
  130. icon: "none"
  131. });
  132. setTimeout(() => {
  133. wx.showToast({
  134. title: isbinging == 0 ? '解除成功' : '绑定成功',
  135. icon: "none"
  136. })
  137. }, 100);
  138. that.queryUserMsg();
  139. })
  140. }
  141. })
  142. },
  143. fail: () => {
  144. wx.showToast({
  145. title: '操作失败,未获得授权',
  146. icon: "none"
  147. })
  148. }
  149. })
  150. },
  151. /* 前去查询 */
  152. bindingOfficialAccounts() {
  153. wx.navigateTo({
  154. url: './webView',
  155. })
  156. }
  157. })