mblog.vue 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336
  1. <template>
  2. <v-container class="grey lighten-5">
  3. <v-row justify="space-between">
  4. <v-col>
  5. <v-row dense>
  6. <v-col>
  7. <v-card
  8. color="#385F73"
  9. dark
  10. >
  11. <v-row dense>
  12. <v-textarea
  13. v-model="statusPost.content"
  14. solo
  15. falt
  16. filled
  17. auto-grow
  18. label="说点什么呢?"
  19. rows="3"
  20. />
  21. </v-row>
  22. <v-row>
  23. <v-col>
  24. <!-- 接收 filepond-image 中 this.$emit('resp', resp) 的数据 -->
  25. <FilePondUploadImage @resp="uploadCallback" />
  26. </v-col>
  27. </v-row>
  28. <v-row dense>
  29. <v-col>
  30. <v-card-actions>
  31. <v-btn text @click="publish">
  32. 发布
  33. </v-btn>
  34. </v-card-actions>
  35. </v-col>
  36. </v-row>
  37. </v-card>
  38. </v-col>
  39. <v-col>
  40. <v-sheet
  41. class="mx-auto"
  42. max-width="700"
  43. >
  44. <v-slide-group
  45. multiple
  46. show-arrows
  47. >
  48. <v-slide-item
  49. v-for="n in 25"
  50. :key="n"
  51. v-slot="{ active }"
  52. >
  53. <v-btn
  54. class="mx-2"
  55. :input-value="active"
  56. active-class="purple white--text"
  57. depressed
  58. rounded
  59. @click="selectUser"
  60. >
  61. 关注的用户 {{ n }}
  62. </v-btn>
  63. </v-slide-item>
  64. </v-slide-group>
  65. </v-sheet>
  66. </v-col>
  67. <v-col cols="12">
  68. <v-card
  69. color="#385F73"
  70. dark
  71. >
  72. <v-card-actions @click="selectCategory">
  73. <v-btn text>
  74. 全部
  75. </v-btn>
  76. <v-btn text>
  77. 视频
  78. </v-btn>
  79. <v-btn text>
  80. 图片
  81. </v-btn>
  82. </v-card-actions>
  83. </v-card>
  84. </v-col>
  85. <v-col
  86. v-for="item in list"
  87. :key="item.statusId"
  88. >
  89. <status-card :item="item" />
  90. </v-col>
  91. </v-row>
  92. </v-col>
  93. <v-col md="4">
  94. <v-row dense>
  95. <v-col cols="12">
  96. <v-card
  97. class="mx-auto"
  98. color="#26c6da"
  99. dark
  100. >
  101. <v-card-title>
  102. <v-avatar size="32">
  103. <v-img
  104. :src="this.$store.state.user.userInfo.avatarUrl"
  105. :alt="this.$store.state.user.userInfo.username"
  106. :title="this.$store.state.user.userInfo.username"
  107. />
  108. </v-avatar>
  109. <span class="text-h6 font-weight-light">{{ this.$store.state.user.userInfo.username }}</span>
  110. </v-card-title>
  111. <v-card-text class="text-h5 font-weight-light">
  112. {{ this.$store.state.user.userInfo.intro }}
  113. </v-card-text>
  114. <v-card-text class="text-h5 font-weight-light">
  115. 关注 {{ this.$store.state.user.userInfo.followingCount }} | 被关注 {{ this.$store.state.user.userInfo.followerCount }}
  116. </v-card-text>
  117. </v-card>
  118. </v-col>
  119. <v-col cols="12">
  120. <v-card
  121. color="#385F73"
  122. light
  123. >
  124. <v-card-title class="text-h5">
  125. 热门搜索
  126. </v-card-title>
  127. <v-card-text>
  128. <p class="text-body-1 text--primary">
  129. 1.第1条
  130. </p>
  131. <p class="text-body-1 text--primary">
  132. 2.第2条
  133. </p>
  134. </v-card-text>
  135. </v-card>
  136. </v-col>
  137. <v-col cols="12">
  138. <v-card
  139. color="#385F73"
  140. light
  141. >
  142. <v-card-title class="text-h5">
  143. 热门视频
  144. </v-card-title>
  145. <v-card-text>
  146. <p class="text-body-1 text--primary">
  147. 1.第1条
  148. </p>
  149. <p class="text-body-1 text--primary">
  150. 2.第2条
  151. </p>
  152. </v-card-text>
  153. </v-card>
  154. </v-col>
  155. </v-row>
  156. </v-col>
  157. </v-row>
  158. <v-snackbar
  159. v-model="showMessage"
  160. :top="true"
  161. :timeout="3000"
  162. >
  163. {{ message }}
  164. <template v-slot:action="{ attrs }">
  165. <v-btn
  166. color="pink"
  167. text
  168. v-bind="attrs"
  169. @click="showMessage = false"
  170. >
  171. 关闭
  172. </v-btn>
  173. </template>
  174. </v-snackbar>
  175. </v-container>
  176. </template>
  177. <script>
  178. import { mapActions, mapGetters } from 'vuex'
  179. import { pubStatus, statusRecommend } from '@/api/mblog/status'
  180. import { videoTimeline } from '@/api/media/video'
  181. import StatusCard from '@/components/card/status-card'
  182. import FilePondUploadImage from '@/components/upload/filepond-image.vue'
  183. export default {
  184. name: 'Home',
  185. components: {
  186. StatusCard,
  187. FilePondUploadImage
  188. },
  189. data() {
  190. return {
  191. statusPost: {
  192. uploadIds: [],
  193. content: ''
  194. },
  195. list: [],
  196. busy: false,
  197. page: 1,
  198. model: null,
  199. showMessage: false,
  200. message: ''
  201. }
  202. },
  203. computed: {
  204. ...mapGetters({
  205. statuses: 'my_content',
  206. option: 'my_content_option',
  207. showImage: 'image_zoom_show'
  208. })
  209. },
  210. watch: {
  211. option: {
  212. handler: function(val, oldVal) {
  213. if (val && val.page === 1) {
  214. this.list = []
  215. }
  216. },
  217. deep: true
  218. },
  219. statuses: function(val, oldVal) {
  220. if (val) {
  221. if (this.option.page === 1) {
  222. this.list = val
  223. } else {
  224. this.list = [...this.list, ...val]
  225. }
  226. }
  227. }
  228. },
  229. created() {
  230. this.getFollowingStatus(this.page)
  231. this.getTimeline(this.page)
  232. },
  233. mounted() {
  234. },
  235. methods: {
  236. ...mapActions([
  237. 'getMyContent'
  238. ]),
  239. loadMore: function() {
  240. this.busy = true
  241. setTimeout(() => {
  242. this.getFollowingStatus(this.page)
  243. }, 1000)
  244. },
  245. getTimeline(page) {
  246. videoTimeline(page)
  247. .then(res => {
  248. if (res.code === 0) {
  249. for (const item of res.data.list) {
  250. console.log(item)
  251. }
  252. this.page += 1
  253. this.busy = false
  254. } else {
  255. this.message = res.msg
  256. this.showMessage = true
  257. }
  258. })
  259. .catch(error => {
  260. this.message = error.message
  261. this.showMessage = true
  262. })
  263. },
  264. getFollowingStatus(page) {
  265. statusRecommend(page)
  266. .then(res => {
  267. if (res.code === 0) {
  268. for (const item of res.data.list) {
  269. this.list.push(item)
  270. }
  271. this.page += 1
  272. this.busy = false
  273. } else {
  274. this.message = res.msg
  275. this.showMessage = true
  276. }
  277. })
  278. .catch(error => {
  279. this.message = error.message
  280. this.showMessage = true
  281. })
  282. },
  283. myContent(page) {
  284. this.getMyContent(page)
  285. },
  286. selectUser() {
  287. console.log('加载选中用户的状态...')
  288. },
  289. selectCategory() {
  290. console.log('加载选中分类的用户状态...')
  291. },
  292. uploadCallback(resp) {
  293. if (resp.code === 0) {
  294. this.statusPost.uploadIds.push(resp.data.uploadId)
  295. } else {
  296. if (resp.msg != null) {
  297. this.message = '上传文件出现异常,请重新上传!' + resp.msg
  298. } else {
  299. this.message = '上传文件出现异常,请重新上传!'
  300. }
  301. this.showMessage = true
  302. }
  303. },
  304. setFile() {
  305. console.log('选择文件')
  306. },
  307. publish() {
  308. if (this.statusPost.content === '') {
  309. this.message = '内容不能为空'
  310. this.showMessage = true
  311. }
  312. pubStatus(this.statusPost)
  313. .then(res => {
  314. if (res.code === 0) {
  315. this.message = '状态已发布'
  316. this.showMessage = true
  317. } else {
  318. this.message = res.msg
  319. this.showMessage = true
  320. }
  321. })
  322. .catch(error => {
  323. this.message = error.message
  324. this.showMessage = true
  325. })
  326. }
  327. }
  328. }
  329. </script>
  330. <style>
  331. </style>