App.vue 9.1 KB

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