<!-- <wxs src="../wxs/utils.wxs" module="utils" /> -->

<view class="van-uploader">
  <view class="van-uploader__wrapper">
    <!-- 预览样式 -->
    <view
      wx:if="{{ previewImage }}"
      wx:for="{{ lists  }}"
      wx:key="index"
      class="van-uploader__preview"
    >
      <image
        wx:if="{{ item.isImage }}"
        mode="{{ imageFit }}"
        src="{{ item.url || item.path }}"
        alt="{{ item.name || ('图片' + index) }}"
        class="van-uploader__preview-image"
        style="width: {{ previewSize }}; height: {{ previewSize }};"
        data-url="{{ item.url || item.path }}"
        bind:tap="doPreviewImage"
      />
      <view
        wx:elif="{{ item.isVideo }}"
        class="van-uploader__preview"
        style="width:280rpx; height:280rpx;"
        class="van-uploader__preview"
      >
        <video class="van-uploader__preview-video" data-url="{{ item.url || item.path }}" style="width:280rpx; height:280rpx;" src="{{ item.url || item.tempFilePath }}" controls></video>
      </view>
      <view
        wx:else
        class="van-uploader__file"
        style="width: {{ previewSize }}; height: {{ previewSize }};"
      >
        <van-icon name="description" class="van-uploader__file-icon" />
        <view class="van-uploader__file-name van-ellipsis">{{ item.name || item.url || item.path }}</view>
      </view>
      <van-icon
        wx:if="{{ deletable && !disabled }}"
        name="clear"
        size='40'
        class="van-uploader__preview-delete"
        data-index="{{ index }}"
        bind:tap="deleteItem"
      />
    </view>

    <!-- 上传样式 -->
    <block wx:if="{{ isInCount && !disabled }}">
      <view class="van-uploader__slot" bind:tap="startUpload">
        <slot />
      </view>

      <!-- 默认上传样式 -->
      <view
        class="van-uploader__upload"
        style="width: {{ previewSize }}; height: {{ previewSize }};"
        bind:tap="startUpload"
      >
        <van-icon name="plus" size='40' class="van-uploader__upload-icon" />
        <text wx:if="{{ uploadText }}" class="van-uploader__upload-text">{{ uploadText }}</text>
      </view>
    </block>
  </view>
</view>
