|
|
|
@ -6,7 +6,7 @@ |
|
|
|
|
<view class="upload-images"> |
|
|
|
|
<view v-for="(item, index) in imageList" :key="index" class="image-box"> |
|
|
|
|
<image :src="item" mode="aspectFill" @click="previewImage(item)"></image> |
|
|
|
|
<image src="/static/delete.png" mode="aspectFill" class="delete" @click="deleteImage(index)"></image> |
|
|
|
|
<image src="/static/delete.png" mode="aspectFill" class="delete" @click.stop="deleteImage(index)"></image> |
|
|
|
|
</view> |
|
|
|
|
<view class="upload-btn" v-if="imageList.length < 5" @click="addImage"> |
|
|
|
|
<image src="/static/add.png" mode="aspectFill"></image> |
|
|
|
@ -17,6 +17,14 @@ |
|
|
|
|
<textarea placeholder="请输入您想发布的内容哦~" placeholder-class="textarea-placeholer" id="" cols="30" rows="10" v-model="content" maxlength="3000"></textarea> |
|
|
|
|
<view class="text-num">已写<text>{{ content.length }}</text>/3000个字</view> |
|
|
|
|
</view> |
|
|
|
|
<view class="file-upload"> |
|
|
|
|
<view v-for="(file, index) in fileList" :key="index" class="file-box" @click="previewFile(file.url)"> |
|
|
|
|
<image src="/static/xls.jpeg" mode="aspectFill"></image> |
|
|
|
|
<text>{{ file.name }}</text> |
|
|
|
|
<image src="/static/delete.png" mode="aspectFill" class="delete" @click.stop="deleteFile(index)"></image> |
|
|
|
|
</view> |
|
|
|
|
<view class="upload-btn" @click="addFile">上传附件</view> |
|
|
|
|
</view> |
|
|
|
|
<view class="good"> |
|
|
|
|
<view class="label">关联商品:</view> |
|
|
|
|
<view class="content els" :style="{ color: !good.goods_name ? '#999999' : ''}" @click="selectGood">{{ good.goods_name || '请选择' }}</view> |
|
|
|
@ -57,16 +65,10 @@ import * as Api from '@/api/squareDynamic/index.js' |
|
|
|
|
isPublish: false, |
|
|
|
|
loading: false, |
|
|
|
|
good: {}, |
|
|
|
|
fileList: [], |
|
|
|
|
uploadFiles: [], |
|
|
|
|
}; |
|
|
|
|
}, |
|
|
|
|
watch: { |
|
|
|
|
good: { |
|
|
|
|
deep: true, |
|
|
|
|
handler() { |
|
|
|
|
console.log(this.good.goods_name); |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
methods: { |
|
|
|
|
addImage() { |
|
|
|
|
const that = this; |
|
|
|
@ -79,11 +81,11 @@ import * as Api from '@/api/squareDynamic/index.js' |
|
|
|
|
}) { |
|
|
|
|
console.log(that.imageList, tempFiles); |
|
|
|
|
that.imageList.push(tempFiles[0].path) |
|
|
|
|
that.upload(tempFiles[0]) |
|
|
|
|
that.upload(tempFiles[0], 'image') |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|
async upload(path) { |
|
|
|
|
async upload(path, type) { |
|
|
|
|
const that = this; |
|
|
|
|
// 批量上传 |
|
|
|
|
return new Promise((resolve, reject) => { |
|
|
|
@ -91,7 +93,11 @@ import * as Api from '@/api/squareDynamic/index.js' |
|
|
|
|
UploadApi.image([path]) |
|
|
|
|
.then(fileIds => { |
|
|
|
|
console.log(fileIds); |
|
|
|
|
if (type === 'image') { |
|
|
|
|
that.uploadImages.push(fileIds[0]); |
|
|
|
|
} else { |
|
|
|
|
that.uploadFiles.push(fileIds[0]) |
|
|
|
|
} |
|
|
|
|
resolve(fileIds) |
|
|
|
|
}) |
|
|
|
|
.catch(reject) |
|
|
|
@ -109,6 +115,39 @@ import * as Api from '@/api/squareDynamic/index.js' |
|
|
|
|
urls:this.imageList, |
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|
addFile() { |
|
|
|
|
const that = this; |
|
|
|
|
uni.chooseMessageFile({ |
|
|
|
|
count: 1, |
|
|
|
|
success({ |
|
|
|
|
tempFiles |
|
|
|
|
}) { |
|
|
|
|
const nameArr = tempFiles[0].name.split('.'); |
|
|
|
|
const fileType = nameArr[nameArr.length - 1]; |
|
|
|
|
if (!['xls', 'xlsx'].includes(fileType)) { |
|
|
|
|
uni.showToast({ |
|
|
|
|
icon: 'error', |
|
|
|
|
title: '文件格式错误' |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
console.log(tempFiles); |
|
|
|
|
that.fileList.push({ url: tempFiles[0].path, name: tempFiles[0].name.replace(`.${fileType}`, '') }); |
|
|
|
|
that.upload(tempFiles[0], 'file'); |
|
|
|
|
}, |
|
|
|
|
fail(e) { |
|
|
|
|
console.log(e); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|
deleteFile(index) { |
|
|
|
|
this.fileList.splice(index, 1); |
|
|
|
|
this.uploadFiles.splice(index, 1); |
|
|
|
|
}, |
|
|
|
|
previewFile(url) { |
|
|
|
|
uni.openDocument({ |
|
|
|
|
filePath: url, |
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|
changePicker(e) { |
|
|
|
|
console.log(e); |
|
|
|
|
this.cateIndex = e.detail.value; |
|
|
|
@ -135,6 +174,7 @@ import * as Api from '@/api/squareDynamic/index.js' |
|
|
|
|
content: this.content, |
|
|
|
|
cate: this.cateList[this.cateIndex], |
|
|
|
|
goods_id: this.good.goods_id, |
|
|
|
|
files: this.uploadFiles.join(',') |
|
|
|
|
}) |
|
|
|
|
.then(res => { |
|
|
|
|
console.log(res); |
|
|
|
@ -244,7 +284,7 @@ import * as Api from '@/api/squareDynamic/index.js' |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
.cate, .good { |
|
|
|
|
.cate, .good, .file-upload { |
|
|
|
|
margin-top: 20rpx; |
|
|
|
|
display: flex; |
|
|
|
|
justify-content: space-between; |
|
|
|
@ -269,6 +309,48 @@ import * as Api from '@/api/squareDynamic/index.js' |
|
|
|
|
height: 100%; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
.file-upload { |
|
|
|
|
display: block; |
|
|
|
|
padding: 30rpx; |
|
|
|
|
height: fit-content; |
|
|
|
|
.file-box { |
|
|
|
|
border-bottom: 1px solid #ddd; |
|
|
|
|
display: flex; |
|
|
|
|
align-items: center; |
|
|
|
|
position: relative; |
|
|
|
|
padding: 10rpx 20rpx; |
|
|
|
|
height: 80rpx; |
|
|
|
|
margin-bottom: 20rpx; |
|
|
|
|
&:last-child { |
|
|
|
|
border-bottom: none; |
|
|
|
|
} |
|
|
|
|
>image { |
|
|
|
|
&:first-child { |
|
|
|
|
width: 60rpx; |
|
|
|
|
height: 60rpx; |
|
|
|
|
margin: 0 10rpx 0 0; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
>text { |
|
|
|
|
width: calc(100% - 120rpx); |
|
|
|
|
} |
|
|
|
|
.delete { |
|
|
|
|
width: 30rpx; |
|
|
|
|
height: 30rpx; |
|
|
|
|
margin-left: 20rpx; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
.upload-btn { |
|
|
|
|
width: 160rpx; |
|
|
|
|
height: 60rpx; |
|
|
|
|
line-height: 60rpx; |
|
|
|
|
background: #4680ff; |
|
|
|
|
border-radius: 30rpx; |
|
|
|
|
color: #fff; |
|
|
|
|
font-size: 28rpx; |
|
|
|
|
text-align: center; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
.good { |
|
|
|
|
height: fit-content; |
|
|
|
|
.content { |
|
|
|
|