LoginNav2.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  1. <template>
  2. <!-- 顶部登录导航 -->
  3. <div class="LoginNav">
  4. <div class="logo" @click="goHome">
  5. <img :src="configInfor.logo_image_url_home" class="logo-img" />
  6. <p class="p1">{{ configInfor.title }}</p>
  7. </div>
  8. <div class="userName">
  9. <el-dropdown trigger="click" @command="changeLang">
  10. <span class="el-dropdown-link" style="cursor: pointer">
  11. {{ lang ? lang : "中文"
  12. }}<i class="el-icon-arrow-down el-icon--right"></i>
  13. </span>
  14. <el-dropdown-menu slot="dropdown" style="width: 200px">
  15. <el-dropdown-item
  16. v-for="item in language_list"
  17. :key="item.language_type"
  18. :command="item"
  19. >{{ item.language_name }}</el-dropdown-item
  20. >
  21. </el-dropdown-menu>
  22. </el-dropdown>
  23. <div class="selectLoginOrRegistration" style="margin: 0 16px">
  24. <!-- 登录 -->
  25. <span @click="cutLoginReg('login')">{{ $t("Key9") }}</span>
  26. </div>
  27. <div class="message">
  28. <img src="../../assets/login/Vector.png" alt="" />
  29. </div>
  30. </div>
  31. </div>
  32. </template>
  33. <script>
  34. import Cookies from "js-cookie";
  35. import { getAcsCode, getStaticContent, getContent } from "@/api/api";
  36. import { getToken } from "@/utils/auth";
  37. export default {
  38. props: ["type", "changeLoginReg", "configInfor"],
  39. data() {
  40. return {
  41. activeIndex: "",
  42. LoginNavIndex: "1",
  43. projectName: "教学中心",
  44. projectDownIndex: 0,
  45. language_list: [],
  46. lang: "",
  47. };
  48. },
  49. methods: {
  50. // 切换导航
  51. handleSelect(key, keyPath) {
  52. console.log(key, keyPath);
  53. this.LoginNavIndex = key;
  54. if (this.LoginNavIndex == "1") {
  55. this.$router.push("/");
  56. } else {
  57. let ulobj = document.getElementsByClassName("el-dropdown-menu")[0];
  58. ulobj.classList.add("LoginNavSeleProject");
  59. }
  60. },
  61. // 切换项目
  62. handleCommand(command) {
  63. let _this = this;
  64. _this.LoginNavIndex = command;
  65. let userInfor = JSON.parse(getToken());
  66. let user_code = "",
  67. user_type = "",
  68. session_id = "";
  69. if (userInfor) {
  70. user_code = userInfor.user_code;
  71. user_type = userInfor.user_type;
  72. session_id = userInfor.session_id;
  73. }
  74. if (!session_id || !user_code || !user_type || !_this.userMessage) {
  75. this.$message.warning("请先登录");
  76. this.projectName = "教学中心";
  77. // window.location.href = "/";
  78. return;
  79. }
  80. this.projectDownIndex = command;
  81. let MethodName = "login_control-CreateAccessCode";
  82. let acsCode = null;
  83. getContent(MethodName, user_code, user_type, session_id).then((res) => {
  84. acsCode = res.access_code;
  85. _this.projectName = this.projectList[command].name;
  86. let id = this.projectList[command].id;
  87. if (id == 0) {
  88. // 教学管理系统
  89. location.href = `/GCLS-Learn/#/EnterSys?AccessCode=${acsCode}`;
  90. } else if (id == 1) {
  91. // 教材管理系统
  92. location.href = `/GCLS-Book/#/EnterSys?AccessCode=${acsCode}`;
  93. } else if (id == 2) {
  94. // 教培中心
  95. location.href = `/GCLS-TRC/#/EnterSys?AccessCode=${acsCode}`;
  96. } else if (id == 3) {
  97. // 教研中心
  98. location.href = `/GCLS-TC/#/EnterSys?AccessCode=${acsCode}`;
  99. } else if (id == 4) {
  100. // 考试中心
  101. location.href = `/GCLS-Test/#/EnterSys?AccessCode=${acsCode}`;
  102. } else if (id == 5) {
  103. // 学习中心
  104. location.href = `/GCLS-LC/#/EnterSys?AccessCode=${acsCode}`;
  105. } else {
  106. // 个人中心
  107. location.href = `/GCLS-Personal/#/EnterSys?AccessCode=${acsCode}`;
  108. }
  109. });
  110. },
  111. // 切换语言
  112. async changeLang(command) {
  113. this.lang = command.language_name;
  114. let lang_type = command.language_type;
  115. //await setI18nLang(lang_type);
  116. localStorage.setItem("language_type", lang_type);
  117. this.$router.go(0);
  118. },
  119. // 切换登录的注册
  120. cutLoginReg(value) {
  121. if (value == "login") {
  122. this.$router.push({ path: "/", query: { type: "login" } });
  123. } else {
  124. this.$router.go(0);
  125. }
  126. },
  127. getLangList() {
  128. let MethodName = "language_manager-GetLanguageList";
  129. let data = {};
  130. getStaticContent(MethodName, data).then((res) => {
  131. this.language_list = res.language_list;
  132. for (let i = 0; i < this.language_list.length; i++) {
  133. let item = this.language_list[i];
  134. if (item.language_type == this.language_type) {
  135. this.lang = item.language_name;
  136. break;
  137. }
  138. }
  139. });
  140. },
  141. goHome() {
  142. this.$router.go(-1);
  143. },
  144. },
  145. created() {
  146. let _this = this;
  147. let language_type = localStorage.getItem("language_type");
  148. if (language_type) {
  149. _this.language_type = language_type;
  150. }
  151. _this.getLangList();
  152. },
  153. };
  154. </script>
  155. <style lang="scss" scoped>
  156. .LoginNav {
  157. height: 65px;
  158. position: relative;
  159. display: flex;
  160. align-items: center;
  161. justify-content: space-between;
  162. padding: 0 45px 0 40px;
  163. z-index: 999;
  164. background: white;
  165. .logo {
  166. display: flex;
  167. align-items: center;
  168. cursor: pointer;
  169. .el-menu-demo {
  170. background: rgba(0, 0, 0, 0);
  171. // margin-left: 100px;
  172. li:hover {
  173. background: none;
  174. }
  175. li {
  176. background: none;
  177. }
  178. }
  179. // 取消组件默认的样式
  180. .el-menu.el-menu--horizontal {
  181. border-bottom: none;
  182. }
  183. .logo-img {
  184. width: 48px;
  185. height: 48px;
  186. }
  187. .p1 {
  188. font-size: 18px;
  189. line-height: 26px;
  190. color: #000;
  191. margin: 0 10px;
  192. }
  193. }
  194. .userName {
  195. display: flex;
  196. align-items: center;
  197. .seek {
  198. margin-right: 100px;
  199. position: relative;
  200. img {
  201. left: 10px;
  202. top: 11px;
  203. position: absolute;
  204. }
  205. }
  206. .flag {
  207. position: relative;
  208. top: 5px;
  209. }
  210. .headPhoto {
  211. width: 50px;
  212. height: 50px;
  213. // background: url("../assets/teacherTrain/image 4.png") no-repeat 100% 100%;
  214. // background-size: 100%;
  215. border-radius: 50%;
  216. margin-right: 10px;
  217. }
  218. .message {
  219. position: relative;
  220. margin-left: 16px;
  221. img {
  222. width: 32px;
  223. height: 32px;
  224. }
  225. .redDot {
  226. width: 6px;
  227. height: 6px;
  228. position: absolute;
  229. display: inline-block;
  230. background: red;
  231. border-radius: 50%;
  232. right: 0;
  233. }
  234. }
  235. .selectLoginOrRegistration {
  236. display: flex;
  237. height: 32px;
  238. border: 1px solid black;
  239. box-sizing: border-box;
  240. border-radius: 4px;
  241. // justify-content: space-evenly;
  242. align-items: center;
  243. color: black;
  244. span {
  245. min-width: 64px;
  246. padding: 0 8px;
  247. text-align: center;
  248. cursor: pointer;
  249. }
  250. }
  251. }
  252. }
  253. </style>
  254. <style lang="scss">
  255. .LoginNavSeleProject {
  256. .el-dropdown-menu__item:hover {
  257. background: #ff9900 !important;
  258. color: black !important;
  259. }
  260. }
  261. </style>