GameView.vue 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389
  1. <script setup>
  2. import { ref, onMounted } from 'vue'
  3. import { useRouter } from "vue-router"
  4. import useSizeAdapt from "@/useFunctions/useSizeAdapt"
  5. import Toast from '@/components/ToastBox.vue'
  6. const router = useRouter()
  7. // home-封面 unity-游戏 scene-线上展 reset-确认是否重新
  8. const mode = ref('home')
  9. const goBack = () => {
  10. window.history.back()
  11. }
  12. const goHome = () => {
  13. // router.replace('/')
  14. mode.value = 'reset'
  15. }
  16. const resetHome = () => {
  17. router.replace('/')
  18. }
  19. const toast = ref(null)
  20. const showToast = () => {
  21. toast.value.show()
  22. setTimeout(() => {
  23. if (toast?.value) {
  24. toast.value.hide()
  25. }
  26. }, 2000)
  27. }
  28. const {
  29. windowSizeInCssForRef,
  30. windowSizeWhenDesignForRef,
  31. } = useSizeAdapt()
  32. onMounted(() => {
  33. window.closeGame = () => {
  34. mode.value = 'home'
  35. }
  36. })
  37. /**
  38. * 右滑返回
  39. */
  40. const fingerPosXWhenTouchStart = ref(0)
  41. const handletouchstart = (event) => {
  42. fingerPosXWhenTouchStart.value = event.changedTouches[0].pageX
  43. }
  44. const touchMove = (event) => {
  45. let currentX = event.changedTouches[0].pageX
  46. let tX = currentX - fingerPosXWhenTouchStart.value
  47. if (tX > 1) {
  48. router.push({
  49. name: 'MoreContent',
  50. query: {
  51. anchorIdx: 1,
  52. }
  53. })
  54. }
  55. }
  56. </script>
  57. <template>
  58. <div
  59. class="game-page"
  60. @touchstart="handletouchstart($event)"
  61. @touchmove="touchMove($event)"
  62. >
  63. <Toast
  64. ref="toast"
  65. :message="`暂未开发`"
  66. :duration="`3000`"
  67. />
  68. <!--默认首页 -->
  69. <div
  70. class="home"
  71. :style="{backgroundImage: mode ==='reset' ?`url(${require('@/assets/images/reset-bg.png')})`:'',background:'cover'}"
  72. >
  73. <div
  74. v-if="mode !='reset'"
  75. class="line-scene"
  76. @click="() => {router.push('/onlone-scene')}"
  77. >
  78. <div class="down-triangle" />
  79. <div class="line-title">
  80. 《无尽藏》
  81. </div>
  82. 线上展
  83. </div>
  84. <div
  85. v-if="mode !='reset'"
  86. class="game-income"
  87. @click="() => { mode = 'unity' }"
  88. >
  89. <div class="down-triangle" />
  90. <div>《修篁树石图》画作创作</div>
  91. </div>
  92. <!-- reset部分 -->
  93. <div
  94. v-if="mode == 'reset'"
  95. class="title"
  96. >
  97. 是否重新开始<div>?</div>
  98. </div>
  99. <div
  100. v-if="mode == 'reset'"
  101. class="cancel"
  102. @click="() => {
  103. mode = 'home'
  104. }"
  105. >
  106. 取消
  107. </div>
  108. <div
  109. v-if="mode == 'reset'"
  110. class="reset"
  111. @click="resetHome()"
  112. >
  113. <img
  114. src="@/assets/images/reset-icon.png"
  115. alt=""
  116. >
  117. 重新开始
  118. <div class="cicle" />
  119. </div>
  120. <div class="btns">
  121. <!-- 加载中... -->
  122. <img
  123. src="@/assets/images/icon-loading.png"
  124. alt="loading"
  125. @click="goHome()"
  126. >
  127. <!-- <BtnBack @click="goBack()" /> -->
  128. </div>
  129. <PaginationComp
  130. class="pagination"
  131. :total="3"
  132. :idx="2"
  133. />
  134. </div>
  135. <!-- 游戏页面 -->
  136. <iframe
  137. v-if="mode === 'unity'"
  138. class="game-box"
  139. :src="`./game/index.html`"
  140. />
  141. </div>
  142. </template>
  143. <style lang="less" scoped>
  144. .game-page {
  145. width: 100%;
  146. height: 100%;
  147. position: relative;
  148. .home {
  149. width: 100%;
  150. height: 100%;
  151. background: url(@/assets/images/bg-game.png);
  152. background-size: cover;
  153. transition: all .3s;
  154. >.line-scene {
  155. padding: 20px 10px;
  156. background-image: url(@/assets/images/line-scene.png);
  157. background-size: 100% 100%;
  158. font-size: calc(24 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
  159. line-height: calc(29 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
  160. display: flex;
  161. align-items: center;
  162. justify-content: center;
  163. width: calc(187 /v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
  164. height: calc(56 /v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
  165. white-space: nowrap;
  166. font-family: 'KaiTi';
  167. position: absolute;
  168. bottom: calc(300 /v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
  169. left: 50%;
  170. transform: translateX(-50%);
  171. padding-top: 30px;
  172. letter-spacing: .05em;
  173. >.down-triangle {
  174. width: 0;
  175. height: 0;
  176. border-left: 8px solid transparent;
  177. border-right: 8px solid transparent;
  178. border-top: 8px solid #6F917F;
  179. margin-bottom: 10px;
  180. position: absolute;
  181. top: -5px;
  182. animation: fade-in-out 1.5s infinite;
  183. @keyframes fade-in-out {
  184. 0%{
  185. opacity: 0.1;
  186. }
  187. 50%{
  188. opacity: 1;
  189. }
  190. 100%{
  191. opacity: 0.1;
  192. }
  193. }
  194. }
  195. >.line-title {
  196. color: #707f48c7;
  197. font-weight: 600;
  198. line-height: 29px;
  199. // text-stroke: 1px #707F48;
  200. // text-align: center;
  201. // font-style: normal;
  202. // text-transform: none;
  203. // -webkit-text-stroke: 1px #707F48;
  204. }
  205. color: #474747;
  206. }
  207. >.game-income {
  208. padding: 20px 10px;
  209. // background-image: url(@/assets/images/line-scene.png);
  210. // background-size: 100% 100%;
  211. font-size: calc(24 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
  212. line-height: calc(29 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
  213. display: flex;
  214. flex-direction: column;
  215. align-items: center;
  216. justify-content: center;
  217. width: calc(187 /v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
  218. height: calc(56 /v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
  219. white-space: nowrap;
  220. font-family: 'KaiTi';
  221. position: absolute;
  222. bottom: calc(229 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
  223. left: 50%;
  224. transform: translateX(-50%);
  225. padding-top: 30px;
  226. letter-spacing: .05em;
  227. >.down-triangle {
  228. width: 0;
  229. height: 0;
  230. border-left: 8px solid transparent;
  231. border-right: 8px solid transparent;
  232. border-top: 8px solid #6F917F;
  233. margin-bottom: 10px;
  234. animation: fade-in-out 1.5s infinite;
  235. @keyframes fade-in-out {
  236. 0%{
  237. opacity: 0.1;
  238. }
  239. 50%{
  240. opacity: 1;
  241. }
  242. 100%{
  243. opacity: 0.1;
  244. }
  245. }
  246. }
  247. }
  248. .title{
  249. position: absolute;
  250. left: 52%;
  251. top:20%;
  252. writing-mode: vertical-rl;
  253. color: #476446;
  254. font-family: 'KingHwa_OldSong';
  255. font-size: calc(26 / v-bind('windowSizeWhenDesignForRef')* v-bind('windowSizeInCssForRef'));
  256. line-height: calc(35 / v-bind('windowSizeWhenDesignForRef')* v-bind('windowSizeInCssForRef'));
  257. display: flex;
  258. letter-spacing: 6px;
  259. justify-content: center;
  260. align-items: center;
  261. text-align: center;
  262. >div{
  263. transform: translateX(-25%);
  264. }
  265. }
  266. .cancel{
  267. width: calc(92 /v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
  268. height: calc(36 /v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
  269. background-image: url(@/assets/images/cancel-bg.png);
  270. background-size: 100% 100%;
  271. position: absolute;
  272. left: 50%;
  273. bottom: 40%;
  274. transform: translateX(-20%);
  275. display: flex;
  276. justify-content: center;
  277. align-items: end;
  278. // padding-bottom: 10px;
  279. color: #474747;
  280. font-size: calc(24 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
  281. font-family: 'KaiTi';
  282. }
  283. .reset{
  284. display: flex;
  285. color: #474747;
  286. font-size: calc(24 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
  287. font-family: 'KaiTi';
  288. position: absolute;
  289. left: 50%;
  290. bottom: 30%;
  291. transform: translateX(-35%);
  292. >img{
  293. margin-right: 10px;
  294. animation: fade-in-out 1.5s infinite;
  295. @keyframes fade-in-out {
  296. 0%{
  297. opacity: 0.1;
  298. }
  299. 50%{
  300. opacity: 1;
  301. }
  302. 100%{
  303. opacity: 0.1;
  304. }
  305. }
  306. }
  307. >.cicle{
  308. width: 15px;
  309. height: 15px;
  310. border-radius: 50px;
  311. border: 1px solid #7B916B;
  312. position: absolute;
  313. right: -5px;
  314. bottom: 0px;
  315. }
  316. }
  317. .btns {
  318. display: flex;
  319. flex-direction: column;
  320. align-items: center;
  321. justify-content: space-evenly;
  322. position: absolute;
  323. // height: calc(150 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
  324. left: calc(25 /v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
  325. bottom: calc(30 /v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
  326. >img {
  327. width: calc(24 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
  328. height: calc(24 /v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
  329. }
  330. }
  331. >.pagination {
  332. position: absolute;
  333. left: 50%;
  334. transform: translateX(-50%);
  335. bottom: calc(22 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
  336. }
  337. }
  338. .game-box {
  339. width: 100%;
  340. height: 100%;
  341. position: fixed;
  342. top: 0;
  343. left: 0;
  344. }
  345. }
  346. </style>