App.vue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  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. import { login_out_url } from "./config/env";
  31. export default {
  32. components: {
  33. HeaderBanner,
  34. Navigation,
  35. LoginInfo,
  36. Routerbanner,
  37. FooterBanner,
  38. },
  39. data() {
  40. return {
  41. isManufacturer: "distributor", // distributor 经销商 manufacturer 厂商
  42. userAccount: "",
  43. userToken: "",
  44. loadingFlag: true,
  45. login_out_url: login_out_url,
  46. };
  47. },
  48. methods: {
  49. goHomePage: function () {
  50. window.location.replace(this.login_out_url);
  51. },
  52. getTokenRequest() {
  53. this.$http({
  54. method: "post",
  55. url: "/auth/checkSign",
  56. data: this.userToken,
  57. })
  58. .then((res) => {
  59. console.log(res);
  60. if (res.data.code === 200) {
  61. let userInfo = res.data.data;
  62. this.userAccount = userInfo.userCode;
  63. localStorage.setItem("userId", userInfo.agentId);
  64. sessionStorage.setItem("userNameAccount", userInfo.userCode);
  65. if (!userInfo.agentId) {
  66. this.isManufacturer = "manufacturer";
  67. // this.$router.replace({ path: "/uploadInfor" });
  68. } else {
  69. if (userInfo.userRole == "1" || userInfo.userRole == "2") {
  70. this.isManufacturer = "distributor";
  71. // this.$router.replace({ path: "/inforList" });
  72. } else {
  73. this.isManufacturer = "manufacturer";
  74. // this.$router.replace({ path: "/uploadInfor" });
  75. }
  76. }
  77. sessionStorage.setItem("userPath", this.isManufacturer);
  78. this.loadingFlag = false;
  79. } else {
  80. let message = res.data.message;
  81. alert(message);
  82. sessionStorage.clear();
  83. localStorage.clear();
  84. this.goHomePage();
  85. }
  86. })
  87. .catch(() => {
  88. alert("无法校验的字符串");
  89. sessionStorage.clear();
  90. localStorage.clear();
  91. this.goHomePage();
  92. });
  93. },
  94. // 测试接口
  95. getData() {
  96. // 正常token
  97. // dXNlcklkPTEwMDEmYWNjb3VudD1MMDIxMF9NTSZmcm9tPXNpd2VpJnRpbWVzdGFtcD0xNjE4NTU2MTQ4JnNpZ249MWI3MmIwODkzNmZhNDdmMDU5MDRiNDc3N2FkOTdkMTI== //测试经销商TOKEN
  98. // dXNlcklkPTE1NiZhY2NvdW50PUwwTTE0X01NJmZyb209c2l3ZWkmdGltZXN0YW1wPTE2MTg1NTYzMDAmc2lnbj1lNDZmM2Q3MmFiZDI3ODYwMDYyMmY2N2NmZjFiNjZmNw== //测试厂商TOKEN
  99. this.userToken = sessionStorage.getItem("setToken");
  100. if (this.userToken) {
  101. console.log(
  102. "已登录",
  103. this.userToken,
  104. this.$route.path,
  105. sessionStorage.getItem("userNameAccount")
  106. );
  107. this.userAccount = sessionStorage.getItem("userNameAccount");
  108. if (sessionStorage.getItem("userPath") === "distributor") {
  109. this.isManufacturer = "distributor";
  110. // if(this.$route.path !== '/inforList') this.$router.replace({ path: "/inforList" });
  111. this.loadingFlag = false;
  112. } else if (sessionStorage.getItem("userPath") === "manufacturer") {
  113. this.isManufacturer = "manufacturer";
  114. this.loadingFlag = false;
  115. // if(this.$route.path !== '/uploadInfor') this.$router.replace({ path: "/uploadInfor" });
  116. } else {
  117. this.loadingFlag = false;
  118. }
  119. } else {
  120. sessionStorage.clear();
  121. localStorage.clear();
  122. let query = this.$route.query || {};
  123. if (query.token) {
  124. sessionStorage.setItem("setToken", query.token);
  125. this.userToken = query.token || "";
  126. console.log("token:", this.userToken);
  127. this.getTokenRequest();
  128. } else {
  129. this.goHomePage();
  130. }
  131. }
  132. },
  133. //localTest
  134. localTest(){
  135. // 本地调试打开
  136. this.loadingFlag = false;
  137. this.isManufacturer = "manufacturer"; // distributor
  138. if (this.isManufacturer === "manufacturer") {
  139. if (this.$route.path === "/loading")
  140. this.$router.replace({ path: "/uploadInfor" });
  141. localStorage.setItem("userId", 3084);
  142. sessionStorage.setItem("userNameAccount", "L0M14_MM");
  143. this.userAccount = "L0M14_MM";
  144. } else {
  145. if (this.$route.path === "/loading")
  146. this.$router.replace({ path: "/inforList" });
  147. localStorage.setItem("userId", 2002);
  148. sessionStorage.setItem("userNameAccount", "L0210_MM");
  149. this.userAccount = "L0210_MM";
  150. }
  151. }
  152. },
  153. mounted() {},
  154. /* created() {
  155. this.loadingFlag = true;
  156. this.getData(); // 线上打开
  157. // 本地调试打开
  158. this.localTest();// 本地调试打开
  159. }, */
  160. created() {
  161. this.loadingFlag = true;
  162. this.getData(); // 线上打开
  163. //this.localTest();// 本地调试打开
  164. },
  165. };
  166. </script>
  167. <style lang="less">
  168. * {
  169. padding: 0;
  170. margin: 0;
  171. /* list-style: none;
  172. color: #333; */
  173. font-size: 12px;
  174. }
  175. button {
  176. border: none;
  177. background-color: #0056a0;
  178. height: 30px;
  179. width: 58px;
  180. color: #fff;
  181. font-weight: 400;
  182. font-family: Arial;
  183. margin-left: 18px;
  184. font-size: 14px;
  185. &:hover {
  186. cursor: pointer;
  187. }
  188. }
  189. .current_button {
  190. background-color: #0056a0;
  191. height: 30px;
  192. width: 58px;
  193. line-height: 30px;
  194. text-align: center;
  195. color: #fff;
  196. font-weight: 400px;
  197. font-family: Arial;
  198. margin-left: 18px;
  199. font-size: 14px;
  200. &:hover {
  201. cursor: pointer;
  202. }
  203. }
  204. #app {
  205. background-color: #eeeeee;
  206. height: 100%;
  207. min-height: 100vh;
  208. .app_content {
  209. width: 1190px;
  210. margin: 0 auto;
  211. font-size: 12px;
  212. color: #333;
  213. font-family: "微软雅黑";
  214. display: flex;
  215. justify-content: space-between;
  216. .router {
  217. width: 150px;
  218. height: 100%;
  219. background-color: #d4d4d4;
  220. height: auto;
  221. min-height: 50vh;
  222. }
  223. .router_view {
  224. width: 1030px;
  225. }
  226. }
  227. }
  228. @media screen and (max-width: 1190px) {
  229. #app {
  230. width: 1190px;
  231. }
  232. }
  233. // 时间选择框样式
  234. .datePickStyle {
  235. height: 28px;
  236. width: 144px;
  237. border: 1px solid #ccc;
  238. padding: 4px 8px;
  239. color: #555;
  240. font-size: 12px;
  241. }
  242. .datePickClass {
  243. height: 28px;
  244. width: 144px;
  245. padding: 4px 8px;
  246. color: #555;
  247. font-size: 12px;
  248. }
  249. </style>