AttachmentCard.vue 1.3 KB

123456789101112131415161718192021222324252627282930
  1. <template>
  2. <view class="attachment" @click="$emit('upload')">
  3. <view>
  4. <text class="attach-title">{{ title }}</text>
  5. <text class="attach-tip">请上传{{ title }}</text>
  6. </view>
  7. <image v-if="item && item.ossPath" :src="imageSrc" mode="aspectFill" />
  8. <view v-else class="camera">+</view>
  9. </view>
  10. </template>
  11. <script>
  12. export default {
  13. props: { title: { type: String, default: '' }, imgType: { type: String, default: '' }, items: { type: Array, default: () => [] } },
  14. computed: {
  15. item() { return this.items.find(v => v.imgType === this.imgType); },
  16. imageSrc() {
  17. const path = this.item.ossPath || '';
  18. if (/^https?:\/\//.test(path)) return path;
  19. return `${this.$constant.imgUrl}/${path}`;
  20. }
  21. }
  22. };
  23. </script>
  24. <style scoped>
  25. .attachment { margin: 0 24upx 24upx; padding: 24upx; background: #fff; border-radius: 18upx; min-height: 180upx; display: flex; align-items: center; justify-content: space-between; }
  26. .attach-title { display: block; font-size: 32upx; color: #111; margin-bottom: 12upx; }
  27. .attach-tip { color: #999; font-size: 28upx; }
  28. .attachment image, .camera { width: 260upx; height: 160upx; border-radius: 12upx; background: #e9f3ff; }
  29. .camera { color: #288bf5; font-size: 60upx; display: flex; align-items: center; justify-content: center; }
  30. </style>