login.js 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. const _Http = getApp().globalData.http;
  2. let count = 0; //接口完成数量
  3. function loginMsg(res) {
  4. wx.setStorageSync('account_list', res.account_list);
  5. if (res.account_list.length == 1) {
  6. let item = res.account_list[0];
  7. if (item.status == "INACTIVE") return wx.showToast({
  8. title: '该账号已被停用,无法登录',
  9. icon: "none"
  10. });
  11. wx.setStorageSync('userrole', item.usertype == 1 ? '业务员' : '经销商');
  12. wx.setStorageSync('userMsg', item)
  13. query_userauth();
  14. } else {
  15. wx.redirectTo({
  16. url: './selectSite',
  17. })
  18. }
  19. }
  20. /* 获取用户权限 */
  21. function query_userauth() {
  22. query_adspacelist();
  23. querySite_Parameter();
  24. wx.setStorageSync('userauth', []);
  25. _Http.basic({
  26. "classname": "sysmanage.develop.userauth.userauth",
  27. // "classname": "sysmanage.develop.userauthforweb.userauth",
  28. "method": "query_userauth",
  29. content: {
  30. nocache: true
  31. }
  32. }).then(res => {
  33. console.log("查询权限", res)
  34. if (res.msg != '成功') return wx.showToast({
  35. title: '权限查询失败,请稍后再试',
  36. icon: "none"
  37. })
  38. wx.setStorageSync('userauth', res.data);
  39. count += 1;
  40. toHome();
  41. });
  42. }
  43. /* 查询站点数据 */
  44. function querySite_Parameter() {
  45. _Http.basic({
  46. "classname": "webmanage.site.site",
  47. "method": "querySite_Parameter",
  48. "content": {}
  49. }).then(res => {
  50. if (res.msg != '成功') return wx.showToast({
  51. title: res.msg,
  52. icon: "none"
  53. });
  54. wx.setStorageSync('siteP', res.data);
  55. count += 1;
  56. toHome();
  57. })
  58. }
  59. /* 查询轮播图 */
  60. function query_adspacelist() {
  61. _Http.basic({
  62. "classname": "common.adspace.adspace",
  63. "method": "query_adspacelist",
  64. "content": {}
  65. }).then(res => {
  66. if (res.msg != '成功') return wx.showToast({
  67. title: res.msg,
  68. icon: "none"
  69. });
  70. wx.setStorageSync('banner_list', res.data)
  71. count += 1;
  72. toHome();
  73. })
  74. }
  75. function toHome() {
  76. if (count < 3) return;
  77. wx.reLaunch({
  78. url: '/pages/index/index'
  79. })
  80. getApp().initSocket();
  81. wx.setStorageSync('isLeader', wx.getStorageSync('userMsg').usertype == 21)
  82. wx.removeStorageSync('domainrelatedaccounts')
  83. count = 0;
  84. }
  85. /* 站点数据查询 */
  86. module.exports = {
  87. loginMsg,
  88. query_userauth
  89. }