App.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468
  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. userid: this.$route.query.userid,
  105. };
  106. },
  107. components: {
  108. "footer-nav": leftBar,
  109. },
  110. methods: {
  111. isLogin() {
  112. const loading = this.$loading.service({
  113. background: "rgba(255, 255, 255)",
  114. target: document.querySelector("body"),
  115. });
  116. var _isLogin = this.$cookies.get("tlogin");
  117. var userInfo = this.$cookies.get("teacherInfo");
  118. if (_isLogin == "1" && userInfo ) {
  119. loading.close();
  120. this.$store.commit("update", ["isLogin", true]);
  121. // var info = JSON.parse(window.sessionStorage.getItem("userInfo"));
  122. this.$store.commit("update", ["userInfo", userInfo]);
  123. // if (this.$route.path == "/login") {
  124. // if (userInfo.type == "1") {
  125. // this.$router.push("/eventCenter?steps=" + "2");
  126. // } else if (userInfo.type == "2" || userInfo.type == "4") {
  127. // this.$router.push("/anliList");
  128. // } else if (userInfo.type == "5" || userInfo.type == "6") {
  129. // this.$router.push("/anliList1");
  130. // } else if (userInfo.type == "3") {
  131. // this.$router.push("/anliList2");
  132. // }
  133. // }
  134. this.routerP();
  135. } else {
  136. this.$store.commit("update", ["isLogin", false]);
  137. // Message({
  138. // message: "未登录,请登录",
  139. // type: "warning",
  140. // });
  141. setTimeout(() => {
  142. loading.close();
  143. // if (this.$route.path != "/login") {
  144. // this.$router.push("/login");
  145. // }
  146. }, 2000);
  147. }
  148. },
  149. routerP() {
  150. const { navTabs, navTabs2, navTabs3 } = this.$data;
  151. const { userInfo } = this.$store.state;
  152. let router_path = this.$route.path;
  153. console.log(router_path);
  154. if (!userInfo.type) {
  155. this.isLogin();
  156. return;
  157. }
  158. var a = 0;
  159. if (userInfo.type == 2 || userInfo.type == 4) {
  160. if (navTabs.indexOf(router_path) != -1) {
  161. a = 1;
  162. this.isShowNav = true;
  163. }
  164. this.nav = navTabs;
  165. } else if (
  166. userInfo.type == 5 ||
  167. userInfo.type == 6 ||
  168. userInfo.type == 0
  169. ) {
  170. if (navTabs2.indexOf(router_path) != -1) {
  171. a = 1;
  172. this.isShowNav = true;
  173. }
  174. this.nav = navTabs2;
  175. } else if (userInfo.type == 3) {
  176. if (navTabs3.indexOf(router_path) != -1) {
  177. a = 1;
  178. this.isShowNav = true;
  179. }
  180. this.nav = navTabs3;
  181. }
  182. if (a == 0) {
  183. this.nav = [];
  184. this.isShowNav = false;
  185. }
  186. this.$forceUpdate();
  187. },
  188. exit() {
  189. sessionStorage.clear();
  190. this.$cookies.remove("tlogin");
  191. this.$cookies.remove("teacherInfo");
  192. this.$store.commit("update", ["isLogin", false]);
  193. this.$store.commit("update", ["userInfo", {}]);
  194. Message({
  195. message: "退出成功",
  196. type: "success",
  197. });
  198. this.$router.push("/login");
  199. },
  200. goTo(path) {
  201. this.$router.push(path);
  202. },
  203. },
  204. watch: {
  205. $route(to, from) {
  206. const { navTabs, navTabs2, navTabs3 } = this.$data;
  207. const { userInfo } = this.$store.state;
  208. const toPath = to.path;
  209. const fromName = from.name;
  210. var a = 0;
  211. if (userInfo.type == 2 || userInfo.type == 4) {
  212. if (navTabs.indexOf(toPath) != -1) {
  213. a = 1;
  214. this.isShowNav = true;
  215. }
  216. this.nav = navTabs;
  217. } else if (userInfo.type == 5 || userInfo.type == 6 || userInfo.type == 0) {
  218. if (navTabs2.indexOf(toPath) != -1) {
  219. a = 1;
  220. this.isShowNav = true;
  221. }
  222. this.nav = navTabs2;
  223. } else if (userInfo.type == 3) {
  224. if (navTabs3.indexOf(toPath) != -1) {
  225. a = 1;
  226. this.isShowNav = true;
  227. }
  228. this.nav = navTabs3;
  229. }
  230. if (a == 0) {
  231. this.nav = [];
  232. this.isShowNav = false;
  233. }
  234. this.$forceUpdate();
  235. },
  236. },
  237. created() {
  238. this.routerP();
  239. },
  240. };
  241. </script>
  242. <style>
  243. * {
  244. margin: 0;
  245. padding: 0;
  246. }
  247. /* body {
  248. font-family: "Helvetica Neue", Helvetica, "PingFang SC", "Hiragino Sans GB",
  249. "Microsoft YaHei", "微软雅黑", Arial, sans-serif;
  250. } */
  251. #app {
  252. height: 100%;
  253. width: 100%;
  254. background: #e6eaf0;
  255. /* min-width: 1380px; */
  256. /* min-width: 1250px; */
  257. }
  258. .appNoWidth {
  259. min-width: unset !important;
  260. display: inline-block !important;
  261. min-width: 550px;
  262. }
  263. .appNoHeight {
  264. min-height: 750px;
  265. }
  266. .app_head,
  267. .app_headBg {
  268. height: 50px;
  269. width: 100%;
  270. background-color: #293e68;
  271. display: flex;
  272. align-items: center;
  273. min-width: 1000px;
  274. }
  275. .app_headBg {
  276. background: url("./assets/icon/topBg.png");
  277. }
  278. .logo {
  279. height: 40px;
  280. width: 40px;
  281. background: url("./assets/logo1.png");
  282. background-size: 100% 100%;
  283. margin-left: 20px;
  284. }
  285. .pb_body {
  286. margin-left: 220px;
  287. width: calc(100% - 240px) !important;
  288. /* min-width: 1140px; */
  289. min-width: 750px;
  290. display: inline-block;
  291. /* height: calc(100% - 100px); */
  292. /* min-height: 750px; */
  293. background: #fff;
  294. margin-top: 20px;
  295. border-radius: 5px;
  296. position: absolute;
  297. height: calc(100% - 100px);
  298. overflow: auto;
  299. }
  300. .ggheight {
  301. height: calc(100% - 67.5px) !important;
  302. }
  303. .pb_head {
  304. font-size: 26px;
  305. /* font-weight: 600; */
  306. width: 95%;
  307. margin: 10px auto;
  308. padding: 10px 5px;
  309. border-bottom: 1px solid #eee;
  310. }
  311. .pb_content {
  312. /* height: 100%; */
  313. }
  314. .pb_content_body {
  315. width: 94%;
  316. margin: 10px auto;
  317. /* overflow: auto;
  318. height: calc(100% - 120px); */
  319. }
  320. .user_head {
  321. display: flex;
  322. align-items: center;
  323. margin-left: auto;
  324. margin-right: 20px;
  325. font-size: 18px;
  326. font-weight: 600;
  327. }
  328. .user_head .user_name {
  329. color: #fff;
  330. margin-right: 20px;
  331. }
  332. .user_head div {
  333. display: flex;
  334. align-items: center;
  335. cursor: pointer;
  336. }
  337. .user_head .exitI {
  338. background-image: url("./assets/exit.png");
  339. width: 25px;
  340. height: 25px;
  341. background-size: 100% 100%;
  342. margin-top: 1px;
  343. line-height: 25px;
  344. vertical-align: text-top;
  345. background-repeat: no-repeat;
  346. }
  347. .noticeBox {
  348. position: relative;
  349. margin-right: 10px;
  350. }
  351. .user_head .noticeI {
  352. background-image: url("./assets/icon/noticeA.png");
  353. width: 25px;
  354. height: 25px;
  355. background-size: 100% 100%;
  356. margin-top: 1px;
  357. line-height: 25px;
  358. vertical-align: text-top;
  359. background-repeat: no-repeat;
  360. cursor: pointer;
  361. }
  362. .noticeBox span {
  363. position: absolute;
  364. background: red;
  365. width: 15px;
  366. height: 15px;
  367. border-radius: 30px;
  368. color: #fff;
  369. text-align: center;
  370. font-size: 12px;
  371. display: flex;
  372. align-items: center;
  373. justify-content: center;
  374. top: -3px;
  375. right: -3px;
  376. }
  377. .stuWidth {
  378. min-width: 1180px;
  379. }
  380. .gHeight {
  381. height: 100%;
  382. }
  383. html::-webkit-scrollbar {
  384. /*滚动条整体样式*/
  385. width: 6px;
  386. /*高宽分别对应横竖滚动条的尺寸*/
  387. height: 6px;
  388. }
  389. /*定义滚动条轨道 内阴影+圆角*/
  390. html::-webkit-scrollbar {
  391. border-radius: 10px;
  392. background-color: #eee;
  393. }
  394. /*定义滑块 内阴影+圆角*/
  395. html::-webkit-scrollbar-thumb {
  396. border-radius: 10px;
  397. -webkit-box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.3);
  398. background-color: rgba(0, 0, 0, 0.1);
  399. }
  400. .btnClassGM {
  401. background: #8681b7 !important;
  402. border-color: #8681b7 !important;
  403. }
  404. .btnClassGM:focus,
  405. .btnClassGM:hover {
  406. background: #8681b7 !important;
  407. border-color: #8681b7 !important;
  408. }
  409. .GMBg {
  410. background: rgb(184, 181, 202) !important;
  411. }
  412. .cancelbtnGM:focus,
  413. .cancelbtnGM:hover {
  414. color: rgb(92, 84, 159) !important;
  415. border-color: #5c549f !important;
  416. background-color: #dbd7ff !important;
  417. }
  418. .changeBg {
  419. background: #fff !important;
  420. }
  421. .settingImg {
  422. background-image: url("./assets/icon/setting.png");
  423. width: 19px;
  424. height: 19px;
  425. background-size: 100% 100%;
  426. margin: 1px 5px 0 0;
  427. line-height: 25px;
  428. vertical-align: text-top;
  429. background-repeat: no-repeat;
  430. }
  431. .settingImg > img {
  432. width: 100%;
  433. height: 100%;
  434. }
  435. </style>