headerItem3.vue 14 KB

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