From 673080cda73d88427832ae0d4a072ea0972a35aa Mon Sep 17 00:00:00 2001 From: mutoe Date: Mon, 25 Feb 2019 13:55:06 +0800 Subject: [PATCH] =?UTF-8?q?fix(SPA):=20=E4=BF=AE=E5=A4=8D=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E6=95=B0=E6=8D=AE=E6=97=B6=E6=95=B0=E9=87=8F=E4=BC=A0?= =?UTF-8?q?=E5=87=BA10=E8=80=8C=E5=88=A4=E6=96=AD=E4=B8=BA15=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- resources/spa/src/api/news.js | 2 +- resources/spa/src/api/questions.js | 3 +- resources/spa/src/api/topic.js | 4 +- resources/spa/src/api/user.js | 55 ++++++++++++++----- resources/spa/src/page/UserFans.vue | 5 +- resources/spa/src/page/UserHome.vue | 14 ++--- .../spa/src/page/article/ArticleLikes.vue | 10 ++-- .../spa/src/page/article/ArticleRewards.vue | 10 ++-- resources/spa/src/page/feed/FeedList.vue | 7 ++- resources/spa/src/page/find/FindNer.vue | 5 +- resources/spa/src/page/find/FindNew.vue | 8 ++- resources/spa/src/page/find/FindPop.vue | 9 ++- resources/spa/src/page/find/FindRec.vue | 7 ++- resources/spa/src/page/find/SearchUser.vue | 9 +-- .../spa/src/page/message/list/MyComments.vue | 5 +- .../spa/src/page/message/list/MyLikes.vue | 5 +- .../src/page/message/list/MyNotifications.vue | 5 +- resources/spa/src/page/topic/TopicDetail.vue | 3 +- .../spa/src/page/topic/TopicParticipants.vue | 5 +- .../topic/components/TopicSearchPanel.vue | 7 ++- .../spa/src/stores/module/easemob/actions.js | 3 +- 21 files changed, 116 insertions(+), 65 deletions(-) diff --git a/resources/spa/src/api/news.js b/resources/spa/src/api/news.js index d2bafabdc..ba83687c6 100644 --- a/resources/spa/src/api/news.js +++ b/resources/spa/src/api/news.js @@ -36,7 +36,7 @@ export function getNewsList (params) { * @param {number} type [类型: 0: 已发布, 1: 待审核, 2: 已驳回] * @returns {Promise} */ -export function getMyNews ({ type = 0, limit = 15, after = 0 }) { +export function getMyNews ({ type = 0, after = 0 }) { const params = { type, limit, after } return api.get('/user/news/contributes', { params, diff --git a/resources/spa/src/api/questions.js b/resources/spa/src/api/questions.js index 97e70f3be..023f88de8 100644 --- a/resources/spa/src/api/questions.js +++ b/resources/spa/src/api/questions.js @@ -1,3 +1,4 @@ +import { limit } from './index' import api from './api' /** @@ -27,6 +28,6 @@ export function queryList (params = {}) { * @return {Promise} * @author Seven Du */ -export function list (type, offset = 0, limit = 15) { +export function list (type, offset = 0) { return queryList({ type, limit, offset }) } diff --git a/resources/spa/src/api/topic.js b/resources/spa/src/api/topic.js index 51d6a541a..1694aad1b 100644 --- a/resources/spa/src/api/topic.js +++ b/resources/spa/src/api/topic.js @@ -1,3 +1,4 @@ +import { limit } from './index' import api from './api' /** @@ -7,13 +8,14 @@ import api from './api' * @export * @param {Object} params * @param {string} [params.q] 搜索关键字 - * @param {number} [params.limit=15] + * @param {number} [params.limit] * @param {string} [params.direction=desc] * @param {number} [params.index=0] * @param {string} [params.only] 是否热门 'hot' * @returns */ export function getTopicList (params) { + if (!params.limit) params.limit = limit if (params.q === '') return Promise.resolve({ data: [] }) const url = '/feed/topics' return api.get(url, { params, validateStatus: s => s === 200 }) diff --git a/resources/spa/src/api/user.js b/resources/spa/src/api/user.js index b28c24949..42a292ab0 100644 --- a/resources/spa/src/api/user.js +++ b/resources/spa/src/api/user.js @@ -1,3 +1,4 @@ +import { limit } from './index' import api from './api' import store from '@/stores' import $Message from '@/plugins/message-box' @@ -5,7 +6,8 @@ import lstore from '@/plugins/lstore/lstore.js' /** * 定义用户对象 - * @typedef {{id: number, name: string, ...more}} UserObject + * @typedef {Object} UserObject + * @property {number} id */ const resArray = { data: [] } @@ -89,34 +91,32 @@ export const findUserByType = (type, params) => { * 查找附近的人 * @author jsonleex * @export - * @param {number} options.lng: longitude 经度 - * @param {number} options.lat: latitude 纬度 - * @param {number} page 当前页 + * @param {number} options.lng: longitude 经度 + * @param {number} options.lat: latitude 纬度 + * @param {number} page 当前页 * @returns {Promise} */ export const findNearbyUser = ({ lng: longitude, lat: latitude }, page = 0) => { const params = { - limit: 10, + limit, longitude, latitude, } page > 0 && (params.page = page) - return api - .get('around-amap', { params }) - .then(data => data) + return api.get('around-amap', { params }) .catch(() => resArray) } /** - * 获取用户基本信息 - * 优先返回本地数据 + * 获取用户基本信息 优先返回本地数据 * @author jsonleex * @export - * @param {number} id + * @param {number} id + * @param {boolean} [force=false] * @returns {Promise} */ -export const getUserInfoById = (id, force = false) => { +export async function getUserInfoById (id, force = false) { const user = store.state.USERS[`user_${id}`] if (user && !force) return user @@ -156,7 +156,7 @@ export function getUserList (params) { * @param {number} options.offset * @returns {Promise} */ -export function getUserFansByType ({ uid, type, limit = 15, offset = 0 }) { +export function getUserFansByType ({ uid, type, offset = 0 }) { const params = { limit, offset, @@ -281,3 +281,32 @@ export function reportUser (userId, reason) { const url = `/report/users/${userId}` return api.post(url, { reason }, { validateStatus: s => s === 201 }) } + +/** + * 获取用户标签 + * + * @author mutoe + * @export + * @param {number} userId + * @returns + */ +export function getUserTags (userId) { + const url = `/users/${userId}/tags` + return api.get(url, { validateStatus: s => s === 200 }) +} + +/** + * 获取好友列表 + * + * @author mutoe + * @export + * @param {Object} [params] + * @param {number} [params.offset] + * @param {number} [params.limit] + * @param {string} [params.keyword] + * @returns {UserObject[]} + */ +export function getUserFriends (params) { + const url = '/user/follow-mutual' + return api.get(url, { params, validateStatus: s => s === 200 }) +} diff --git a/resources/spa/src/page/UserFans.vue b/resources/spa/src/page/UserFans.vue index 6a2451ce0..576da2d30 100644 --- a/resources/spa/src/page/UserFans.vue +++ b/resources/spa/src/page/UserFans.vue @@ -47,8 +47,9 @@