login.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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. if (item.usertype == 2) return wx.showModal({
  12. title: '提示',
  13. content: '该账号为区域经理,请使用云链E营销小程序登录',
  14. showCancel: false
  15. })
  16. wx.setStorageSync('userrole', item.usertype == 1 ? '业务员' : '经销商');
  17. wx.setStorageSync('userMsg', item)
  18. query_userauth();
  19. } else {
  20. wx.redirectTo({
  21. url: './selectSite',
  22. })
  23. }
  24. }
  25. /* 获取用户权限 */
  26. function query_userauth() {
  27. query_adspacelist();
  28. querySite_Parameter();
  29. wx.setStorageSync('userauth', []);
  30. _Http.basic({
  31. "classname": "sysmanage.develop.userauth.userauth",
  32. // "classname": "sysmanage.develop.userauthforweb.userauth",
  33. "method": "query_userauth",
  34. content: {
  35. nocache: true
  36. }
  37. }).then(res => {
  38. console.log("查询权限", res)
  39. if (res.msg != '成功') return wx.showToast({
  40. title: '权限查询失败,请稍后再试',
  41. icon: "none"
  42. })
  43. wx.setStorageSync('userauth', res.data);
  44. count += 1;
  45. toHome();
  46. });
  47. }
  48. /* 查询站点数据 */
  49. function querySite_Parameter() {
  50. _Http.basic({
  51. "classname": "webmanage.site.site",
  52. "method": "querySite_Parameter",
  53. "content": {}
  54. }).then(res => {
  55. if (res.msg != '成功') return wx.showToast({
  56. title: res.msg,
  57. icon: "none"
  58. });
  59. wx.setStorageSync('siteP', res.data);
  60. count += 1;
  61. toHome();
  62. })
  63. }
  64. /* 查询轮播图 */
  65. function query_adspacelist() {
  66. _Http.basic({
  67. "classname": "common.adspace.adspace",
  68. "method": "query_adspacelist",
  69. "content": {}
  70. }).then(res => {
  71. if (res.msg != '成功') return wx.showToast({
  72. title: res.msg,
  73. icon: "none"
  74. });
  75. wx.setStorageSync('banner_list', res.data)
  76. count += 1;
  77. toHome();
  78. })
  79. }
  80. function toHome() {
  81. if (count < 3) return;
  82. wx.reLaunch({
  83. url: '/pages/index/index'
  84. })
  85. getApp().initSocket();
  86. wx.setStorageSync('isLeader', wx.getStorageSync('userMsg').usertype == 21)
  87. wx.removeStorageSync('domainrelatedaccounts')
  88. count = 0;
  89. }
  90. /* 站点数据查询 */
  91. module.exports = {
  92. loginMsg,
  93. query_userauth
  94. }