Commit fb9889fd authored by Damon's avatar Damon

完工-上传组件适配scroll-view

parent 4d886b4b
...@@ -2,10 +2,6 @@ ...@@ -2,10 +2,6 @@
<template> <template>
<view> <view>
<view class="file-box"> <view class="file-box">
<!-- <view class="u-flex">
<view class="txt u-flex-1">{{item.fieldsTitle}}</view>
<u-icon name="arrow-right" color="#666" size="28"></u-icon>
</view> -->
<view class="pics u-flex u-flex-wrap"> <view class="pics u-flex u-flex-wrap">
<view class="img-list" v-for="(item,index) in imgList" :key="index"> <view class="img-list" v-for="(item,index) in imgList" :key="index">
<u-image class="pic" width="160" height="160" :src="item.path ? item.path : item.src + '?imageView2/1/w/100/h/100/q/75'" :border-radius="10" @click.stop="prviewImage(item,index)"></u-image> <u-image class="pic" width="160" height="160" :src="item.path ? item.path : item.src + '?imageView2/1/w/100/h/100/q/75'" :border-radius="10" @click.stop="prviewImage(item,index)"></u-image>
...@@ -14,13 +10,14 @@ ...@@ -14,13 +10,14 @@
<view class="icon-del rotate"></view> <view class="icon-del rotate"></view>
</view> </view>
</view> </view>
<view class="img-list"> <slot></slot>
<!-- <view class="img-list">
<u-image class="pic" width="160rpx" height="160rpx" :border-radius="10" @click="selectUpload" :src="uploadImage"></u-image> <u-image class="pic" width="160rpx" height="160rpx" :border-radius="10" @click="selectUpload" :src="uploadImage"></u-image>
</view> </view> -->
</view> </view>
<u-action-sheet :list="list" v-model="maskShow" :cancel-btn="true" @click="uploadSelect"></u-action-sheet> <!-- <u-action-sheet :list="list" v-model="maskShow" :cancel-btn="true" @click="uploadSelect"></u-action-sheet> -->
</view> </view>
<take-photo v-if="takeStatus" @close="closeTake" :upload="false" :currentItem="currentItemDate"></take-photo> <!-- <take-photo v-if="takeStatus" @close="closeTake" :upload="false" :currentItem="currentItemDate"></take-photo> -->
</view> </view>
</template> </template>
...@@ -86,6 +83,26 @@ ...@@ -86,6 +83,26 @@
} }
}, },
methods: { methods: {
setTmpValue(values) {
this.imgList = this.imgList.concat(values)
const dataValue = this.imgList.map(v => v.src)
this.valueChange(dataValue)
},
setValue() {
const dataValue = this.imgList.map(item => item.src)
this.valueChange(dataValue)
},
prviewImage(item, index) {
uni.previewImage({
urls: [item.path ? item.path : item.src],
current: index
});
},
delFile(index) {
this.imgList.splice(index, 1)
this.setValue()
},
/*
selectUpload(){ selectUpload(){
if (this.imgList.length === 10) { if (this.imgList.length === 10) {
return this.$refs.uToast.show({ return this.$refs.uToast.show({
...@@ -122,18 +139,6 @@ ...@@ -122,18 +139,6 @@
this.photograph() this.photograph()
this.getWatermark() this.getWatermark()
}, },
setTmpValue(values) {
this.imgList = this.imgList.concat(values)
const dataValue = values.map(v => v.key)
this.valueChange(dataValue)
},
setValue() {
const dataValue = []
this.imgList.map(item=>{
dataValue.push(item.src)
})
this.valueChange(dataValue)
},
closeTake(val) { closeTake(val) {
if(val && val.length > 0){ if(val && val.length > 0){
// val.forEach(item=>{ // val.forEach(item=>{
...@@ -164,16 +169,6 @@ ...@@ -164,16 +169,6 @@
// } // }
// uploader.qnFileUpload(options) // uploader.qnFileUpload(options)
}, },
prviewImage(item, index) {
uni.previewImage({
urls: [item.path ? item.path : item.src],
current: index
});
},
delFile(index) {
this.imgList.splice(index, 1)
this.setValue()
},
photograph(){// 获取拍照规范接口 photograph(){// 获取拍照规范接口
let self = this let self = this
let param = {"partnerCompanyId":self.partnerCompanyId, let param = {"partnerCompanyId":self.partnerCompanyId,
...@@ -201,7 +196,7 @@ ...@@ -201,7 +196,7 @@
console.log("获取水印备注异常",res.data.message) console.log("获取水印备注异常",res.data.message)
} }
}); });
} }*/
} }
} }
</script> </script>
......
...@@ -48,10 +48,11 @@ export default { ...@@ -48,10 +48,11 @@ export default {
async saveToTask(files) { async saveToTask(files) {
// 生成key返回,然后把key放到异步上传的任务队列 // 生成key返回,然后把key放到异步上传的任务队列
let lists = files.map(v => { let lists = files.map(v => {
const key = randomChar(10)
return { return {
key: randomChar(10), key: key,
path: v, path: v,
src: '' src: key
} }
}) })
// for (let i = 0; i < files.length; i++) { // for (let i = 0; i < files.length; i++) {
...@@ -92,10 +93,11 @@ export default { ...@@ -92,10 +93,11 @@ export default {
tempFilePath: path, tempFilePath: path,
success(e) { success(e) {
const { savedFilePath } = e const { savedFilePath } = e
const key = randomChar(10)
const img = { const img = {
key: randomChar(10), key: key,
path: savedFilePath, path: savedFilePath,
src: '' src: key
} }
resolve(img) resolve(img)
}, },
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment