login.js 2.1 KB

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