App.vue 9.3 KB

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