App.vue 10 KB

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