|
@@ -11,12 +11,15 @@
|
|
|
</view>
|
|
|
<view class="uploading">
|
|
|
<view class="title Regular">上传图片</view>
|
|
|
- <u-upload width='140' height='140' :file-list="fileList" :custom-btn="true" :show-upload-list="showUploadList" ref="uUpload" :max-size="5 * 1024 * 1024" max-count="6" :action="$uploadUrl">
|
|
|
+ <!-- <u-upload width='140' height='140' :file-list="fileList" :custom-btn="true" :show-upload-list="showUploadList" ref="uUpload" :max-size="5 * 1024 * 1024" max-count="6" :action="$uploadUrl">
|
|
|
<view slot="addBtn" class="slot-btn" hover-class="slot-btn__hover" hover-stay-time="150">
|
|
|
<image style='width:23px;height:23px;margin-top:10px;' src="../../static/img/liangmai/xiangji-2.png" mode=""></image>
|
|
|
<view style='color:#AFB3BF;font-size:10px;' class='Medium'>上传图片</view>
|
|
|
</view>
|
|
|
- </u-upload>
|
|
|
+ </u-upload> -->
|
|
|
+ <upload class="upload" ref="upload" :action="action" :max-size="maxSize" :max-count="1"
|
|
|
+ :size-type="['compressed']" :custom="uploadCustom" :options="uploadOptions" @on-success="getImgUrl" @on-error="onError" @on-remove="onRemove"
|
|
|
+ @on-uploaded="isAdd = true" :before-upload="filterFileType" @on-progress="onProgress"></upload>
|
|
|
</view>
|
|
|
</view>
|
|
|
<view class="commitwrap">
|
|
@@ -27,24 +30,51 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
+ import upload from '@/components/upload.vue';
|
|
|
export default {
|
|
|
- components: {
|
|
|
-
|
|
|
- },
|
|
|
+ components: {
|
|
|
+ upload
|
|
|
+ },
|
|
|
data() {
|
|
|
return {
|
|
|
+ action: this.$uploadUrl,
|
|
|
+ maxSize: 5 * 1024 * 1024, //限制文件大小 5M
|
|
|
+ btnLoading: false, //防止重复点击
|
|
|
+ isAdd: true,
|
|
|
+ imgUrls: [],
|
|
|
status:'',
|
|
|
- fileList:[]
|
|
|
+ fileList:[],
|
|
|
+ uploadOptions: {
|
|
|
+ "text": "",
|
|
|
+ "bgc": ""
|
|
|
+ },
|
|
|
}
|
|
|
},
|
|
|
onReady() {
|
|
|
// 得到整个组件对象,内部图片列表变量为"lists"
|
|
|
- this.fileList = this.$refs.uUpload.lists;
|
|
|
+ // this.fileList = this.$refs.uUpload.lists;
|
|
|
},
|
|
|
onLoad(){
|
|
|
|
|
|
},
|
|
|
methods: {
|
|
|
+ filterFileType(index, lists) {
|
|
|
+ if (lists[index].fileType != 'jpg' && lists[index].fileType != 'png' && lists[index].fileType != 'gif') {
|
|
|
+ lists.splice(index, 1);
|
|
|
+ // 当前文件不支持
|
|
|
+ uni.showModal({
|
|
|
+ title: '暂不支持当前图片类型',
|
|
|
+ showCancel: false
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ this.isAdd = false;
|
|
|
+ }
|
|
|
+ },
|
|
|
+ getImgUrl(res) {
|
|
|
+ console.log(res)
|
|
|
+ console.log('------------res-----------')
|
|
|
+ this.imgUrls.push(res);
|
|
|
+ },
|
|
|
commit(){
|
|
|
console.log(this.fileList)
|
|
|
}
|