|
@@ -7,12 +7,13 @@
|
|
|
<el-upload
|
|
|
:multiple="true"
|
|
|
:file-list="fileList"
|
|
|
+ action="/api/artical/uploadFile"
|
|
|
+ :headers="headers"
|
|
|
:show-file-list="true"
|
|
|
:on-remove="handleRemove"
|
|
|
:on-success="handleSuccess"
|
|
|
:before-upload="beforeUpload"
|
|
|
class="editor-slide-upload"
|
|
|
- action="https://httpbin.org/post"
|
|
|
list-type="picture-card"
|
|
|
>
|
|
|
<el-button size="small" type="primary">
|
|
@@ -30,7 +31,7 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-// import { getToken } from 'api/qiniu'
|
|
|
+import { authDB } from '@/db'
|
|
|
|
|
|
export default {
|
|
|
name: 'EditorSlideUpload',
|
|
@@ -44,7 +45,11 @@ export default {
|
|
|
return {
|
|
|
dialogVisible: false,
|
|
|
listObj: {},
|
|
|
- fileList: []
|
|
|
+ fileList: [],
|
|
|
+ headers:{
|
|
|
+ 'x-token': authDB.get('token'),
|
|
|
+ 'x-user-id': authDB.get('uid')
|
|
|
+ },
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
@@ -53,24 +58,25 @@ export default {
|
|
|
},
|
|
|
handleSubmit() {
|
|
|
const arr = Object.keys(this.listObj).map(v => this.listObj[v])
|
|
|
- if (!this.checkAllSuccess()) {
|
|
|
- this.$message('Please wait for all images to be uploaded successfully. If there is a network problem, please refresh the page and upload again!')
|
|
|
- return
|
|
|
- }
|
|
|
+ // if (!this.checkAllSuccess()) {
|
|
|
+ // this.$message('Please wait for all images to be uploaded successfully. If there is a network problem, please refresh the page and upload again!')
|
|
|
+ // return
|
|
|
+ // }
|
|
|
+ console.log( "this.listObj", this.listObj)
|
|
|
this.$emit('successCBK', arr)
|
|
|
this.listObj = {}
|
|
|
this.fileList = []
|
|
|
this.dialogVisible = false
|
|
|
},
|
|
|
handleSuccess(response, file) {
|
|
|
- const uid = file.uid
|
|
|
- const objKeyArr = Object.keys(this.listObj)
|
|
|
- for (let i = 0, len = objKeyArr.length; i < len; i++) {
|
|
|
- if (this.listObj[objKeyArr[i]].uid === uid) {
|
|
|
- this.listObj[objKeyArr[i]].url = response.files.file
|
|
|
- this.listObj[objKeyArr[i]].hasSuccess = true
|
|
|
- return
|
|
|
- }
|
|
|
+ const uid = response.data.filename
|
|
|
+ this.listObj[uid] = {
|
|
|
+ uid,
|
|
|
+ hasSuccess: true,
|
|
|
+ width: file.width,
|
|
|
+ height: file.height,
|
|
|
+ url : "http://smoa.ndjsxh.cn:8888/api/preview/"+ uid
|
|
|
+ // url : "http://localhost:8000/api/preview/"+ uid
|
|
|
}
|
|
|
},
|
|
|
handleRemove(file) {
|
|
@@ -87,13 +93,15 @@ export default {
|
|
|
const _self = this
|
|
|
const _URL = window.URL || window.webkitURL
|
|
|
const fileName = file.uid
|
|
|
+
|
|
|
+
|
|
|
this.listObj[fileName] = {}
|
|
|
return new Promise((resolve, reject) => {
|
|
|
const img = new Image()
|
|
|
img.src = _URL.createObjectURL(file)
|
|
|
- img.onload = function() {
|
|
|
- _self.listObj[fileName] = { hasSuccess: false, uid: file.uid, width: this.width, height: this.height }
|
|
|
- }
|
|
|
+ // img.onload = function() {
|
|
|
+ // _self.listObj[fileName] = { hasSuccess: false, uid: file.uid, width: this.width, height: this.height }
|
|
|
+ // }
|
|
|
resolve(true)
|
|
|
})
|
|
|
}
|