index.js 5.4 KB

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