App.vue 8.1 KB

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