index.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  1. <template>
  2. <div>
  3. <!--<v-container fill-height fluid style="padding: 0px;">
  4. <v-row>
  5. <v-col style="padding: 0px;">
  6. <v-img :src="userInfo.backgroundUrl" :aspect-ratio="5.98" />
  7. </v-col>
  8. </v-row>
  9. </v-container>-->
  10. <v-container fill-height>
  11. <v-row align="center">
  12. <v-col
  13. cols="12"
  14. md="8"
  15. >
  16. <v-avatar size="80" style="float: left;">
  17. <v-img :src="userInfo.avatarUrl" />
  18. </v-avatar>
  19. <h2 style="margin-top: 20px;margin-left: 100px;">
  20. {{ userInfo.username }}
  21. <v-chip color="yellow" @click="goToVip()">
  22. <!--<v-chip v-if="Power.checkPower(userInfo) === 'vip'" color="yellow" @click="goTOVIP()">-->
  23. 小会员
  24. </v-chip>
  25. </h2>
  26. </v-col>
  27. <v-col
  28. v-if="userInfo && userInfo.userId !== userId"
  29. cols="6"
  30. md="4"
  31. class="hidden-sm-and-down ml-0 pl-4"
  32. >
  33. <!--<v-btn color="primary" @click="goToSetting">自定义频道</v-btn> <v-btn color="primary" @click="goToStudio">创作中心</v-btn>-->
  34. <v-btn color="primary">关注他</v-btn>
  35. </v-col>
  36. </v-row>
  37. <v-row>
  38. <v-col>
  39. {{ userInfo.intro }}
  40. </v-col>
  41. </v-row>
  42. <v-row>
  43. <v-col
  44. v-if="userInfo || userInfo.userId !== userId"
  45. cols="6"
  46. md="4"
  47. >
  48. 关注数: {{ userInfo.followerCount }}
  49. 粉丝数: {{ userInfo.followerCount }}
  50. </v-col>
  51. </v-row>
  52. <v-tabs>
  53. <v-tab @click="setType(0)">视频</v-tab>
  54. <v-tab @click="setType(1)">状态</v-tab>
  55. <v-tab @click="setType(2)">评论</v-tab>
  56. </v-tabs>
  57. </v-container>
  58. <v-divider />
  59. <v-container fill-height>
  60. <div id="top" />
  61. <div v-if="type === 4">
  62. <v-row>
  63. <v-col>
  64. 用户名: {{ userInfo.username }}
  65. </v-col>
  66. </v-row>
  67. <v-row>
  68. <v-col>
  69. 简介: {{ userInfo.intro }}
  70. </v-col>
  71. </v-row>
  72. <v-row>
  73. <v-col>
  74. 视频总数: {{ userInfo.submitCount }}
  75. </v-col>
  76. </v-row>
  77. <v-row>
  78. <v-col>
  79. 粉丝数: {{ userInfo.followerCount }}
  80. </v-col>
  81. </v-row>
  82. <v-row>
  83. <v-col>
  84. 关注数: {{ userInfo.followingCount }}
  85. </v-col>
  86. </v-row>
  87. <v-row>
  88. <v-col>
  89. 加入时间: {{ TimeUtil.renderTime(userInfo.createTime) }}
  90. </v-col>
  91. </v-row>
  92. </div>
  93. <v-row v-if="type === 0">
  94. <v-col
  95. v-for="item in videoList"
  96. :key="item.id"
  97. cols="12"
  98. >
  99. <VideoList :video="item" />
  100. </v-col>
  101. </v-row>
  102. <v-row justify="center">
  103. <v-pagination
  104. v-model="page"
  105. :length="length"
  106. @input="pageChange"
  107. />
  108. </v-row>
  109. </v-container>
  110. </div>
  111. </template>
  112. <script>
  113. import { userVideoList } from '@/api/media/video'
  114. import Power from '@/utils/check-power.vue'
  115. import VideoList from '@/components/player/video-list.vue'
  116. import TimeUtil from '@/utils/time-util.vue'
  117. export default {
  118. name: 'UserHome',
  119. components: {
  120. VideoList
  121. },
  122. data() {
  123. return {
  124. TimeUtil,
  125. Power,
  126. userId: 0,
  127. userInfo: {},
  128. videoList: [],
  129. page: 1,
  130. size: 20,
  131. length: 1,
  132. totalCount: 0,
  133. type: 0
  134. }
  135. },
  136. created() {
  137. this.userId = parseInt(this.$route.params.userId)
  138. this.getUserInfo()
  139. this.getVideoList()
  140. },
  141. methods: {
  142. getUserInfo() {
  143. if (this.$store.state.user.userInfo !== null && this.$store.state.user.userInfo.userId === this.userId) {
  144. this.userInfo = this.$store.state.user.userInfo
  145. document.title = this.userInfo.username
  146. } else {
  147. fetch(`/api/user/info/${this.userId}`, {
  148. headers: {
  149. 'Content-Type': 'application/json; charset=UTF-8',
  150. 'X-XSRF-TOKEN': this.$cookies.get('XSRF-TOKEN')
  151. },
  152. method: 'GET',
  153. credentials: 'include'
  154. }).then(response => response.json())
  155. .then(json => {
  156. this.userInfo = json.data
  157. document.title = json.data.username
  158. if (json.data.id === -1) {
  159. this.$router.push('/404')
  160. }
  161. })
  162. .catch(e => {
  163. return null
  164. })
  165. }
  166. },
  167. getStatusList() {
  168. console.log('获取状态列表')
  169. },
  170. getVideoList() {
  171. console.log('获取视频列表')
  172. userVideoList(this.userId).then(res => {
  173. if (res.code === 0) {
  174. for (const item of res.data.list) {
  175. this.videoList.push(item)
  176. }
  177. this.page += 1
  178. this.busy = false
  179. } else {
  180. this.$notify({
  181. title: res.code,
  182. message: res.msg,
  183. type: 'warning',
  184. duration: 500
  185. })
  186. }
  187. })
  188. .catch(error => {
  189. console.error(error.message)
  190. })
  191. /* fetch(`/api/article/user/list/${this.userId}?page=${this.page}&limit=${this.size}&type=${this.type}`, {
  192. headers: {
  193. 'Content-Type': 'application/json; charset=UTF-8',
  194. 'X-XSRF-TOKEN': this.$cookies.get('XSRF-TOKEN')
  195. },
  196. method: 'GET',
  197. credentials: 'include'
  198. }).then(response => response.json())
  199. .then(json => {
  200. this.videoList = json.data.list
  201. this.page = json.data.currPage
  202. this.length = json.data.totalPage
  203. this.totalCount = json.data.totalCount
  204. })
  205. .catch(e => {
  206. return null
  207. })*/
  208. },
  209. getCommentList() {
  210. console.log('获取评论列表')
  211. },
  212. pageChange(page) {
  213. this.page = page
  214. this.getVideoList(this.type)
  215. this.$vuetify.goTo(0)
  216. },
  217. setType(type) {
  218. if (type === this.type) {
  219. return
  220. }
  221. this.type = type
  222. this.page = 1
  223. if (type === 0) {
  224. this.getVideoList()
  225. this.$vuetify.goTo(type)
  226. } else if (type === 1) {
  227. this.getStatusList()
  228. this.$vuetify.goTo(type)
  229. } else if (type === 2) {
  230. this.getCommentList()
  231. this.$vuetify.goTo(type)
  232. }
  233. },
  234. goToVip() {
  235. this.$router.push('/vip')
  236. },
  237. goToStudio() {
  238. this.$router.push('/studio')
  239. },
  240. goToSetting() {
  241. this.$router.push('/user/setting')
  242. }
  243. }
  244. }
  245. </script>
  246. <style>
  247. </style>