| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336 |
- <template>
- <v-container class="grey lighten-5">
- <v-row justify="space-between">
- <v-col>
- <v-row dense>
- <v-col>
- <v-card
- color="#385F73"
- dark
- >
- <v-row dense>
- <v-textarea
- v-model="statusPost.content"
- solo
- falt
- filled
- auto-grow
- label="说点什么呢?"
- rows="3"
- />
- </v-row>
- <v-row>
- <v-col>
- <!-- 接收 filepond-image 中 this.$emit('resp', resp) 的数据 -->
- <FilePondUploadImage @resp="uploadCallback" />
- </v-col>
- </v-row>
- <v-row dense>
- <v-col>
- <v-card-actions>
- <v-btn text @click="publish">
- 发布
- </v-btn>
- </v-card-actions>
- </v-col>
- </v-row>
- </v-card>
- </v-col>
- <v-col>
- <v-sheet
- class="mx-auto"
- max-width="700"
- >
- <v-slide-group
- multiple
- show-arrows
- >
- <v-slide-item
- v-for="n in 25"
- :key="n"
- v-slot="{ active }"
- >
- <v-btn
- class="mx-2"
- :input-value="active"
- active-class="purple white--text"
- depressed
- rounded
- @click="selectUser"
- >
- 关注的用户 {{ n }}
- </v-btn>
- </v-slide-item>
- </v-slide-group>
- </v-sheet>
- </v-col>
- <v-col cols="12">
- <v-card
- color="#385F73"
- dark
- >
- <v-card-actions @click="selectCategory">
- <v-btn text>
- 全部
- </v-btn>
- <v-btn text>
- 视频
- </v-btn>
- <v-btn text>
- 图片
- </v-btn>
- </v-card-actions>
- </v-card>
- </v-col>
- <v-col
- v-for="item in list"
- :key="item.statusId"
- >
- <status-card :item="item" />
- </v-col>
- </v-row>
- </v-col>
- <v-col md="4">
- <v-row dense>
- <v-col cols="12">
- <v-card
- class="mx-auto"
- color="#26c6da"
- dark
- >
- <v-card-title>
- <v-avatar size="32">
- <v-img
- :src="this.$store.state.user.userInfo.avatarUrl"
- :alt="this.$store.state.user.userInfo.username"
- :title="this.$store.state.user.userInfo.username"
- />
- </v-avatar>
- <span class="text-h6 font-weight-light">{{ this.$store.state.user.userInfo.username }}</span>
- </v-card-title>
- <v-card-text class="text-h5 font-weight-light">
- {{ this.$store.state.user.userInfo.intro }}
- </v-card-text>
- <v-card-text class="text-h5 font-weight-light">
- 关注 {{ this.$store.state.user.userInfo.followingCount }} | 被关注 {{ this.$store.state.user.userInfo.followerCount }}
- </v-card-text>
- </v-card>
- </v-col>
- <v-col cols="12">
- <v-card
- color="#385F73"
- light
- >
- <v-card-title class="text-h5">
- 热门搜索
- </v-card-title>
- <v-card-text>
- <p class="text-body-1 text--primary">
- 1.第1条
- </p>
- <p class="text-body-1 text--primary">
- 2.第2条
- </p>
- </v-card-text>
- </v-card>
- </v-col>
- <v-col cols="12">
- <v-card
- color="#385F73"
- light
- >
- <v-card-title class="text-h5">
- 热门视频
- </v-card-title>
- <v-card-text>
- <p class="text-body-1 text--primary">
- 1.第1条
- </p>
- <p class="text-body-1 text--primary">
- 2.第2条
- </p>
- </v-card-text>
- </v-card>
- </v-col>
- </v-row>
- </v-col>
- </v-row>
- <v-snackbar
- v-model="showMessage"
- :top="true"
- :timeout="3000"
- >
- {{ message }}
- <template v-slot:action="{ attrs }">
- <v-btn
- color="pink"
- text
- v-bind="attrs"
- @click="showMessage = false"
- >
- 关闭
- </v-btn>
- </template>
- </v-snackbar>
- </v-container>
- </template>
- <script>
- import { mapActions, mapGetters } from 'vuex'
- import { pubStatus, statusRecommend } from '@/api/mblog/status'
- import { videoTimeline } from '@/api/media/video'
- import StatusCard from '@/components/card/status-card'
- import FilePondUploadImage from '@/components/upload/filepond-image.vue'
- export default {
- name: 'Home',
- components: {
- StatusCard,
- FilePondUploadImage
- },
- data() {
- return {
- statusPost: {
- uploadIds: [],
- content: ''
- },
- list: [],
- busy: false,
- page: 1,
- model: null,
- showMessage: false,
- message: ''
- }
- },
- computed: {
- ...mapGetters({
- statuses: 'my_content',
- option: 'my_content_option',
- showImage: 'image_zoom_show'
- })
- },
- watch: {
- option: {
- handler: function(val, oldVal) {
- if (val && val.page === 1) {
- this.list = []
- }
- },
- deep: true
- },
- statuses: function(val, oldVal) {
- if (val) {
- if (this.option.page === 1) {
- this.list = val
- } else {
- this.list = [...this.list, ...val]
- }
- }
- }
- },
- created() {
- this.getFollowingStatus(this.page)
- this.getTimeline(this.page)
- },
- mounted() {
- },
- methods: {
- ...mapActions([
- 'getMyContent'
- ]),
- loadMore: function() {
- this.busy = true
- setTimeout(() => {
- this.getFollowingStatus(this.page)
- }, 1000)
- },
- getTimeline(page) {
- videoTimeline(page)
- .then(res => {
- if (res.code === 0) {
- for (const item of res.data.list) {
- console.log(item)
- }
- this.page += 1
- this.busy = false
- } else {
- this.message = res.msg
- this.showMessage = true
- }
- })
- .catch(error => {
- this.message = error.message
- this.showMessage = true
- })
- },
- getFollowingStatus(page) {
- statusRecommend(page)
- .then(res => {
- if (res.code === 0) {
- for (const item of res.data.list) {
- this.list.push(item)
- }
- this.page += 1
- this.busy = false
- } else {
- this.message = res.msg
- this.showMessage = true
- }
- })
- .catch(error => {
- this.message = error.message
- this.showMessage = true
- })
- },
- myContent(page) {
- this.getMyContent(page)
- },
- selectUser() {
- console.log('加载选中用户的状态...')
- },
- selectCategory() {
- console.log('加载选中分类的用户状态...')
- },
- uploadCallback(resp) {
- if (resp.code === 0) {
- this.statusPost.uploadIds.push(resp.data.uploadId)
- } else {
- if (resp.msg != null) {
- this.message = '上传文件出现异常,请重新上传!' + resp.msg
- } else {
- this.message = '上传文件出现异常,请重新上传!'
- }
- this.showMessage = true
- }
- },
- setFile() {
- console.log('选择文件')
- },
- publish() {
- if (this.statusPost.content === '') {
- this.message = '内容不能为空'
- this.showMessage = true
- }
- pubStatus(this.statusPost)
- .then(res => {
- if (res.code === 0) {
- this.message = '状态已发布'
- this.showMessage = true
- } else {
- this.message = res.msg
- this.showMessage = true
- }
- })
- .catch(error => {
- this.message = error.message
- this.showMessage = true
- })
- }
- }
- }
- </script>
- <style>
- </style>
|