Metaverse.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278
  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. <div
  22. class="txt"
  23. v-html="desc.detail || ''"
  24. />
  25. </article>
  26. <!-- element-ui的loading效果从调用到出现有延时,这期间要遮盖住组件 -->
  27. <div
  28. v-show="isShowLoadingMask"
  29. class="loading-mask"
  30. />
  31. </div>
  32. </template>
  33. <script>
  34. import {
  35. reactive,
  36. toRefs,
  37. ref,
  38. onMounted,
  39. } from 'vue'
  40. export default {
  41. name: 'MetaverseView',
  42. beforeRouteLeave() {
  43. gUnityInst.SendMessage('Page4', 'ResetCamera')
  44. },
  45. setup () {
  46. const rawData = reactive({ value: null })
  47. onMounted(async () => {
  48. rawData.value = await api.getMetaverseList()
  49. })
  50. const isShowDesc = ref(false)
  51. const desc = reactive({})
  52. function onClickCloseDesc() {
  53. isShowDesc.value = false
  54. gUnityInst.SendMessage('Page4', 'ResetCamera')
  55. }
  56. function onClickStar(idx) {
  57. desc.name = rawData.value[idx].name
  58. desc.detail = rawData.value[idx].description
  59. isShowDesc.value = true
  60. }
  61. window.handleClickPlanet = function(id) {
  62. console.log('click planet', id)
  63. onClickStar(id - 1)
  64. }
  65. onMounted(async () => {
  66. const url = window.location.href
  67. if (url.includes('id=')) {
  68. const id = url.split('id=')[1]
  69. // console.log('ppppppppppppppppp', id)
  70. setTimeout(() => {
  71. onClickStar(Number(id))
  72. }, 400)
  73. }
  74. })
  75. window.handleMovedPlanet = function(id) {
  76. console.log('moved planet', id)
  77. }
  78. const isShowLoadingMask = ref(true)
  79. onMounted(() => {
  80. setTimeout(() => {
  81. isShowLoadingMask.value = false
  82. }, 200)
  83. })
  84. return {
  85. rawData,
  86. isShowDesc,
  87. desc,
  88. onClickCloseDesc,
  89. onClickStar,
  90. isShowLoadingMask,
  91. }
  92. }
  93. }
  94. </script>
  95. <style lang="less" scoped>
  96. .metaverse-root {
  97. height: 100%;
  98. position: relative;
  99. pointer-events: none;
  100. >article {
  101. pointer-events: initial;
  102. position: absolute;
  103. top: calc(100% / 2);
  104. transform: translateY(-50%);
  105. right: 102px;
  106. width: 653px;
  107. height: calc(100% - 74px - 50px);
  108. max-height: 740px;
  109. backdrop-filter: blur(10px);
  110. background-image: url(@/assets/images/general-article-bg.png);
  111. background-size: 100% auto;
  112. background-repeat: no-repeat;
  113. background-position: left top;
  114. padding: 32px 50px 50px 50px;
  115. display: flex;
  116. flex-direction: column;
  117. @media only screen and (max-width: 1700px) {
  118. right: 0;
  119. }
  120. >button.close {
  121. position: absolute;
  122. top: 30px;
  123. right: 50px;
  124. width: 32px;
  125. height: 32px;
  126. background-image: url(@/assets/images/icon-close.png);
  127. background-size: cover;
  128. background-repeat: no-repeat;
  129. background-position: center center;
  130. }
  131. >h2 {
  132. flex: 0 0 auto;
  133. font-size: 24px;
  134. font-family: Source Han Sans CN-Bold, Source Han Sans CN;
  135. font-weight: bold;
  136. color: #FFFFFF;
  137. margin-bottom: 21px;
  138. }
  139. >img.splitter {
  140. flex: 0 0 auto;
  141. width: 100%;
  142. margin-bottom: 37px;
  143. }
  144. >img.banner {
  145. flex: 0 0 auto;
  146. width: 100%;
  147. height: 34.8%;
  148. object-fit: contain;
  149. margin-bottom: 20px;
  150. }
  151. >.txt {
  152. flex: 1 0 1px;
  153. font-size: 20px;
  154. font-family: Source Han Sans CN-Light, Source Han Sans CN;
  155. font-weight: 400;
  156. color: rgba(255, 255, 255, 0.8);
  157. line-height: 1.7;
  158. overflow: auto;
  159. padding-right: 10px;
  160. margin-right: -10px;
  161. &::-webkit-scrollbar { background: transparent; width: 4px; } /*宽度是对垂直滚动条而言,高度是对水平滚动条而言*/
  162. &::-webkit-scrollbar-thumb {
  163. background: rgba(220, 231, 240, 0.2);
  164. border-radius: 2px;
  165. }
  166. }
  167. }
  168. .loading-mask {
  169. position: absolute;
  170. left: 0;
  171. top: 0;
  172. width: 100%;
  173. height: 100%;
  174. background: black;
  175. }
  176. }
  177. .mobile {
  178. .metaverse-root {
  179. height: 100%;
  180. position: relative;
  181. pointer-events: none;
  182. >article {
  183. pointer-events: initial;
  184. position: absolute;
  185. top: calc(100% / 2);
  186. transform: translateY(-50%);
  187. right: calc(102 / 1080 * 83vh);
  188. width: calc(653 / 1080 * 83vh);
  189. height: calc(100% - 74px - 50px);
  190. max-height: calc(740 / 1080 * 83vh);
  191. backdrop-filter: blur(10px);
  192. background-image: url(@/assets/images/general-article-bg.png);
  193. background-size: 100% auto;
  194. background-repeat: no-repeat;
  195. background-position: left top;
  196. padding: calc(32 / 1080 * 83vh) calc(50 / 1080 * 83vh) calc(50 / 1080 * 83vh) calc(50 / 1080 * 83vh);
  197. display: flex;
  198. flex-direction: column;
  199. @media only screen and (max-width: 1700px) {
  200. right: 0;
  201. }
  202. >button.close {
  203. position: absolute;
  204. top: calc(30 / 1080 * 83vh);
  205. right: calc(50 / 1080 * 83vh);
  206. width: calc(32 / 1080 * 83vh);
  207. height: calc(32 / 1080 * 83vh);
  208. background-image: url(@/assets/images/icon-close.png);
  209. background-size: cover;
  210. background-repeat: no-repeat;
  211. background-position: center center;
  212. }
  213. >h2 {
  214. flex: 0 0 auto;
  215. font-size: calc(24 / 1080 * 83vh);
  216. font-family: Source Han Sans CN-Bold, Source Han Sans CN;
  217. font-weight: bold;
  218. color: #FFFFFF;
  219. margin-bottom: calc(21 / 1080 * 83vh);
  220. }
  221. >img.splitter {
  222. flex: 0 0 auto;
  223. width: 100%;
  224. margin-bottom: calc(37 / 1080 * 83vh);
  225. }
  226. >img.banner {
  227. flex: 0 0 auto;
  228. width: 100%;
  229. height: 34.8%;
  230. object-fit: contain;
  231. margin-bottom: calc(20 / 1080 * 83vh);
  232. }
  233. >.txt {
  234. flex: 1 0 1px;
  235. font-size: calc(20 / 1080 * 83vh);
  236. font-family: Source Han Sans CN-Light, Source Han Sans CN;
  237. font-weight: 400;
  238. color: rgba(255, 255, 255, 0.8);
  239. line-height: 1.7;
  240. overflow: auto;
  241. padding-right: calc(10 / 1080 * 83vh);
  242. margin-right: calc(-10 / 1080 * 83vh);
  243. &::-webkit-scrollbar { background: transparent; width: calc(4 / 1080 * 83vh); } /*宽度是对垂直滚动条而言,高度是对水平滚动条而言*/
  244. &::-webkit-scrollbar-thumb {
  245. background: rgba(220, 231, 240, 0.2);
  246. border-radius: 2px;
  247. }
  248. }
  249. }
  250. .loading-mask {
  251. position: absolute;
  252. left: 0;
  253. top: 0;
  254. width: 100%;
  255. height: 100%;
  256. background: black;
  257. }
  258. }
  259. }
  260. </style>