image.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318
  1. <template>
  2. <div class="page">
  3. <div class="page-top flex flex-col justify-center items-center">
  4. <img class="logo" :src="supplierInfo.logo" />
  5. <span class="name mt-2" v-text="supplierInfo.shopName + '资料库'"></span>
  6. </div>
  7. <div class="page-content">
  8. <!-- 搜索区域 -->
  9. <div class="search">
  10. <simple-search v-model="listQuery.imageTitle" @search="onSearch" />
  11. </div>
  12. <div class="divider"></div>
  13. <!-- tabbar -->
  14. <simple-tabs
  15. :tabs="tabs"
  16. :current="current"
  17. @change="onTabChange"
  18. @search="onSearch"
  19. ></simple-tabs>
  20. <div class="list">
  21. <div class="section" v-for="item in list" :key="item.imageId">
  22. <div class="info">
  23. <div class="name" v-text="item.imageTitle"></div>
  24. <div class="date">{{ item.createTime | dateFormat }}</div>
  25. <div class="download" @click="downloadLink(item.imageZipUrl)">
  26. 保存所有图片
  27. </div>
  28. </div>
  29. <div class="images grid grid-cols-4 md:grid-cols-8 gap-3 md:gap-4">
  30. <div
  31. class="item"
  32. v-for="(image, index) in item.imageList"
  33. :key="index"
  34. @click="onImagePreview(item.imageList, index)"
  35. >
  36. <img class="object-cover" :src="image" />
  37. </div>
  38. </div>
  39. </div>
  40. </div>
  41. <!-- 列表为空 -->
  42. <SimpleEmpty
  43. v-if="!total && !isRequest"
  44. description="敬请期待~"
  45. ></SimpleEmpty>
  46. <!-- 页码 -->
  47. <SimplePagination
  48. v-if="total > listQuery.pageSize"
  49. :total="total"
  50. :pageItems="listQuery.pageSize"
  51. @change="onPagiantionChange"
  52. ></SimplePagination>
  53. </div>
  54. </div>
  55. </template>
  56. <script>
  57. import { mapGetters } from 'vuex'
  58. import { tabs } from '@/configs/tabs'
  59. import downloadLink from '@/utils/download-link'
  60. import { ImagePreview } from 'vant'
  61. export default {
  62. layout: 'app',
  63. data() {
  64. return {
  65. isRequest: true,
  66. tabs: tabs(),
  67. current: 1,
  68. listQuery: {
  69. imageTitle: '',
  70. authUserId: '',
  71. pageNum: 1,
  72. pageSize: 4,
  73. },
  74. list: [],
  75. total: 0,
  76. }
  77. },
  78. computed: {
  79. ...mapGetters(['userInfo', 'supplierInfo']),
  80. },
  81. mounted() {
  82. this.fetchList()
  83. },
  84. methods: {
  85. // 下载方法
  86. downloadLink,
  87. // 获取列表
  88. async fetchList() {
  89. try {
  90. this.listQuery.authUserId = this.userInfo.authUserId
  91. const res = await this.$http.api.getImageList(this.listQuery)
  92. this.list = res.data.list
  93. this.total = res.data.total
  94. } catch (error) {
  95. console.log(error)
  96. } finally {
  97. this.isRequest = false
  98. }
  99. },
  100. // 图片预览
  101. onImagePreview(imageList, index) {
  102. ImagePreview({
  103. images: imageList,
  104. startPosition: index,
  105. loop: true,
  106. showIndex: true,
  107. showIndicators: true,
  108. closeable: true,
  109. })
  110. },
  111. // tab切换
  112. onTabChange(item) {
  113. console.log(item)
  114. this.$router.push(`/ph${item.path}`)
  115. },
  116. // 搜索
  117. onSearch(keyword) {
  118. this.listQuery.imageTitle = keyword
  119. this.listQuery.pageNum = 1
  120. this.fetchList()
  121. },
  122. // 页码变化
  123. onPagiantionChange(index) {
  124. this.listQuery.pageNum = index
  125. this.fetchList()
  126. },
  127. },
  128. }
  129. </script>
  130. <style scoped lang="scss">
  131. /* scss中可以用mixin来扩展 */
  132. @mixin ellipsis($line: 1) {
  133. overflow: hidden;
  134. text-overflow: ellipsis;
  135. display: -webkit-box;
  136. -webkit-line-clamp: $line;
  137. -webkit-box-orient: vertical;
  138. }
  139. // pc 端
  140. @media screen and (min-width: 768px) {
  141. .page-top {
  142. height: 360px;
  143. background: url(https://static.caimei365.com/www/authentic/pc/bg-doc.png);
  144. background-size: auto 360px;
  145. .logo {
  146. display: block;
  147. width: 120px;
  148. height: 120px;
  149. border-radius: 50%;
  150. }
  151. .name {
  152. font-size: 30px;
  153. color: #fff;
  154. }
  155. }
  156. .page-content {
  157. width: 1200px;
  158. margin: 0 auto;
  159. background-color: #fff;
  160. .divider {
  161. height: 16px;
  162. background: #f7f7f7;
  163. }
  164. .search {
  165. display: none;
  166. }
  167. }
  168. .list {
  169. border-top: 16px solid #f7f7f7;
  170. border-bottom: 16px solid #f7f7f7;
  171. .section {
  172. padding: 32px 0;
  173. margin: 0 24px;
  174. background: #fff;
  175. border-bottom: 1px solid #d8d8d8;
  176. &:last-child {
  177. border-bottom: 0;
  178. }
  179. .info {
  180. position: relative;
  181. .name {
  182. font-size: 18px;
  183. color: #404040;
  184. line-height: 1.6;
  185. margin-bottom: 18px;
  186. text-align: justify;
  187. }
  188. .date {
  189. font-size: 18px;
  190. color: #b2b2b2;
  191. line-height: 1.4;
  192. }
  193. .download {
  194. bottom: 0;
  195. right: 0;
  196. position: absolute;
  197. color: #bc1724;
  198. font-size: 16px;
  199. cursor: pointer;
  200. }
  201. }
  202. .images {
  203. margin-top: 24px;
  204. .item {
  205. width: 126px;
  206. height: 126px;
  207. overflow: hidden;
  208. img {
  209. display: block;
  210. width: 100%;
  211. height: 100%;
  212. cursor: pointer;
  213. }
  214. }
  215. }
  216. }
  217. }
  218. }
  219. // 移动 端
  220. @media screen and (max-width: 768px) {
  221. .page-top {
  222. height: 46vw;
  223. background: url(https://static.caimei365.com/www/authentic/h5/bg-club.png);
  224. background-size: auto 46vw;
  225. .logo {
  226. display: block;
  227. width: 14.8vw;
  228. height: 14.8vw;
  229. border-radius: 50%;
  230. }
  231. .name {
  232. font-size: 4vw;
  233. color: #fff;
  234. }
  235. }
  236. .page-content {
  237. position: relative;
  238. .divider {
  239. border-bottom: 3.2vw solid #f7f7f7;
  240. height: 12.4vw;
  241. }
  242. }
  243. .search {
  244. position: absolute;
  245. left: 50%;
  246. top: 0;
  247. transform: translate(-50%, -50%);
  248. }
  249. .list {
  250. .section {
  251. position: relative;
  252. padding: 2.4vw 0;
  253. margin: 0 4vw;
  254. padding-bottom: 9.8vw;
  255. background: #fff;
  256. border-bottom: 0.1vw solid #d8d8d8;
  257. &:first-child {
  258. border-top: 0.1vw solid #d8d8d8;
  259. }
  260. .info {
  261. .name {
  262. font-size: 3.6vw;
  263. color: #404040;
  264. line-height: 1.5;
  265. margin-bottom: 2.4vw;
  266. @include ellipsis(2);
  267. text-align: justify;
  268. }
  269. .date {
  270. bottom: 2.4vw;
  271. left: 0;
  272. position: absolute;
  273. font-size: 3.2vw;
  274. color: #b2b2b2;
  275. line-height: 1.4;
  276. }
  277. .download {
  278. bottom: 2.4vw;
  279. right: 0;
  280. position: absolute;
  281. color: #bc1724;
  282. font-size: 3.6vw;
  283. cursor: pointer;
  284. }
  285. }
  286. .images {
  287. margin-top: 2.4vw;
  288. .item {
  289. width: 21vw;
  290. height: 21vw;
  291. overflow: hidden;
  292. img {
  293. display: block;
  294. width: 100%;
  295. height: 100%;
  296. }
  297. }
  298. }
  299. }
  300. }
  301. }
  302. </style>