headerItem.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492
  1. <template>
  2. <div>
  3. <div class="header1">
  4. <div class="header2">
  5. <div class="language">
  6. <div v-if="!langeInfo">
  7. <span class="active" v-if="$store.state.router!='ConferenceNetwork' && $store.state.router!='MeetingApplyForm'">
  8. <span class="cursor" @click="locale('zh')">{{
  9. $t("common.CN")
  10. }}</span>
  11. <span
  12. style="
  13. margin: 0 14px;
  14. display: inline-block;
  15. width: 2px;
  16. height: 14px;
  17. background: #f9f9f9;
  18. "
  19. ></span>
  20. <span style="margin-right: 9px" class="cursor" @click="locale('en')"
  21. >EN</span
  22. >
  23. </span></div>
  24. <span class="active" style="float: right">
  25. <span
  26. class="cursor"
  27. style="margin-right: 12px"
  28. @click="toView(2, 'Register', '')"
  29. v-if="i == 1"
  30. ><img
  31. src="@/assets/注册.png"
  32. style="height: 12px; width: 12px; margin-right: 4px"
  33. />{{ $t("common.register") }}</span
  34. >
  35. <span
  36. class="cursor"
  37. style="margin-right: 12px"
  38. @click="toView(2, 'login', '')"
  39. v-if="i == 1"
  40. ><img
  41. src="@/assets/登录.png"
  42. style="height: 12px; width: 12px; margin-right: 4px"
  43. />{{ $t("common.login") }}</span
  44. >
  45. <!-- <span class="cursor" style="margin-right: 12px;" v-if="i==2 || i==3">{{ $t('common.OngoingProject')}}(<span style="color: #ff0000;">0</span>)</span> -->
  46. <!-- <span class="cursor" style="margin-right: 12px;" v-if="i==2 || i==3">{{ $t('common.MyAttention')}}(<span style="color: #ff0000;">0</span>)</span> -->
  47. <!-- <span class="cursor" style="margin-right: 12px;" v-if="i==2 || i==3">{{ $t('common.MyCollection')}}</span> -->
  48. <i
  49. class="el-icon-s-custom"
  50. style="color: #fff; margin-right: 4px"
  51. v-if="i == 2 || i == 3"
  52. ></i>
  53. <el-dropdown
  54. trigger="click"
  55. @command="handleCommand"
  56. v-if="i == 2 || i == 3"
  57. >
  58. <!-- <i class="el-icon-s-custom" style="color: #fff;"></i> -->
  59. <span
  60. style="margin-right: 9px; cursor: pointer; font-size: 16px"
  61. v-if="i == 2 || i == 3"
  62. >
  63. {{ $t("common.Usercenter") }}
  64. <i class="el-icon-arrow-down"></i>
  65. <el-dropdown-menu slot="dropdowns">
  66. <el-dropdown-item
  67. v-for="(item, index) in options"
  68. :key="index"
  69. :command="item"
  70. >{{ $t(item.label) }}
  71. <el-dropdown-menu slot="dropdowns">
  72. <el-dropdown-item
  73. v-for="(item, index) in options"
  74. :key="index"
  75. :command="item"
  76. >{{ $t(item.label) }}
  77. </el-dropdown-item>
  78. </el-dropdown-menu>
  79. </el-dropdown-item>
  80. </el-dropdown-menu>
  81. </span>
  82. </el-dropdown>
  83. <i
  84. class="el-icon-message-solid"
  85. style="margin-left: 20px; color: #fff"
  86. v-if="i == 2 || i == 3"
  87. ></i>
  88. <span
  89. class="cursor"
  90. @click="systemMessageNumToView(0, 'SystemMessage', '/SystemMessage')"
  91. style="margin-right: 12px"
  92. v-if="i == 2 || i == 3"
  93. >
  94. {{ $t("common.MessageNotification") }}
  95. ( <span style="color: #ff0000">{{systemMessageNum}}</span> )
  96. </span>
  97. <!-- <span class="cursor" style="margin-right: 12px;" @click="toView(2,'customerService')">{{ $t('common.CustomerService')}}</span> -->
  98. <!-- <span class="cursor" style="margin-right: 12px;" @click="toView(2,'helpCenter')">{{ $t('common.HelpCenter')}}</span> -->
  99. </span>
  100. </div>
  101. <div class="logo">
  102. <img
  103. src="@/assets/img/home/LOGO2020-12-22.png"
  104. alt=""
  105. style="width: 260px"
  106. class="cursor"
  107. @click="toView(0, 'home')"
  108. />
  109. </div>
  110. <div class="title" v-show="searchLoad">
  111. <!-- <span class="cursor" style="font-family: Microsoft YaHei;font-size: 34px;">GEIDCP</span> -->
  112. <span style="float: left; width: 74%">
  113. <el-input
  114. :placeholder="$t('common.EnterContent')"
  115. class="input-with-select"
  116. v-model="homeItemTitle"
  117. maxlength="50"
  118. show-word-limit
  119. @keyup.enter.native="toViewChange('WholeStationSearch')"
  120. >
  121. <el-select v-model="select" slot="prepend">
  122. <el-option
  123. :label="$t('common.WholeStation')"
  124. value="all"
  125. ></el-option>
  126. <el-option
  127. :label="$t('common.Project')"
  128. value="project"
  129. ></el-option>
  130. <el-option
  131. :label="$t('common.Enterprise')"
  132. value="unit"
  133. ></el-option>
  134. <el-option
  135. :label="$t('common.News')"
  136. value="information"
  137. ></el-option>
  138. <el-option
  139. :label="$t('common.Events')"
  140. value="activity"
  141. ></el-option>
  142. <el-option
  143. :label="$t('common.Conference')"
  144. value="meeting"
  145. ></el-option>
  146. <el-option
  147. :label="$t('common.Publications')"
  148. value="journal"
  149. ></el-option>
  150. <el-option
  151. :label="$t('common.Country')"
  152. value="country"
  153. ></el-option>
  154. </el-select>
  155. <el-button
  156. slot="append"
  157. icon="el-icon-search"
  158. @click="toViewChange('WholeStationSearch')"
  159. ></el-button>
  160. </el-input>
  161. </span>
  162. </div>
  163. </div>
  164. </div>
  165. </div>
  166. </template>
  167. <script>
  168. import Bus from "@/api/bus"; //注意引入
  169. import {selectPushMsgNum,selectNoticeInfoNum} from '@/api/userCenter'
  170. export default {
  171. name: "HeaderItem",
  172. props:['selectShow'],
  173. data() {
  174. return {
  175. langeInfo:'',
  176. //消息通知消息类型
  177. messageType:0,
  178. title: "项目资源",
  179. systemMessageNum:0,
  180. homeItemTitle: "",
  181. select: "all",
  182. searchLoad:true,
  183. i: "1",
  184. options: [
  185. {
  186. value: "userCenterView",
  187. label: "common.Usercenter",
  188. json: "",
  189. },{
  190. value: 'SystemMessage',
  191. label: 'common.MessageCenter',
  192. json:'/SystemMessage'
  193. },{
  194. value: 'myConcerns',
  195. label: 'common.ManagementCenter',
  196. json:'/myConcerns'
  197. },
  198. {
  199. value: "information",
  200. label: "common.BasicInformation",
  201. json: "information",
  202. },
  203. {
  204. value: "loginOut",
  205. label: "common.Logout",
  206. json: "",
  207. },
  208. ],
  209. };
  210. },
  211. created() {
  212. Bus.$on("title", (val) => {
  213. this.title = val.label;
  214. });
  215. // Bus.$on("serch", (val) => {
  216. // this.serch=val.label.substring(0,2)
  217. // });
  218. },
  219. watch: {
  220. "$route.path"(){
  221. this.getSearchLoad();
  222. },
  223. "$i18n.locale"() {
  224. if (this.$i18n.locale == "en" && this.$Cookies.get('token')) {
  225. this.i = 3;
  226. } else if (
  227. this.$i18n.locale == "zh" &&
  228. this.$Cookies.get('token')
  229. ) {
  230. this.i = 2;
  231. } else {
  232. this.i = 1;
  233. }
  234. },
  235. },
  236. mounted() {
  237. this.langeInfo = localStorage.getItem('aaa')
  238. this.getSearchLoad();
  239. this.getInitData();
  240. this.getMessageNum();
  241. },
  242. methods: {
  243. getMessageNum(){
  244. if(this.i !=1){
  245. this.messageType = 0;
  246. this.systemMessageNum = 0;
  247. let readStatus='unread'
  248. selectPushMsgNum(readStatus).then(res=>{
  249. if(res.data.page.totalCount>0){
  250. this.systemMessageNum = this.systemMessageNum+parseInt(res.data.page.totalCount);
  251. this.messageType = 1;
  252. }
  253. })
  254. selectNoticeInfoNum(readStatus).then(res=>{
  255. if(res.data.page.totalCount>0){
  256. this.systemMessageNum = this.systemMessageNum+parseInt(res.data.page.totalCount);
  257. this.messageType = 2;
  258. }
  259. })
  260. }
  261. },
  262. getSearchLoad(){
  263. let router = this.$route.path;
  264. this.searchLoad = true;
  265. if(router == '/WholeStationSearch'){
  266. this.searchLoad=false;
  267. this.$forceUpdate();
  268. }
  269. },
  270. getInitData() {
  271. let locale = window.localStorage.getItem("locale");
  272. if (!locale) {
  273. this.$store.commit("modify", router);
  274. window.localStorage.setItem("locale", "en");
  275. }
  276. document.title = this.$t('common.GEIDcpTitleSeptember');
  277. this.$i18n.locale = locale;
  278. console.log(
  279. window.localStorage.getItem("locale"),
  280. window.localStorage.getItem("userLogin")
  281. );
  282. //if (window.localStorage.getItem('userLogin')) {
  283. if (this.$Cookies.get("token") && this.$i18n.locale == "zh") {
  284. return (this.i = 2);
  285. } else if (
  286. this.$i18n.locale == "en" &&
  287. this.$Cookies.get("token")
  288. ) {
  289. return (this.i = 3);
  290. } else {
  291. return (this.i = 1);
  292. }
  293. },
  294. handleCommand(command) {
  295. if (command.value == "loginOut") {
  296. sessionStorage.removeItem("pathReminder");
  297. this.loginOut();
  298. } else {
  299. this.toView(0, command.value, command.json);
  300. }
  301. },
  302. locale(lang) {
  303. this.$i18n.locale = lang;
  304. let locale = window.localStorage.getItem("locale");
  305. if (locale) {
  306. window.localStorage.setItem("locale", lang);
  307. } else {
  308. window.localStorage["locale"] = lang;
  309. }
  310. console.log(window.localStorage.getItem("locale"));
  311. this.$bus.emit("setLang", window.localStorage.getItem("locale"));
  312. },
  313. loginOut() {
  314. this.$confirm(this.$t("common.Thisoperationwilllogout") + "?",this.$t("common.Tips"),{ confirmButtonText: this.$t("common.OK"),cancelButtonText: this.$t("common.cancel"), type: "warning",}).then(() => {
  315. // Cookies.remove('login');
  316. // let ss=Cookies.get('login');
  317. // debugger
  318. // 退出的逻辑代码
  319. this.$store
  320. .dispatch("user/LOGOUT")
  321. .then(() => {
  322. // location.href = "/";
  323. this.$router.push({
  324. path: "/login",
  325. });
  326. })
  327. .catch((error) => {
  328. location.href = "/";
  329. });
  330. // this.toView(2,'login','')// 返回登录
  331. // window.localStorage.removeItem('token')
  332. window.sessionStorage.removeItem("token");
  333. // debugger
  334. this.getInitData();
  335. })
  336. .catch(() => {
  337. this.$message({
  338. type: "info",
  339. message: this.$t("common.Cancelled"),
  340. });
  341. });
  342. },
  343. toViewChange(router, json) {
  344. if (!this.homeItemTitle) {
  345. this.$message({
  346. message: this.$t("common.Theinputboxcannotbeempty"),
  347. type: "warning",
  348. });
  349. } else {
  350. this.$store.commit("modify", router);
  351. window.localStorage.setItem("router", router);
  352. const { href } = this.$router.resolve({
  353. name: router,
  354. query: {
  355. select: this.select,
  356. input: this.homeItemTitle,
  357. },
  358. });
  359. window.open(href, "_blank");
  360. }
  361. },
  362. systemMessageNumToView(num, router, json){
  363. if(this.messageType==2){
  364. this.toView(0,'notification','/notification')
  365. }else{
  366. this.toView(0, 'SystemMessage', '/SystemMessage');
  367. }
  368. },
  369. toView(num, router, json) {
  370. if (json) {
  371. this.$store.commit("modify", router);
  372. window.localStorage.setItem("router", router);
  373. this.$router.push({ name: router, query: { key: json } });
  374. } else {
  375. this.$store.commit("modify", router);
  376. window.localStorage.setItem("router", router);
  377. this.$router.push({ name: router });
  378. }
  379. if (num == 1) {
  380. let i = {
  381. label: "用户中心",
  382. value: "userCenterView",
  383. };
  384. if (this.$Cookies.get('token')) {
  385. return (this.i = 2);
  386. } else if (this.$i18n.locale == "en") {
  387. return (this.i = 3);
  388. } else {
  389. return (this.i = 1);
  390. }
  391. this.$nextTick(() => {
  392. Bus.$emit("title", i);
  393. });
  394. }
  395. },
  396. },
  397. };
  398. </script>
  399. <!-- Add "scoped" attribute to limit CSS to this component only -->
  400. <style scoped>
  401. body {
  402. margin: 0;
  403. padding: 0;
  404. }
  405. .header1 {
  406. /* width:1500px; */
  407. height: 170px;
  408. margin: auto;
  409. /* background: #2c558a; */
  410. /* background: url("../assets/img/home/banner2.jpg") no-repeat ; */
  411. /* animation: panoramic 10s linear infinite alternate; */
  412. }
  413. /* .header1:hover {
  414. animation-play-state: paused;
  415. } */
  416. /* @keyframes panoramic {
  417. to {
  418. background-position: 100% 0;
  419. }
  420. } */
  421. .header2 {
  422. width: 1200px;
  423. height: 170px;
  424. margin: auto;
  425. position: relative;
  426. border-bottom: 1px solid #4e84b9;
  427. /* background: skyblue; */
  428. }
  429. .language {
  430. line-height: 12px;
  431. color: #f9f9f9;
  432. font-weight: 400;
  433. font-size: 16px;
  434. padding-top: 15px;
  435. }
  436. .logo {
  437. position: absolute;
  438. top: 50px;
  439. left: 70px;
  440. /* width: 200px; */
  441. /* height: 55px; */
  442. margin-top: 15px;
  443. /* background-image: url(@/assets/logo.png); */
  444. }
  445. .title {
  446. margin-top: 15px;
  447. position: absolute;
  448. top: 60px;
  449. left: 605px;
  450. font-size: 27px;
  451. font-weight: 700;
  452. height: 50px;
  453. /* line-height: 50px; */
  454. color: #fff;
  455. width: 705px;
  456. }
  457. @media (max-width: 1199px) {
  458. .title {
  459. width: 580px;
  460. }
  461. }
  462. .header1 >>> .el-input__inner {
  463. height: 50px !important;
  464. }
  465. .header1 >>> .el-input-group__prepend {
  466. background-color: #fff;
  467. color: #000;
  468. }
  469. .active span:hover {
  470. color: #ff0000;
  471. cursor: pointer;
  472. }
  473. .el-dropdown {
  474. color: #f9f9f9;
  475. font-size: 16px;
  476. }
  477. .header1 >>> .el-select {
  478. width: 88px;
  479. }
  480. </style>