CollectionView.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301
  1. <template>
  2. <div class="collection-view">
  3. <div class="wrapper">
  4. <div class="banner-area">
  5. <div class="search-wrapper">
  6. <input
  7. v-model.trim="keyword"
  8. type="text"
  9. placeholder="请输入要搜索的内容..."
  10. >
  11. <button class="search">
  12. <img
  13. class=""
  14. src="@/assets/images/icon_search-big.png"
  15. alt=""
  16. draggable="false"
  17. >
  18. </button>
  19. </div>
  20. </div>
  21. <div class="tab-bar">
  22. <button
  23. v-for="item in collectionTypeList"
  24. :key="item.id"
  25. class="tab-item"
  26. :class="{
  27. active: item.id === activeTabId
  28. }"
  29. @click="activeTabId = item.id"
  30. >
  31. {{ item.cn }}
  32. </button>
  33. </div>
  34. <div
  35. class="card-list"
  36. >
  37. <div
  38. v-for="item in collectionList"
  39. :key="item.name"
  40. class="card"
  41. @click="onClickCollection(item.bs)"
  42. >
  43. <img
  44. class="thumb"
  45. :src="`https://yuhuatai.4dage.com/YHT/goodsData/3D/${item.bs}.png`"
  46. alt=""
  47. draggable="false"
  48. >
  49. <div class="bottom">
  50. <span
  51. class="name"
  52. :title="item.name"
  53. >
  54. {{ item.name }}
  55. </span>
  56. <img
  57. class="icon"
  58. src="@/assets/images/icon_arrow-right-blue.png"
  59. alt=""
  60. draggable="false"
  61. >
  62. </div>
  63. </div>
  64. </div>
  65. <div class="pagination-wrap">
  66. <el-pagination
  67. v-model:current-page="currentPage"
  68. class="pagination"
  69. :size="'large'"
  70. :page-size="pageSize"
  71. layout="prev, pager, next"
  72. :total="collectionListlengh"
  73. prev-text="上一页"
  74. next-text="下一页"
  75. :hide-on-single-page="true"
  76. />
  77. </div>
  78. </div>
  79. <router-view />
  80. </div>
  81. </template>
  82. <script setup>
  83. import { ref, computed, watch, onMounted, onBeforeUnmount, inject } from "vue"
  84. import { useRoute, useRouter } from "vue-router"
  85. import { useStore } from "vuex"
  86. import { fetchRelicList } from "@/api.js"
  87. const route = useRoute()
  88. const router = useRouter()
  89. const store = useStore()
  90. const $env = inject('$env')
  91. const keyword = ref('')
  92. const collectionTypeList = ref([{
  93. id: 'all',
  94. cn: '全部',
  95. }, ...staticConfig.collectionTypeList])
  96. const activeTabId = ref('all')
  97. const currentPage = ref(1)
  98. const pageSize = 8
  99. const collectionListlengh = computed(() => {
  100. return fetchRelicList(activeTabId.value, keyword.value, currentPage.value - 1, pageSize).total
  101. })
  102. const collectionList = computed(() => {
  103. return fetchRelicList(activeTabId.value, keyword.value, currentPage.value - 1, pageSize).list
  104. })
  105. function onClickCollection(id) {
  106. router.push({
  107. name: 'CollectionDetail',
  108. query: {
  109. id,
  110. }
  111. })
  112. }
  113. </script>
  114. <style lang="less" scoped>
  115. .collection-view{
  116. position: absolute;
  117. left: 0;
  118. top: 0;
  119. width: 100%;
  120. height: 100%;
  121. background-color: #fff;
  122. >.wrapper{
  123. position: absolute;
  124. left: 0;
  125. top: 0;
  126. width: 100%;
  127. height: 100%;
  128. overflow: auto;
  129. >.banner-area{
  130. width: 100%;
  131. height: calc(651 / 1920 * 100vw);
  132. background-image: url(@/assets/images/about/banner-collection.jpg);
  133. background-size: cover;
  134. background-repeat: no-repeat;
  135. background-position: center center;
  136. position: relative;
  137. >.search-wrapper{
  138. position: absolute;
  139. left: 50%;
  140. bottom: 24px;
  141. transform: translateX(-50%);
  142. width: 790px;
  143. height: 70px;
  144. background: rgba(255,255,255,0.7);
  145. box-shadow: 0px 4px 18px 0px rgba(0,0,0,0.25);
  146. border-radius: 35px;
  147. border: 2px solid #589498;
  148. display: flex;
  149. align-items: center;
  150. padding-left: 33px;
  151. padding-right: 29px;
  152. >input{
  153. font-family: Source Han Sans CN, Source Han Sans CN;
  154. font-weight: 400;
  155. font-size: 24px;
  156. color: #474747;
  157. width: 680px;
  158. }
  159. input::placeholder {
  160. color: #FFFFFF;
  161. }
  162. >button.search{
  163. pointer-events: none;
  164. width: 40px;
  165. height: 40px;
  166. padding: 5px;
  167. >img{
  168. width: 100%;
  169. height: 100%;
  170. }
  171. }
  172. }
  173. }
  174. >.tab-bar{
  175. height: 138px;
  176. display: flex;
  177. justify-content: center;
  178. align-items: center;
  179. text-align: center;
  180. gap: calc(184 / 1920 * 100vw);
  181. >.tab-item {
  182. font-family: Source Han Sans CN, Source Han Sans CN;
  183. font-weight: 400;
  184. font-size: 24px;
  185. color: #474747;
  186. height: 38px;
  187. }
  188. >.tab-item.active{
  189. font-weight: bold;
  190. position: relative;
  191. z-index: 0;
  192. &::after{
  193. content: '';
  194. display: block;
  195. position: absolute;
  196. height: 14px;
  197. width: 100%;
  198. background: #FFE794;
  199. bottom: 0;
  200. z-index: -1;
  201. }
  202. }
  203. }
  204. >.card-list{
  205. height: calc(457px * 2 + 58px * 2);
  206. width: calc(355px * 4 + 36px * 4);
  207. margin-left: auto;
  208. margin-right: auto;
  209. transform: translate(calc(36px / 2), 0);
  210. >.card{
  211. display: inline-block;
  212. width: 355px;
  213. background: #FFFFFF;
  214. box-shadow: 0px 4px 62px 0px rgba(81,112,114,0.25);
  215. border-radius: 9px 9px 9px 9px;
  216. margin-right: 36px;
  217. margin-bottom: 58px;
  218. cursor: pointer;
  219. >img.thumb{
  220. width: 100%;
  221. height: 355px;
  222. object-fit: cover;
  223. }
  224. >.bottom{
  225. height: 102px;
  226. display: flex;
  227. align-items: center;
  228. justify-content: space-between;
  229. padding-left: 42px;
  230. padding-right: 35px;
  231. >.name{
  232. font-family: Source Han Serif CN, Source Han Serif CN;
  233. font-weight: bold;
  234. font-size: 21px;
  235. color: #474747;
  236. width: 240px;
  237. overflow: hidden;
  238. white-space: pre;
  239. text-overflow: ellipsis;
  240. }
  241. >img.icon{
  242. height: 39px;
  243. }
  244. }
  245. }
  246. >.card:hover{
  247. }
  248. }
  249. >.pagination-wrap{
  250. display: flex;
  251. justify-content: center;
  252. padding-bottom: 52px;
  253. >.pagination{
  254. ::v-deep{
  255. button.btn-prev, button.btn-next{
  256. width: 126px;
  257. height: 45px;
  258. border-radius: 23px;
  259. border: 1px solid #474747;
  260. margin-left: 20px;
  261. margin-right: 20px;
  262. >span{
  263. font-family: Source Han Sans CN, Source Han Sans CN;
  264. font-weight: 400;
  265. font-size: 20px;
  266. color: #474747;
  267. }
  268. }
  269. ul.el-pager{
  270. >li.number{
  271. font-family: Source Han Sans CN, Source Han Sans CN;
  272. font-weight: 400;
  273. font-size: 20px;
  274. color: #474747;
  275. }
  276. >li.number.is-active{
  277. color: #47392C;
  278. background: #FFE794;
  279. border-radius: 50%;
  280. }
  281. }
  282. }
  283. }
  284. }
  285. }
  286. }
  287. </style>