App.vue 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415
  1. <template>
  2. <div id="app" :class="{}">
  3. <div class="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. height: 50px;
  238. width: 100%;
  239. background-color: #293e68;
  240. display: flex;
  241. align-items: center;
  242. min-width: 1000px;
  243. }
  244. .logo {
  245. height: 40px;
  246. width: 40px;
  247. background: url("./assets/logo1.png");
  248. background-size: 100% 100%;
  249. margin-left: 20px;
  250. }
  251. .pb_body {
  252. margin-left: 220px;
  253. width: calc(100% - 240px) !important;
  254. /* min-width: 1140px; */
  255. min-width: 750px;
  256. display: inline-block;
  257. /* height: calc(100% - 100px); */
  258. /* min-height: 750px; */
  259. background: #fff;
  260. margin-top: 20px;
  261. border-radius: 5px;
  262. position: absolute;
  263. height: calc(100% - 100px);
  264. overflow: auto;
  265. }
  266. .ggheight {
  267. height: calc(100% - 67.5px) !important;
  268. }
  269. .pb_head {
  270. font-size: 26px;
  271. /* font-weight: 600; */
  272. width: 95%;
  273. margin: 10px auto;
  274. padding: 10px 5px;
  275. border-bottom: 1px solid #eee;
  276. }
  277. .pb_content {
  278. /* height: 100%; */
  279. }
  280. .pb_content_body {
  281. width: 94%;
  282. margin: 10px auto;
  283. /* overflow: auto;
  284. height: calc(100% - 120px); */
  285. }
  286. .user_head {
  287. display: flex;
  288. align-items: center;
  289. margin-left: auto;
  290. margin-right: 20px;
  291. font-size: 18px;
  292. font-weight: 600;
  293. }
  294. .user_head .user_name {
  295. color: #fff;
  296. margin-right: 10px;
  297. }
  298. .user_head div {
  299. display: flex;
  300. align-items: center;
  301. cursor: pointer;
  302. }
  303. .user_head .exitI {
  304. background-image: url("./assets/exit.png");
  305. width: 25px;
  306. height: 25px;
  307. background-size: 100% 100%;
  308. margin-top: 1px;
  309. line-height: 25px;
  310. vertical-align: text-top;
  311. background-repeat: no-repeat;
  312. }
  313. .noticeBox {
  314. position: relative;
  315. margin-right: 10px;
  316. }
  317. .user_head .noticeI {
  318. background-image: url("./assets/icon/noticeA.png");
  319. width: 25px;
  320. height: 25px;
  321. background-size: 100% 100%;
  322. margin-top: 1px;
  323. line-height: 25px;
  324. vertical-align: text-top;
  325. background-repeat: no-repeat;
  326. cursor: pointer;
  327. }
  328. .noticeBox span {
  329. position: absolute;
  330. background: red;
  331. width: 15px;
  332. height: 15px;
  333. border-radius: 30px;
  334. color: #fff;
  335. text-align: center;
  336. font-size: 12px;
  337. display: flex;
  338. align-items: center;
  339. justify-content: center;
  340. top: -3px;
  341. right: -3px;
  342. }
  343. .stuWidth {
  344. min-width: 1180px;
  345. }
  346. .gHeight {
  347. height: 100%;
  348. }
  349. html::-webkit-scrollbar {
  350. /*滚动条整体样式*/
  351. width: 6px;
  352. /*高宽分别对应横竖滚动条的尺寸*/
  353. height: 6px;
  354. }
  355. /*定义滚动条轨道 内阴影+圆角*/
  356. html::-webkit-scrollbar {
  357. border-radius: 10px;
  358. background-color: #eee;
  359. }
  360. /*定义滑块 内阴影+圆角*/
  361. html::-webkit-scrollbar-thumb {
  362. border-radius: 10px;
  363. -webkit-box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.3);
  364. background-color: rgba(0, 0, 0, 0.1);
  365. }
  366. .btnClassGM {
  367. background: #8681b7 !important;
  368. border-color: #8681b7 !important;
  369. }
  370. .btnClassGM:focus,
  371. .btnClassGM:hover {
  372. background: #8681b7 !important;
  373. border-color: #8681b7 !important;
  374. }
  375. .GMBg {
  376. background: rgb(184, 181, 202) !important;
  377. }
  378. .cancelbtnGM:focus,
  379. .cancelbtnGM:hover {
  380. color: rgb(92, 84, 159) !important;
  381. border-color: #5c549f !important;
  382. background-color: #dbd7ff !important;
  383. }
  384. </style>