|
|
@@ -22,7 +22,30 @@
|
|
|
<v-row>
|
|
|
<v-col>
|
|
|
<!-- 接收 filepond-image 中 this.$emit('resp', resp) 的数据 -->
|
|
|
- <FilePondUploadImage @resp="uploadCallback" />
|
|
|
+ <!--<FilePondUploadImage @resp="uploadCallback" />-->
|
|
|
+ <div>
|
|
|
+ <file-pond
|
|
|
+ ref="pond"
|
|
|
+ name="file"
|
|
|
+ label-idle="选择图片或拖动图片到此处"
|
|
|
+ label-file-processing="图片正在上传,请稍后"
|
|
|
+ label-file-processing-aborted="图片上传被取消"
|
|
|
+ label-tap-to-retry="尝试重试"
|
|
|
+ label-file-processing-complete="图片上传成功!"
|
|
|
+ label-max-file-size="上传的图片大小不能超过 10MB"
|
|
|
+ label-max-file-size-exceeded="上传的图片大小不能超过 10MB"
|
|
|
+ allow-file-size-validation="true"
|
|
|
+ max-file-size="10MB"
|
|
|
+ accepted-file-types="image/png, image/jpeg, image/jpg, image/gif"
|
|
|
+ :allow-multiple="true"
|
|
|
+ :max-files="12"
|
|
|
+ :server="server"
|
|
|
+ :instant-upload="true"
|
|
|
+ @init="handleFilePondInit"
|
|
|
+ @processfile="success"
|
|
|
+ @removefile="removeFile"
|
|
|
+ />
|
|
|
+ </div>
|
|
|
</v-col>
|
|
|
</v-row>
|
|
|
<v-row dense>
|
|
|
@@ -39,49 +62,30 @@
|
|
|
<v-col>
|
|
|
<v-sheet
|
|
|
class="mx-auto"
|
|
|
- max-width="700"
|
|
|
- >
|
|
|
- <v-slide-group
|
|
|
- show-arrows
|
|
|
- >
|
|
|
- <v-slide-item
|
|
|
- v-for="item in 10"
|
|
|
- :key="item"
|
|
|
- v-slot="{ active }"
|
|
|
- >
|
|
|
- <v-btn
|
|
|
- class="mx-2"
|
|
|
- :input-value="active"
|
|
|
- active-class="purple white--text"
|
|
|
- depressed
|
|
|
- rounded
|
|
|
- @click="selectFollowingUser"
|
|
|
- >
|
|
|
- 关注的用户 {{ item }}
|
|
|
- <!--{{ item.username }}-->
|
|
|
- <!--{{ this.$store.state.user.userInfo.username }}-->
|
|
|
- </v-btn>
|
|
|
- </v-slide-item>
|
|
|
- </v-slide-group>
|
|
|
- </v-sheet>
|
|
|
+ max-width="720"
|
|
|
+ />
|
|
|
</v-col>
|
|
|
- <div v-infinite-scroll="loadMore" infinite-scroll-disabled="true" infinite-scroll-distance="10">
|
|
|
- <v-col cols="12">
|
|
|
- <v-tabs>
|
|
|
- <v-tab @click="setType(0)">状态</v-tab>
|
|
|
- <v-tab @click="setType(1)">视频</v-tab>
|
|
|
- <v-tab @click="setType(2)">回答</v-tab>
|
|
|
- </v-tabs>
|
|
|
+ <v-col>
|
|
|
+ <div v-infinite-scroll="loadMore" infinite-scroll-disabled="true" infinite-scroll-distance="10">
|
|
|
+ <v-col cols="12">
|
|
|
+ <v-tabs>
|
|
|
+ <v-tab @click="setType(0)">状态</v-tab>
|
|
|
+ <v-tab @click="setType(1)">视频</v-tab>
|
|
|
+ <v-tab @click="setType(2)">回答</v-tab>
|
|
|
+ </v-tabs>
|
|
|
|
|
|
- <v-row
|
|
|
+ <v-row
|
|
|
v-for="item in cardList"
|
|
|
:key="item.statusId"
|
|
|
- >
|
|
|
- <status-card v-if="cardType === 'status'" :item="item" />
|
|
|
- <item-card v-if="cardType === 'video'" :video="item" />
|
|
|
- </v-row>
|
|
|
- </v-col>
|
|
|
- </div>
|
|
|
+ dense
|
|
|
+ >
|
|
|
+ <status-card v-if="cardType === 'status'" :item="item" />
|
|
|
+ <item-card v-if="cardType === 'video'" :video="item" />
|
|
|
+ <status-card v-if="cardType === 'answer'" :item="item" />
|
|
|
+ </v-row>
|
|
|
+ </v-col>
|
|
|
+ </div>
|
|
|
+ </v-col>
|
|
|
</v-row>
|
|
|
</v-col>
|
|
|
<v-col md="4">
|
|
|
@@ -176,20 +180,49 @@ import { pubStatus, statusRecommend } from '@/api/mblog/status'
|
|
|
import { videoTimeline } from '@/api/media/video'
|
|
|
import StatusCard from '@/components/card/status-card'
|
|
|
import ItemCard from '@/components/card/item-card'
|
|
|
-import FilePondUploadImage from '@/components/upload/filepond-image.vue'
|
|
|
+import VueFilePond from 'vue-filepond'
|
|
|
+import 'filepond/dist/filepond.min.css'
|
|
|
+import FilePondPluginImagePreview from 'filepond-plugin-image-preview'
|
|
|
+import 'filepond-plugin-image-preview/dist/filepond-plugin-image-preview.min.css'
|
|
|
+import FilePondPluginFileValidateType from 'filepond-plugin-file-validate-type'
|
|
|
+import FilePondPluginFileValidateSize from 'filepond-plugin-file-validate-size'
|
|
|
+
|
|
|
+const FilePond = VueFilePond(
|
|
|
+ FilePondPluginFileValidateType,
|
|
|
+ FilePondPluginImagePreview,
|
|
|
+ FilePondPluginFileValidateSize
|
|
|
+)
|
|
|
+var resp = ''
|
|
|
|
|
|
export default {
|
|
|
name: 'Home',
|
|
|
components: {
|
|
|
+ FilePond,
|
|
|
StatusCard,
|
|
|
- ItemCard,
|
|
|
- FilePondUploadImage
|
|
|
+ ItemCard
|
|
|
},
|
|
|
data() {
|
|
|
return {
|
|
|
+ imgMap: {},
|
|
|
+ server: {
|
|
|
+ url: '//file.reghao.cn/api/file/upload/image',
|
|
|
+ revert: null,
|
|
|
+ process: {
|
|
|
+ headers: {
|
|
|
+ 'Authorization': this.$store.getters.token
|
|
|
+ },
|
|
|
+ ondata(formData) {
|
|
|
+ return formData
|
|
|
+ },
|
|
|
+ onload(response) {
|
|
|
+ resp = JSON.parse(response)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
statusPost: {
|
|
|
- imageFileIds: [],
|
|
|
- content: ''
|
|
|
+ imageUrls: [],
|
|
|
+ content: '',
|
|
|
+ location: ''
|
|
|
},
|
|
|
cardType: null,
|
|
|
cardList: [],
|
|
|
@@ -239,6 +272,49 @@ export default {
|
|
|
...mapActions([
|
|
|
'getMyContent'
|
|
|
]),
|
|
|
+ handleFilePondInit() {
|
|
|
+ // FilePond instance methods are available on `this.$refs.pond`
|
|
|
+ },
|
|
|
+ success(error, metadata) {
|
|
|
+ if (error === null) {
|
|
|
+ if (resp.code === 0) {
|
|
|
+ const file = metadata.file
|
|
|
+ const filename = file.name
|
|
|
+ this.imgMap[filename] = resp.data.uploadId
|
|
|
+
|
|
|
+ const imageUrl = {}
|
|
|
+ imageUrl.imageFileId = resp.data.imageFileId
|
|
|
+ imageUrl.thumbnailUrl = resp.data.thumbnailUrl
|
|
|
+ imageUrl.originalUrl = resp.data.originalUrl
|
|
|
+ this.statusPost.imageUrls.push(imageUrl)
|
|
|
+ } else {
|
|
|
+ if (resp.msg != null) {
|
|
|
+ this.message = '上传文件出现异常,请重新上传!' + resp.msg
|
|
|
+ } else {
|
|
|
+ this.message = '上传文件出现异常,请重新上传!'
|
|
|
+ }
|
|
|
+ this.showMessage = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ removeFile(error, metadata) {
|
|
|
+ if (error === null) {
|
|
|
+ const file = metadata.file
|
|
|
+ const uploadId = this.imgMap[file.name]
|
|
|
+ fetch('http://file.reghao.cn/api/file/rm/' + uploadId, {
|
|
|
+ headers: {
|
|
|
+ 'Authorization': this.$store.getters.token
|
|
|
+ },
|
|
|
+ method: 'DELETE'
|
|
|
+ }).then(response => response.json())
|
|
|
+ .then(json => {
|
|
|
+ console.log('删除 this.statusPost.imageUrls 中相应的图片')
|
|
|
+ })
|
|
|
+ .catch(e => {
|
|
|
+ return null
|
|
|
+ })
|
|
|
+ }
|
|
|
+ },
|
|
|
setType(type) {
|
|
|
if (type === this.type) {
|
|
|
return
|
|
|
@@ -326,27 +402,17 @@ export default {
|
|
|
selectFollowingUser() {
|
|
|
console.log('加载选中用户的状态...')
|
|
|
},
|
|
|
- uploadCallback(resp) {
|
|
|
- if (resp.code === 0) {
|
|
|
- this.statusPost.imageFileIds.push(resp.data.uploadId)
|
|
|
- } else {
|
|
|
- if (resp.msg != null) {
|
|
|
- this.message = '上传文件出现异常,请重新上传!' + resp.msg
|
|
|
- } else {
|
|
|
- this.message = '上传文件出现异常,请重新上传!'
|
|
|
- }
|
|
|
- this.showMessage = true
|
|
|
- }
|
|
|
- },
|
|
|
publish() {
|
|
|
if (this.statusPost.content === '') {
|
|
|
this.message = '内容不能为空'
|
|
|
this.showMessage = true
|
|
|
+ return
|
|
|
}
|
|
|
|
|
|
pubStatus(this.statusPost)
|
|
|
.then(res => {
|
|
|
if (res.code === 0) {
|
|
|
+ // TODO 发布成功后应该清除本地文本和图片数据
|
|
|
this.message = '状态已发布'
|
|
|
this.showMessage = true
|
|
|
} else {
|