开放接口
网站与小程序共用同一套 JSON 接口,读接口公开,写接口需会话 + CSRF Token 或 API Key。
| 方法 | 路径 | 说明 | 参数 |
|---|---|---|---|
| GET | /api/search | 搜索服务名片 | q, cat, region, sort, page |
| GET | /api/merchant?slug= | 名片详情与服务项目 | slug |
| GET | /api/token | 获取写接口用的 CSRF Token | — |
| GET | /api/categories | 服务分类 | — |
| GET | /api/regions | 区域列表 | — |
| GET | /api/qr?slug= | 活码与二维码信息 | slug |
| GET | /api/stats | 站点公开统计 | — |
| GET | /api/me | 当前登录用户 | 需会话 |
| GET | /api/notifications | 我的消息 | 需会话 |
| POST | /api/auth/login | 登录并建立会话 | username, password |
| POST | /api/auth/register | 注册账号 | username, password, phone, question, answer |
| POST | /api/favorite | 收藏 / 取消收藏 | id |
| POST | /api/lead | 发布需求 | content, category_id, region_id, budget |
| POST | /api/report | 举报名片 | merchant_id, reason, detail |
| POST | /api/notifications/read | 全部标记已读 | — |
写接口请在请求头带
X-CSRF-Token(页面 meta 中的 csrf-token),服务端接口可改带 X-Api-Key(后台「系统设置」配置)。返回结构统一为 {"ok":true,"data":…} 或 {"ok":false,"error":…}。