index.js 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  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. getApp().globalData.Language.getLanguagePackage(this)
  12. let authlist = getApp().globalData.queryPer.query(wx.getStorageSync('userauth'), ['通用'], ['个人中心']);
  13. let pathList = [{
  14. name: "修改登录密码",
  15. icon: "icon-a-wodeguanyuyingyong",
  16. color: "var(--warning)",
  17. path: `/pages/tabbar/mine/changePassword/index`
  18. }]
  19. if (authlist.length) {
  20. authlist[0].apps.forEach(v => {
  21. switch (v.name) {
  22. case "teamManagement":
  23. pathList.unshift({
  24. name: "团队管理",
  25. icon: "icon-a-wodetuanduiguanli",
  26. color: "var(--assist)",
  27. path: `/${v.path}`
  28. })
  29. this.setData({
  30. teamAuth: JSON.stringify(v.meta.auth)
  31. })
  32. break;
  33. }
  34. });
  35. this.setData({
  36. pathList
  37. })
  38. };
  39. this.setData({
  40. auth: JSON.stringify(wx.getStorageSync('auth')),
  41. userMsg: JSON.stringify(wx.getStorageSync('userMsg')),
  42. site: JSON.stringify(wx.getStorageSync('siteP')),
  43. templetList: JSON.stringify(wx.getStorageSync('templetList')),
  44. languagecode: wx.getStorageSync('languagecode'),
  45. isWorderform: getApp().globalData.queryPer.query(wx.getStorageSync('userauth'), ['E-订单'], ['销售管理'])[0].apps.some(v => v.name == "worderform")
  46. })
  47. },
  48. /* 查询用户信息 */
  49. queryUserMsg() {
  50. _Http.basic({
  51. "classname": "common.usercenter.usercenter",
  52. "method": "queryUserMsg",
  53. "content": {
  54. "nocache": true
  55. }
  56. }).then(res => {
  57. console.log("查询用户信息", res)
  58. if (res.code != '1') return wx.showToast({
  59. title: res.msg,
  60. icon: "none"
  61. })
  62. this.setData({
  63. userMsg: res.data
  64. })
  65. })
  66. },
  67. onShow() {
  68. this.getTabBar().init();
  69. if (this.data.isWorderform) _Http.basic({
  70. "id": 2025030613432602,
  71. "content": {},
  72. "languagecode": "ZH",
  73. }).then(res => {
  74. console.log("获取订单数量", res)
  75. if (res.code != '1') return wx.showToast({
  76. title: res.msg,
  77. icon: "none"
  78. })
  79. let list = [{
  80. key: "新建",
  81. icon: "icon-xinjian"
  82. }, {
  83. key: "预提交",
  84. icon: "icon-yutijiao"
  85. }, {
  86. key: "提交",
  87. icon: "icon-tijiao1"
  88. }, {
  89. key: "交期待确认",
  90. icon: "icon-jiaoqidaiqueren"
  91. }, {
  92. key: "交期确认",
  93. icon: "icon-jiaoqiqueren"
  94. }, {
  95. key: "审核",
  96. icon: "icon-shenhe1"
  97. }]
  98. this.setData({
  99. orders: list.map(v => {
  100. v.badge = res.data[v.key]
  101. return v
  102. })
  103. })
  104. })
  105. },
  106. /* 退出登录 */
  107. outLogin() {
  108. clearTimeout(downCount);
  109. wx.showLoading({
  110. title: getApp().globalData.Language.getMapText('加载中') + '...',
  111. })
  112. downCount = setTimeout(() => {
  113. _Http.logout().then(res => {
  114. wx.showToast({
  115. title: getApp().globalData.Language.getMapText('退出成功')
  116. });
  117. let loginMsg = wx.getStorageSync("loginMsg"),
  118. languagecode = wx.getStorageSync("languagecode"),
  119. logins = wx.getStorageSync("logins");
  120. wx.clearStorageSync();
  121. wx.setStorageSync('loginMsg', loginMsg)
  122. wx.setStorageSync('logins', logins)
  123. wx.setStorageSync('isAgree', true)
  124. wx.removeStorageSync('languagecode');
  125. wx.setStorageSync('languagecode', languagecode)
  126. setTimeout(() => {
  127. wx.reLaunch({
  128. url: '/pages/login/phone',
  129. })
  130. }, 300)
  131. })
  132. }, 300);
  133. },
  134. /* 去修改用户信息 */
  135. changeUserMsg() {
  136. let {
  137. name,
  138. phonenumber,
  139. attinfos,
  140. hr,
  141. accountno
  142. } = this.data.userMsg;
  143. wx.navigateTo({
  144. url: `./userMsg/index?attinfos=${JSON.stringify(attinfos)}&name=${name}&phonenumber=${phonenumber}&email=${hr.email}&accountno=${accountno}`
  145. })
  146. },
  147. /* 绑定或解绑微信 */
  148. bindingWechat(e) {
  149. if (this.data.userMsg.iswechatbinding) {
  150. let that = this;
  151. wx.showModal({
  152. title: getApp().globalData.Language.getMapText('提示'),
  153. content: getApp().globalData.Language.getMapText('是否解除绑定'),
  154. cancelText: getApp().globalData.Language.getMapText('取消'),
  155. confirmText: getApp().globalData.Language.getMapText('确定'),
  156. success: (res) => {
  157. if (res.confirm) that.handleBDWechat(0);
  158. }
  159. })
  160. } else {
  161. this.handleBDWechat(1);
  162. }
  163. },
  164. handleBDWechat(isbinging) {
  165. let that = this;
  166. wx.getUserProfile({
  167. desc: getApp().globalData.Language.getMapText('用于完善用户资料'),
  168. success: ({
  169. userInfo
  170. }) => {
  171. wx.login({
  172. success(res) {
  173. if (res.code) _Http.basic({
  174. "classname": "common.usercenter.usercenter",
  175. "method": "WechatBinding",
  176. content: {
  177. "wechat_code": res.code,
  178. isbinging, // 0解绑 1绑定
  179. wechatuserinfo: userInfo,
  180. "appid": "wx197f219a82a89d7b"
  181. }
  182. }).then(s => {
  183. console.log("微信绑定", isbinging, s)
  184. if (s.code != '1') return wx.showToast({
  185. title: s.data,
  186. icon: "none"
  187. });
  188. setTimeout(() => {
  189. wx.showToast({
  190. title: isbinging == 0 ? getApp().globalData.Language.getMapText('解绑成功') : getApp().globalData.Language.getMapText('绑定成功'),
  191. icon: "none"
  192. })
  193. }, 100);
  194. that.queryUserMsg();
  195. })
  196. }
  197. })
  198. },
  199. fail: () => {
  200. wx.showToast({
  201. title: getApp().globalData.Language.getMapText('未获取授权'),
  202. icon: "none"
  203. })
  204. }
  205. })
  206. },
  207. /* 前去查询 */
  208. bindingOfficialAccounts() {
  209. wx.navigateTo({
  210. url: './webView',
  211. })
  212. }
  213. })