index.js 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  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. orders: []
  12. },
  13. onLoad(options) {
  14. this.queryUserMsg();
  15. getApp().globalData.Language.getLanguagePackage(this)
  16. let authlist = getApp().globalData.queryPer.query(wx.getStorageSync('userauth'), ['通用'], ['个人中心']);
  17. let pathList = [{
  18. name: "修改登录密码",
  19. icon: "icon-a-wodeguanyuyingyong",
  20. color: "var(--warning)",
  21. path: `/pages/tabbar/mine/changePassword/index`
  22. }]
  23. if (authlist.length) {
  24. authlist[0].apps.forEach(v => {
  25. switch (v.name) {
  26. case "teamManagement":
  27. pathList.unshift({
  28. name: "团队管理",
  29. icon: "icon-a-wodetuanduiguanli",
  30. color: "var(--assist)",
  31. path: `/${v.path}`
  32. })
  33. this.setData({
  34. teamAuth: JSON.stringify(v.meta.auth)
  35. })
  36. break;
  37. }
  38. });
  39. this.setData({
  40. pathList
  41. })
  42. };
  43. this.setData({
  44. isWorderform: getApp().globalData.queryPer.query(wx.getStorageSync('userauth'), ['E-订单'], ['销售管理'])[0].apps.some(v => v.name == "worderform")
  45. })
  46. },
  47. /* 查询用户信息 */
  48. queryUserMsg() {
  49. _Http.basic({
  50. "classname": "common.usercenter.usercenter",
  51. "method": "queryUserMsg",
  52. "content": {
  53. "nocache": true
  54. }
  55. }).then(res => {
  56. console.log("查询用户信息", res)
  57. if (res.code != '1') return wx.showToast({
  58. title: res.msg,
  59. icon: "none"
  60. })
  61. this.setData({
  62. userMsg: res.data
  63. })
  64. })
  65. },
  66. onShow() {
  67. this.getTabBar().init();
  68. if (this.data.isWorderform) _Http.basic({
  69. "id": 2025030613432602,
  70. "content": {},
  71. "languagecode": "ZH",
  72. }).then(res => {
  73. console.log("获取订单数量", res)
  74. if (res.code != '1') return wx.showToast({
  75. title: res.msg,
  76. icon: "none"
  77. })
  78. let list = [{
  79. key: "新建",
  80. icon: "icon-xinjian"
  81. }, {
  82. key: "提交",
  83. icon: "icon-tijiao1"
  84. }, {
  85. key: "交期待确认",
  86. icon: "icon-jiaoqidaiqueren"
  87. }, {
  88. key: "交期确认",
  89. icon: "icon-jiaoqiqueren"
  90. }, {
  91. key: "审核",
  92. icon: "icon-shenhe1"
  93. }]
  94. if (wx.getStorageSync('userMsg').siteid == 'HY') list.splice(1, 0, {
  95. key: "预提交",
  96. icon: "icon-yutijiao"
  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. })