|
@@ -6,7 +6,7 @@
|
|
|
</div>
|
|
|
<div class="imgList">
|
|
|
<div v-for="(item, index) in imgList" :key="index" class="imgItem">
|
|
|
- <div class="itemImg" @click="previewImg(pptImgUrl1)">
|
|
|
+ <div class="itemImg" @click="previewImg(item)">
|
|
|
<img :src="item" alt="" />
|
|
|
</div>
|
|
|
<div class="deleteImg" @click="deleteItem(item)">
|
|
@@ -19,9 +19,17 @@
|
|
|
|
|
|
<script>
|
|
|
export default {
|
|
|
+ props: {
|
|
|
+ imgList: {
|
|
|
+ type: Array,
|
|
|
+ default: () => {
|
|
|
+ return []
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
data() {
|
|
|
return {
|
|
|
- imgList: []
|
|
|
+ // imgList: []
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
@@ -34,7 +42,10 @@ export default {
|
|
|
e.target.value = ''
|
|
|
},
|
|
|
deleteItem(i) {
|
|
|
- this.imgList.splice(this.imgList.indexOf(i), 1)
|
|
|
+ const a = JSON.parse(JSON.stringify(this.imgList))
|
|
|
+ a.splice(a.indexOf(i), 1)
|
|
|
+ // this.imgList.splice(this.imgList.indexOf(i), 1)
|
|
|
+ this.$emit('update:imgList', a)
|
|
|
this.$forceUpdate()
|
|
|
},
|
|
|
beforeUpload(event) {
|
|
@@ -42,10 +53,10 @@ export default {
|
|
|
var credentials = {
|
|
|
accessKeyId: 'AKIATLPEDU37QV5CHLMH',
|
|
|
secretAccessKey: 'Q2SQw37HfolS7yeaR1Ndpy9Jl4E2YZKUuuy2muZR'
|
|
|
- } //秘钥形式的登录上传
|
|
|
+ } // 秘钥形式的登录上传
|
|
|
window.AWS.config.update(credentials)
|
|
|
- window.AWS.config.region = 'cn-northwest-1' //设置区域
|
|
|
- var bucket = new window.AWS.S3({ params: { Bucket: 'ccrb' } }) //选择桶
|
|
|
+ window.AWS.config.region = 'cn-northwest-1' // 设置区域
|
|
|
+ var bucket = new window.AWS.S3({ params: { Bucket: 'ccrb' }}) // 选择桶
|
|
|
var _this = this
|
|
|
if (file) {
|
|
|
var params = {
|
|
@@ -58,7 +69,7 @@ export default {
|
|
|
Body: file,
|
|
|
'Access-Control-Allow-Credentials': '*',
|
|
|
ACL: 'public-read'
|
|
|
- } //key可以设置为桶的相抵路径,Body为文件, ACL最好要设置
|
|
|
+ } // key可以设置为桶的相抵路径,Body为文件, ACL最好要设置
|
|
|
var options = {
|
|
|
partSize: 2048 * 1024 * 1024,
|
|
|
queueSize: 2,
|
|
@@ -66,15 +77,22 @@ export default {
|
|
|
}
|
|
|
bucket
|
|
|
.upload(params, options)
|
|
|
- .on('httpUploadProgress', function (evt) {
|
|
|
- //这里可以写进度条
|
|
|
+ .on('httpUploadProgress', function(evt) {
|
|
|
+ // 这里可以写进度条
|
|
|
})
|
|
|
- .send(function (err, data) {
|
|
|
+ .send(function(err, data) {
|
|
|
if (err) {
|
|
|
- _this.$message.error('上传失败')
|
|
|
+ // _this.$message.error('上传失败')
|
|
|
} else {
|
|
|
- _this.imgList.push(data.Location)
|
|
|
- _this.getImage(_this.imgList)
|
|
|
+ _this.$toast({
|
|
|
+ message: '上传成功',
|
|
|
+ type: 'success'
|
|
|
+ })
|
|
|
+ const a = JSON.parse(JSON.stringify(_this.imgList))
|
|
|
+ a.push(data.Location)
|
|
|
+ _this.$emit('update:imgList', a)
|
|
|
+
|
|
|
+ // _this.getImage(_this.imgList)
|
|
|
}
|
|
|
})
|
|
|
}
|
|
@@ -136,4 +154,4 @@ export default {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-</style>
|
|
|
+</style>
|