Metaverse.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610
  1. <template>
  2. <div class="metaverse-root">
  3. <article v-if="isShowDesc">
  4. <button
  5. class="close"
  6. @click="onClickCloseDesc"
  7. />
  8. <h2>{{ desc.name }}</h2>
  9. <img
  10. class="splitter"
  11. src="@/assets/images/splitter.png"
  12. alt=""
  13. draggable="false"
  14. >
  15. <!-- <img
  16. class="banner"
  17. src="@/assets/images/for-dev.jpg"
  18. alt=""
  19. draggable="false"
  20. > -->
  21. <!-- 大盒子 -->
  22. <div class="G4mainBox">
  23. <!-- 企业 -->
  24. <div
  25. v-if="G4info.company.length"
  26. class="G4box"
  27. >
  28. <div class="G4Tit">
  29. <div class="G4TitOne">
  30. 企业
  31. </div>
  32. <div
  33. class="G4rightMore"
  34. @click="$router.push('/general')"
  35. >
  36. 更多 +
  37. </div>
  38. </div>
  39. <!-- 单个企业 -->
  40. <div
  41. v-for="item in G4info.company"
  42. :key="item.id"
  43. class="G41row"
  44. @click="$router.push(`/general?id=${item.id}`)"
  45. >
  46. {{ item.name }}
  47. </div>
  48. </div>
  49. <!-- 人物 -->
  50. <div
  51. v-if="G4info.person.length"
  52. class="G4box"
  53. >
  54. <div class="G4Tit">
  55. <div class="G4TitOne">
  56. 人物
  57. </div>
  58. <div
  59. class="G4rightMore"
  60. @click="$router.push('/history')"
  61. >
  62. 更多 +
  63. </div>
  64. </div>
  65. <div
  66. v-for="item in G4info.person"
  67. :key="item.id"
  68. class="G42row"
  69. >
  70. <img
  71. v-if="item.thumb"
  72. :src="`${prefix}/${item.thumb}`"
  73. alt=""
  74. >
  75. <img
  76. v-else
  77. :src="require('@/assets/images/imgErr.png')"
  78. alt=""
  79. >
  80. <div class="G1RenBoxTxt">
  81. <h3>{{ item.name }}</h3>
  82. <p>&emsp;&emsp;{{ item.description }}</p>
  83. </div>
  84. </div>
  85. </div>
  86. <!-- 重器 -->
  87. <div
  88. v-if="G4info.goods.length"
  89. class="G4box"
  90. >
  91. <div class="G4Tit">
  92. <div class="G4TitOne">
  93. 重器
  94. </div>
  95. <div
  96. class="G4rightMore"
  97. @click="$router.push('/treasure')"
  98. >
  99. 更多 +
  100. </div>
  101. </div>
  102. <div class="G43rowBox">
  103. <div
  104. v-for="item in G4info.goods"
  105. :key="item.id"
  106. class="G43row"
  107. :title="item.name"
  108. @click="$router.push(`/Treasure-detail?id=${item.id}`)"
  109. >
  110. <img
  111. v-if="item.thumb"
  112. :src="`${prefix}/${item.thumb}`"
  113. alt=""
  114. >
  115. <img
  116. v-else
  117. :src="require('@/assets/images/imgErr.png')"
  118. alt=""
  119. >
  120. <p>{{ item.description }}</p>
  121. </div>
  122. </div>
  123. </div>
  124. <!-- 简介 -->
  125. <div class="G4box">
  126. <div class="G4Tit">
  127. <div class="G4TitOne">
  128. 简介
  129. </div>
  130. </div>
  131. <div
  132. class="G4Txt"
  133. v-html="desc.detail || ''"
  134. />
  135. </div>
  136. </div>
  137. </article>
  138. <!-- element-ui的loading效果从调用到出现有延时,这期间要遮盖住组件 -->
  139. <div
  140. v-show="isShowLoadingMask"
  141. class="loading-mask"
  142. />
  143. </div>
  144. </template>
  145. <script>
  146. import {
  147. reactive,
  148. toRefs,
  149. ref,
  150. onMounted,
  151. } from 'vue'
  152. export default {
  153. name: 'MetaverseView',
  154. beforeRouteLeave() {
  155. gUnityInst.SendMessage('Page4', 'ResetCamera')
  156. },
  157. setup() {
  158. const prefix = ref(process.env.VUE_APP_API_ORIGIN)
  159. const rawData = reactive({ value: null })
  160. onMounted(async () => {
  161. rawData.value = await api.getMetaverseList()
  162. window.G4AllList = await api.getMetaverseList()
  163. })
  164. const isShowDesc = ref(false)
  165. const desc = reactive({})
  166. function onClickCloseDesc() {
  167. isShowDesc.value = false
  168. gUnityInst.SendMessage('Page4', 'ResetCamera')
  169. }
  170. function onClickStar(idx) {
  171. desc.name = rawData.value[idx].name
  172. desc.detail = rawData.value[idx].description
  173. isShowDesc.value = true
  174. }
  175. function focusStar(idx) {
  176. desc.name = rawData.value[idx].name
  177. desc.detail = rawData.value[idx].description
  178. isShowDesc.value = true
  179. window.gUnityInst.SendMessage('Page4', 'OnClickPlaneId', idx + 1)
  180. }
  181. onMounted(async () => {
  182. const url = window.location.href
  183. if (url.includes('id=')) {
  184. const id = url.split('id=')[1]
  185. // console.log('ppppppppppppppppp', id)
  186. setTimeout(() => {
  187. focusStar(Number(id) - 1)
  188. }, 400)
  189. }
  190. })
  191. // 详情数据
  192. const G4info = ref({
  193. company: [],
  194. person: [],
  195. goods: []
  196. })
  197. // 获取详情接口
  198. const getInfoFu = async (id) => {
  199. const res = await api.getG4InfoApi(id)
  200. G4info.value = {
  201. company: res.company || [],
  202. person: res.person || [],
  203. goods: res.goods || []
  204. }
  205. }
  206. window.handleClickPlanet = function (id) {
  207. G4info.value = {
  208. company: [],
  209. person: [],
  210. goods: []
  211. }
  212. // 点击详情
  213. // 发送接口拿到详情数据
  214. getInfoFu(id)
  215. console.log('click planet', id)
  216. onClickStar(id - 1)
  217. }
  218. window.handleMovedPlanet = function (id) {
  219. console.log('moved planet', id)
  220. }
  221. const isShowLoadingMask = ref(true)
  222. onMounted(() => {
  223. setTimeout(() => {
  224. isShowLoadingMask.value = false
  225. }, 200)
  226. })
  227. return {
  228. prefix,
  229. rawData,
  230. isShowDesc,
  231. desc,
  232. onClickCloseDesc,
  233. onClickStar,
  234. isShowLoadingMask,
  235. G4info
  236. }
  237. }
  238. }
  239. </script>
  240. <style lang="less" scoped>
  241. .metaverse-root {
  242. height: 100%;
  243. position: relative;
  244. pointer-events: none;
  245. >article {
  246. pointer-events: initial;
  247. position: absolute;
  248. top: calc(100% / 2);
  249. transform: translateY(-50%);
  250. right: 102px;
  251. width: 653px;
  252. height: calc(100% - 74px - 50px);
  253. max-height: 740px;
  254. backdrop-filter: blur(10px);
  255. background-image: url(@/assets/images/general-article-bg.png);
  256. background-size: 100% auto;
  257. background-repeat: no-repeat;
  258. background-position: left top;
  259. padding: 32px 50px 50px 50px;
  260. display: flex;
  261. flex-direction: column;
  262. @media only screen and (max-width: 1700px) {
  263. right: 0;
  264. }
  265. >button.close {
  266. position: absolute;
  267. top: 30px;
  268. right: 50px;
  269. width: 32px;
  270. height: 32px;
  271. background-image: url(@/assets/images/icon-close.png);
  272. background-size: cover;
  273. background-repeat: no-repeat;
  274. background-position: center center;
  275. }
  276. >h2 {
  277. flex: 0 0 auto;
  278. font-size: 24px;
  279. font-family: Source Han Sans CN-Bold, Source Han Sans CN;
  280. font-weight: bold;
  281. color: #FFFFFF;
  282. margin-bottom: 21px;
  283. }
  284. >img.splitter {
  285. flex: 0 0 auto;
  286. width: 100%;
  287. margin-bottom: 37px;
  288. }
  289. // 邵根
  290. .G4mainBox {
  291. padding-right: 8px;
  292. overflow-y: auto;
  293. height: 100%;
  294. font-size: 20px;
  295. font-family: Source Han Sans CN-Light, Source Han Sans CN;
  296. font-weight: 400;
  297. color: rgba(255, 255, 255, 0.8);
  298. &::-webkit-scrollbar {
  299. background: transparent;
  300. width: 4px;
  301. }
  302. /*宽度是对垂直滚动条而言,高度是对水平滚动条而言*/
  303. &::-webkit-scrollbar-thumb {
  304. background: rgba(220, 231, 240, 0.2);
  305. border-radius: 2px;
  306. }
  307. .G4box {
  308. margin: 0 0 24px;
  309. .G4Tit {
  310. display: flex;
  311. justify-content: space-between;
  312. align-items: center;
  313. margin-bottom: 15px;
  314. .G4TitOne {
  315. font-weight: 700;
  316. font-size: 22px;
  317. color: #FFFFFF;
  318. }
  319. .G4rightMore {
  320. padding-right: 10px;
  321. font-size: 16px;
  322. cursor: pointer;
  323. }
  324. }
  325. // 企业
  326. .G41row {
  327. position: relative;
  328. padding-left: 30px;
  329. cursor: pointer;
  330. font-size: 16px;
  331. height: 30px;
  332. line-height: 30px;
  333. &::before {
  334. opacity: .5;
  335. content: '';
  336. position: absolute;
  337. top: 50%;
  338. left: 8px;
  339. transform: translateY(-50%);
  340. width: 10px;
  341. height: 10px;
  342. background-color: #FFE59F;
  343. border-radius: 50%;
  344. }
  345. &::after {
  346. content: '';
  347. opacity: 0;
  348. position: absolute;
  349. top: 50%;
  350. left: 4px;
  351. transform: translateY(-50%);
  352. width: 16px;
  353. height: 16px;
  354. border: 1px dashed #FFE59F;
  355. border-radius: 50%;
  356. }
  357. &:hover {
  358. color: #FFE59F;
  359. &::before {
  360. opacity: 1;
  361. }
  362. &::after {
  363. opacity: 1;
  364. }
  365. }
  366. }
  367. // 人物
  368. .G42row {
  369. align-items: flex-start;
  370. display: flex;
  371. margin-bottom: 20px;
  372. &>img {
  373. width: 105px;
  374. object-fit: contain;
  375. }
  376. .G1RenBoxTxt {
  377. width: calc(100% - 125px);
  378. margin-left: 20px;
  379. color: #fff;
  380. &>h3 {
  381. font-size: 18px;
  382. font-weight: 700;
  383. margin-bottom: 15px;
  384. }
  385. &>p {
  386. font-size: 18px;
  387. font-family: Source Han Sans CN-Light, Source Han Sans CN;
  388. font-weight: 400;
  389. color: rgba(255, 255, 255, 0.8);
  390. line-height: 1.5;
  391. white-space: pre-wrap;
  392. }
  393. }
  394. }
  395. // 重器
  396. .G43rowBox {
  397. display: flex;
  398. flex-wrap: wrap;
  399. }
  400. .G43row {
  401. cursor: pointer;
  402. margin-bottom: 20px;
  403. margin-right: 24px;
  404. width: calc(50% - 24px);
  405. height: 180px;
  406. &>img {
  407. width: 100%;
  408. height: calc(100% - 30px);
  409. object-fit: cover;
  410. }
  411. &>p {
  412. font-size: 16px;
  413. height: 30px;
  414. line-height: 30px;
  415. text-align: center;
  416. padding: 0 3px;
  417. overflow: hidden;
  418. text-overflow: ellipsis;
  419. white-space: nowrap;
  420. }
  421. }
  422. // 简介
  423. .G4Txt {
  424. line-height: 1.7;
  425. font-size: 18px;
  426. text-indent: 2em;
  427. }
  428. }
  429. }
  430. >img.banner {
  431. flex: 0 0 auto;
  432. width: 100%;
  433. height: 34.8%;
  434. object-fit: contain;
  435. margin-bottom: 20px;
  436. }
  437. >.txt {
  438. flex: 1 0 1px;
  439. }
  440. }
  441. .loading-mask {
  442. position: absolute;
  443. left: 0;
  444. top: 0;
  445. width: 100%;
  446. height: 100%;
  447. background: black;
  448. }
  449. }
  450. .mobile {
  451. .metaverse-root {
  452. height: 100%;
  453. position: relative;
  454. pointer-events: none;
  455. >article {
  456. pointer-events: initial;
  457. position: absolute;
  458. top: calc(100% / 2);
  459. transform: translateY(-50%);
  460. right: calc(102 / 1080 * 83vh);
  461. width: calc(653 / 1080 * 83vh);
  462. height: calc(100% - 74px - 50px);
  463. max-height: calc(740 / 1080 * 83vh);
  464. backdrop-filter: blur(10px);
  465. background-image: url(@/assets/images/general-article-bg.png);
  466. background-size: 100% auto;
  467. background-repeat: no-repeat;
  468. background-position: left top;
  469. padding: calc(32 / 1080 * 83vh) calc(50 / 1080 * 83vh) calc(50 / 1080 * 83vh) calc(50 / 1080 * 83vh);
  470. display: flex;
  471. flex-direction: column;
  472. @media only screen and (max-width: 1700px) {
  473. right: 0;
  474. }
  475. >button.close {
  476. position: absolute;
  477. top: calc(30 / 1080 * 83vh);
  478. right: calc(50 / 1080 * 83vh);
  479. width: calc(32 / 1080 * 83vh);
  480. height: calc(32 / 1080 * 83vh);
  481. background-image: url(@/assets/images/icon-close.png);
  482. background-size: cover;
  483. background-repeat: no-repeat;
  484. background-position: center center;
  485. }
  486. >h2 {
  487. flex: 0 0 auto;
  488. font-size: calc(24 / 1080 * 83vh);
  489. font-family: Source Han Sans CN-Bold, Source Han Sans CN;
  490. font-weight: bold;
  491. color: #FFFFFF;
  492. margin-bottom: calc(21 / 1080 * 83vh);
  493. }
  494. >img.splitter {
  495. flex: 0 0 auto;
  496. width: 100%;
  497. margin-bottom: calc(37 / 1080 * 83vh);
  498. }
  499. >img.banner {
  500. flex: 0 0 auto;
  501. width: 100%;
  502. height: 34.8%;
  503. object-fit: contain;
  504. margin-bottom: calc(20 / 1080 * 83vh);
  505. }
  506. >.txt {
  507. flex: 1 0 1px;
  508. font-size: calc(20 / 1080 * 83vh);
  509. font-family: Source Han Sans CN-Light, Source Han Sans CN;
  510. font-weight: 400;
  511. color: rgba(255, 255, 255, 0.8);
  512. line-height: 1.7;
  513. overflow: auto;
  514. padding-right: calc(10 / 1080 * 83vh);
  515. margin-right: calc(-10 / 1080 * 83vh);
  516. &::-webkit-scrollbar {
  517. background: transparent;
  518. width: calc(4 / 1080 * 83vh);
  519. }
  520. /*宽度是对垂直滚动条而言,高度是对水平滚动条而言*/
  521. &::-webkit-scrollbar-thumb {
  522. background: rgba(220, 231, 240, 0.2);
  523. border-radius: 2px;
  524. }
  525. }
  526. }
  527. .loading-mask {
  528. position: absolute;
  529. left: 0;
  530. top: 0;
  531. width: 100%;
  532. height: 100%;
  533. background: black;
  534. }
  535. }
  536. }
  537. </style>