Commit 85c23e48 by wangyalan-git

修改图片上传/新增佣金

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