artwork.vue 3.6 KB

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