123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461 |
- <template>
- <div
- id="app"
- :class="
- this.$route.path == '/data' && this.$store.state.userInfo.type == 1
- ? 'changeBg'
- : ''
- "
- >
- <div :class="this.$route.path == '/anliDetail' ? 'app_headBg' : 'app_head'">
- <div
- class="logo"
- style="cursor: pointer"
- @click="goTo('/eventCenter')"
- ></div>
- <span
- style="margin-left: 10px; color: #fff; font-size: 16px; cursor: pointer"
- @click="goTo('/eventCenter')"
- >光明区项目式学习教师挑战赛</span
- >
- <div class="user_head" v-if="this.$store.state.isLogin">
- <span class="user_name">{{
- this.$store.state.userInfo ? this.$store.state.userInfo.name : "用户"
- }}</span>
- <!-- <div
- class="settingImg"
- @click="goTo('/data')"
- v-if="this.$store.state.userInfo.type == 1"
- ></div>
- <span
- v-if="this.$store.state.userInfo.type == 1"
- style="
- color: rgb(255, 255, 255);
- margin-right: 20px;
- font-weight: 500;
- font-size: 15px;
- cursor: pointer;
- text-align: center;
- "
- @click="goTo('/data')"
- >设置</span
- >
- <div @click="exit">
- <i class="exitI"></i>
- <el-button type="text" style="color: white">退出</el-button>
- </div> -->
- </div>
- </div>
- <div
- style="width: 100%; height: 100%"
- :class="{
- ggheight: true,
- }"
- >
- <!-- main 内容 -->
- <keep-alive v-if="$route.meta.keepAlive">
- <!-- 这里是会被缓存的视图组件 -->
- <router-view
- v-if="$route.meta.keepAlive"
- :class="{ pb_body: isShowNav }"
- />
- </keep-alive>
- <!-- 这里是不被缓存的视图组件 -->
- <router-view
- v-if="!$route.meta.keepAlive"
- :class="{ pb_body: isShowNav }"
- />
- <!-- 底部导航 -->
- <footer-nav
- v-if="isShowNav && $store.state.userInfo.type != 1"
- :nav="nav"
- :luyou="this.$store.state.luyou"
- ></footer-nav>
- </div>
- </div>
- </template>
- <script>
- import leftBar from "./components/tools/leftBar";
- import { Message } from "element-ui";
- export default {
- name: "App",
- data() {
- return {
- isShowNav: false, // 是否显示导航 Tab
- navTabs: [
- "/anliList",
- "/county",
- "/user",
- "/score",
- "/data",
- "/notice",
- "/school",
- ], // 市级导航
- navTabs2: [
- "/anliList1",
- "/user1",
- "/school1",
- "/score1",
- "/data",
- "/notice",
- ], // 区级导航
- navTabs3: ["/anliList2", "/data", "/notice"], // 省级导航
- nav: [],
- };
- },
- components: {
- "footer-nav": leftBar,
- },
- methods: {
- isLogin() {
- const loading = this.$loading.service({
- background: "rgba(255, 255, 255)",
- target: document.querySelector("body"),
- });
- var _isLogin = this.$cookies.get("tlogin");
- var userInfo = this.$cookies.get("teacherInfo");
- if (_isLogin == "1" && userInfo) {
- loading.close();
- this.$store.commit("update", ["isLogin", true]);
- // var info = JSON.parse(window.sessionStorage.getItem("userInfo"));
- this.$store.commit("update", ["userInfo", userInfo]);
- if (this.$route.path == "/login") {
- if (userInfo.type == "1") {
- this.$router.push("/eventCenter?steps=" + "2");
- } else if (userInfo.type == "2" || userInfo.type == "4") {
- this.$router.push("/anliList");
- } else if (userInfo.type == "5" || userInfo.type == "6") {
- this.$router.push("/anliList1");
- } else if (userInfo.type == "3") {
- this.$router.push("/anliList2");
- }
- }
- this.routerP();
- } else {
- this.$store.commit("update", ["isLogin", false]);
- Message({
- message: "未登录,请登录",
- type: "warning",
- });
- setTimeout(() => {
- loading.close();
- if (this.$route.path != "/login") {
- this.$router.push("/login");
- }
- }, 2000);
- }
- },
- routerP() {
- const { navTabs, navTabs2, navTabs3 } = this.$data;
- const { userInfo } = this.$store.state;
- let router_path = this.$route.path;
- console.log(router_path);
- if (!userInfo.type) {
- this.isLogin();
- return;
- }
- var a = 0;
- if (userInfo.type == 2 || userInfo.type == 4) {
- if (navTabs.indexOf(router_path) != -1) {
- a = 1;
- this.isShowNav = true;
- }
- this.nav = navTabs;
- } else if (userInfo.type == 5 || userInfo.type == 6) {
- if (navTabs2.indexOf(router_path) != -1) {
- a = 1;
- this.isShowNav = true;
- }
- this.nav = navTabs;
- } else if (userInfo.type == 3) {
- if (navTabs3.indexOf(router_path) != -1) {
- a = 1;
- this.isShowNav = true;
- }
- this.nav = navTabs;
- }
- if (a == 0) {
- this.nav = [];
- this.isShowNav = false;
- }
- },
- exit() {
- sessionStorage.clear();
- this.$cookies.remove("tlogin");
- this.$cookies.remove("teacherInfo");
- this.$store.commit("update", ["isLogin", false]);
- this.$store.commit("update", ["userInfo", {}]);
- Message({
- message: "退出成功",
- type: "success",
- });
- this.$router.push("/login");
- },
- goTo(path) {
- this.$router.push(path);
- },
- },
- watch: {
- $route(to, from) {
- const { navTabs, navTabs2, navTabs3 } = this.$data;
- const { userInfo } = this.$store.state;
- const toPath = to.path;
- const fromName = from.name;
- var a = 0;
- if (userInfo.type == 2 || userInfo.type == 4) {
- if (navTabs.indexOf(toPath) != -1) {
- a = 1;
- this.isShowNav = true;
- }
- this.nav = navTabs;
- } else if (userInfo.type == 5 || userInfo.type == 6) {
- if (navTabs2.indexOf(toPath) != -1) {
- a = 1;
- this.isShowNav = true;
- }
- this.nav = navTabs2;
- } else if (userInfo.type == 3) {
- if (navTabs3.indexOf(toPath) != -1) {
- a = 1;
- this.isShowNav = true;
- }
- this.nav = navTabs3;
- }
- if (a == 0) {
- this.nav = [];
- this.isShowNav = false;
- }
- },
- },
- created() {
- this.routerP();
- },
- };
- </script>
- <style>
- * {
- margin: 0;
- padding: 0;
- }
- body {
- font-family: "Helvetica Neue", Helvetica, "PingFang SC", "Hiragino Sans GB",
- "Microsoft YaHei", "微软雅黑", Arial, sans-serif;
- }
- #app {
- height: 100%;
- width: 100%;
- background: #e6eaf0;
- /* min-width: 1380px; */
- /* min-width: 1250px; */
- }
- .appNoWidth {
- min-width: unset !important;
- display: inline-block !important;
- min-width: 550px;
- }
- .appNoHeight {
- min-height: 750px;
- }
- .app_head,
- .app_headBg {
- height: 50px;
- width: 100%;
- background-color: #293e68;
- display: flex;
- align-items: center;
- min-width: 1000px;
- }
- .app_headBg {
- background: url("./assets/icon/topBg.png");
- }
- .logo {
- height: 40px;
- width: 40px;
- background: url("./assets/logo1.png");
- background-size: 100% 100%;
- margin-left: 20px;
- }
- .pb_body {
- margin-left: 220px;
- width: calc(100% - 240px) !important;
- /* min-width: 1140px; */
- min-width: 750px;
- display: inline-block;
- /* height: calc(100% - 100px); */
- /* min-height: 750px; */
- background: #fff;
- margin-top: 20px;
- border-radius: 5px;
- position: absolute;
- height: calc(100% - 100px);
- overflow: auto;
- }
- .ggheight {
- height: calc(100% - 67.5px) !important;
- }
- .pb_head {
- font-size: 26px;
- /* font-weight: 600; */
- width: 95%;
- margin: 10px auto;
- padding: 10px 5px;
- border-bottom: 1px solid #eee;
- }
- .pb_content {
- /* height: 100%; */
- }
- .pb_content_body {
- width: 94%;
- margin: 10px auto;
- /* overflow: auto;
- height: calc(100% - 120px); */
- }
- .user_head {
- display: flex;
- align-items: center;
- margin-left: auto;
- margin-right: 20px;
- font-size: 18px;
- font-weight: 600;
- }
- .user_head .user_name {
- color: #fff;
- margin-right: 20px;
- }
- .user_head div {
- display: flex;
- align-items: center;
- cursor: pointer;
- }
- .user_head .exitI {
- background-image: url("./assets/exit.png");
- width: 25px;
- height: 25px;
- background-size: 100% 100%;
- margin-top: 1px;
- line-height: 25px;
- vertical-align: text-top;
- background-repeat: no-repeat;
- }
- .noticeBox {
- position: relative;
- margin-right: 10px;
- }
- .user_head .noticeI {
- background-image: url("./assets/icon/noticeA.png");
- width: 25px;
- height: 25px;
- background-size: 100% 100%;
- margin-top: 1px;
- line-height: 25px;
- vertical-align: text-top;
- background-repeat: no-repeat;
- cursor: pointer;
- }
- .noticeBox span {
- position: absolute;
- background: red;
- width: 15px;
- height: 15px;
- border-radius: 30px;
- color: #fff;
- text-align: center;
- font-size: 12px;
- display: flex;
- align-items: center;
- justify-content: center;
- top: -3px;
- right: -3px;
- }
- .stuWidth {
- min-width: 1180px;
- }
- .gHeight {
- height: 100%;
- }
- html::-webkit-scrollbar {
- /*滚动条整体样式*/
- width: 6px;
- /*高宽分别对应横竖滚动条的尺寸*/
- height: 6px;
- }
- /*定义滚动条轨道 内阴影+圆角*/
- html::-webkit-scrollbar {
- border-radius: 10px;
- background-color: #eee;
- }
- /*定义滑块 内阴影+圆角*/
- html::-webkit-scrollbar-thumb {
- border-radius: 10px;
- -webkit-box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.3);
- background-color: rgba(0, 0, 0, 0.1);
- }
- .btnClassGM {
- background: #8681b7 !important;
- border-color: #8681b7 !important;
- }
- .btnClassGM:focus,
- .btnClassGM:hover {
- background: #8681b7 !important;
- border-color: #8681b7 !important;
- }
- .GMBg {
- background: rgb(184, 181, 202) !important;
- }
- .cancelbtnGM:focus,
- .cancelbtnGM:hover {
- color: rgb(92, 84, 159) !important;
- border-color: #5c549f !important;
- background-color: #dbd7ff !important;
- }
- .changeBg {
- background: #fff !important;
- }
- .settingImg {
- background-image: url("./assets/icon/setting.png");
- width: 19px;
- height: 19px;
- background-size: 100% 100%;
- margin: 1px 5px 0 0;
- line-height: 25px;
- vertical-align: text-top;
- background-repeat: no-repeat;
- }
- .settingImg > img {
- width: 100%;
- height: 100%;
- }
- </style>
|