login.js 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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. wx.setStorageSync('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. wx.setStorageSync('userauth', []);
  21. _Http.basic({
  22. "classname": "sysmanage.develop.userauth.userauth",
  23. "method": "query_userauth",
  24. content: {
  25. nocache: true
  26. }
  27. }).then(res => {
  28. console.log("查询权限", res.data)
  29. if (res.msg != '成功') return wx.showToast({
  30. title: '权限查询失败,请稍后再试',
  31. icon: "none"
  32. })
  33. wx.setStorageSync('userauth', res.data);
  34. count += 1;
  35. toHome();
  36. });
  37. }
  38. /* 查询站点数据 */
  39. function querySite_Parameter() {
  40. _Http.basic({
  41. "classname": "webmanage.site.site",
  42. "method": "querySite_Parameter",
  43. "content": {}
  44. }).then(res => {
  45. if (res.msg != '成功') return wx.showToast({
  46. title: res.msg,
  47. icon: "none"
  48. });
  49. wx.setStorageSync('siteP', res.data);
  50. count += 1;
  51. toHome();
  52. })
  53. }
  54. /* 查询轮播图 */
  55. function query_adspacelist() {
  56. _Http.basic({
  57. "classname": "common.adspace.adspace",
  58. "method": "query_adspacelist",
  59. "content": {}
  60. }).then(res => {
  61. if (res.msg != '成功') return wx.showToast({
  62. title: res.msg,
  63. icon: "none"
  64. });
  65. wx.setStorageSync('banner_list', res.data)
  66. count += 1;
  67. toHome();
  68. })
  69. }
  70. function toHome() {
  71. if (count < 3) return;
  72. wx.reLaunch({
  73. url: '/pages/index/index'
  74. })
  75. if (!getApp().globalData.socketEstablish) getApp().initSocket();
  76. }
  77. /* 站点数据查询 */
  78. module.exports = {
  79. loginMsg,
  80. query_userauth
  81. }