App.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349
  1. <template>
  2. <div id="app">
  3. <!-- <div class="app_head" :class="{ stuWidth: $route.path == '/student' }">
  4. <div class="logo" @click="goTo('/')"></div>
  5. <div class="app_right">
  6. <div class="box_right_three">
  7. <div class="pic_img"><img src="./assets/myProject.png" alt="" /></div>
  8. <div @click="goTo('/project')">我的课程</div>
  9. </div>
  10. <div class="box_right_three">
  11. <div class="pic_img"><img src="./assets/myMessage.png" alt="" /></div>
  12. <div @click="goTo('/mine')">个人中心</div>
  13. </div>
  14. <div class="box_right_three">
  15. <div class="pic_img"><img src="./assets/mine.png" alt="" /></div>
  16. <div>
  17. {{
  18. this.$store.state.studentInfo
  19. ? this.$store.state.studentInfo.name
  20. : "用户"
  21. }}
  22. </div>
  23. </div>
  24. <div class="user_head" @click="exit">
  25. <div>
  26. <i class="exitI"></i>
  27. <el-button type="text" style="color: white">退出</el-button>
  28. </div>
  29. </div>
  30. </div>
  31. </div> -->
  32. <div>
  33. <!-- main 内容 -->
  34. <keep-alive v-if="$route.meta.keepAlive">
  35. <!-- 这里是会被缓存的视图组件 -->
  36. <router-view
  37. v-if="$route.meta.keepAlive"
  38. :class="{ pb_body: isShowNav }"
  39. />
  40. </keep-alive>
  41. <!-- 这里是不被缓存的视图组件 -->
  42. <router-view
  43. v-if="!$route.meta.keepAlive"
  44. :class="{ pb_body: isShowNav }"
  45. />
  46. <!-- 底部导航 -->
  47. <!-- <footer-nav
  48. v-if="isShowNav"
  49. :luyou="this.$store.state.luyou"
  50. ></footer-nav> -->
  51. </div>
  52. <!-- <div class="bottom">
  53. <div class="bottom_flex">
  54. <div class="left_bottom_flex">
  55. <div class="left_title">联系我们</div>
  56. <div class="left_content">
  57. <div>地址:深圳市南山区</div>
  58. <div>手机:13418906754</div>
  59. <div>邮箱:win.wu@qichuangxin.com</div>
  60. <div>电话:0755-84658992</div>
  61. <div>邮编:518129</div>
  62. </div>
  63. </div>
  64. <div class="right_bottom_flex">
  65. <img src="./assets/logo2.png" alt="" />
  66. </div>
  67. </div>
  68. </div> -->
  69. </div>
  70. </template>
  71. <script>
  72. import { Message } from "element-ui";
  73. export default {
  74. // name: "App",
  75. data() {
  76. return {
  77. isShowNav: true, // 是否显示导航 Tab
  78. };
  79. },
  80. components: {},
  81. created: function () {
  82. // this.isLogin();
  83. // this.getnCount();
  84. setInterval(() => {
  85. // this.getnCount();
  86. }, 60000);
  87. },
  88. methods: {
  89. goTo(path) {
  90. this.$router.push(path);
  91. },
  92. isLogin() {
  93. const loading = this.$loading.service({
  94. background: "rgba(255, 255, 255)",
  95. target: document.querySelector("body"),
  96. });
  97. var _isLogin = this.$cookies.get("slogin");
  98. var studentInfo = this.$cookies.get("studentInfo");
  99. if (_isLogin == "1" && studentInfo) {
  100. loading.close();
  101. this.$store.commit("update", ["isLogin", true]);
  102. // var info = JSON.parse(window.sessionStorage.getItem("userInfo"));
  103. this.$store.commit("update", ["studentInfo", studentInfo]);
  104. let router_path = this.$route.path;
  105. if (router_path == "/") {
  106. this.$router.push("/index");
  107. }
  108. }
  109. // else {
  110. // this.$store.commit("update", ["isLogin", false]);
  111. // Message({
  112. // message: "未登录,请登录",
  113. // type: "warning",
  114. // });
  115. // setTimeout(() => {
  116. // loading.close();
  117. // this.$router.push("/login");
  118. // }, 2000);
  119. // }
  120. },
  121. getnCount() {
  122. let params = {
  123. bid: this.$store.state.studentInfo.userid,
  124. };
  125. this.ajax
  126. .get(this.$store.state.api + "getNcount", params)
  127. .then((res) => {
  128. console.log(res);
  129. if (res.data[0].length > 0) {
  130. this.$store.commit("update", ["nCount", res.data[0][0].num]);
  131. } else {
  132. this.$store.commit("update", ["nCount", 0]);
  133. }
  134. })
  135. .catch((err) => {
  136. console.error(err);
  137. });
  138. },
  139. exit() {
  140. sessionStorage.clear();
  141. this.$cookies.remove("slogin");
  142. this.$cookies.remove("studentInfo");
  143. this.$store.commit("update", ["isLogin", false]);
  144. this.$store.commit("update", ["studentInfo", {}]);
  145. Message({
  146. message: "退出成功",
  147. type: "success",
  148. });
  149. this.$router.push("/login");
  150. },
  151. goTo(path) {
  152. this.$router.push(path);
  153. },
  154. },
  155. };
  156. </script>
  157. <style>
  158. * {
  159. margin: 0;
  160. padding: 0;
  161. }
  162. ul,
  163. li {
  164. list-style: none;
  165. }
  166. html,
  167. body {
  168. height: 100%;
  169. width: 100%;
  170. background: #f2f2f2;
  171. }
  172. body {
  173. font-family: "Helvetica Neue", Helvetica, "PingFang SC", "Hiragino Sans GB",
  174. "Microsoft YaHei", "微软雅黑", Arial, sans-serif;
  175. }
  176. #app {
  177. height: 100%;
  178. width: 100%;
  179. background: #f2f2f2;
  180. /* min-width: 1380px; */
  181. min-width: 1000px;
  182. }
  183. .app_head {
  184. height: 67.5px;
  185. width: 100%;
  186. background-color: rgb(129, 179, 253);
  187. display: flex;
  188. align-items: center;
  189. min-width: 1000px;
  190. flex-direction: row;
  191. justify-content: space-around;
  192. }
  193. .logo {
  194. height: 48px;
  195. width: 73px;
  196. background: url("./assets/logo.png");
  197. background-size: 100% 100%;
  198. margin-left: 20px;
  199. cursor: pointer;
  200. }
  201. .pb_body {
  202. width: 100%;
  203. min-width: 1140px;
  204. min-width: 745px;
  205. display: inline-block;
  206. height: calc(100% - 67.5px);
  207. /* height: calc(100% - 67.5px - 226px); */
  208. min-height: 750px;
  209. background: #f2f2f2;
  210. border-radius: 5px;
  211. position: relative;
  212. overflow: auto;
  213. }
  214. .pb_head {
  215. font-size: 26px;
  216. /* font-weight: 600; */
  217. width: 95%;
  218. margin: 10px auto;
  219. padding: 10px 5px;
  220. border-bottom: 3px solid #eee;
  221. }
  222. .pb_content {
  223. /* height: 100%; */
  224. }
  225. .pb_content_body {
  226. margin: 0px auto;
  227. width: 100%;
  228. /* overflow: auto;
  229. height: calc(100% - 120px); */
  230. }
  231. .user_head {
  232. display: flex;
  233. align-items: center;
  234. margin-right: 20px;
  235. font-size: 18px;
  236. font-weight: 600;
  237. }
  238. .user_head .user_name {
  239. color: #fff;
  240. margin-right: 10px;
  241. }
  242. .user_head div {
  243. display: flex;
  244. align-items: center;
  245. cursor: pointer;
  246. }
  247. .user_head .exitI {
  248. background-image: url("./assets/exit.png");
  249. width: 25px;
  250. height: 25px;
  251. background-size: 100% 100%;
  252. margin-top: 1px;
  253. line-height: 25px;
  254. vertical-align: text-top;
  255. background-repeat: no-repeat;
  256. }
  257. .noticeBox {
  258. position: relative;
  259. margin-right: 10px;
  260. }
  261. .user_head .noticeI {
  262. background-image: url("./assets/icon/noticeA.png");
  263. width: 25px;
  264. height: 25px;
  265. background-size: 100% 100%;
  266. margin-top: 1px;
  267. line-height: 25px;
  268. vertical-align: text-top;
  269. background-repeat: no-repeat;
  270. cursor: pointer;
  271. }
  272. .noticeBox span {
  273. position: absolute;
  274. background: red;
  275. width: 15px;
  276. height: 15px;
  277. border-radius: 30px;
  278. color: #fff;
  279. text-align: center;
  280. font-size: 12px;
  281. display: flex;
  282. align-items: center;
  283. justify-content: center;
  284. top: -3px;
  285. right: -3px;
  286. }
  287. .stuWidth {
  288. min-width: 1180px;
  289. }
  290. .app_right {
  291. display: flex;
  292. flex-direction: row;
  293. justify-content: flex-end;
  294. color: #fff;
  295. align-items: center;
  296. }
  297. .pic_img {
  298. width: 30px;
  299. height: 30px;
  300. }
  301. .pic_img > img {
  302. width: 100%;
  303. height: 100%;
  304. }
  305. .box_right_three {
  306. display: flex;
  307. margin: 0 25px 0px 0;
  308. }
  309. .box_right_three > div:nth-child(2) {
  310. margin: 5px 10px 0 5px;
  311. cursor: pointer;
  312. line-height: 22px;
  313. }
  314. .bottom {
  315. background: #ccc;
  316. width: 100%;
  317. }
  318. .bottom_flex {
  319. display: flex;
  320. justify-content: space-around;
  321. }
  322. .left_bottom_flex {
  323. margin: 10px 0 5px 0;
  324. }
  325. .left_title {
  326. font-size: 18px;
  327. margin: 5px 0 15px 5px;
  328. color: #747474;
  329. }
  330. .left_content {
  331. color: #767676;
  332. font-size: 14px;
  333. }
  334. .left_content > div {
  335. margin-bottom: 15px;
  336. }
  337. .right_bottom_flex {
  338. width: 219px;
  339. height: 144px;
  340. margin: auto 0;
  341. }
  342. .right_bottom_flex > img {
  343. width: 100%;
  344. height: 100%;
  345. }
  346. </style>