
	<wxs src="../wxs/utils.wxs" module="utils"/>
	<wxs module="tools">
		var includes = function includes(data, target) {
			return data.indexOf(target) !== -1;
		};

		module.exports = {
			includes: includes
		};
	</wxs>
	<view class="mc-upload-picker mc-class" style="{{ mcStyle }}">
		<view class="mc-upload-picker__wrapper">
			<!-- 以下为视频上传 -->
			<block wx:if="{{ tools.includes(picker, 'video')}}">
				<view wx:if="{{ previewVideo }}" wx:for="{{ currentValue.video }}" wx:key="index" class="mc-upload-picker__preview">
					<video wx:if="{{ utils.assertTypeof(item, 'string') }}" src="{{ item }}" mc-class="mc-upload-picker__preview-video" style="width: {{ previewSize }}rpx; height: {{ previewSize }}rpx" data-index="{{ index }}" data-src="{{ item }}" controls="{{ false }}" showPlayBtn="{{ false }}" showCenterPlayBtn="{{ false }}" catchtap="handlePreviewVideo"/>
					<view wx:elif="{{ item.status === 'uploading' || item.status === 'failed' }}" class="mc-upload-picker__mask">
						<block wx:if="{{ item.status === 'failed' }}">
							<mc-icon type="o-warning" class="mc-upload-picker__mask-icon"/>
							<text class="mc-upload-picker__upload-text">上传失败</text>
						</block>
						<mc-spin wx:else size="{{ 50 }}" color="#ffffff" class="mc-upload-picker__loading"/>
					</view>
					<mc-icon wx:if="{{!disabled && (utils.assertTypeof(item, 'string') || item.status === 'failed')}}" type="close" mc-class="mc-upload-picker__preview-delete" data-index="{{ index }}" data-type="video" catchtap="handleDeleteItem"/>
				</view>

				<!-- 上传样式 -->
				<block wx:if="{{!disabled && currentMultiple.video}}">
					<!-- fns="{{ currentUploadOptions.fns }}" -->
					<mc-upload mode="video" max="{{currentMax.video}}" multiple="{{currentMultiple.video}}" disabled="{{ currentUploadOptions.disabled }}" url="{{ currentUploadOptions.url }}" headers="{{ currentUploadOptions.headers }}" name="{{ currentUploadOptions.name }}" accept="{{ currentUploadOptions.accept }}" size="{{ currentUploadOptions.size }}" sizeType="{{ currentUploadOptions.sizeType }}" sourceType="{{ currentUploadOptions.sourceType }}" compressed="{{ currentUploadOptions.compressed }}" maxDuration="{{ currentUploadOptions.maxDuration }}" camera="{{ currentUploadOptions.camera }}" parallel="{{ currentUploadOptions.parallel }}" fns="{{ currentUploadOptions.fns }}" class="mc-upload-picker__slot" bind:ready="handleReady">
						<view class="mc-upload-picker__upload {{ disabled ? 'mc-upload-picker__upload--disabled': ''}}" style="width: {{ previewSize }}rpx; height: {{ previewSize }}rpx;">
							<mc-icon type="plus" mc-class="mc-upload-picker__upload-icon"/>
							<text wx:if="{{ uploadText }}" class="mc-upload-picker__upload-text">{{ uploadText }}</text>
						</view>
					</mc-upload>
				</block>
			</block>
			<!-- TODO file -->

			<!-- 以下为图片上传 -->
			<block wx:if="{{ tools.includes(picker, 'image')}}">
				<view wx:if="{{ previewImage }}" wx:for="{{ currentValue.image }}" wx:key="index" class="mc-upload-picker__preview">
					<mc-image wx:if="{{ utils.assertTypeof(item, 'string') }}" fit="{{ imageFit }}" src="{{ item }}" alt="{{ '图片' + index }}" mc-class="mc-upload-picker__preview-image" width="{{ previewSize }}rpx" height="{{ previewSize }}rpx" data-index="{{ index }}" data-src="{{ item }}" catchtap="handlePreviewImage"/>
					<view wx:elif="{{ item.status === 'uploading' || item.status === 'failed' }}" class="mc-upload-picker__mask">
						<block wx:if="{{ item.status === 'failed' }}">
							<mc-icon type="o-warning" class="mc-upload-picker__mask-icon"/>
							<text class="mc-upload-picker__upload-text">上传失败</text>
						</block>
						<mc-spin wx:else size="{{50}}" color="#ffffff" class="mc-upload-picker__loading"/>
					</view>
					<mc-icon wx:if="{{!disabled && (utils.assertTypeof(item, 'string') || item.status === 'failed')}}" type="close" mc-class="mc-upload-picker__preview-delete" data-index="{{ index }}" data-type="image" catchtap="handleDeleteItem"/>
				</view>

				<!-- 上传样式 -->
				<block wx:if="{{!disabled && currentMultiple.image}}">
					<!-- fns="{{ currentUploadOptions.fns }}" -->
					<mc-upload mode="image" max="{{currentMax.image}}" multiple="{{currentMultiple.image}}" disabled="{{ currentUploadOptions.disabled }}" url="{{ currentUploadOptions.url }}" headers="{{ currentUploadOptions.headers }}" name="{{ currentUploadOptions.name }}" accept="{{ currentUploadOptions.accept }}" size="{{ currentUploadOptions.size }}" sizeType="{{ currentUploadOptions.sizeType }}" sourceType="{{ currentUploadOptions.sourceType }}" compressed="{{ currentUploadOptions.compressed }}" maxDuration="{{ currentUploadOptions.maxDuration }}" camera="{{ currentUploadOptions.camera }}" parallel="{{ currentUploadOptions.parallel }}" fns="{{ currentUploadOptions.fns }}" class="mc-upload-picker__slot" bind:ready="handleReady">
						<view class="mc-upload-picker__upload {{ disabled ? 'mc-upload-picker__upload--disabled': ''}}" style="width: {{ previewSize }}rpx; height: {{ previewSize }}rpx;">
							<mc-icon type="plus" mc-class="mc-upload-picker__upload-icon"/>
							<text wx:if="{{ uploadText }}" class="mc-upload-picker__upload-text">{{ uploadText }}</text>
						</view>
					</mc-upload>
				</block>
			</block>
		</view>
	</view>

