LoginNav.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451
  1. <template>
  2. <!-- 顶部登录导航 -->
  3. <div class="LoginNav" :style="{ color: type == 'Live' ? 'black' : 'white' }">
  4. <div class="logo">
  5. <!-- <span> logo </span> -->
  6. <!-- <el-menu
  7. :default-active="activeIndex"
  8. class="el-menu-demo"
  9. mode="horizontal"
  10. @select="handleSelect"
  11. text-color="#fff"
  12. active-text-color="#FF9900"
  13. >
  14. <el-menu-item index="1">首页</el-menu-item>
  15. <el-menu-item index="2" v-if="projectListArr.length > 0">
  16. <el-dropdown trigger="click" @command="handleCommand">
  17. <span
  18. class="el-dropdown-link"
  19. :style="{ color: LoginNavIndex == 2 ? '#FF9900' : '#fff' }"
  20. >
  21. {{ projectName }}
  22. <img
  23. class="dropdownIcon"
  24. src="../../assets/login/dropdownIcon.png"
  25. alt=""
  26. />
  27. </span>
  28. <el-dropdown-menu slot="dropdown" style="width: 300px">
  29. <el-dropdown-item
  30. v-for="(item, i) in projectListArr"
  31. :key="i"
  32. :command="i"
  33. :class="projectDownIndex == i ? 'downsele' : ''"
  34. >
  35. <img
  36. style="position: relative; top: 5px; width: 24px"
  37. :src="item.icon_url_memu_default"
  38. alt=""
  39. />
  40. <span style="margin-left: 16px">
  41. {{ item.name }}
  42. </span>
  43. </el-dropdown-item>
  44. </el-dropdown-menu>
  45. </el-dropdown>
  46. </el-menu-item>
  47. </el-menu> -->
  48. <img :src="configInfor.logo_image_url_home" class="logo-img" />
  49. <p class="p1">{{ configInfor.title }}</p>
  50. </div>
  51. <div class="userName">
  52. <el-dropdown style="margin: 0 16px" trigger="click" @command="changeLang">
  53. <span class="el-dropdown-link" style="color: #fff; cursor: pointer">
  54. {{ lang ? lang : "中文" }}<img src="../../assets/arrow-down.png" />
  55. </span>
  56. <el-dropdown-menu slot="dropdown" style="width: 200px">
  57. <el-dropdown-item
  58. v-for="item in language_list"
  59. :key="item.language_type"
  60. :command="item"
  61. >{{ item.language_name }}</el-dropdown-item
  62. >
  63. </el-dropdown-menu>
  64. </el-dropdown>
  65. <!-- <div v-if="!userMessage" class="selectLoginOrRegistration">
  66. <span class="lrBtn" @click="cutLoginReg('login')">{{
  67. $t("Key9")
  68. }}</span>
  69. <span> | </span>
  70. <span class="lrBtn" @click="cutLoginReg('signin')">{{
  71. $t("Key10")
  72. }}</span>
  73. </div> -->
  74. <!-- 用户头像和用户名 -->
  75. <div class="user" v-if="userMessage">
  76. <img
  77. @click="userShow = !userShow"
  78. class="headPhoto"
  79. :src="
  80. userMessage.image_url
  81. ? userMessage.image_url
  82. : require('../../assets/login/Group3214.png')
  83. "
  84. alt=""
  85. />
  86. <span @click="userShow = !userShow">{{
  87. userMessage.user_real_name
  88. }}</span>
  89. <div class="userShow" v-show="userShow">
  90. <p @click="gotoPersonalcenter">
  91. <img src="../../assets/login/project7.png" alt="" />{{
  92. $t("Key38")
  93. }}
  94. <!-- 个人中心 -->
  95. </p>
  96. <p @click="QuitLogin">
  97. <img src="../../assets/login/Frame77.png" alt="" />{{ $t("Key39") }}
  98. <!-- 退出登录 -->
  99. </p>
  100. </div>
  101. </div>
  102. <!-- 消息 铃铛图片 -->
  103. <div class="message" v-if="userMessage">
  104. <img
  105. @click="gotoPersonalcenter"
  106. src="../../assets/login/Vector2.png"
  107. alt=""
  108. />
  109. </div>
  110. </div>
  111. </div>
  112. </template>
  113. <script>
  114. import Cookies from "js-cookie";
  115. import { getStaticContent, getContent } from "@/api/api";
  116. import { getToken, removeToken, setToken } from "@/utils/auth";
  117. import { setI18nLang } from "@/utils/i18n";
  118. export default {
  119. props: [
  120. "type",
  121. "changeLoginReg",
  122. "FatheruserMessage",
  123. "projectList",
  124. "configInfor",
  125. ],
  126. data() {
  127. return {
  128. activeIndex: "1",
  129. LoginNavIndex: "1",
  130. projectName: "",
  131. userMessage: null,
  132. userShow: false,
  133. projectDownIndex: 0,
  134. language_list: [],
  135. lang: "",
  136. projectListArr: [],
  137. };
  138. },
  139. watch: {
  140. FatheruserMessage(newval, oldval) {
  141. this.userMessage = null;
  142. this.userMessage = newval;
  143. },
  144. projectList: {
  145. handler: function (val, oldVal) {
  146. if (val.length > 0) {
  147. this.projectListArr = val;
  148. this.projectName = val[0].name;
  149. }
  150. },
  151. // 深度观察监听
  152. deep: true,
  153. },
  154. },
  155. methods: {
  156. // 切换导航
  157. handleSelect(key, keyPath) {
  158. this.LoginNavIndex = key;
  159. if (this.LoginNavIndex == "1") {
  160. this.$router.push("/");
  161. } else {
  162. let ulobj = document.getElementsByClassName("el-dropdown-menu")[0];
  163. ulobj.classList.add("LoginNavSeleProject");
  164. }
  165. },
  166. // 切换项目
  167. handleCommand(command) {
  168. let _this = this;
  169. _this.LoginNavIndex = "2";
  170. let userInfor = getToken();
  171. let user_code = "",
  172. user_type = "",
  173. session_id = "";
  174. if (userInfor) {
  175. userInfor = JSON.parse(getToken());
  176. user_code = userInfor.user_code;
  177. user_type = userInfor.user_type;
  178. session_id = userInfor.session_id;
  179. }
  180. if (!session_id || !user_code || !user_type || !_this.userMessage) {
  181. this.$message.warning("请先登录");
  182. this.projectName = "教学中心";
  183. return;
  184. }
  185. _this.projectDownIndex = command;
  186. let relative_path = _this.projectList[command].relative_path;
  187. location.href = relative_path;
  188. },
  189. // 切换语言
  190. async changeLang(command) {
  191. this.lang = command.language_name;
  192. let lang_type = command.language_type;
  193. console.log(lang_type);
  194. let userInfor = getToken();
  195. if (userInfor) {
  196. await setI18nLang(lang_type);
  197. userInfor = JSON.parse(getToken());
  198. userInfor.language_type = lang_type;
  199. setToken(userInfor);
  200. } else {
  201. localStorage.setItem("language_type", lang_type);
  202. }
  203. this.$router.go(0);
  204. },
  205. // 切换登录的注册
  206. cutLoginReg(value) {
  207. this.changeLoginReg(value);
  208. },
  209. // 前往个人中心
  210. gotoPersonalcenter() {
  211. let userInfor = getToken();
  212. let user_code = "",
  213. user_type = "",
  214. session_id = "";
  215. if (userInfor) {
  216. userInfor = JSON.parse(getToken());
  217. user_code = userInfor.user_code;
  218. user_type = userInfor.user_type;
  219. session_id = userInfor.session_id;
  220. }
  221. if (!session_id) {
  222. this.$message.warning("请先登录");
  223. return;
  224. }
  225. location.href = `/GCLS-Personal/#/EnterSys`;
  226. },
  227. QuitLogin() {
  228. Cookies.remove("userMessage");
  229. Cookies.remove("session_id");
  230. Cookies.remove("user_code");
  231. Cookies.remove("user_type");
  232. Cookies.remove("GCLSCode");
  233. sessionStorage.removeItem("useragent_root_close");
  234. removeToken();
  235. this.userShow = false;
  236. this.userMessage = null;
  237. this.changeLoginReg("login", null);
  238. this.projectListArr = [];
  239. },
  240. getLangList() {
  241. let MethodName = "language_manager-GetLanguageList";
  242. let data = {};
  243. getStaticContent(MethodName, data).then((res) => {
  244. this.language_list = res.language_list;
  245. for (let i = 0; i < this.language_list.length; i++) {
  246. let item = this.language_list[i];
  247. if (item.language_type == this.language_type) {
  248. this.lang = item.language_name;
  249. break;
  250. }
  251. }
  252. });
  253. },
  254. },
  255. created() {
  256. let _this = this;
  257. let language_type = localStorage.getItem("language_type");
  258. if (language_type) {
  259. _this.language_type = language_type;
  260. }
  261. if (this.FatheruserMessage) {
  262. _this.userMessage = this.FatheruserMessage;
  263. } else {
  264. _this.userMessage = null;
  265. }
  266. _this.getLangList();
  267. },
  268. mounted() {
  269. // this.projectName =
  270. // this.projectList.length > 0 ? this.projectList[0].name : "";
  271. },
  272. };
  273. </script>
  274. <style lang="scss" scoped>
  275. .LoginNav {
  276. height: 64px;
  277. position: relative;
  278. display: flex;
  279. align-items: center;
  280. justify-content: space-between;
  281. padding: 0 60px 0 40px;
  282. z-index: 999;
  283. // background: linear-gradient(180deg, #000000 0%, rgba(44, 44, 44, 0) 100%);
  284. .logo {
  285. display: flex;
  286. align-items: center;
  287. .el-menu-demo {
  288. background: rgba(0, 0, 0, 0);
  289. // margin-left: 100px;
  290. li:hover {
  291. background: none;
  292. }
  293. li {
  294. background: none;
  295. }
  296. }
  297. .dropdownIcon {
  298. margin-left: 8px;
  299. width: 8px;
  300. height: 4px;
  301. }
  302. // 取消组件默认的样式
  303. .el-menu.el-menu--horizontal {
  304. border-bottom: none;
  305. }
  306. .logo-img {
  307. width: 48px;
  308. height: 48px;
  309. }
  310. .p1 {
  311. font-size: 18px;
  312. line-height: 26px;
  313. color: #ffffff;
  314. margin: 0 10px;
  315. }
  316. }
  317. .userName {
  318. display: flex;
  319. align-items: center;
  320. .seek {
  321. margin-right: 100px;
  322. position: relative;
  323. img {
  324. left: 10px;
  325. top: 11px;
  326. position: absolute;
  327. }
  328. }
  329. .flag {
  330. position: relative;
  331. top: 5px;
  332. }
  333. .headPhoto {
  334. width: 50px;
  335. height: 50px;
  336. // background: url("../assets/teacherTrain/image 4.png") no-repeat 100% 100%;
  337. // background-size: 100%;
  338. border-radius: 50%;
  339. // margin-right: 10px;
  340. }
  341. .message {
  342. position: relative;
  343. margin-left: 16px;
  344. img {
  345. width: 32px;
  346. height: 32px;
  347. cursor: pointer;
  348. }
  349. .redDot {
  350. width: 6px;
  351. height: 6px;
  352. position: absolute;
  353. display: inline-block;
  354. background: red;
  355. border-radius: 50%;
  356. right: 0;
  357. }
  358. }
  359. .selectLoginOrRegistration {
  360. display: flex;
  361. height: 32px;
  362. border: 1px solid #ffffff;
  363. box-sizing: border-box;
  364. border-radius: 4px;
  365. align-items: center;
  366. .lrBtn {
  367. min-width: 64px;
  368. padding: 0 8px;
  369. cursor: pointer;
  370. text-align: center;
  371. }
  372. }
  373. .user {
  374. display: flex;
  375. align-items: center;
  376. cursor: pointer;
  377. position: relative;
  378. > img {
  379. width: 34px;
  380. height: 34px;
  381. }
  382. > span {
  383. padding-left: 10px;
  384. }
  385. .userShow {
  386. position: absolute;
  387. width: 156px;
  388. height: 96px;
  389. background: #ffffff;
  390. box-shadow: 0px 2px 8px rgba(0, 0, 0, 0.15);
  391. border-radius: 8px;
  392. bottom: -100px;
  393. left: 0;
  394. color: black;
  395. img {
  396. width: 24px;
  397. height: 24px;
  398. margin-right: 10px;
  399. }
  400. p {
  401. height: 40px;
  402. display: flex;
  403. align-items: center;
  404. padding-left: 20px;
  405. margin: 0;
  406. margin-top: 5px;
  407. }
  408. > p:hover {
  409. background: #f2f2f2;
  410. }
  411. }
  412. }
  413. }
  414. }
  415. </style>
  416. <style lang="scss">
  417. .downsele {
  418. background: #ff9900;
  419. }
  420. .LoginNav {
  421. .el-menu--horizontal > .el-menu-item {
  422. height: 64px;
  423. }
  424. .el-menu-item {
  425. font-size: 16px;
  426. }
  427. .is-active {
  428. font-weight: bold;
  429. line-height: 64px;
  430. }
  431. .el-menu-item i {
  432. color: white;
  433. }
  434. .el-dropdown {
  435. font-size: 16px;
  436. img {
  437. width: 24px;
  438. height: 24px;
  439. }
  440. .el-dropdown-link {
  441. display: flex;
  442. align-items: center;
  443. }
  444. }
  445. }
  446. </style>