App.vue 8.3 KB

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