App.vue 10 KB

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