login.js 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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. getApp().globalData.userrole = item.usertype == 1 ? '业务员' : '经销商';
  8. wx.setStorageSync('userMsg', item)
  9. query_userauth();
  10. } else {
  11. wx.redirectTo({
  12. url: './selectSite',
  13. })
  14. }
  15. }
  16. /* 获取用户权限 */
  17. function query_userauth() {
  18. query_adspacelist();
  19. querySite_Parameter();
  20. _Http.basic({
  21. "classname": "sysmanage.develop.userauth.userauth",
  22. "method": "query_userauth",
  23. content: {
  24. nocache: true
  25. }
  26. }).then(res => {
  27. if (res.msg != '成功') return wx.showToast({
  28. title: '权限查询失败,请稍后再试',
  29. icon: "none"
  30. })
  31. wx.setStorageSync('userauth', res.data);
  32. count += 1;
  33. toHome();
  34. });
  35. if (!getApp().globalData.socketEstablish) getApp().initSocket();
  36. }
  37. /* 查询站点数据 */
  38. function querySite_Parameter() {
  39. _Http.basic({
  40. "classname": "webmanage.site.site",
  41. "method": "querySite_Parameter",
  42. "content": {}
  43. }).then(res => {
  44. if (res.msg != '成功') return wx.showToast({
  45. title: res.msg,
  46. icon: "none"
  47. });
  48. wx.setStorageSync('siteP', res.data);
  49. count += 1;
  50. toHome();
  51. })
  52. }
  53. /* 查询轮播图 */
  54. function query_adspacelist() {
  55. _Http.basic({
  56. "classname": "common.adspace.adspace",
  57. "method": "query_adspacelist",
  58. "content": {}
  59. }).then(res => {
  60. if (res.msg != '成功') return wx.showToast({
  61. title: res.msg,
  62. icon: "none"
  63. });
  64. wx.setStorageSync('banner_list', res.data)
  65. count += 1;
  66. toHome();
  67. })
  68. }
  69. function toHome() {
  70. if (count < 3) return;
  71. let pages = getCurrentPages();
  72. let prevPage = pages[pages.length - 2];
  73. if (prevPage && prevPage.__route__ == 'pages/tabbar/home/index') prevPage.refreshData();
  74. wx.switchTab({
  75. url: '/pages/tabbar/home/index'
  76. })
  77. }
  78. /* 站点数据查询 */
  79. module.exports = {
  80. loginMsg,
  81. query_userauth
  82. }