login.js 2.9 KB

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