App.vue 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420
  1. <template>
  2. <div id="app" :class="{}">
  3. <div :class="this.$route.path == '/anliDetail' ? 'app_headBg' : 'app_head'">
  4. <div class="logo" @click="goTo('/course')"></div>
  5. <span
  6. style="margin-left: 10px; color: #fff; font-size: 16px"
  7. @click="goTo('/course')"
  8. >广东省案例征集</span
  9. >
  10. <div class="user_head" v-if="this.$store.state.isLogin">
  11. <!-- <div class="noticeBox">
  12. <i class="noticeI" @click="goTo('/works')"></i>
  13. <span v-if="this.$store.state.nCount != 0">{{
  14. this.$store.state.nCount > 99 ? "99+" : this.$store.state.nCount
  15. }}</span>
  16. </div> -->
  17. <span class="user_name">{{
  18. this.$store.state.userInfo ? this.$store.state.userInfo.name : "用户"
  19. }}</span>
  20. <div @click="exit">
  21. <i class="exitI"></i>
  22. <el-button type="text" style="color: white">退出</el-button>
  23. </div>
  24. </div>
  25. </div>
  26. <div
  27. style="width: 100%; height: 100%"
  28. :class="{
  29. ggheight: true,
  30. }"
  31. >
  32. <!-- main 内容 -->
  33. <keep-alive v-if="$route.meta.keepAlive">
  34. <!-- 这里是会被缓存的视图组件 -->
  35. <router-view
  36. v-if="$route.meta.keepAlive"
  37. :class="{ pb_body: isShowNav }"
  38. />
  39. </keep-alive>
  40. <!-- 这里是不被缓存的视图组件 -->
  41. <router-view
  42. v-if="!$route.meta.keepAlive"
  43. :class="{ pb_body: isShowNav }"
  44. />
  45. <!-- 底部导航 -->
  46. <footer-nav
  47. v-if="isShowNav && $store.state.userInfo.type != 1"
  48. :nav="nav"
  49. :luyou="this.$store.state.luyou"
  50. ></footer-nav>
  51. </div>
  52. </div>
  53. </template>
  54. <script>
  55. import leftBar from "./components/tools/leftBar";
  56. import { Message } from "element-ui";
  57. export default {
  58. name: "App",
  59. data() {
  60. return {
  61. isShowNav: false, // 是否显示导航 Tab
  62. navTabs: [
  63. "/anliList",
  64. "/county",
  65. "/user",
  66. "/score",
  67. "/data",
  68. "/notice",
  69. "/school",
  70. ], // 市级导航
  71. navTabs2: [
  72. "/anliList1",
  73. "/user1",
  74. "/school1",
  75. "/score1",
  76. "/data",
  77. "/notice",
  78. ], // 区级导航
  79. navTabs3: ["/anliList2", "/data", "/notice"], // 省级导航
  80. nav: [],
  81. };
  82. },
  83. components: {
  84. "footer-nav": leftBar,
  85. },
  86. methods: {
  87. isLogin() {
  88. const loading = this.$loading.service({
  89. background: "rgba(255, 255, 255)",
  90. target: document.querySelector("body"),
  91. });
  92. var _isLogin = this.$cookies.get("tlogin");
  93. var userInfo = this.$cookies.get("teacherInfo");
  94. if (_isLogin == "1" && userInfo) {
  95. loading.close();
  96. this.$store.commit("update", ["isLogin", true]);
  97. // var info = JSON.parse(window.sessionStorage.getItem("userInfo"));
  98. this.$store.commit("update", ["userInfo", userInfo]);
  99. if (this.$route.path == "/login") {
  100. if (userInfo.type == "1") {
  101. this.$router.push("/eventCenter?steps=" + "2");
  102. } else if (userInfo.type == "2" || userInfo.type == "4") {
  103. this.$router.push("/anliList");
  104. } else if (userInfo.type == "5" || userInfo.type == "6") {
  105. this.$router.push("/anliList1");
  106. } else if (userInfo.type == "3") {
  107. this.$router.push("/anliList2");
  108. }
  109. }
  110. this.routerP();
  111. } else {
  112. this.$store.commit("update", ["isLogin", false]);
  113. Message({
  114. message: "未登录,请登录",
  115. type: "warning",
  116. });
  117. setTimeout(() => {
  118. loading.close();
  119. if (this.$route.path != "/login") {
  120. this.$router.push("/login");
  121. }
  122. }, 2000);
  123. }
  124. },
  125. routerP() {
  126. const { navTabs, navTabs2, navTabs3 } = this.$data;
  127. const { userInfo } = this.$store.state;
  128. let router_path = this.$route.path;
  129. console.log(router_path);
  130. if (!userInfo.type) {
  131. this.isLogin();
  132. return;
  133. }
  134. var a = 0;
  135. if (userInfo.type == 2 || userInfo.type == 4) {
  136. if (navTabs.indexOf(router_path) != -1) {
  137. a = 1;
  138. this.isShowNav = true;
  139. }
  140. this.nav = navTabs;
  141. } else if (userInfo.type == 5 || userInfo.type == 6) {
  142. if (navTabs2.indexOf(router_path) != -1) {
  143. a = 1;
  144. this.isShowNav = true;
  145. }
  146. this.nav = navTabs;
  147. } else if (userInfo.type == 3) {
  148. if (navTabs3.indexOf(router_path) != -1) {
  149. a = 1;
  150. this.isShowNav = true;
  151. }
  152. this.nav = navTabs;
  153. }
  154. if (a == 0) {
  155. this.nav = [];
  156. this.isShowNav = false;
  157. }
  158. },
  159. exit() {
  160. sessionStorage.clear();
  161. this.$cookies.remove("tlogin");
  162. this.$cookies.remove("teacherInfo");
  163. this.$store.commit("update", ["isLogin", false]);
  164. this.$store.commit("update", ["userInfo", {}]);
  165. Message({
  166. message: "退出成功",
  167. type: "success",
  168. });
  169. this.$router.push("/login");
  170. },
  171. goTo(path) {
  172. this.$router.push(path);
  173. },
  174. },
  175. watch: {
  176. $route(to, from) {
  177. const { navTabs, navTabs2, navTabs3 } = this.$data;
  178. const { userInfo } = this.$store.state;
  179. const toPath = to.path;
  180. const fromName = from.name;
  181. var a = 0;
  182. if (userInfo.type == 2 || userInfo.type == 4) {
  183. if (navTabs.indexOf(toPath) != -1) {
  184. a = 1;
  185. this.isShowNav = true;
  186. }
  187. this.nav = navTabs;
  188. } else if (userInfo.type == 5 || userInfo.type == 6) {
  189. if (navTabs2.indexOf(toPath) != -1) {
  190. a = 1;
  191. this.isShowNav = true;
  192. }
  193. this.nav = navTabs2;
  194. } else if (userInfo.type == 3) {
  195. if (navTabs3.indexOf(toPath) != -1) {
  196. a = 1;
  197. this.isShowNav = true;
  198. }
  199. this.nav = navTabs3;
  200. }
  201. if (a == 0) {
  202. this.nav = [];
  203. this.isShowNav = false;
  204. }
  205. },
  206. },
  207. created() {
  208. this.routerP();
  209. },
  210. };
  211. </script>
  212. <style>
  213. * {
  214. margin: 0;
  215. padding: 0;
  216. }
  217. body {
  218. font-family: "Helvetica Neue", Helvetica, "PingFang SC", "Hiragino Sans GB",
  219. "Microsoft YaHei", "微软雅黑", Arial, sans-serif;
  220. }
  221. #app {
  222. height: 100%;
  223. width: 100%;
  224. background: #e6eaf0;
  225. /* min-width: 1380px; */
  226. /* min-width: 1250px; */
  227. }
  228. .appNoWidth {
  229. min-width: unset !important;
  230. display: inline-block !important;
  231. min-width: 550px;
  232. }
  233. .appNoHeight {
  234. min-height: 750px;
  235. }
  236. .app_head,
  237. .app_headBg {
  238. height: 50px;
  239. width: 100%;
  240. background-color: #293e68;
  241. display: flex;
  242. align-items: center;
  243. min-width: 1000px;
  244. }
  245. .app_headBg {
  246. background: url("./assets/icon/topBg.png");
  247. }
  248. .logo {
  249. height: 40px;
  250. width: 40px;
  251. background: url("./assets/logo1.png");
  252. background-size: 100% 100%;
  253. margin-left: 20px;
  254. }
  255. .pb_body {
  256. margin-left: 220px;
  257. width: calc(100% - 240px) !important;
  258. /* min-width: 1140px; */
  259. min-width: 750px;
  260. display: inline-block;
  261. /* height: calc(100% - 100px); */
  262. /* min-height: 750px; */
  263. background: #fff;
  264. margin-top: 20px;
  265. border-radius: 5px;
  266. position: absolute;
  267. height: calc(100% - 100px);
  268. overflow: auto;
  269. }
  270. .ggheight {
  271. height: calc(100% - 67.5px) !important;
  272. }
  273. .pb_head {
  274. font-size: 26px;
  275. /* font-weight: 600; */
  276. width: 95%;
  277. margin: 10px auto;
  278. padding: 10px 5px;
  279. border-bottom: 1px solid #eee;
  280. }
  281. .pb_content {
  282. /* height: 100%; */
  283. }
  284. .pb_content_body {
  285. width: 94%;
  286. margin: 10px auto;
  287. /* overflow: auto;
  288. height: calc(100% - 120px); */
  289. }
  290. .user_head {
  291. display: flex;
  292. align-items: center;
  293. margin-left: auto;
  294. margin-right: 20px;
  295. font-size: 18px;
  296. font-weight: 600;
  297. }
  298. .user_head .user_name {
  299. color: #fff;
  300. margin-right: 10px;
  301. }
  302. .user_head div {
  303. display: flex;
  304. align-items: center;
  305. cursor: pointer;
  306. }
  307. .user_head .exitI {
  308. background-image: url("./assets/exit.png");
  309. width: 25px;
  310. height: 25px;
  311. background-size: 100% 100%;
  312. margin-top: 1px;
  313. line-height: 25px;
  314. vertical-align: text-top;
  315. background-repeat: no-repeat;
  316. }
  317. .noticeBox {
  318. position: relative;
  319. margin-right: 10px;
  320. }
  321. .user_head .noticeI {
  322. background-image: url("./assets/icon/noticeA.png");
  323. width: 25px;
  324. height: 25px;
  325. background-size: 100% 100%;
  326. margin-top: 1px;
  327. line-height: 25px;
  328. vertical-align: text-top;
  329. background-repeat: no-repeat;
  330. cursor: pointer;
  331. }
  332. .noticeBox span {
  333. position: absolute;
  334. background: red;
  335. width: 15px;
  336. height: 15px;
  337. border-radius: 30px;
  338. color: #fff;
  339. text-align: center;
  340. font-size: 12px;
  341. display: flex;
  342. align-items: center;
  343. justify-content: center;
  344. top: -3px;
  345. right: -3px;
  346. }
  347. .stuWidth {
  348. min-width: 1180px;
  349. }
  350. .gHeight {
  351. height: 100%;
  352. }
  353. html::-webkit-scrollbar {
  354. /*滚动条整体样式*/
  355. width: 6px;
  356. /*高宽分别对应横竖滚动条的尺寸*/
  357. height: 6px;
  358. }
  359. /*定义滚动条轨道 内阴影+圆角*/
  360. html::-webkit-scrollbar {
  361. border-radius: 10px;
  362. background-color: #eee;
  363. }
  364. /*定义滑块 内阴影+圆角*/
  365. html::-webkit-scrollbar-thumb {
  366. border-radius: 10px;
  367. -webkit-box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.3);
  368. background-color: rgba(0, 0, 0, 0.1);
  369. }
  370. .btnClassGM {
  371. background: #8681b7 !important;
  372. border-color: #8681b7 !important;
  373. }
  374. .btnClassGM:focus,
  375. .btnClassGM:hover {
  376. background: #8681b7 !important;
  377. border-color: #8681b7 !important;
  378. }
  379. .GMBg {
  380. background: rgb(184, 181, 202) !important;
  381. }
  382. .cancelbtnGM:focus,
  383. .cancelbtnGM:hover {
  384. color: rgb(92, 84, 159) !important;
  385. border-color: #5c549f !important;
  386. background-color: #dbd7ff !important;
  387. }
  388. </style>