index.js 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  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. getApp().globalData.Language.getLanguagePackage(this)
  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. "nocache": true
  50. }
  51. }).then(res => {
  52. console.log("查询用户信息", res)
  53. if (res.code != '1') return wx.showToast({
  54. title: res.msg,
  55. icon: "none"
  56. })
  57. this.setData({
  58. userMsg: res.data
  59. })
  60. })
  61. },
  62. onShow() {
  63. this.getTabBar().init();
  64. },
  65. /* 退出登录 */
  66. outLogin() {
  67. clearTimeout(downCount);
  68. wx.showLoading({
  69. title: getApp().globalData.Language.getMapText('加载中') + '...',
  70. })
  71. downCount = setTimeout(() => {
  72. _Http.logout().then(res => {
  73. wx.showToast({
  74. title: getApp().globalData.Language.getMapText('退出成功')
  75. });
  76. let loginMsg = wx.getStorageSync("loginMsg"),
  77. languagecode = wx.getStorageSync("languagecode"),
  78. logins = wx.getStorageSync("logins");
  79. wx.clearStorageSync();
  80. wx.setStorageSync('loginMsg', loginMsg)
  81. wx.setStorageSync('logins', logins)
  82. wx.setStorageSync('isAgree', true)
  83. wx.removeStorageSync('languagecode');
  84. wx.setStorageSync('languagecode', languagecode)
  85. setTimeout(() => {
  86. wx.reLaunch({
  87. url: '/pages/login/phone',
  88. })
  89. }, 300)
  90. })
  91. }, 300);
  92. },
  93. /* 去修改用户信息 */
  94. changeUserMsg() {
  95. let {
  96. name,
  97. phonenumber,
  98. attinfos,
  99. hr,
  100. accountno
  101. } = this.data.userMsg;
  102. wx.navigateTo({
  103. url: `./userMsg/index?attinfos=${JSON.stringify(attinfos)}&name=${name}&phonenumber=${phonenumber}&email=${hr.email}&accountno=${accountno}`
  104. })
  105. },
  106. /* 绑定或解绑微信 */
  107. bindingWechat(e) {
  108. if (this.data.userMsg.iswechatbinding) {
  109. let that = this;
  110. wx.showModal({
  111. title: getApp().globalData.Language.getMapText('提示'),
  112. content: getApp().globalData.Language.getMapText('是否解除绑定'),
  113. cancelText: getApp().globalData.Language.getMapText('取消'),
  114. confirmText: getApp().globalData.Language.getMapText('确定'),
  115. success: (res) => {
  116. if (res.confirm) that.handleBDWechat(0);
  117. }
  118. })
  119. } else {
  120. this.handleBDWechat(1);
  121. }
  122. },
  123. handleBDWechat(isbinging) {
  124. let that = this;
  125. wx.getUserProfile({
  126. desc: getApp().globalData.Language.getMapText('用于完善用户资料'),
  127. success: ({
  128. userInfo
  129. }) => {
  130. wx.login({
  131. success(res) {
  132. if (res.code) _Http.basic({
  133. "classname": "common.usercenter.usercenter",
  134. "method": "WechatBinding",
  135. content: {
  136. "wechat_code": res.code,
  137. isbinging, // 0解绑 1绑定
  138. wechatuserinfo: userInfo,
  139. "appid": "wx197f219a82a89d7b"
  140. }
  141. }).then(s => {
  142. console.log("微信绑定", isbinging, s)
  143. if (s.code != '1') return wx.showToast({
  144. title: s.data,
  145. icon: "none"
  146. });
  147. setTimeout(() => {
  148. wx.showToast({
  149. title: isbinging == 0 ? getApp().globalData.Language.getMapText('解绑成功') : getApp().globalData.Language.getMapText('绑定成功'),
  150. icon: "none"
  151. })
  152. }, 100);
  153. that.queryUserMsg();
  154. })
  155. }
  156. })
  157. },
  158. fail: () => {
  159. wx.showToast({
  160. title: getApp().globalData.Language.getMapText('未获取授权'),
  161. icon: "none"
  162. })
  163. }
  164. })
  165. },
  166. /* 前去查询 */
  167. bindingOfficialAccounts() {
  168. wx.navigateTo({
  169. url: './webView',
  170. })
  171. }
  172. })