index.js 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  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-yutijiao"
  84. }, {
  85. key: "提交",
  86. icon: "icon-tijiao1"
  87. }, {
  88. key: "交期待确认",
  89. icon: "icon-jiaoqidaiqueren"
  90. }, {
  91. key: "交期确认",
  92. icon: "icon-jiaoqiqueren"
  93. }, {
  94. key: "审核",
  95. icon: "icon-shenhe1"
  96. }]
  97. this.setData({
  98. orders: list.map(v => {
  99. v.badge = res.data[v.key]
  100. return v
  101. })
  102. })
  103. })
  104. },
  105. /* 退出登录 */
  106. outLogin() {
  107. clearTimeout(downCount);
  108. wx.showLoading({
  109. title: getApp().globalData.Language.getMapText('加载中') + '...',
  110. })
  111. downCount = setTimeout(() => {
  112. _Http.logout().then(res => {
  113. wx.showToast({
  114. title: getApp().globalData.Language.getMapText('退出成功')
  115. });
  116. let loginMsg = wx.getStorageSync("loginMsg"),
  117. languagecode = wx.getStorageSync("languagecode"),
  118. logins = wx.getStorageSync("logins");
  119. wx.clearStorageSync();
  120. wx.setStorageSync('loginMsg', loginMsg)
  121. wx.setStorageSync('logins', logins)
  122. wx.setStorageSync('isAgree', true)
  123. wx.removeStorageSync('languagecode');
  124. wx.setStorageSync('languagecode', languagecode)
  125. setTimeout(() => {
  126. wx.reLaunch({
  127. url: '/pages/login/phone',
  128. })
  129. }, 300)
  130. })
  131. }, 300);
  132. },
  133. /* 去修改用户信息 */
  134. changeUserMsg() {
  135. let {
  136. name,
  137. phonenumber,
  138. attinfos,
  139. hr,
  140. accountno
  141. } = this.data.userMsg;
  142. wx.navigateTo({
  143. url: `./userMsg/index?attinfos=${JSON.stringify(attinfos)}&name=${name}&phonenumber=${phonenumber}&email=${hr.email}&accountno=${accountno}`
  144. })
  145. },
  146. /* 绑定或解绑微信 */
  147. bindingWechat(e) {
  148. if (this.data.userMsg.iswechatbinding) {
  149. let that = this;
  150. wx.showModal({
  151. title: getApp().globalData.Language.getMapText('提示'),
  152. content: getApp().globalData.Language.getMapText('是否解除绑定'),
  153. cancelText: getApp().globalData.Language.getMapText('取消'),
  154. confirmText: getApp().globalData.Language.getMapText('确定'),
  155. success: (res) => {
  156. if (res.confirm) that.handleBDWechat(0);
  157. }
  158. })
  159. } else {
  160. this.handleBDWechat(1);
  161. }
  162. },
  163. handleBDWechat(isbinging) {
  164. let that = this;
  165. wx.getUserProfile({
  166. desc: getApp().globalData.Language.getMapText('用于完善用户资料'),
  167. success: ({
  168. userInfo
  169. }) => {
  170. wx.login({
  171. success(res) {
  172. if (res.code) _Http.basic({
  173. "classname": "common.usercenter.usercenter",
  174. "method": "WechatBinding",
  175. content: {
  176. "wechat_code": res.code,
  177. isbinging, // 0解绑 1绑定
  178. wechatuserinfo: userInfo,
  179. "appid": "wx197f219a82a89d7b"
  180. }
  181. }).then(s => {
  182. console.log("微信绑定", isbinging, s)
  183. if (s.code != '1') return wx.showToast({
  184. title: s.data,
  185. icon: "none"
  186. });
  187. setTimeout(() => {
  188. wx.showToast({
  189. title: isbinging == 0 ? getApp().globalData.Language.getMapText('解绑成功') : getApp().globalData.Language.getMapText('绑定成功'),
  190. icon: "none"
  191. })
  192. }, 100);
  193. that.queryUserMsg();
  194. })
  195. }
  196. })
  197. },
  198. fail: () => {
  199. wx.showToast({
  200. title: getApp().globalData.Language.getMapText('未获取授权'),
  201. icon: "none"
  202. })
  203. }
  204. })
  205. },
  206. /* 前去查询 */
  207. bindingOfficialAccounts() {
  208. wx.navigateTo({
  209. url: './webView',
  210. })
  211. }
  212. })