|
@@ -3,38 +3,33 @@
|
|
|
<view class="uv-upload__wrap">
|
|
|
<template v-if="previewImage">
|
|
|
<view class="uv-upload__wrap__preview" v-for="(item, index) in lists" :key="index">
|
|
|
- <image
|
|
|
- v-if="item.isImage || (item.type && item.type === 'image')"
|
|
|
- :src="item.thumb || item.url" :mode="imageMode"
|
|
|
- class="uv-upload__wrap__preview__image"
|
|
|
- @tap="onPreviewImage(item,index)"
|
|
|
+ <image v-if="item.isImage || (item.type && item.type === 'image')" :src="item.thumb || item.url"
|
|
|
+ :mode="imageMode" class="uv-upload__wrap__preview__image" @tap="onPreviewImage(item,index)"
|
|
|
:style="[{
|
|
|
width: $uv.addUnit(width),
|
|
|
height: $uv.addUnit(height)
|
|
|
- }]"
|
|
|
- />
|
|
|
- <view
|
|
|
- v-else
|
|
|
- class="uv-upload__wrap__preview__other"
|
|
|
- @tap="onPreviewVideo(item,index)"
|
|
|
- :style="[{
|
|
|
+ }]" />
|
|
|
+ <view v-else class="uv-upload__wrap__preview__other" @tap="onPreviewVideo(item,index)" :style="[{
|
|
|
width: $uv.addUnit(width),
|
|
|
height: $uv.addUnit(height)
|
|
|
- }]"
|
|
|
- >
|
|
|
- <uv-icon color="#80CBF9" size="26" :name="item.isVideo || (item.type && item.type === 'video') ? 'movie' : 'folder'"></uv-icon>
|
|
|
- <text class="uv-upload__wrap__preview__other__text">{{item.isVideo || (item.type && item.type === 'video') ? '视频' : '文件'}}</text>
|
|
|
+ }]">
|
|
|
+ <uv-icon color="#80CBF9" size="52"
|
|
|
+ :name="item.isVideo || (item.type && item.type === 'video') ? 'movie' : 'folder'"></uv-icon>
|
|
|
+ <text
|
|
|
+ class="uv-upload__wrap__preview__other__text">{{item.isVideo || (item.type && item.type === 'video') ? '视频' : '文件'}}</text>
|
|
|
</view>
|
|
|
<view class="uv-upload__status" v-if="item.status === 'uploading' || item.status === 'failed'">
|
|
|
<view class="uv-upload__status__icon">
|
|
|
- <uv-icon v-if="item.status === 'failed'" name="close-circle" color="#ffffff" size="25" />
|
|
|
- <uv-loading-icon size="22" mode="circle" v-else />
|
|
|
+ <uv-icon v-if="item.status === 'failed'" name="close-circle" color="#ffffff" size="50" />
|
|
|
+ <uv-loading-icon size="44" mode="circle" v-else />
|
|
|
</view>
|
|
|
<text v-if="item.message" class="uv-upload__status__message">{{ item.message }}</text>
|
|
|
</view>
|
|
|
- <view class="uv-upload__deletable" v-if="item.status !== 'uploading' && (deletable || item.deletable)" @tap.stop="deleteItem(index)">
|
|
|
+ <view class="uv-upload__deletable"
|
|
|
+ v-if="item.status !== 'uploading' && (deletable || item.deletable)"
|
|
|
+ @tap.stop="deleteItem(index)">
|
|
|
<view class="uv-upload__deletable__icon">
|
|
|
- <uv-icon name="close" color="#ffffff" size="10"></uv-icon>
|
|
|
+ <uv-icon name="close" color="#ffffff" size="20"></uv-icon>
|
|
|
</view>
|
|
|
</view>
|
|
|
<view class="uv-upload__success" v-if="item.status === 'success'">
|
|
@@ -43,7 +38,7 @@
|
|
|
<!-- #endif -->
|
|
|
<!-- #ifndef APP-NVUE -->
|
|
|
<view class="uv-upload__success__icon">
|
|
|
- <uv-icon name="checkmark" color="#ffffff" size="12"></uv-icon>
|
|
|
+ <uv-icon name="checkmark" color="#ffffff" size="24"></uv-icon>
|
|
|
</view>
|
|
|
<!-- #endif -->
|
|
|
</view>
|
|
@@ -52,11 +47,13 @@
|
|
|
<template v-if="isInCount">
|
|
|
<view @tap="chooseFile">
|
|
|
<slot>
|
|
|
- <view class="uv-upload__button" :hover-class="!disabled ? 'uv-upload__button--hover' : ''" hover-stay-time="150" @tap.stop="chooseFile" :class="[disabled && 'uv-upload__button--disabled']" :style="[{
|
|
|
+ <view class="uv-upload__button" :hover-class="!disabled ? 'uv-upload__button--hover' : ''"
|
|
|
+ hover-stay-time="150" @tap.stop="chooseFile"
|
|
|
+ :class="[disabled && 'uv-upload__button--disabled']" :style="[{
|
|
|
width: $uv.addUnit(width),
|
|
|
height: $uv.addUnit(height)
|
|
|
}]">
|
|
|
- <uv-icon :name="uploadIcon" size="26" :color="uploadIconColor"></uv-icon>
|
|
|
+ <uv-icon :name="uploadIcon" size="56" :color="uploadIconColor"></uv-icon>
|
|
|
<text v-if="uploadText" class="uv-upload__button__text">{{ uploadText }}</text>
|
|
|
</view>
|
|
|
</slot>
|
|
@@ -68,10 +65,18 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
- import { func, image, video, array, promise } from '@/uni_modules/uv-ui-tools/libs/function/test.js';
|
|
|
+ import {
|
|
|
+ func,
|
|
|
+ image,
|
|
|
+ video,
|
|
|
+ array,
|
|
|
+ promise
|
|
|
+ } from '@/uni_modules/uv-ui-tools/libs/function/test.js';
|
|
|
import mpMixin from '@/uni_modules/uv-ui-tools/libs/mixin/mpMixin.js'
|
|
|
import mixin from '@/uni_modules/uv-ui-tools/libs/mixin/mixin.js'
|
|
|
- import { chooseFile } from './utils';
|
|
|
+ import {
|
|
|
+ chooseFile
|
|
|
+ } from './utils';
|
|
|
import mixin_accept from './mixin.js';
|
|
|
import props from './props.js';
|
|
|
/**
|
|
@@ -133,8 +138,8 @@
|
|
|
}
|
|
|
},
|
|
|
deletable(newVal) {
|
|
|
- if(!newVal) {
|
|
|
- this.lists.map(item=>{
|
|
|
+ if (!newVal) {
|
|
|
+ this.lists.map(item => {
|
|
|
item.deletable = this.deletable;
|
|
|
})
|
|
|
}
|
|
@@ -148,11 +153,12 @@
|
|
|
const lists = fileList.map((item) =>
|
|
|
Object.assign(Object.assign({}, item), {
|
|
|
// 如果item.url为本地选择的blob文件的话,无法判断其为video还是image,此处优先通过accept做判断处理
|
|
|
- isImage: this.accept === 'image' || image(item.url || item.thumb),
|
|
|
+ isImage: item.isImage,
|
|
|
isVideo: this.accept === 'video' || video(item.url || item.thumb),
|
|
|
deletable: typeof(item.deletable) === 'boolean' ? item.deletable : this.deletable,
|
|
|
})
|
|
|
);
|
|
|
+ console.log(lists);
|
|
|
this.lists = lists
|
|
|
this.isInCount = lists.length < maxCount
|
|
|
},
|
|
@@ -267,18 +273,19 @@
|
|
|
// 预览图片
|
|
|
onPreviewImage(item, index) {
|
|
|
const lists = this.$uv.deepClone(this.lists);
|
|
|
- lists.map((i,j)=>{
|
|
|
- if(j == index) {
|
|
|
+ lists.map((i, j) => {
|
|
|
+ if (j == index) {
|
|
|
i.current = true;
|
|
|
}
|
|
|
});
|
|
|
- const filters = lists.filter(i=>i.isImage);
|
|
|
- const findIndex = filters.findIndex(i=>i.current);
|
|
|
+ const filters = lists.filter(i => i.isImage);
|
|
|
+ const findIndex = filters.findIndex(i => i.current);
|
|
|
this.onClickPreview(item, index);
|
|
|
if (!item.isImage || !this.previewFullImage) return
|
|
|
uni.previewImage({
|
|
|
// 先filter找出为图片的item,再返回filter结果中的图片url
|
|
|
- urls: this.lists.filter((item) => this.accept === 'image' || image(item.url || item.thumb)).map((item) => item.url || item.thumb),
|
|
|
+ urls: this.lists.filter((item) => this.accept === 'image' || image(item.url || item.thumb))
|
|
|
+ .map((item) => item.url || item.thumb),
|
|
|
current: findIndex,
|
|
|
fail() {
|
|
|
this.$uv.toast('预览图片失败')
|
|
@@ -354,23 +361,28 @@
|
|
|
$uv-upload-text-margin-top: 2px !default;
|
|
|
$uv-upload-hover-bgColor: rgb(230, 231, 233) !default;
|
|
|
$uv-upload-disabled-opacity: .5 !default;
|
|
|
+
|
|
|
.uv-upload {
|
|
|
@include flex(column);
|
|
|
flex: 1;
|
|
|
+
|
|
|
&__wrap {
|
|
|
@include flex;
|
|
|
flex-wrap: wrap;
|
|
|
flex: 1;
|
|
|
+
|
|
|
&__preview {
|
|
|
border-radius: $uv-upload-preview-border-radius;
|
|
|
margin: $uv-upload-preview-margin;
|
|
|
position: relative;
|
|
|
overflow: hidden;
|
|
|
@include flex;
|
|
|
+
|
|
|
&__image {
|
|
|
width: $uv-upload-image-width;
|
|
|
height: $uv-upload-image-height;
|
|
|
}
|
|
|
+
|
|
|
&__other {
|
|
|
width: $uv-upload-image-width;
|
|
|
height: $uv-upload-image-height;
|
|
@@ -379,6 +391,7 @@
|
|
|
@include flex(column);
|
|
|
justify-content: center;
|
|
|
align-items: center;
|
|
|
+
|
|
|
&__text {
|
|
|
font-size: $uv-upload-text-font-size;
|
|
|
color: $uv-upload-text-color;
|
|
@@ -387,6 +400,7 @@
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
&__deletable {
|
|
|
position: absolute;
|
|
|
top: $uv-upload-deletable-top;
|
|
@@ -399,6 +413,7 @@
|
|
|
align-items: center;
|
|
|
justify-content: center;
|
|
|
z-index: $uv-upload-deletable-zIndex;
|
|
|
+
|
|
|
&__icon {
|
|
|
position: absolute;
|
|
|
transform: scale(0.7);
|
|
@@ -410,6 +425,7 @@
|
|
|
/* #endif */
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
&__success {
|
|
|
position: absolute;
|
|
|
bottom: $uv-upload-success-bottom;
|
|
@@ -426,6 +442,7 @@
|
|
|
border-width: $uv-upload-success-border-width;
|
|
|
align-items: center;
|
|
|
justify-content: center;
|
|
|
+
|
|
|
/* #endif */
|
|
|
&__icon {
|
|
|
/* #ifndef APP-NVUE */
|
|
@@ -440,6 +457,7 @@
|
|
|
/* #endif */
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
&__status {
|
|
|
position: absolute;
|
|
|
top: $uv-upload-status-top;
|
|
@@ -450,16 +468,19 @@
|
|
|
@include flex(column);
|
|
|
align-items: center;
|
|
|
justify-content: center;
|
|
|
+
|
|
|
&__icon {
|
|
|
position: relative;
|
|
|
z-index: $uv-upload-status-icon-Zindex;
|
|
|
}
|
|
|
+
|
|
|
&__message {
|
|
|
font-size: $uv-upload-message-font-size;
|
|
|
color: $uv-upload-message-color;
|
|
|
margin-top: $uv-upload-message-margin-top;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
&__button {
|
|
|
@include flex(column);
|
|
|
align-items: center;
|
|
@@ -471,15 +492,18 @@
|
|
|
margin: $uv-upload-botton-margin;
|
|
|
/* #ifndef APP-NVUE */
|
|
|
box-sizing: border-box;
|
|
|
+
|
|
|
/* #endif */
|
|
|
&__text {
|
|
|
font-size: $uv-upload-text-font-size;
|
|
|
color: $uv-upload-text-color;
|
|
|
margin-top: $uv-upload-text-margin-top;
|
|
|
}
|
|
|
+
|
|
|
&--hover {
|
|
|
background-color: $uv-upload-hover-bgColor;
|
|
|
}
|
|
|
+
|
|
|
&--disabled {
|
|
|
opacity: $uv-upload-disabled-opacity;
|
|
|
}
|