index.wxml 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <wxs src="../wxs/utils.wxs" module="utils" />
  2. <wxs src="./index.wxs" module="computed" />
  3. <view class="van-uploader">
  4. <view class="van-uploader__wrapper">
  5. <!-- 预览样式 -->
  6. <view
  7. wx:if="{{ previewImage }}"
  8. wx:for="{{ lists }}"
  9. wx:key="index"
  10. class="van-uploader__preview"
  11. data-index="{{ index }}"
  12. bindtap="onClickPreview"
  13. >
  14. <image
  15. wx:if="{{ item.isImage }}"
  16. mode="{{ imageFit }}"
  17. src="{{ item.thumb || item.url }}"
  18. alt="{{ item.name || ('图片' + index) }}"
  19. class="van-uploader__preview-image"
  20. style="{{ computed.sizeStyle({ previewSize }) }}"
  21. data-index="{{ index }}"
  22. bindtap="onPreviewImage"
  23. />
  24. <video
  25. wx:elif="{{ item.isVideo }}"
  26. src="{{ item.url }}"
  27. title="{{ item.name || ('视频' + index) }}"
  28. poster="{{ item.thumb }}"
  29. autoplay="{{ item.autoplay }}"
  30. object-fit="{{videoFit}}"
  31. class="van-uploader__preview-image"
  32. style="{{ computed.sizeStyle({ previewSize }) }}"
  33. data-index="{{ index }}"
  34. bindtap="onPreviewVideo"
  35. >
  36. </video>
  37. <view
  38. wx:else
  39. class="van-uploader__file"
  40. style="{{ computed.sizeStyle({ previewSize }) }}"
  41. data-index="{{ index }}"
  42. bindtap="onPreviewFile"
  43. >
  44. <van-icon name="description" class="van-uploader__file-icon" />
  45. <view class="van-uploader__file-name van-ellipsis">{{ item.name || item.url }}</view>
  46. </view>
  47. <view
  48. wx:if="{{ item.status === 'uploading' || item.status === 'failed' }}"
  49. class="van-uploader__mask"
  50. >
  51. <van-icon wx:if="{{ item.status === 'failed' }}" name="close" class="van-uploader__mask-icon" />
  52. <van-loading wx:else custom-class="van-uploader__loading" />
  53. <text wx:if="{{ item.message }}" class="van-uploader__mask-message">{{ item.message }}</text>
  54. </view>
  55. <view
  56. wx:if="{{ deletable && item.deletable }}"
  57. data-index="{{ index }}"
  58. class="van-uploader__preview-delete"
  59. catch:tap="deleteItem"
  60. >
  61. <van-icon name="cross" class="van-uploader__preview-delete-icon" />
  62. </view>
  63. </view>
  64. <!-- 上传样式 -->
  65. <block wx:if="{{ isInCount }}">
  66. <view class="van-uploader__slot" bindtap="startUpload">
  67. <slot />
  68. </view>
  69. <!-- 默认上传样式 -->
  70. <view
  71. wx:if="{{ showUpload }}"
  72. class="van-uploader__upload {{ disabled ? 'van-uploader__upload--disabled': ''}}"
  73. style="{{ computed.sizeStyle({ previewSize }) }}"
  74. bindtap="startUpload"
  75. >
  76. <van-icon name="{{ uploadIcon }}" class="van-uploader__upload-icon" />
  77. <text wx:if="{{ uploadText }}" class="van-uploader__upload-text">{{ uploadText }}</text>
  78. </view>
  79. </block>
  80. </view>
  81. </view>