| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211 |
- export default class PersonalData {
- constructor({ $axios, req, app, redirect, error }) {
- this.$axios = $axios
- this.req = req
- this.app = app
- this.redirect = redirect
- this.error = error
- this.from = ''
- this.isExist = true
- this.pagesize = 10
- }
- async dealData() {
- let {
- name,
- path,
- params,
- fullPath,
- query
- } = this.app.context.route
- let [
- personalUserInfo,
- dynamicData,
- articleCount,
- courseCount,
- adList,
- isFollowing
- ] = await Promise.all([
- this._getPersonalUserInfo(),
- this._getDynamicCount(),
- this._getArticleCount(),
- this._getCourseCount(),
- this._getAdvert(),
- this._getFollowStatus()
- ])
- return {
- isExist: this.isExist,
- mobile: this.app.$deviceType.isMobile(),
- // head: this.dealThisMeta(),
- personalUserInfo,
- dynamicCount:dynamicData.dynamicCount,
- articleCount,
- courseCount,
- list:dynamicData.dynamicList,
- adList,
- isFollowing
- }
- }
- // 获取开发者个人信息
- async _getPersonalUserInfo() {
- let {
- name,
- path,
- params,
- fullPath,
- query
- } = this.app.context.route
- let res = await this.$axios.post('/uapi/user/info/action/other', {
- uid: params.uid
- })
- let personalUserInfo = {}
- if (Number(res.data.status) === 1) {
- personalUserInfo = {
- ...res.data.data
- }
- } else if (Number(res.status) === 40001) {
- this.isExist = false
- }
- return personalUserInfo
- }
- async _getDynamicCount(){
- let {
- name,
- path,
- params,
- fullPath,
- query
- } = this.app.context.route
- let uid = params.uid
- let res = await this.$axios.post('/uapi/dynamic/get_dynamic_list_my', {
- to_uid: params.uid,
- page:1,
- pagesize:10
- })
-
-
- let count = 0
- let dynamicList = []
- if (Number(res.data.status) === 1) {
- count = res.data.data.user.dynamic_num
- dynamicList = res.data.data.list
- } else if (Number(res.status) === 40001) {
- this.isExist = false
- }
- return {
- dynamicList,
- dynamicCount:count
- }
- }
- async _getArticleCount(){
- let {
- name,
- path,
- params,
- fullPath,
- query
- } = this.app.context.route
- let uid = params.uid
- let res = await this.$axios.post('/uapi/news/index/list', {
- uid: params.uid,
- page:1,
- pagesize:1
- })
- let count = 0
- if (Number(res.data.status) === 1) {
- count = res.data.data.total
- } else if (Number(res.status) === 40001) {
- this.isExist = false
- }
- return count
- }
- async _getCourseCount(){
- let {
- name,
- path,
- params,
- fullPath,
- query
- } = this.app.context.route
- let uid = params.uid
- let res = await this.$axios.post('/uapi/goods/video/list', {
- to_uid: params.uid,
- page:1,
- pagesize:1
- })
- let count = 0
- if (Number(res.data.status) === 1) {
- count = res.data.data.total
- } else if (Number(res.status) === 40001) {
- this.isExist = false
- }
- return count
- }
- // 获取广告位
- async _getAdvert() {
- let res = await this.$axios.post('/uapi/pub/adInfo', {
- position: 'personal'
- })
- let adList = []
- if (Number(res.data.status) === 1) {
- adList = {
- ...res.data.data.list
- }
- } else if (Number(res.status) === 40001) {
- this.isExist = false
- }
- return adList
- }
- // 获取当前关注状态
- async _getFollowStatus() {
- let {
- name,
- path,
- params,
- fullPath,
- query
- } = this.app.context.route
- let uid = params.uid
- let res = await this.$axios.post('/uapi/dynamic/check_followers', {
- to_uid: uid
- })
- let isFollowing = false
- if (Number(res.data.status) === 1) {
- if(res.data.data.result == 1){
- isFollowing = true
- }
- } else if (Number(res.status) === 40001) {
- this.isExist = false
- }
- return isFollowing
- }
- }
|