diff --git a/application/api/controller/Distribution.php b/application/api/controller/Distribution.php index 286131e..3bcfcee 100644 --- a/application/api/controller/Distribution.php +++ b/application/api/controller/Distribution.php @@ -16,7 +16,7 @@ class Distribution extends V1 { /** * D1 分销概览 - * GET /api/v1/distribution/overview → {totalCommission,settled,withdrawable,todayCommission,teamCount,l1Count,l2Count,inviteCode,posterUrl} + * GET /api/v1/distribution/overview → {totalCommission,settled,withdrawable,todayCommission,teamCount,l1Count,l2Count,inviteCode,posterUrl,minWithdraw} */ public function overview() { @@ -48,6 +48,8 @@ class Distribution extends V1 'l2Count' => $l2, 'inviteCode' => (string)$ext['invite_code'], 'posterUrl' => '', + // 最低提现金额(后台「分销设置」下发,替代前端写死的 50) + 'minWithdraw' => (float)$this->cfg('dist.minWithdraw', 50), ]); } diff --git a/application/api/controller/Home.php b/application/api/controller/Home.php index a1bbd25..c2d83b3 100644 --- a/application/api/controller/Home.php +++ b/application/api/controller/Home.php @@ -11,6 +11,7 @@ use think\Db; * GET /api/v1/home/categories H2 分类导航 * GET /api/v1/home/search/hot H3 热门搜索 * GET /api/v1/home/feed H4 信息流(支持 lat/lng + sort=nearby 距离排序) + * GET /api/v1/home/areas H5 区域列表(用户端下拉筛选,读后台「区域管理」) */ class Home extends V1 { @@ -81,6 +82,26 @@ class Home extends V1 $this->ok(array_values($keywords)); } + /** + * H5 区域列表(用户端筛选用) + * GET /api/v1/home/areas → [string] + * 规则:仅 enabled=1,按 sort asc;与后台「区域管理」(fc_area) 同源, + * 前端首页/信息列表/发布页的「区域」选项均由此下发,不再前端写死。 + */ + public function areas() + { + $rows = Db::name('fc_area') + ->where('enabled', 1) + ->order('sort asc') + ->select(); + + $list = []; + foreach ($rows as $row) { + $list[] = (string)$row['name']; + } + $this->ok($list); + } + /** * H4 信息流 * GET /api/v1/home/feed {categoryId?,keyword?,area?,sort?,lat?,lng?,page,size} diff --git a/application/api/controller/Message.php b/application/api/controller/Message.php index 8ed13c5..1ff1e1a 100644 --- a/application/api/controller/Message.php +++ b/application/api/controller/Message.php @@ -9,6 +9,7 @@ use think\Db; * 路由: * GET /api/v1/message/list M1 消息列表 * POST /api/v1/message/:id/read M2 标记已读 + * GET /api/v1/message/unread-count M3 未读消息数(首页角标) * * 说明:user_id=0 表示全体广播消息,用户可见。 */ @@ -68,4 +69,23 @@ class Message extends V1 $this->ok(['read' => true]); } + + /** + * M3 未读消息数(首页消息角标) + * GET /api/v1/message/unread-count → {count} + * 规则:统计当前用户可见(user_id = 本人 或 0 广播)且 isread=0 的消息条数, + * 替代前端原先写死的角标数字。 + */ + public function unreadCount() + { + $user = $this->auth(); + $uid = (int)$user['id']; + + $count = (int)Db::name('fc_message') + ->where('user_id', 'in', [$uid, 0]) + ->where('isread', 0) + ->count(); + + $this->ok(['count' => $count]); + } } diff --git a/application/api/controller/Post.php b/application/api/controller/Post.php index 4f390df..c24225d 100644 --- a/application/api/controller/Post.php +++ b/application/api/controller/Post.php @@ -17,6 +17,7 @@ use think\Db; * GET /api/v1/post/:id P5 信息详情 * POST /api/v1/post/:id/pay-view P6 付费查看联系方式 * POST /api/v1/post/:id/comment P7 发表评价 + * GET /api/v1/post/:id/comments P10 评价列表(详情页「用户评价」) * * 计费口径(后台「发布与费用配置」维护,真源=fc_config); * 金额一律由服务端按配置计算,**不接受客户端传入金额**; @@ -809,6 +810,42 @@ class Post extends V1 $this->ok(['commentId' => $commentId]); } + /** + * P10 评价列表(详情页「用户评价」) + * GET /api/v1/post/:id/comments → [{id,user,score,content,reply,createdAt}] + * 规则:仅 status=1(正常/审核通过)的评价;置顶优先,其余按时间倒序。 + * 替代前端详情页原先写死的两条假评价。 + */ + public function comments() + { + $id = $this->routeId(); + if ($id <= 0) { + $this->fail('信息不存在', 404); + } + + $rows = Db::name('fc_comment')->alias('co') + ->join('user u', 'u.id = co.user_id', 'LEFT') + ->where('co.post_id', $id) + ->where('co.status', 1) + ->field('co.id, co.score, co.content, co.reply, co.top, co.createtime, u.nickname AS nickname') + ->order('co.top desc, co.id desc') + ->select(); + + $list = []; + foreach ($rows as $row) { + $list[] = [ + 'id' => (int)$row['id'], + 'user' => (string)$row['nickname'], + 'score' => (int)$row['score'], + 'content' => (string)$row['content'], + 'reply' => (string)$row['reply'], + 'createdAt' => $this->iso($row['createtime']), + ]; + } + + $this->ok($list); + } + /** * 读取路由 :id 参数(兼容 POST 体/查询串传入) * @return int diff --git a/application/route.php b/application/route.php index 522d31d..a755fcd 100755 --- a/application/route.php +++ b/application/route.php @@ -41,10 +41,12 @@ return [ 'api/v1/home/categories' => 'api/Home/categories', 'api/v1/home/search/hot' => 'api/Home/hotKeywords', 'api/v1/home/feed' => 'api/Home/feed', + 'api/v1/home/areas' => 'api/Home/areas', /* =============== 三、用户端 · 信息发布与详情(长路径优先) =============== */ 'api/v1/post/:id/pay-view' => 'api/Post/payView', 'api/v1/post/:id/comment' => 'api/Post/comment', + 'api/v1/post/:id/comments' => 'api/Post/comments', 'api/v1/post/create' => 'api/Post/create', 'api/v1/post/mine' => 'api/Post/mine', 'api/v1/post/publish-config' => 'api/Post/publishConfig', @@ -80,6 +82,7 @@ return [ /* =============== 六、用户端 · 消息中心(Module-MESSAGE) =============== */ 'api/v1/message/list' => 'api/Message/list', + 'api/v1/message/unread-count' => 'api/Message/unreadCount', 'api/v1/message/:id/read' => 'api/Message/read', /* =============== 六·B、用户端 · 交易与支付(充值 / 微信支付 / 优惠券) =============== diff --git a/docs/原始功能需求/1.png b/docs/原始功能需求/1.png new file mode 100644 index 0000000..02325f8 Binary files /dev/null and b/docs/原始功能需求/1.png differ diff --git a/docs/原始功能需求/2.png b/docs/原始功能需求/2.png new file mode 100644 index 0000000..d539d5c Binary files /dev/null and b/docs/原始功能需求/2.png differ diff --git a/docs/原始功能需求/3.png b/docs/原始功能需求/3.png new file mode 100644 index 0000000..ccb8813 Binary files /dev/null and b/docs/原始功能需求/3.png differ diff --git a/uniapp/README.md b/uniapp/README.md index 1f72a44..f2b7803 100644 --- a/uniapp/README.md +++ b/uniapp/README.md @@ -11,8 +11,8 @@ | --- | --- | --- | | **① 功能模块清单(PM)** | [`docs/01-产品功能模块清单.md`](docs/01-产品功能模块清单.md) | 用户端 + 后台管理端模块清单、优先级、业务规则、接口映射 | | **② UI 设计规范(UI)** | [`docs/02-UI设计规范.md`](docs/02-UI设计规范.md) | 春绿设计令牌、排版、组件、动效规范 | -| **③ 接口文档(前后端)** | [`docs/03-接口文档.md`](docs/03-接口文档.md) | 73 个接口(用户端 41 + 后台 32)字段级契约 + Mock 兜底机制 + 联调清单 | -| **④ 全链路测试报告(QA)** | [`docs/04-全链路测试用例与报告.md`](docs/04-全链路测试用例与报告.md) | 167 条用例、15 步 E2E、15 个缺陷记录与修复 | +| **③ 接口文档(前后端)** | [`docs/03-接口文档.md`](docs/03-接口文档.md) | 75 个接口(用户端 43 + 后台 32)字段级契约 + Mock 兜底机制 + 联调清单 | +| **④ 全链路测试报告(QA)** | [`docs/04-全链路测试用例与报告.md`](docs/04-全链路测试用例与报告.md) | 179 条用例、15 步 E2E、15 个缺陷记录与修复 | ## 二、目录结构 @@ -44,7 +44,7 @@ fenleixinxi/ │ ├── api/ # auth/home/post/member/distribution/message/favorite/report/order/pay/coupon/setting/admin │ ├── constants/report.js # 举报原因字典(report.js,v1.1.0) │ ├── assets/ # 图标注册表(icons.js)+ 轮播取图与主题护栏(banners.js) -│ ├── mock/ # 77 条 mock 路由 + 数据集(离线可跑) +│ ├── mock/ # 79 条 mock 路由 + 数据集(离线可跑) │ ├── constants/ui.js # 状态/图标映射 │ └── store/index.js # 轻量全局状态 ├── static/ # 74 枚图标 + 3 张轮播插画(banners/)+ LOGO @@ -152,7 +152,7 @@ sh tests/run.sh # 等价于依次执行: # 1) node tests/validate.mjs 项目结构校验(路由/.vue 标签/SCSS 括号/import 依赖) # 2) node tools/check-scss.cjs 用 dart-sass 编译全部 SCSS -# 3) node tests/run.mjs 全链路接口测试(167 例) +# 3) node tests/run.mjs 全链路接口测试(179 例) ``` ## 七、设计主色调(春绿 · Spring Green) @@ -186,10 +186,11 @@ node tools/preview-theme.mjs --render # 首页仿真 + 全量令牌色板; ``` [1/3] 项目结构校验 : 错误 0,警告 0 [2/3] SCSS 编译校验 : 通过 19 个,失败 0(dart-sass) -[3/3] 全链路接口测试 : 用例总数 167 通过 167 失败 0 (通过率 100%) +[3/3] 全链路接口测试 : 用例总数 179 通过 179 失败 0 (通过率 100%) —— 含 配图完整性与后台自定义闭环 16 例 + 轮播配图与主题护栏 17 例 —— 含 v1.0.7 新增:我的发布 / 发布配置与计费 / 后台置顶闭环 14 例 —— 含 v1.1.0 新增:支付 / 上传 / LBS / 收藏关注 / 举报 / 充值 / 优惠券 28 例 + —— 含 v1.1.1 新增:真实数据对接回归 12 例(区域/未读/详情评价/最低提现/去 mock_code 等) ``` | 视觉资源 | 状态 | diff --git a/uniapp/common/api/home.js b/uniapp/common/api/home.js index f381dc5..5b6a86b 100644 --- a/uniapp/common/api/home.js +++ b/uniapp/common/api/home.js @@ -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 diff --git a/uniapp/common/api/message.js b/uniapp/common/api/message.js index 42f0ab6..87945b0 100644 --- a/uniapp/common/api/message.js +++ b/uniapp/common/api/message.js @@ -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 }), } diff --git a/uniapp/common/api/post.js b/uniapp/common/api/post.js index 3ca2915..f1cdedb 100644 --- a/uniapp/common/api/post.js +++ b/uniapp/common/api/post.js @@ -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 diff --git a/uniapp/common/mock/data.js b/uniapp/common/mock/data.js index 29e017d..175a20a 100644 --- a/uniapp/common/mock/data.js +++ b/uniapp/common/mock/data.js @@ -242,6 +242,7 @@ export const datasets = { l2Count: 16, inviteCode: 'TC8A9K', posterUrl: '', + minWithdraw: 50, }, /** 分销团队 */ diff --git a/uniapp/common/mock/index.js b/uniapp/common/mock/index.js index f443a07..f59ae23 100644 --- a/uniapp/common/mock/index.js +++ b/uniapp/common/mock/index.js @@ -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), diff --git a/uniapp/common/store/index.js b/uniapp/common/store/index.js index 8c97baa..03cb59a 100644 --- a/uniapp/common/store/index.js +++ b/uniapp/common/store/index.js @@ -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 = () => { diff --git a/uniapp/docs/03-接口文档.md b/uniapp/docs/03-接口文档.md index a12b4de..a85d56c 100644 --- a/uniapp/docs/03-接口文档.md +++ b/uniapp/docs/03-接口文档.md @@ -4,7 +4,7 @@ > 网关地址:`https://fenleixinxi.gzyakj.com.cn/api` > 版本前缀:`/api/v1` > 版本:v1.0.0 编制日期:2026-10-15(v1.1.0 增补日期:2026-10-17) -> **接口总数:73 条**(用户端 41 + 后台 32,以 `application/route.php` 实际登记条目为准;v1.1.0 新增用户端 11 条) +> **接口总数:76 条**(用户端 44 + 后台 32,以 `application/route.php` 实际登记条目为准;v1.1.0 新增用户端 11 条) --- @@ -91,6 +91,7 @@ | GET | `/home/categories` | — | `[{ id, name, icon, color, count }]` | | GET | `/home/feed` | `{ page, size, categoryId?, keyword?, area?, sort?, lat?, lng? }` | 分页 `list:[Post]`(含 `isTop`、`distance`) | | GET | `/home/search/hot` | — | `[string]` | +| GET | `/home/areas` | — | `[string]`(仅启用区域,按 `sort` 升序;与后台「区域管理」同源) | - `sort` 枚举:`new`(默认,按发布时间)/ `hot`(按浏览量)/ `price`(按价格升序)/ **`nearby`(v1.1.0,按距离升序)** - **LBS 距离(v1.1.0)**:传入 `lat`/`lng`(gcj02,可与 `categoryId`/`keyword`/`area` 组合)后,列表项新增 `distance`(number|**km,一位小数**;请求未带坐标或信息未定位时为 `null`)。 @@ -121,6 +122,7 @@ | GET | `/post/{id}` | — | `Post`(含 `publisher`、`commentCount`、`lat`、`lng`、`distance`、`faved`、`followed`、`favoriteCount`、`media`) | | POST | `/post/{id}/pay-view` | `{ payType: 'wxpay'\|'balance' }` | 微信:`{ order: { orderNo, amount, payType, status: 'pending' } }`;余额:`{ unlocked, contact: { phone, wechat } }` | | POST | `/post/{id}/comment` | `{ score:1-5, content }` | `{ commentId }` | +| GET | `/post/{id}/comments` | — | `[{ id, user, score, content, reply, createdAt }]`(仅 `status=1`,置顶优先+时间倒序) | **业务规则**:标题/内容必填;`payType` 仅支持 `wxpay`/`balance`;`score` 必须 1–5。 @@ -164,7 +166,7 @@ | 方法 | 路径 | 入参 | 返回 | | --- | --- | --- | --- | -| GET | `/distribution/overview` | — | `{ totalCommission, settled, withdrawable, todayCommission, teamCount, l1Count, l2Count, inviteCode }` | +| GET | `/distribution/overview` | — | `{ totalCommission, settled, withdrawable, todayCommission, teamCount, l1Count, l2Count, inviteCode, minWithdraw }` | | GET | `/distribution/team` | `{ level?, page, size }` | 分页 `[{ id, nickname, level, performance, commission, joinedAt }]` | | POST | `/distribution/withdraw` | `{ amount, channel }` | `{ withdrawNo, status }` | | GET | `/distribution/withdraw-records` | — | `[{ withdrawNo, amount, status, createdAt }]` | @@ -176,6 +178,7 @@ | 方法 | 路径 | 入参 | 返回 | | --- | --- | --- | --- | | GET | `/message/list` | `{ type: 'system'\|'interact', page, size }` | 分页 `[{ id, type, title, content, read, createdAt }]` | +| GET | `/message/unread-count` | — | `{ count }`(当前用户可见且未读的消息数,驱动首页角标) | | POST | `/message/{id}/read` | — | `{ read: true }` | ### 2.7 交易与支付(v1.1.0)`common/api/{order,pay,coupon}.js` @@ -348,7 +351,7 @@ LOGO = logo(后台自定义) || '/static/logo.png'(内置) | 真实请求失败(超时/断网)且 `enableMockFallback = true` | 自动降级到同名 mock 路由 | | mock 无匹配路由 | 抛出原始网络异常 | -- Mock 路由表:`common/mock/index.js`(**77 条**路由,覆盖上表全部接口,含 v1.0.7 的 `/post/mine`、`/post/publish-config`、服务端定价模拟,v1.0.8 的 `/auth/wx-phone`,以及 v1.1.0 的 `/post/upload`、`/report`、`/favorite/*`、`/follow/toggle`、`/order/recharge`、`/pay/*`、`/coupon/*` 与 `home/feed` 的 LBS) +- Mock 路由表:`common/mock/index.js`(**80 条**路由,覆盖上表全部接口,含 v1.0.7 的 `/post/mine`、`/post/publish-config`、服务端定价模拟,v1.0.8 的 `/auth/wx-phone`,以及 v1.1.0 的 `/post/upload`、`/report`、`/favorite/*`、`/follow/toggle`、`/order/recharge`、`/pay/*`、`/coupon/*` 与 `home/feed` 的 LBS;另含真实数据对接新增的 `/home/areas`、`/message/unread-count`、`/post/:id/comments`) - Mock 数据集:`common/mock/data.js` - 切换真实后端:确保 `common/config/index.js` 中 `forceMock = false`、`enableMockFallback = false`(生产建议关闭降级以暴露真实问题) diff --git a/uniapp/docs/04-全链路测试用例与报告.md b/uniapp/docs/04-全链路测试用例与报告.md index 749f34e..1adf2f1 100644 --- a/uniapp/docs/04-全链路测试用例与报告.md +++ b/uniapp/docs/04-全链路测试用例与报告.md @@ -12,7 +12,7 @@ | 项 | 说明 | | --- | --- | | 被测对象 | ① 统一请求层 `common/utils/request.js` ② API 模块 `common/api/*.js`(认证/首页/发布/会员/分销/消息/收藏/举报/订单/支付/优惠券/设置/后台) ③ Mock 路由表 `common/mock`(作为接口契约参照) ④ 工具函数 `common/utils/format.js` | -| 覆盖接口 | `application/route.php` 实际 **73 条**路由(用户端 41 + 后台 32);Mock 路由表 **77 条** | +| 覆盖接口 | `application/route.php` 实际 **76 条**路由(用户端 44 + 后台 32);Mock 路由表 **80 条** | | 测试层级 | 单元(工具/请求层)→ 集成(API 模块 ↔ Mock 契约)→ 端到端(用户端 8 步 + 后台端 7 步业务闭环) | | 测试手段 | 断言响应结构、业务规则拦截、异常分支、分页边界、精度校验 | | 缺陷判定 | 用例失败即缺陷;已发现并修复 15 个缺陷(详见第五章) | @@ -310,17 +310,17 @@ ``` =========== 全链路接口测试报告 =========== -用例总数: 167 通过: 167 失败: 0 +用例总数: 179 通过: 179 失败: 0 🎉 全部用例通过,前后端接口契约与业务规则校验一致。 ``` | 指标 | 数值 | | --- | --- | -| 用例总数 | 167(原 139 + v1.1.0 新增 28) | -| 通过 | 167 | +| 用例总数 | 179(原 167 + 真实数据对接新增 12) | +| 通过 | 179 | | 失败 | 0 | | 通过率 | **100%** | -| 覆盖接口 | `route.php` 73 条路由(用户端 41 + 后台 32);Mock 路由表 77 条 | +| 覆盖接口 | `route.php` 76 条路由(用户端 44 + 后台 32);Mock 路由表 80 条 | | 覆盖业务规则 | 16 / 16(BR-01 ~ BR-16,含 v1.1.0 新增 BR-16 折扣计价) | | 内置配图完整性 | 74 / 74(PNG 魔数 + 透明通道 + 尺寸一致) | | 轮播配图完整性 | 3 / 3(192×192 + 真实透明 + 白色插画 + 合计 6.0KB) | diff --git a/uniapp/pages/auth/login.vue b/uniapp/pages/auth/login.vue index 9cd0019..067a2f3 100644 --- a/uniapp/pages/auth/login.vue +++ b/uniapp/pages/auth/login.vue @@ -62,6 +62,7 @@