|
@@ -3,99 +3,58 @@
|
|
|
|
|
|
|
|
<file-pond
|
|
<file-pond
|
|
|
ref="pond"
|
|
ref="pond"
|
|
|
- name="file[]"
|
|
|
|
|
|
|
+ name="file"
|
|
|
label-idle="选择图片或拖动图片到此处"
|
|
label-idle="选择图片或拖动图片到此处"
|
|
|
label-file-processing="图片正在上传,请稍后"
|
|
label-file-processing="图片正在上传,请稍后"
|
|
|
label-file-processing-aborted="图片上传被取消"
|
|
label-file-processing-aborted="图片上传被取消"
|
|
|
label-tap-to-retry="尝试重试"
|
|
label-tap-to-retry="尝试重试"
|
|
|
label-file-processing-complete="图片上传成功!"
|
|
label-file-processing-complete="图片上传成功!"
|
|
|
- :allow-multiple="false"
|
|
|
|
|
accepted-file-types="image/png, image/jpeg, image/jpg, image/gif"
|
|
accepted-file-types="image/png, image/jpeg, image/jpg, image/gif"
|
|
|
|
|
+ :allow-multiple="true"
|
|
|
|
|
+ :max-files="9"
|
|
|
:server="server"
|
|
:server="server"
|
|
|
- :files="myFiles"
|
|
|
|
|
- :instant-upload="false"
|
|
|
|
|
- :image-edit-editor="editor"
|
|
|
|
|
- :image-edit-instant-edit="true"
|
|
|
|
|
|
|
+ :instant-upload="true"
|
|
|
@init="handleFilePondInit"
|
|
@init="handleFilePondInit"
|
|
|
@processfile="success"
|
|
@processfile="success"
|
|
|
/>
|
|
/>
|
|
|
- <!-- :instant-upload="false" 关闭立即上传到服务器 -->
|
|
|
|
|
</div>
|
|
</div>
|
|
|
</template>
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
<script>
|
|
|
-// Import Vue FilePond
|
|
|
|
|
import vueFilePond from 'vue-filepond'
|
|
import vueFilePond from 'vue-filepond'
|
|
|
-
|
|
|
|
|
-// Import FilePond styles
|
|
|
|
|
import 'filepond/dist/filepond.min.css'
|
|
import 'filepond/dist/filepond.min.css'
|
|
|
-
|
|
|
|
|
-// Import FilePond plugins
|
|
|
|
|
-// Please note that you need to install these plugins separately
|
|
|
|
|
-
|
|
|
|
|
-// Import image preview plugin styles
|
|
|
|
|
import 'filepond-plugin-image-preview/dist/filepond-plugin-image-preview.min.css'
|
|
import 'filepond-plugin-image-preview/dist/filepond-plugin-image-preview.min.css'
|
|
|
-import 'filepond-plugin-image-edit/dist/filepond-plugin-image-edit.css'
|
|
|
|
|
-// Import image preview and file type validation plugins
|
|
|
|
|
import FilePondPluginFileValidateType from 'filepond-plugin-file-validate-type'
|
|
import FilePondPluginFileValidateType from 'filepond-plugin-file-validate-type'
|
|
|
-import FilePondPluginImageEdit from 'filepond-plugin-image-edit'
|
|
|
|
|
import FilePondPluginImagePreview from 'filepond-plugin-image-preview'
|
|
import FilePondPluginImagePreview from 'filepond-plugin-image-preview'
|
|
|
-import FilePondPluginImageExifOrientation from 'filepond-plugin-image-exif-orientation'
|
|
|
|
|
import FilePondPluginFileValidateSize from 'filepond-plugin-file-validate-size'
|
|
import FilePondPluginFileValidateSize from 'filepond-plugin-file-validate-size'
|
|
|
|
|
+
|
|
|
// Create component
|
|
// Create component
|
|
|
const FilePond = vueFilePond(
|
|
const FilePond = vueFilePond(
|
|
|
FilePondPluginFileValidateType,
|
|
FilePondPluginFileValidateType,
|
|
|
FilePondPluginImagePreview,
|
|
FilePondPluginImagePreview,
|
|
|
- FilePondPluginImageExifOrientation,
|
|
|
|
|
- FilePondPluginFileValidateSize,
|
|
|
|
|
- FilePondPluginImageEdit
|
|
|
|
|
|
|
+ FilePondPluginFileValidateSize
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
-let videMessage = {}
|
|
|
|
|
|
|
+var resp = ''
|
|
|
|
|
|
|
|
export default {
|
|
export default {
|
|
|
- name: 'FilePondUpdate',
|
|
|
|
|
|
|
+ name: 'FilePondImage',
|
|
|
components: {
|
|
components: {
|
|
|
FilePond
|
|
FilePond
|
|
|
},
|
|
},
|
|
|
- videMessage,
|
|
|
|
|
|
|
+ resp,
|
|
|
data() {
|
|
data() {
|
|
|
return {
|
|
return {
|
|
|
- videMessage: {},
|
|
|
|
|
- myFiles: [],
|
|
|
|
|
server: {
|
|
server: {
|
|
|
- url: '/api/file/upload/image',
|
|
|
|
|
|
|
+ url: '//file.reghao.cn/api/file/upload/image',
|
|
|
process: {
|
|
process: {
|
|
|
headers: {
|
|
headers: {
|
|
|
- 'X-XSRF-TOKEN': this.$cookies.get('XSRF-TOKEN')
|
|
|
|
|
|
|
+ 'Authorization': this.$store.getters.token
|
|
|
},
|
|
},
|
|
|
onload(response) {
|
|
onload(response) {
|
|
|
- // 返回上传数据
|
|
|
|
|
- videMessage = JSON.parse(response)
|
|
|
|
|
|
|
+ resp = JSON.parse(response)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- },
|
|
|
|
|
- editor: {
|
|
|
|
|
-
|
|
|
|
|
- // Called by FilePond to edit the image
|
|
|
|
|
- // - should open your image editor
|
|
|
|
|
- // - receives file object and image edit instructions
|
|
|
|
|
- open: (file, instructions) => {
|
|
|
|
|
- // open editor here
|
|
|
|
|
- },
|
|
|
|
|
-
|
|
|
|
|
- // Callback set by FilePond
|
|
|
|
|
- // - should be called by the editor when user confirms editing
|
|
|
|
|
- // - should receive output object, resulting edit information
|
|
|
|
|
- onconfirm: (output) => {},
|
|
|
|
|
-
|
|
|
|
|
- // Callback set by FilePond
|
|
|
|
|
- // - should be called by the editor when user cancels editing
|
|
|
|
|
- oncancel: () => {},
|
|
|
|
|
-
|
|
|
|
|
- // Callback set by FilePond
|
|
|
|
|
- // - should be called by the editor when user closes the editor
|
|
|
|
|
- onclose: () => {}
|
|
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
@@ -103,11 +62,10 @@ export default {
|
|
|
},
|
|
},
|
|
|
methods: {
|
|
methods: {
|
|
|
handleFilePondInit() {
|
|
handleFilePondInit() {
|
|
|
- // console.log('FilePond has initialized')
|
|
|
|
|
// FilePond instance methods are available on `this.$refs.pond`
|
|
// FilePond instance methods are available on `this.$refs.pond`
|
|
|
},
|
|
},
|
|
|
success() {
|
|
success() {
|
|
|
- this.$emit('photo', videMessage)
|
|
|
|
|
|
|
+ this.$emit('resp', resp)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|