App.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. <template>
  2. <div id="app">
  3. <HeaderBanner></HeaderBanner>
  4. <div v-if="!loadingFlag">
  5. <Navigation></Navigation>
  6. </div>
  7. <div class="app_content">
  8. <div class="router" v-if="!loadingFlag">
  9. <LoginInfo :userAccount="userAccount"></LoginInfo>
  10. <Routerbanner :isManufacturer="isManufacturer" />
  11. </div>
  12. <div class="router_view">
  13. <router-view
  14. :isManufacturer="isManufacturer"
  15. :isLoading="loadingFlag"
  16. ></router-view>
  17. </div>
  18. </div>
  19. <div v-if="!loadingFlag">
  20. <FooterBanner />
  21. </div>
  22. </div>
  23. </template>
  24. <script>
  25. import HeaderBanner from "./components/HeaderBanner";
  26. import Navigation from "./components/Navigation";
  27. import LoginInfo from "./components/LoginInfo";
  28. import Routerbanner from "./components/RouterBanner";
  29. import FooterBanner from "./components/Footerbanner";
  30. export default {
  31. components: {
  32. HeaderBanner,
  33. Navigation,
  34. LoginInfo,
  35. Routerbanner,
  36. FooterBanner,
  37. },
  38. data() {
  39. return {
  40. isManufacturer: "manufacturer", // distributor 经销商 manufacturer 厂商
  41. userAccount: "",
  42. userToken: "",
  43. loadingFlag: true,
  44. };
  45. },
  46. methods: {
  47. getTokenRequest() {
  48. this.$http({
  49. method: "post",
  50. url: "/auth/checkSign",
  51. data: this.userToken,
  52. })
  53. .then((res) => {
  54. console.log(res);
  55. if (res.data.code === 200) {
  56. let userInfo = res.data.data;
  57. this.userAccount = userInfo.userCode;
  58. localStorage.setItem("userId", userInfo.agentId);
  59. sessionStorage.setItem("userNameAccount", userInfo.userCode);
  60. if (!userInfo.agentId) {
  61. this.isManufacturer = "manufacturer";
  62. // this.$router.replace({ path: "/uploadInfor" });
  63. } else {
  64. if (userInfo.userRole == "1" || userInfo.userRole == "2") {
  65. this.isManufacturer = "distributor";
  66. // this.$router.replace({ path: "/inforList" });
  67. } else {
  68. this.isManufacturer = "manufacturer";
  69. // this.$router.replace({ path: "/uploadInfor" });
  70. }
  71. }
  72. sessionStorage.setItem("userPath", this.isManufacturer);
  73. this.loadingFlag = false;
  74. } else {
  75. if (process.env.NODE_ENV === "development") {
  76. this.loadingFlag = false;
  77. console.log(this.loadingFlag)
  78. } else {
  79. let message = res.data.message;
  80. alert(message);
  81. }
  82. }
  83. })
  84. .catch((err) => {
  85. alert("无法校验的字符串");
  86. console.log(err);
  87. });
  88. },
  89. // 测试接口
  90. getData() {
  91. // 正常token
  92. // dXNlcklkPTEwMDEmYWNjb3VudD1MMDIxMF9NTSZmcm9tPXNpd2VpJnRpbWVzdGFtcD0xNjE4NTU2MTQ4JnNpZ249MWI3MmIwODkzNmZhNDdmMDU5MDRiNDc3N2FkOTdkMTI== //测试经销商TOKEN
  93. // dXNlcklkPTE1NiZhY2NvdW50PUwwTTE0X01NJmZyb209c2l3ZWkmdGltZXN0YW1wPTE2MTg1NTYzMDAmc2lnbj1lNDZmM2Q3MmFiZDI3ODYwMDYyMmY2N2NmZjFiNjZmNw== //测试厂商TOKEN
  94. this.userToken = sessionStorage.getItem("setToken");
  95. if (this.userToken) {
  96. console.log(
  97. "已登录",
  98. this.userToken,
  99. this.$route.path,
  100. sessionStorage.getItem("userNameAccount")
  101. );
  102. this.userAccount = sessionStorage.getItem("userNameAccount");
  103. if (sessionStorage.getItem("userPath") === "distributor") {
  104. this.isManufacturer = "distributor";
  105. // if(this.$route.path !== '/inforList') this.$router.replace({ path: "/inforList" });
  106. this.loadingFlag = false;
  107. } else if (sessionStorage.getItem("userPath") === "manufacturer") {
  108. this.isManufacturer = "manufacturer";
  109. this.loadingFlag = false;
  110. // if(this.$route.path !== '/uploadInfor') this.$router.replace({ path: "/uploadInfor" });
  111. } else {
  112. this.loadingFlag = false;
  113. }
  114. } else {
  115. sessionStorage.clear();
  116. localStorage.clear();
  117. let query = this.$route.query || {};
  118. sessionStorage.setItem("setToken", query.token);
  119. this.userToken = query.token || 'dXNlcklkPTEwMDEmYWNjb3VudD1MMDIxMF9NTSZmcm9tPXNpd2VpJnRpbWVzdGFtcD0xNjE4NTU2MTQ4JnNpZ249MWI3MmIwODkzNmZhNDdmMDU5MDRiNDc3N2FkOTdkMTI==';
  120. console.log("token:", this.userToken);
  121. this.getTokenRequest();
  122. }
  123. },
  124. },
  125. mounted() {},
  126. created() {
  127. this.loadingFlag = true;
  128. this.getData();
  129. },
  130. };
  131. </script>
  132. <style lang="less">
  133. * {
  134. padding: 0;
  135. margin: 0;
  136. list-style: none;
  137. color: #333;
  138. font-size: 12px;
  139. }
  140. button {
  141. border: none;
  142. background-color: #0056a0;
  143. height: 30px;
  144. width: 58px;
  145. color: #fff;
  146. font-weight: 400px;
  147. font-family: Arial;
  148. margin-left: 18px;
  149. font-size: 14px;
  150. &:hover {
  151. cursor: pointer;
  152. }
  153. }
  154. .current_button {
  155. background-color: #0056a0;
  156. height: 30px;
  157. width: 58px;
  158. line-height: 30px;
  159. text-align: center;
  160. color: #fff;
  161. font-weight: 400px;
  162. font-family: Arial;
  163. margin-left: 18px;
  164. font-size: 14px;
  165. &:hover {
  166. cursor: pointer;
  167. }
  168. }
  169. #app {
  170. background-color: #eeeeee;
  171. height: 100%;
  172. min-height: 100vh;
  173. .app_content {
  174. width: 1190px;
  175. margin: 0 auto;
  176. font-size: 12px;
  177. color: #333;
  178. font-family: "微软雅黑";
  179. display: flex;
  180. justify-content: space-between;
  181. .router {
  182. width: 150px;
  183. height: 100%;
  184. background-color: #d4d4d4;
  185. height: auto;
  186. min-height: 50vh;
  187. }
  188. .router_view {
  189. width: 1030px;
  190. }
  191. }
  192. }
  193. @media screen and (max-width: 1190px) {
  194. #app {
  195. width: 1190px;
  196. }
  197. }
  198. </style>