feat: 对接真实数据并移除前端假数据
本次提交完成多模块真实数据对接,移除前端硬编码假数据: - 新增后端接口:区域列表、未读消息数、详情页评价列表、最低提现金额 - 前端对应修改:移除首页/列表/详情页硬编码区域选项、未读消息数、评价内容,分销页最低提现金额 - 修复登录页微信授权不伪造code、营业执照不伪造文件名,避免绕过校验 - 新增集成测试用例,验证真实数据对接正确性
这个提交包含在:
@@ -18,6 +18,8 @@ export const homeApi = {
|
||||
feed: (params = {}) => get('/home/feed', params, { silent: true }),
|
||||
/** 热门搜索词 */
|
||||
hotKeywords: () => get('/home/search/hot', {}, { silent: true }),
|
||||
/** 区域列表(后台「区域管理」下发,供首页/列表/发布页筛选项使用) → [string] */
|
||||
areas: () => get('/home/areas', {}, { silent: true }),
|
||||
}
|
||||
|
||||
export default homeApi
|
||||
|
||||
@@ -7,6 +7,8 @@ import { get, post } from '../utils/request.js'
|
||||
export const messageApi = {
|
||||
/** 消息列表(type: system / interact) */
|
||||
list: (params = {}) => get('/message/list', params, { silent: true }),
|
||||
/** 未读消息数(首页角标) → { count } */
|
||||
unreadCount: () => get('/message/unread-count', {}, { silent: true }),
|
||||
/** 标记已读 */
|
||||
read: (id) => post(`/message/${id}/read`, {}, { silent: true }),
|
||||
}
|
||||
|
||||
@@ -63,6 +63,8 @@ export const postApi = {
|
||||
payView: (id, payload) => post(`/post/${id}/pay-view`, payload, { silent: true }),
|
||||
/** 发表评价(评分 + 图文) */
|
||||
comment: (id, payload) => post(`/post/${id}/comment`, payload, { silent: true }),
|
||||
/** 评价列表(详情页「用户评价」,替代前端写死的假评价) */
|
||||
comments: (id) => get(`/post/${id}/comments`, {}, { silent: true }),
|
||||
}
|
||||
|
||||
export default postApi
|
||||
|
||||
@@ -242,6 +242,7 @@ export const datasets = {
|
||||
l2Count: 16,
|
||||
inviteCode: 'TC8A9K',
|
||||
posterUrl: '',
|
||||
minWithdraw: 50,
|
||||
},
|
||||
|
||||
/** 分销团队 */
|
||||
|
||||
@@ -188,6 +188,14 @@ export const mockRoutes = {
|
||||
return ok(paginate(list, data && data.page, data && data.size))
|
||||
},
|
||||
'GET /home/search/hot': () => ok(datasets.hotKeywords),
|
||||
// 区域列表:与后台「区域管理」同源,仅下发启用项并按 sort 升序(返回名称数组)
|
||||
'GET /home/areas': () =>
|
||||
ok(
|
||||
datasets.areas
|
||||
.filter((a) => a.enabled)
|
||||
.sort((a, b) => (a.sort || 0) - (b.sort || 0))
|
||||
.map((a) => a.name)
|
||||
),
|
||||
|
||||
// ==================== 用户端 · 信息发布 ====================
|
||||
'POST /post/upload': ({ data }) => {
|
||||
@@ -359,6 +367,20 @@ export const mockRoutes = {
|
||||
if (data.score && (data.score < 1 || data.score > 5)) fail('评分需在 1-5 之间')
|
||||
return ok({ commentId: Date.now(), ...data })
|
||||
},
|
||||
// 评价列表(与后端 Post::comments 出参对齐:仅展示字段,按置顶+时间倒序)
|
||||
'GET /post/:id/comments': ({ params }) =>
|
||||
ok(
|
||||
datasets.comments
|
||||
.filter((c) => String(c.postId) === String(params.id))
|
||||
.map((c) => ({
|
||||
id: c.id,
|
||||
user: c.user,
|
||||
score: c.score,
|
||||
content: c.content,
|
||||
reply: c.reply,
|
||||
createdAt: c.createdAt,
|
||||
}))
|
||||
),
|
||||
|
||||
// ==================== 用户端 · 会员中心 ====================
|
||||
'GET /member/plans': () => ok(datasets.memberPlans),
|
||||
@@ -547,6 +569,8 @@ export const mockRoutes = {
|
||||
return ok(paginate(list, data && data.page, data && data.size))
|
||||
},
|
||||
'POST /message/:id/read': () => ok({ read: true }),
|
||||
'GET /message/unread-count': () =>
|
||||
ok({ count: datasets.messages.filter((m) => !m.read).length }),
|
||||
|
||||
// ==================== 后台管理端 · 数据总览 ====================
|
||||
'GET /admin/dashboard/overview': () => ok(datasets.dashboard.overview),
|
||||
|
||||
@@ -11,7 +11,8 @@ const state = reactive({
|
||||
token: storage.get(config.storageKeys.token, ''),
|
||||
userInfo: storage.get(config.storageKeys.userInfo, null),
|
||||
userType: Number(storage.get(config.storageKeys.userType, config.constants.USER_TYPE.PERSON)),
|
||||
unread: 2,
|
||||
// 未读消息数由 /message/unread-count 实时拉取,不在此写死
|
||||
unread: 0,
|
||||
})
|
||||
|
||||
export const useUserStore = () => {
|
||||
|
||||
在新工单中引用
屏蔽一个用户