artwork.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. <!-- eslint-disable vue/multi-word-component-names -->
  2. <script setup lang='ts'>
  3. import { ArtworkApi } from '@/api/api/artwork'
  4. import { showToast } from 'vant'
  5. import SearchInput from '@/components/SearchInput/index.vue'
  6. import { baseIMGUrl } from '@/api/request.ts'
  7. export type artworkType = {
  8. createTime: string,
  9. creatorId: null,
  10. creatorName: string,
  11. id: number,
  12. link: string,
  13. name: string,
  14. // 发布日期
  15. publishDate: string,
  16. thumb: string,
  17. updateTime: string
  18. }
  19. const searchParames = ref({
  20. pageNum: 0,
  21. pageSize: 0,
  22. searchKey: ''
  23. } as {
  24. pageNum: number,
  25. pageSize: number,
  26. searchKey: string
  27. })
  28. const searchList = ref([] as artworkType[])
  29. const getList = async () => {
  30. const res: any = await ArtworkApi.getSearchByKeyword(searchParames.value)
  31. if (res.code == 0) {
  32. searchList.value = res.data.records
  33. } else {
  34. showToast(res.msg)
  35. }
  36. }
  37. const onSearch = (eventData: any) => {
  38. searchParames.value.searchKey = eventData
  39. getList()
  40. }
  41. const isShowIframe = ref(false)
  42. const iframeLink = ref('')
  43. onBeforeMount(() => {
  44. getList()
  45. })
  46. </script>
  47. <template>
  48. <div class='artwork-box'>
  49. <SearchInput @onSearch="onSearch" />
  50. <div class="search-list" v-if="searchList.length > 0">
  51. <div class="list-item" v-for="(item, index) in searchList" :key="index"
  52. @click="() => { isShowIframe = true, iframeLink = item.link }">
  53. <img :src="baseIMGUrl + item.thumb" alt="">
  54. <div class="name">{{ item.name }}</div>
  55. </div>
  56. </div>
  57. <div class="no-data" v-else>
  58. <img src="@/assets/images/no-data.png" alt="">
  59. <div class="tips">暂时没有数据 ,请试一下其他关键字</div>
  60. </div>
  61. </div>
  62. <div class="iframe-box" v-show="isShowIframe">
  63. <img src="@/assets/images/sceneBack.png" alt="" @click="isShowIframe = false">
  64. <iframe :src="iframeLink" frameborder="0"></iframe>
  65. </div>
  66. </template>
  67. <style lang='less' scoped>
  68. .artwork-box {
  69. width: 100%;
  70. min-height: 100%;
  71. background: #F7F3E8;
  72. overflow: auto;
  73. .search-list {
  74. width: 100%;
  75. padding: 10px;
  76. display: grid;
  77. grid-template-columns: 1fr 1fr;
  78. grid-auto-rows: auto;
  79. gap: 10px;
  80. box-sizing: border-box;
  81. .list-item {
  82. width: 100%;
  83. height: auto;
  84. background: #F7F3E8;
  85. // padding: 10px;
  86. box-sizing: border-box;
  87. box-shadow: 0px 0px 20px 0px rgba(222, 216, 199, 0.6);
  88. border-radius: 10px 10px 10px 10px;
  89. padding-bottom: 10px;
  90. img {
  91. width: 100%;
  92. height: 21vh;
  93. object-fit: cover;
  94. border-radius: 10px 10px 0 0;
  95. }
  96. .name {
  97. font-size: 1em;
  98. display: -webkit-box;
  99. /* 必须添加,以启用WebKit的弹性盒模型布局 */
  100. -webkit-line-clamp: 2;
  101. /* 最多显示两行 */
  102. -webkit-box-orient: vertical;
  103. /* 必须添加,使文本垂直显示 */
  104. overflow: hidden;
  105. /* 隐藏超出部分 */
  106. text-overflow: ellipsis;
  107. /* 末尾显示省略号 */
  108. word-break: break-all;
  109. /* 可选,根据需要断开长单词以适应行宽 */
  110. padding: 5px 10px 0 10px;
  111. font-family: 'SourceHanSansCN-Regular';
  112. color: #333333;
  113. text-align: justified;
  114. }
  115. }
  116. }
  117. .no-data {
  118. width: 100%;
  119. height: calc(100% - 7vh);
  120. display: flex;
  121. flex-direction: column;
  122. justify-content: center;
  123. align-items: center;
  124. margin-top: 10%;
  125. img {
  126. width: 40%;
  127. }
  128. .tips {
  129. color: #88866F;
  130. margin-top: 10px;
  131. font-family: 'SourceHanSansCN-Regular';
  132. }
  133. }
  134. }
  135. .iframe-box {
  136. width: 100%;
  137. height: 100%;
  138. position: absolute;
  139. top: 0;
  140. left: 0;
  141. z-index: 10;
  142. iframe {
  143. width: 100%;
  144. height: 100%;
  145. position: absolute;
  146. top: 0;
  147. left: 0;
  148. }
  149. img {
  150. width: 30px;
  151. height: 30px;
  152. position: absolute;
  153. top: 3%;
  154. left: 3%;
  155. z-index: 11;
  156. }
  157. }
  158. </style>