index.wxml 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <wxs src="../wxs/utils.wxs" module="utils" />
  2. <view class="van-uploader">
  3. <view class="van-uploader__wrapper">
  4. <!-- 预览样式 -->
  5. <view
  6. wx:if="{{ previewImage }}"
  7. wx:for="{{ lists }}"
  8. wx:key="index"
  9. class="van-uploader__preview"
  10. >
  11. <image
  12. wx:if="{{ item.isImage }}"
  13. mode="{{ imageFit }}"
  14. src="{{ item.url || item.path }}"
  15. alt="{{ item.name || ('图片' + index) }}"
  16. class="van-uploader__preview-image"
  17. style="width: {{ computedPreviewSize }}; height: {{ computedPreviewSize }};"
  18. data-url="{{ item.url || item.path }}"
  19. bind:tap="doPreviewImage"
  20. />
  21. <view
  22. wx:else
  23. class="van-uploader__file"
  24. style="width: {{ computedPreviewSize }}; height: {{ computedPreviewSize }};"
  25. >
  26. <van-icon name="description" class="van-uploader__file-icon" />
  27. <view class="van-uploader__file-name van-ellipsis">{{ item.name || item.url || item.path }}</view>
  28. </view>
  29. <van-icon
  30. wx:if="{{ deletable }}"
  31. name="clear"
  32. class="van-uploader__preview-delete"
  33. data-index="{{ index }}"
  34. bind:tap="deleteItem"
  35. />
  36. </view>
  37. <!-- 上传样式 -->
  38. <block wx:if="{{ isInCount }}">
  39. <view wx:if="{{ useSlot }}" class="van-uploader__slot" bind:tap="startUpload">
  40. <slot />
  41. </view>
  42. <!-- 默认上传样式 -->
  43. <view
  44. wx:else
  45. class="van-uploader__upload"
  46. style="width: {{ computedPreviewSize }}; height: {{ computedPreviewSize }};"
  47. bind:tap="startUpload"
  48. >
  49. <van-icon name="plus" class="van-uploader__upload-icon" />
  50. <text wx:if="{{ uploadText }}" class="van-uploader__upload-text">{{ uploadText }}</text>
  51. </view>
  52. </block>
  53. </view>
  54. </view>