index.wxml 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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. class="van-uploader__preview-image"
  31. style="{{ computed.sizeStyle({ previewSize }) }}"
  32. data-index="{{ index }}"
  33. bindtap="onPreviewVideo"
  34. >
  35. </video>
  36. <view
  37. wx:else
  38. class="van-uploader__file"
  39. style="{{ computed.sizeStyle({ previewSize }) }}"
  40. data-index="{{ index }}"
  41. bindtap="onPreviewFile"
  42. >
  43. <van-icon name="description" class="van-uploader__file-icon" />
  44. <view class="van-uploader__file-name van-ellipsis">{{ item.name || item.url }}</view>
  45. </view>
  46. <view
  47. wx:if="{{ item.status === 'uploading' || item.status === 'failed' }}"
  48. class="van-uploader__mask"
  49. >
  50. <van-icon wx:if="{{ item.status === 'failed' }}" name="close" class="van-uploader__mask-icon" />
  51. <van-loading wx:else custom-class="van-uploader__loading" />
  52. <text wx:if="{{ item.message }}" class="van-uploader__mask-message">{{ item.message }}</text>
  53. </view>
  54. <view
  55. wx:if="{{ deletable && item.deletable }}"
  56. data-index="{{ index }}"
  57. class="van-uploader__preview-delete"
  58. catch:tap="deleteItem"
  59. >
  60. <van-icon name="cross" class="van-uploader__preview-delete-icon" />
  61. </view>
  62. </view>
  63. <!-- 上传样式 -->
  64. <block wx:if="{{ isInCount }}">
  65. <view class="van-uploader__slot" bindtap="startUpload">
  66. <slot />
  67. </view>
  68. <!-- 默认上传样式 -->
  69. <view
  70. wx:if="{{ showUpload }}"
  71. class="van-uploader__upload {{ disabled ? 'van-uploader__upload--disabled': ''}}"
  72. style="{{ computed.sizeStyle({ previewSize }) }}"
  73. bindtap="startUpload"
  74. >
  75. <van-icon name="{{ uploadIcon }}" class="van-uploader__upload-icon" />
  76. <text wx:if="{{ uploadText }}" class="van-uploader__upload-text">{{ uploadText }}</text>
  77. </view>
  78. </block>
  79. </view>
  80. </view>