login.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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. "method": "query_userauth",
  28. content: {
  29. nocache: true
  30. }
  31. }).then(res => {
  32. console.log("查询权限", res)
  33. if (res.msg != '成功') return wx.showToast({
  34. title: '权限查询失败,请稍后再试',
  35. icon: "none"
  36. })
  37. wx.setStorageSync('userauth', res.data);
  38. count += 1;
  39. toHome();
  40. });
  41. let {
  42. siteid,
  43. userid
  44. } = wx.getStorageSync('userMsg');
  45. _Http.basic({
  46. "classname": "sysmanage.develop.optiontype.optiontype",
  47. "method": "optiontypeselect",
  48. "content": {
  49. "pageNumber": 1,
  50. "pageSize": 20,
  51. "typename": "shieldrole",
  52. "parameter": {
  53. siteid,
  54. userid
  55. }
  56. }
  57. }).then(res => {
  58. console.log("查询是否隐私金额", res)
  59. if (res.msg == '成功') wx.setStorageSync('hidePrice', res.data.length == 0 ? 0 : 1);
  60. console.log(wx.getStorageSync('hidePrice'))
  61. })
  62. }
  63. /* 查询站点数据 */
  64. function querySite_Parameter() {
  65. _Http.basic({
  66. "classname": "webmanage.site.site",
  67. "method": "querySite_Parameter",
  68. "content": {}
  69. }).then(res => {
  70. if (res.msg != '成功') return wx.showToast({
  71. title: res.msg,
  72. icon: "none"
  73. });
  74. wx.setStorageSync('siteP', res.data);
  75. count += 1;
  76. toHome();
  77. })
  78. }
  79. /* 查询轮播图 */
  80. function query_adspacelist() {
  81. _Http.basic({
  82. "classname": "common.adspace.adspace",
  83. "method": "query_adspacelist",
  84. "content": {}
  85. }).then(res => {
  86. if (res.msg != '成功') return wx.showToast({
  87. title: res.msg,
  88. icon: "none"
  89. });
  90. wx.setStorageSync('banner_list', res.data)
  91. count += 1;
  92. toHome();
  93. })
  94. }
  95. function toHome() {
  96. if (count < 3) return;
  97. wx.reLaunch({
  98. url: '/pages/index/index'
  99. })
  100. getApp().initSocket();
  101. wx.setStorageSync('isLeader', wx.getStorageSync('userMsg').usertype == 21)
  102. }
  103. /* 站点数据查询 */
  104. module.exports = {
  105. loginMsg,
  106. query_userauth
  107. }