RelicList.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300
  1. <template>
  2. <div class="relic-list">
  3. <button
  4. class="return"
  5. @click="router.go(-1)"
  6. />
  7. <menu>
  8. <button class="scene-select">
  9. 大汗之城
  10. </button>
  11. <button class="camera-select">
  12. 雄伟帝都
  13. </button>
  14. <button class="all">
  15. 全部
  16. </button>
  17. </menu>
  18. <div class="search-ui">
  19. <input
  20. v-model.trim="keyword"
  21. type="text"
  22. placeholder="请输入要搜索内容"
  23. @keydown.enter="onSearch"
  24. >
  25. <button
  26. class="search"
  27. @click="onSearch"
  28. />
  29. </div>
  30. <div
  31. class="the-list"
  32. >
  33. <div
  34. ref="listEl"
  35. class="content-wrap"
  36. >
  37. <div
  38. v-for="(item, idx) in relicData"
  39. :key="idx"
  40. class="relic-item"
  41. @click="onClickItem(idx)"
  42. >
  43. <img
  44. class=""
  45. :src="getRelicThumbUrl(idx)"
  46. alt=""
  47. draggable="false"
  48. >
  49. <div
  50. class="name"
  51. :title="item['名称']"
  52. >
  53. {{ item['名称'] }}
  54. </div>
  55. </div>
  56. </div>
  57. </div>
  58. </div>
  59. </template>
  60. <script setup>
  61. /**
  62. * todo: 自动恢复上次滚动位置
  63. */
  64. import { ref, computed, watch, watchEffect, onMounted } from "vue"
  65. import { useRoute, useRouter } from "vue-router"
  66. import { useStore } from "vuex"
  67. import useSmoothSwipe from '@/useFunctions/useSmoothSwipe.js'
  68. import { useElementSize } from '@vueuse/core'
  69. const route = useRoute()
  70. const router = useRouter()
  71. const store = useStore()
  72. const keyword = ref('')
  73. function onSearch() {
  74. }
  75. const sceneIdx = computed(() => {
  76. return route.query.sceneIdx
  77. })
  78. const cameraIdx = computed(() => {
  79. return route.query.cameraIdx
  80. })
  81. const relicData = computed(() => {
  82. return store.getters.relicData
  83. })
  84. function getRelicThumbUrl(idx) {
  85. if (Array.isArray(relicData.value[idx]['图片名']) && relicData.value[idx]['图片名'][0]) {
  86. return `${process.env.BASE_URL}relic-data/small-photo/${relicData.value[idx]['图片名'][0]}`
  87. } else {
  88. return ''
  89. }
  90. }
  91. const listEl = ref(null)
  92. const { width: listWidth, height: listHeight } = useElementSize(listEl)
  93. const { hasOperatedThisTime } = useSmoothSwipe({
  94. scrollTargetRef: listEl,
  95. viewportWidth: listWidth,
  96. })
  97. function onClickItem(idx) {
  98. if (!hasOperatedThisTime.value) {
  99. router.push({
  100. name: 'RelicDetail',
  101. query: {
  102. sceneIdx: route.query.sceneIdx,
  103. cameraIdx: route.query.cameraIdx,
  104. relicIdx: idx,
  105. }
  106. })
  107. }
  108. }
  109. </script>
  110. <style lang="less" scoped>
  111. @page-height-design-px: 970;
  112. .relic-list{
  113. height: 100%;
  114. background-image: url(@/assets/images/relic-list-bg.jpg);
  115. background-size: cover;
  116. background-repeat: no-repeat;
  117. background-position: center center;
  118. >button.return{
  119. position: absolute;
  120. width: 58px;
  121. height: 58px;
  122. left: 42px;
  123. top: 68px;
  124. background-image: url(@/assets/images/btn-return.png);
  125. background-size: contain;
  126. background-repeat: no-repeat;
  127. background-position: center center;
  128. }
  129. >menu{
  130. position: absolute;
  131. width: 524px;
  132. height: 66px;
  133. left: 150px;
  134. top: 64px;
  135. background-image: url(@/assets/images/relic-list-page-menu-bg.png);
  136. background-size: contain;
  137. background-repeat: no-repeat;
  138. background-position: center center;
  139. >button.scene-select{
  140. position: absolute;
  141. top: 50%;
  142. left: 10px;
  143. transform: translateY(-50%);
  144. width: 220px;
  145. height: 50px;
  146. padding-left: 10px;
  147. font-size: 30px;
  148. font-family: Source Han Serif CN, Source Han Serif CN;
  149. font-weight: bold;
  150. color: #43310E;
  151. line-height: 46px;
  152. letter-spacing: 6px;
  153. }
  154. >button.camera-select{
  155. position: absolute;
  156. top: 50%;
  157. left: 230px;
  158. transform: translateY(-50%);
  159. width: 160px;
  160. height: 50px;
  161. font-size: 24px;
  162. font-family: Source Han Sans CN, Source Han Sans CN;
  163. font-weight: 500;
  164. color: #FFF7D9;
  165. line-height: 36px;
  166. letter-spacing: 5px;
  167. }
  168. >button.all{
  169. position: absolute;
  170. top: 50%;
  171. left: 400px;
  172. transform: translateY(-50%);
  173. width: 100px;
  174. height: 50px;
  175. font-size: 24px;
  176. font-family: Source Han Sans CN, Source Han Sans CN;
  177. font-weight: 500;
  178. color: rgba(255,247,217,0.7);
  179. line-height: 36px;
  180. letter-spacing: 5px;
  181. }
  182. }
  183. >.search-ui{
  184. position: absolute;
  185. top: 65px;
  186. right: 27px;
  187. width: 406px;
  188. height: 62px;
  189. background-image: url(@/assets/images/search-bg.png);
  190. background-size: cover;
  191. background-repeat: no-repeat;
  192. background-position: center center;
  193. >input{
  194. position: absolute;
  195. left: 50px;
  196. top: 50%;
  197. transform: translateY(-50%);
  198. height: 35px;
  199. width: 250PX;
  200. font-size: 24px;
  201. font-family: Source Han Sans CN, Source Han Sans CN;
  202. font-weight: 400;
  203. color: rgba(255,255,255,0.7);
  204. line-height: 28px;
  205. &::placeholder{
  206. font-size: 24px;
  207. font-family: Source Han Sans CN, Source Han Sans CN;
  208. font-weight: 400;
  209. color: rgba(255,255,255,0.3);
  210. line-height: 28px;
  211. }
  212. }
  213. >button.search{
  214. position: absolute;
  215. width: 31px;
  216. height: 31px;
  217. position: absolute;
  218. top: 50%;
  219. right: 53px;
  220. transform: translateY(-50%);
  221. background-image: url(@/assets/images/icon-search.png);
  222. background-size: cover;
  223. background-repeat: no-repeat;
  224. background-position: center center;
  225. }
  226. }
  227. >.the-list{
  228. position: absolute;
  229. left: 0;
  230. top: 150px;
  231. width: 100%;
  232. height: calc(650 / @page-height-design-px * 100vh);
  233. background-image: url(@/assets/images/relic-list-bg-1.png);
  234. background-size: auto 100%;
  235. background-repeat: no-repeat;
  236. background-position: left center;
  237. padding-left: calc(56 / @page-height-design-px * 100vh);
  238. box-sizing: border-box;
  239. >.content-wrap{
  240. &::-webkit-scrollbar { height: 0; }
  241. box-sizing: border-box;
  242. height: 100%;
  243. width: 100%;
  244. overflow: auto;
  245. user-select: none;
  246. display: flex;
  247. align-items: center;
  248. background-image: url(@/assets/images/relic-list-bg-2.png);
  249. background-size: auto 92%;
  250. background-repeat: repeat no-repeat;
  251. background-position: left 44%;
  252. background-attachment: local;
  253. padding-top: calc(50 / @page-height-design-px * 100vh);
  254. >.relic-item{
  255. flex: 0 0 auto;
  256. width: calc(290 / @page-height-design-px * 100vh);
  257. height: 80%;
  258. padding: calc(10 / @page-height-design-px * 100vh);
  259. margin-right: calc(100 / @page-height-design-px * 100vh);
  260. display: flex;
  261. flex-direction: column;
  262. justify-content: center;
  263. align-items: center;
  264. cursor: pointer;
  265. >img{
  266. flex: 0 0 auto;
  267. width: 100%;
  268. height: calc(150 / @page-height-design-px * 100vh);
  269. object-fit: contain;
  270. margin-bottom: calc(10 / @page-height-design-px * 100vh);
  271. }
  272. >.name{
  273. text-align: center;
  274. flex: 0 0 auto;
  275. height: 4em;
  276. width: 100%;
  277. font-size: calc(32 / @page-height-design-px * 100vh);
  278. font-family: Source Han Serif CN, Source Han Serif CN;
  279. font-weight: 500;
  280. color: #281D0C;
  281. line-height: calc(37 / @page-height-design-px * 100vh);
  282. display: -webkit-box;
  283. -webkit-box-orient: vertical;
  284. -webkit-line-clamp: 3;
  285. overflow: hidden;
  286. }
  287. }
  288. }
  289. }
  290. }
  291. </style>