General.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494
  1. <template>
  2. <div
  3. class="general"
  4. >
  5. <h1
  6. v-if="activeCorpInfo"
  7. :title="activeCorpInfo.name"
  8. >
  9. {{ activeCorpInfo.name }}
  10. </h1>
  11. <form @submit.prevent="onSearch">
  12. <input
  13. v-model="filterKeyword"
  14. type="text"
  15. placeholder="请输入企业名称"
  16. >
  17. <button type="submit">
  18. <img
  19. class=""
  20. src="@/assets/images/icon_search.png"
  21. alt=""
  22. draggable="false"
  23. >
  24. </button>
  25. </form>
  26. <ul>
  27. <li
  28. v-for="(decade) in corpListMap.keys()"
  29. :key="decade"
  30. >
  31. <h2>
  32. <img
  33. class=""
  34. src="@/assets/images/decade-decorator-left.png"
  35. alt=""
  36. draggable="false"
  37. >
  38. <span>{{ decade }}</span>
  39. <img
  40. class=""
  41. src="@/assets/images/decade-decorator-right.png"
  42. alt=""
  43. draggable="false"
  44. >
  45. </h2>
  46. <div
  47. v-for="(corpItem) in corpListMap.get(decade)"
  48. :id="`corp-item-${corpItem.id}`"
  49. :key="corpItem.id"
  50. class="corp-item"
  51. :class="{
  52. active: activeCorpId === corpItem.id
  53. }"
  54. @click="onClickCorpItem(corpItem.id)"
  55. >
  56. <div class="item-icon" />
  57. <div class="verticle-line" />
  58. <span
  59. class="corp-name"
  60. :title="corpItem.name"
  61. >
  62. {{ corpItem.name }}
  63. </span>
  64. <span class="corp-time">
  65. {{ corpItem.createDay }}
  66. </span>
  67. </div>
  68. </li>
  69. </ul>
  70. <article v-if="activeCorpInfo && isShowDesc">
  71. <button
  72. class="close"
  73. @click="isShowDesc = false"
  74. />
  75. <h2>{{ activeCorpInfo.name }}</h2>
  76. <img
  77. class="splitter"
  78. src="@/assets/images/splitter.png"
  79. alt=""
  80. draggable="false"
  81. >
  82. <img
  83. v-show="activeCorpInfo.thumb"
  84. class="banner"
  85. :src="activeCorpInfo.thumb"
  86. alt=""
  87. draggable="false"
  88. >
  89. <div
  90. class="txt"
  91. v-html="activeCorpInfo.description || ''"
  92. />
  93. </article>
  94. <!-- element-ui的loading效果从调用到出现有延时,这期间要遮盖住组件 -->
  95. <div
  96. v-show="isShowLoadingMask"
  97. class="loading-mask"
  98. />
  99. </div>
  100. </template>
  101. <script>
  102. import {
  103. computed,
  104. onMounted,
  105. watch,
  106. reactive,
  107. ref,
  108. } from 'vue'
  109. export default {
  110. name: 'GeneralView',
  111. components: {
  112. },
  113. setup () {
  114. const filterKeyword = ref('')
  115. const corpListRaw = reactive({ value: null })
  116. const corpListMap = reactive(new Map())
  117. watch(filterKeyword, utils.debounce(async (vNew) => {
  118. corpListRaw.value = await api.getGeneralList({
  119. searchKey: filterKeyword.value
  120. })
  121. corpListMap.clear()
  122. corpListRaw.value.forEach(element => {
  123. let decade = ''
  124. if (element.createDay.substring(0, 2) === '18') {
  125. decade = `十九世纪`
  126. } else if (element.createDay.substring(0, 2) === '19') {
  127. const decadeValue = element.createDay[2]
  128. decade = `上世纪${decadeValue}0年代`
  129. } else {
  130. const decadeValue = element.createDay[2]
  131. decade = `本世纪${decadeValue}0年代`
  132. }
  133. if (!corpListMap.get(decade)) {
  134. corpListMap.set(decade, [])
  135. }
  136. corpListMap.get(decade).push(element)
  137. })
  138. }, 500, false), {
  139. immediate: true,
  140. })
  141. const activeCorpId = ref(null)
  142. const isShowDesc = ref(true)
  143. const activeCorpInfo = computed(() => {
  144. if (corpListRaw.value) {
  145. return corpListRaw.value.find((item) => {
  146. return item.id === activeCorpId.value
  147. })
  148. } else {
  149. return {}
  150. }
  151. })
  152. // 无论是网页里还是unity内部点击了企业,都调用这个
  153. function onClickCorpItem(id) {
  154. if ((typeof activeCorpId.value === 'number')) {
  155. gUnityInst.SendMessage('Panel1', 'SetEnterpriseUnSelected', activeCorpId.value) //设置id为1的企业为未选中状态(此id需要是已显示的)
  156. }
  157. gUnityInst.SendMessage('Panel1', 'SetEnterpriseSelected', id) //设置id为1的企业为选中状态(此id需要是已显示的)
  158. activeCorpId.value = id
  159. isShowDesc.value = true
  160. console.log(`corp-item-${id}`)
  161. const clickedElement = document.querySelector(`#corp-item-${id}`)
  162. if (clickedElement) {
  163. clickedElement.scrollIntoView()
  164. }
  165. }
  166. window.onCorpOnMapClicked = onClickCorpItem
  167. const isShowLoadingMask = ref(true)
  168. onMounted(() => {
  169. setTimeout(() => {
  170. isShowLoadingMask.value = false
  171. }, 200)
  172. })
  173. return {
  174. filterKeyword,
  175. corpListMap,
  176. activeCorpId,
  177. activeCorpInfo,
  178. onClickCorpItem,
  179. isShowDesc,
  180. isShowLoadingMask,
  181. }
  182. },
  183. data() {
  184. return {
  185. }
  186. },
  187. computed: {
  188. ...mapState([
  189. ]),
  190. },
  191. mounted() {
  192. // this.$mitt.emit('test', { msg: 'home mounted' })
  193. },
  194. beforeUnmount() {
  195. },
  196. unmounted() {
  197. },
  198. methods: {
  199. ...mapMutations([
  200. ]),
  201. onSearch() {
  202. console.log('search!')
  203. }
  204. },
  205. }
  206. </script>
  207. <style lang="less" scoped>
  208. .general {
  209. >h1 {
  210. position: absolute;
  211. top: 51px;
  212. left: 81px;
  213. max-width: 50%;
  214. overflow: hidden;
  215. white-space: pre;
  216. text-overflow: ellipsis;
  217. font-size: 48px;
  218. font-family: Source Han Sans CN-Heavy, Source Han Sans CN;
  219. font-weight: 800;
  220. color: #FFFFFF;
  221. padding-top: 20px;
  222. padding-bottom: 20px;
  223. border-top: 1px solid rgba(217, 217, 217, 0.2);
  224. border-bottom: 1px solid rgba(217, 217, 217, 0.2);
  225. }
  226. >form {
  227. position: absolute;
  228. top: 196px;
  229. left: 81px;
  230. display: flex;
  231. align-items: center;
  232. >input {
  233. background: rgba(255,255,255,0.1);
  234. border-radius: 3px 3px 3px 3px;
  235. border: 1px solid rgba(255, 255, 255, 0.5);
  236. width: 220px;
  237. height: 40px;
  238. padding-left: 13px;
  239. padding-right: 13px;
  240. font-size: 16px;
  241. font-family: Source Han Sans CN-Regular, Source Han Sans CN;
  242. font-weight: 400;
  243. color: #FFFFFF;
  244. &:focus {
  245. border: 1px solid rgba(255, 255, 255, 1);
  246. }
  247. &::placeholder {
  248. font-size: 16px;
  249. font-family: Source Han Sans CN-Regular, Source Han Sans CN;
  250. font-weight: 400;
  251. color: rgba(255, 255, 255, 0.5);
  252. }
  253. }
  254. >button {
  255. margin-left: 8px;
  256. width: 40px;
  257. height: 40px;
  258. background: rgba(255,255,255,0.3);
  259. border-radius: 3px 3px 3px 3px;
  260. opacity: 1;
  261. border: 1px solid #FFFFFF;
  262. &:hover {
  263. background: rgba(255,255,255,0.5);
  264. }
  265. >img {
  266. width: 100%;
  267. height: 100%;
  268. }
  269. }
  270. }
  271. >ul {
  272. position: absolute;
  273. top: 272px;
  274. left: 81px;
  275. max-height: 520px;
  276. overflow: auto;
  277. user-select: none;
  278. >li {
  279. display: block;
  280. color: #fff;
  281. >h2 {
  282. width: 323px;
  283. height: 47px;
  284. background: linear-gradient(92deg, rgba(176,161,121,0) 0%, rgba(176,161,121,0.3) 50%, rgba(176,161,121,0) 100%);
  285. // border-radius: 3px;
  286. font-size: 16px;
  287. font-family: Source Han Sans CN-Bold, Source Han Sans CN;
  288. font-weight: bold;
  289. color: #FFFFFF;
  290. text-shadow: 0px 0px 5px #FFD15B;
  291. display: flex;
  292. justify-content: center;
  293. align-items: center;
  294. margin-bottom: 17px;
  295. >span {
  296. margin-left: 13px;
  297. margin-right: 13px;
  298. }
  299. >img {
  300. width: 60px;
  301. height: 15px;
  302. }
  303. }
  304. >.corp-item {
  305. position: relative;
  306. width: 363px;
  307. height: 50px;
  308. background: linear-gradient(90deg, #3A454F 0%, rgba(22,28,33,0) 100%);
  309. backdrop-filter: blur(3px);
  310. border-radius: 3px 3px 3px 3px;
  311. opacity: 1;
  312. border: 1px solid;
  313. border-right: none;
  314. border-image: linear-gradient(98deg, rgba(78, 96, 112, 1), rgba(78, 96, 112, 0)) 1 1;
  315. padding-left: 72px;
  316. display: flex;
  317. flex-direction: column;
  318. justify-content: space-around;
  319. align-items: flex-start;
  320. margin-bottom: 24px;
  321. cursor: pointer;
  322. >.item-icon {
  323. position: absolute;
  324. border-radius: 50%;
  325. left: 35px;
  326. top: 50%;
  327. transform: translateY(-50%);
  328. width: 8px;
  329. height: 8px;
  330. background: #6D9DC6;
  331. z-index: 2;
  332. }
  333. >.verticle-line {
  334. position: absolute;
  335. top: -1px;
  336. left: 38px;
  337. width: 2px;
  338. height: 75px;
  339. background: #B0A179 50%;
  340. z-index: 1;
  341. }
  342. &:first-of-type {
  343. >.verticle-line {
  344. top: 50%;
  345. }
  346. }
  347. &:last-of-type {
  348. >.verticle-line {
  349. top: initial;
  350. bottom: 50%;
  351. }
  352. }
  353. &:first-of-type:last-of-type {
  354. >.verticle-line {
  355. display: none;
  356. }
  357. }
  358. >span.corp-name {
  359. display: block;
  360. font-size: 16px;
  361. font-family: Source Han Sans CN-Bold, Source Han Sans CN;
  362. font-weight: bold;
  363. color: #FFFFFF;
  364. overflow: hidden;
  365. white-space: pre;
  366. text-overflow: ellipsis;
  367. }
  368. &.active {
  369. >span.corp-name {
  370. font-size: 20px;
  371. font-family: Source Han Sans CN-Bold, Source Han Sans CN;
  372. text-shadow: 0px 0px 16px #BD9D48;
  373. }
  374. }
  375. >span.corp-time {
  376. display: block;
  377. font-size: 16px;
  378. font-family: Source Han Sans CN-Regular, Source Han Sans CN;
  379. font-weight: 400;
  380. color: #FFFFFF;
  381. }
  382. &:hover {
  383. background: linear-gradient(90deg, #B0A179 0%, rgba(255,209,91,0) 100%);
  384. border-image: linear-gradient(98deg, rgba(176, 161, 121, 1), rgba(176, 161, 121, 0)) 1 1;
  385. }
  386. &.active {
  387. background: linear-gradient(90deg, #B0A179 0%, rgba(255,209,91,0) 100%);
  388. border-image: linear-gradient(98deg, rgba(176, 161, 121, 1), rgba(176, 161, 121, 0)) 1 1;
  389. >.item-icon {
  390. background: #FFFFFF;
  391. box-shadow: 0px 0px 12px 0px #FFD15B, 0px 0px 8px 0px #FFD15B, 0px 0px 10px 0px #FFD15B, 0px 0px 5px 0px #FFD15B;
  392. }
  393. }
  394. }
  395. }
  396. &::-webkit-scrollbar { background: transparent; width: 4px; } /*宽度是对垂直滚动条而言,高度是对水平滚动条而言*/
  397. &::-webkit-scrollbar-thumb {
  398. background: transparent;
  399. border-radius: 2px;
  400. }
  401. &:hover {
  402. &::-webkit-scrollbar-thumb {
  403. background: rgba(220, 231, 240, 0.2);
  404. }
  405. }
  406. }
  407. >article {
  408. position: absolute;
  409. top: 74px;
  410. right: 0;
  411. width: 653px;
  412. height: calc(100% - 74px - 112px - 50px);
  413. backdrop-filter: blur(5px);
  414. background-image: url(@/assets/images/general-article-bg.png);
  415. background-size: 100% auto;
  416. background-repeat: no-repeat;
  417. background-position: left top;
  418. padding: 32px 50px 50px 50px;
  419. display: flex;
  420. flex-direction: column;
  421. >button.close {
  422. position: absolute;
  423. top: 30px;
  424. right: 50px;
  425. width: 32px;
  426. height: 32px;
  427. background-image: url(@/assets/images/icon-close.png);
  428. background-size: cover;
  429. background-repeat: no-repeat;
  430. background-position: center center;
  431. }
  432. >h2 {
  433. flex: 0 0 auto;
  434. font-size: 24px;
  435. font-family: Source Han Sans CN-Bold, Source Han Sans CN;
  436. font-weight: bold;
  437. color: #FFFFFF;
  438. margin-bottom: 21px;
  439. }
  440. >img.splitter {
  441. flex: 0 0 auto;
  442. width: 100%;
  443. margin-bottom: 37px;
  444. }
  445. >img.banner {
  446. flex: 0 0 auto;
  447. width: 100%;
  448. height: 34.8%;
  449. object-fit: contain;
  450. margin-bottom: 20px;
  451. }
  452. >.txt {
  453. flex: 1 0 1px;
  454. font-size: 20px;
  455. font-family: Source Han Sans CN-Regular, Source Han Sans CN;
  456. font-weight: 400;
  457. color: rgba(255, 255, 255, 0.8);
  458. line-height: 23px;
  459. overflow: auto;
  460. padding-right: 10px;
  461. margin-right: -10px;
  462. white-space: pre-wrap;
  463. text-indent: 2em;
  464. &::-webkit-scrollbar { background: transparent; width: 4px; } /*宽度是对垂直滚动条而言,高度是对水平滚动条而言*/
  465. &::-webkit-scrollbar-thumb {
  466. background: rgba(220, 231, 240, 0.2);
  467. border-radius: 2px;
  468. }
  469. }
  470. }
  471. .loading-mask {
  472. position: absolute;
  473. left: 0;
  474. top: 0;
  475. width: 100%;
  476. height: 100%;
  477. background: black;
  478. }
  479. }
  480. </style>