collection.vue 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. <template>
  2. <ul class="con">
  3. <li class="item" v-for="(item,i) in list" @click="handleClick(item)" :key="i">
  4. <div class="card-img">
  5. <img class="full" :src="item.imgstr||require('@/assets/images/myModel.jpg')" alt="" />
  6. <img class="real" :src="item.imgstr||require('@/assets/images/myModel.jpg')" alt="" />
  7. </div>
  8. <div class="card-txt">
  9. <div class="title">
  10. <span :title="item.name">{{ item.name||'名字' }}</span>
  11. </div>
  12. </div>
  13. </li>
  14. <div v-if="list.length<=0" class="no-record">
  15. 暂无数据
  16. </div>
  17. </ul>
  18. </template>
  19. <script>
  20. export default {
  21. props: ["data"],
  22. data() {
  23. return {
  24. };
  25. },
  26. computed:{
  27. list(){
  28. return this.data
  29. }
  30. },
  31. methods:{
  32. handleClick(item){
  33. this.$showBroadcast({item})
  34. this.$emit('toggle',false)
  35. }
  36. }
  37. };
  38. </script>
  39. <style lang="less" scoped>
  40. @margin: 36px;
  41. .item {
  42. text-align: center;
  43. display: inline-block;
  44. width: calc((100% - @margin * 3) / 4);
  45. margin-right: @margin;
  46. margin-bottom: @margin;
  47. background: #FFFFFF;
  48. border-radius: 8px;
  49. overflow: hidden;
  50. cursor: pointer;
  51. &:nth-of-type(4n) {
  52. margin-right: 0;
  53. }
  54. .card-img {
  55. position: relative;
  56. max-height: 190px;
  57. overflow: hidden;
  58. background: linear-gradient(180deg, #AAAAAA 0%, #D1D1D1 100%);
  59. img {
  60. height: 100%;
  61. }
  62. .full {
  63. opacity: 0;
  64. }
  65. .real {
  66. position: absolute;
  67. z-index: 99;
  68. top: 50%;
  69. left: 50%;
  70. transform: translate(-50%, -50%);
  71. }
  72. }
  73. .card-txt {
  74. display: flex;
  75. justify-content: space-between;
  76. align-items: center;
  77. font-size: 14px;
  78. padding: 8px 10px;
  79. color: #333;
  80. width: 100%;
  81. overflow: hidden;
  82. white-space: nowrap;
  83. text-overflow: ellipsis;
  84. .tag {
  85. color: @theme;
  86. }
  87. div{
  88. overflow: hidden;
  89. text-overflow:ellipsis;
  90. white-space: nowrap;
  91. }
  92. }
  93. }
  94. @media screen and (min-width: 500px) and (max-width: 1400px) {
  95. .item {
  96. width: calc((100% - @margin * 2) / 3);
  97. &:nth-of-type(3n) {
  98. margin-right: 0;
  99. }
  100. &:nth-of-type(4n){
  101. margin-right: @margin;
  102. }
  103. .card-img{
  104. max-height: 150px;
  105. }
  106. }
  107. }
  108. </style>