Commit 85c23e48 by wangyalan-git

修改图片上传/新增佣金

parent 24338677
<template> <template>
<div> <div>
<el-upload <el-upload
:action="$http.adornUrl('/admin/file/upload/element')" :action="$http.adornUrl(`/fileBapi/upload`)"
:headers="{Authorization: $cookie.get('Authorization')}" :headers="{Authorization: $cookie.get('Authorization')}"
list-type="picture-card" list-type="picture-card"
:data="obj"
:on-preview="handlePictureCardPreview" :on-preview="handlePictureCardPreview"
:on-remove="handleRemove" :on-remove="handleRemove"
:on-success="handleUploadSuccess" :on-success="handleUploadSuccess"
...@@ -23,7 +24,11 @@ ...@@ -23,7 +24,11 @@
return { return {
dialogImageUrl: '', dialogImageUrl: '',
dialogVisible: false, dialogVisible: false,
resourcesUrl: window.SITE_CONFIG.resourcesUrl resourcesUrl: window.SITE_CONFIG.resourcesUrl,
obj : {
fileType: 'sku',
t: new Date().getTime()
}
} }
}, },
props: { props: {
...@@ -38,7 +43,7 @@ ...@@ -38,7 +43,7 @@
if (this.value) { if (this.value) {
let imageArray = this.value.split(',') let imageArray = this.value.split(',')
for (let i = 0; i < imageArray.length; i++) { for (let i = 0; i < imageArray.length; i++) {
res.push({url: imageArray[i], response: imageArray[i]}) res.push({url: this.resourcesUrl + imageArray[i], response: imageArray[i]})
} }
} }
this.$emit('input', this.value) this.$emit('input', this.value)
...@@ -49,7 +54,7 @@ ...@@ -49,7 +54,7 @@
// 图片上传 // 图片上传
handleUploadSuccess (response, file, fileList) { handleUploadSuccess (response, file, fileList) {
let pics = fileList.map(file => { let pics = fileList.map(file => {
return file.response return file.response.result.filePath
}).join(',') }).join(',')
this.$emit('input', pics) this.$emit('input', pics)
}, },
......
...@@ -2,22 +2,28 @@ ...@@ -2,22 +2,28 @@
<div> <div>
<el-upload <el-upload
class="pic-uploader-component" class="pic-uploader-component"
:action="$http.adornUrl('/admin/file/upload/element')" :action="$http.adornUrl(`/fileBapi/upload`)"
:headers="{Authorization: $cookie.get('Authorization')}" :headers="{Authorization: $cookie.get('Authorization')}"
:show-file-list="false" :show-file-list="false"
:data="obj"
:on-success="handleUploadSuccess" :on-success="handleUploadSuccess"
:before-upload="beforeAvatarUpload"> :before-upload="beforeAvatarUpload"
<img v-if="value" :src="value" class="pic"> >
<img v-if="value" :src="resourcesUrl + value" class="pic">
<i v-else class="el-icon-plus pic-uploader-icon"></i> <i v-else class="el-icon-plus pic-uploader-icon"></i>
</el-upload> </el-upload>
</div> </div>
</template> </template>
<script> <script>
export default { export default {
data () { data () {
return { return {
resourcesUrl: window.SITE_CONFIG.resourcesUrl resourcesUrl: window.SITE_CONFIG.resourcesUrl,
obj : {
fileType: 'sku',
t: new Date().getTime()
}
} }
}, },
props: { props: {
...@@ -29,7 +35,8 @@ ...@@ -29,7 +35,8 @@
methods: { methods: {
// 图片上传 // 图片上传
handleUploadSuccess (response, file, fileList) { handleUploadSuccess (response, file, fileList) {
this.$emit('input', file.response) console.log('file.response',file.response)
this.$emit('input', file.response.result.filePath)
}, },
// 限制图片上传大小 // 限制图片上传大小
beforeAvatarUpload (file) { beforeAvatarUpload (file) {
...@@ -40,7 +47,7 @@ ...@@ -40,7 +47,7 @@
return isLt2M return isLt2M
} }
} }
} }
</script> </script>
<style lang="scss"> <style lang="scss">
...@@ -50,6 +57,7 @@ ...@@ -50,6 +57,7 @@
cursor: pointer; cursor: pointer;
position: relative; position: relative;
overflow: hidden; overflow: hidden;
.pic-uploader-icon { .pic-uploader-icon {
font-size: 28px; font-size: 28px;
color: #8c939d; color: #8c939d;
...@@ -58,12 +66,14 @@ ...@@ -58,12 +66,14 @@
line-height: 178px; line-height: 178px;
text-align: center; text-align: center;
} }
.pic { .pic {
width: 178px; width: 178px;
height: 178px; height: 178px;
display: block; display: block;
} }
} }
.pic-uploader-component .el-upload:hover { .pic-uploader-component .el-upload:hover {
border-color: #409EFF; border-color: #409EFF;
} }
......
...@@ -67,8 +67,8 @@ ...@@ -67,8 +67,8 @@
<el-col :span="8"> <el-col :span="8">
<el-switch <el-switch
v-model="dataForm.commissionStatus" v-model="dataForm.commissionStatus"
active-value="1" :active-value="1"
inactive-value="0"> :inactive-value="0">
</el-switch> </el-switch>
</el-col> </el-col>
</el-form-item> </el-form-item>
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
window.SITE_CONFIG['baseUrl'] = 'http://192.168.0.143:8085' window.SITE_CONFIG['baseUrl'] = 'http://192.168.0.143:8085'
// 静态资源文件url // 静态资源文件url
window.SITE_CONFIG['resourcesUrl'] = 'http://img-test.gz-yami.com/' window.SITE_CONFIG['resourcesUrl'] = 'http://192.168.31.113/zhqgImages'
// cdn地址 = 域名 + 版本号 // cdn地址 = 域名 + 版本号
window.SITE_CONFIG['domain'] = './' // 域名 window.SITE_CONFIG['domain'] = './' // 域名
window.SITE_CONFIG['version'] = '' // 版本号(年月日时分) window.SITE_CONFIG['version'] = '' // 版本号(年月日时分)
......
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