item-img.vue 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <template>
  2. <view class="item-line" :class="{'line-one':lineType===1,'line-two':lineType===2}">
  3. <view class="item-img">
  4. <view class="item-key">{{label}}</view>
  5. <view class="item-img">
  6. <view class="img-item" v-for="img in imgList">
  7. <image :src="img" @click="previewImage(img)" mode="aspectFill"></image>
  8. </view>
  9. </view>
  10. </view>
  11. </view>
  12. </template>
  13. <script>
  14. export default {
  15. name: "item-img",
  16. components: {},
  17. props: {
  18. lineType:{
  19. type:Number,
  20. default:0
  21. },
  22. label: {
  23. type: String,
  24. default: '标题'
  25. },
  26. value: {
  27. default: []
  28. },
  29. keyStr: {
  30. default: true
  31. },
  32. typeKeys:{
  33. default:[]
  34. }
  35. },
  36. data() {
  37. return {
  38. imgList:[],
  39. isShow:true
  40. }
  41. },
  42. watch: {},
  43. mounted() {
  44. this.setIsShow()
  45. this.setImgList()
  46. },
  47. methods: {
  48. setImgList(){
  49. if(typeof this.value ==='string'){
  50. this.imgList=[this.value]
  51. }else {
  52. this.imgList=this.value
  53. }
  54. },
  55. setIsShow(){
  56. if(this.keyStr!==true){
  57. if(this.typeKeys.indexOf(this.keyStr)<0){
  58. this.isShow=false
  59. }
  60. }
  61. },
  62. previewImage(img){
  63. this.$emit('onShowImg',img)
  64. }
  65. }
  66. }
  67. </script>
  68. <style scoped lang="scss">
  69. .item-line{
  70. padding: 16rpx 0;
  71. .item-img{
  72. .item-key{
  73. color: #999999;
  74. font-size: 30rpx;
  75. margin-bottom: 16rpx;
  76. }
  77. .item-img{
  78. height: auto;
  79. display: flex;
  80. flex-wrap: wrap;
  81. .img-item{
  82. display: inline-block;
  83. margin-right:12rpx;
  84. image{
  85. width: calc((100vw - 100rpx)/4);
  86. height: calc((100vw - 100rpx)/4);
  87. border-radius: 8rpx;
  88. }
  89. }
  90. .img-item:nth-of-type(4n+0){
  91. margin-right:0;
  92. }
  93. .img-item:nth-of-type(n+5){
  94. margin-top:12rpx;
  95. }
  96. }
  97. }
  98. }
  99. .line-one{
  100. padding-top: 0;
  101. }
  102. .line-two{
  103. padding-bottom: 0;
  104. }
  105. </style>