diff --git a/src/api/README.md b/src/api/README.md new file mode 100644 index 0000000..d5a3076 --- /dev/null +++ b/src/api/README.md @@ -0,0 +1,241 @@ +# 小说网站 API 接口文档 + +本项目基于提供的 Swagger API 文档创建了完整的前端接口调用封装。 + +## 📁 文件结构 + +``` +src/api/ +├── index.js # axios 基础配置 +├── auth.js # 授权登录相关接口 +├── home.js # 首页相关接口 +├── bookshelf.js # 书架相关接口(阅读书架、我的作品、读者成就) +├── user.js # 用户相关接口(流水、评论、任务、申请作家、礼物订阅) +├── modules.js # 统一导出所有API模块 +├── example.js # 使用示例 +├── types.ts # TypeScript 类型定义 +├── api.json # 原始 Swagger 文档 +└── README.md # 本文档 +``` + +## 🚀 快速开始 + +### 1. 基础配置 + +项目已配置好 axios 实例,自动处理: +- ✅ X-Access-Token 认证头 +- ✅ 统一的响应格式处理 +- ✅ 错误处理和401重定向 +- ✅ 请求超时设置 + +### 2. 使用方式 + +#### 方式一:按需导入 +```javascript +import { authApi, homeApi, commentApi } from '@/api/modules.js'; + +// 用户登录 +const loginResult = await authApi.appletLogin(loginData); + +// 获取首页banner +const banner = await homeApi.getBanner(); + +// 发表评论 +await commentApi.saveComment({ bookId: '123', content: '很棒的小说!' }); +``` + +#### 方式二:全量导入 +```javascript +import api from '@/api/modules.js'; + +// 使用方式 +const books = await api.myBook.getMyShopPage({ pageNo: 1, pageSize: 10 }); +const userInfo = await api.auth.getUserByToken(); +``` + +### 3. 在 Vue 组件中使用 + +```vue + + + +``` + +## 📚 API 模块说明 + +### 🔐 授权登录模块 (authApi) +```javascript +// 微信小程序登录 +authApi.appletLogin(params) + +// 绑定手机号 +authApi.bindPhone(code) + +// 获取用户信息 +authApi.getUserByToken() + +// 更新用户信息 +authApi.updateUserInfo(userInfo) + +// 获取平台配置 +authApi.getConfig() +``` + +### 🏠 首页模块 (homeApi) +```javascript +// 获取banner +homeApi.getBanner() + +// 获取分类列表 +homeApi.getCategoryList() + +// 获取书籍详情 +homeApi.getBookDetail({ id: bookId }) + +// 获取书籍目录 +homeApi.getBookCatalogList({ bookId, pageNo: 1, pageSize: 20 }) + +// 获取章节详情 +homeApi.getBookCatalogDetail(chapterId) + +// 投票 +homeApi.vote({ bookId, num: '1' }) +``` + +### 📚 书架模块 + +#### 阅读书架 (readBookApi) +```javascript +// 添加到阅读记录 +readBookApi.addReadBook(bookData) + +// 获取阅读记录 +readBookApi.getReadBookPage({ pageNo: 1, pageSize: 10 }) + +// 移除阅读记录 +readBookApi.removeReadBook(bookId) +``` + +#### 我的作品 (myBookApi) +```javascript +// 获取我的作品 +myBookApi.getMyShopPage({ pageNo: 1, pageSize: 10 }) + +// 创建/更新作品 +myBookApi.saveOrUpdateShop(shopData) + +// 获取章节列表 +myBookApi.getMyShopNovelPage({ bookId, pageNo: 1, pageSize: 20 }) + +// 创建/更新章节 +myBookApi.saveOrUpdateShopNovel(novelData) + +// 删除作品 +myBookApi.deleteMyShop(bookId) +``` + +### 👤 用户模块 + +#### 评论 (commentApi) +```javascript +// 发表评论 +commentApi.saveComment({ bookId, content }) + +// 获取评论列表 +commentApi.getCommentList({ bookId, pageNo: 1, pageSize: 10 }) + +// 回复评论 +commentApi.replyComment({ commentId, content }) + +// 删除评论 +commentApi.deleteComment(commentId) +``` + +#### 任务 (taskApi) +```javascript +// 获取签到任务 +taskApi.getSignTaskList() + +// 执行签到 +taskApi.clickSignTask(taskId) + +// 获取更多任务 +taskApi.getMoreTaskList() + +// 获取推荐票数 +taskApi.getMyRecommendTicketNum() +``` + +## 🔧 环境变量配置 + +在 `.env` 文件中配置API基础URL: + +```env +# 开发环境 +VITE_API_BASE_URL=http://127.0.0.1:8080 + +# 生产环境 +VITE_API_BASE_URL=https://your-api-domain.com +``` + +## 🛠️ 错误处理 + +所有API调用都应该使用 try-catch 进行错误处理: + +```javascript +try { + const result = await authApi.appletLogin(loginData); + // 处理成功结果 +} catch (error) { + // 处理错误 + console.error('登录失败:', error.message); + // 显示错误提示给用户 +} +``` + +## 📝 注意事项 + +1. **认证token**: 所有需要认证的接口都会自动添加 `X-Access-Token` 头 +2. **分页参数**: 统一使用 `pageNo` 和 `pageSize` +3. **响应格式**: 所有接口返回统一的格式 `{ code, message, result, success, timestamp }` +4. **错误处理**: 401错误会自动清除token并跳转到登录页 +5. **超时设置**: 默认10秒超时,可在 `index.js` 中调整 + +## 🔗 相关链接 + +- [Axios 官方文档](https://axios-http.com/) +- [Vue 3 文档](https://vuejs.org/) +- [Element Plus 文档](https://element-plus.org/) + +## 📞 技术支持 + +如有问题,请查看 `example.js` 中的使用示例或联系开发团队。 \ No newline at end of file diff --git a/src/api/api.json b/src/api/api.json new file mode 100644 index 0000000..2454ff6 --- /dev/null +++ b/src/api/api.json @@ -0,0 +1,3817 @@ +{ + "swagger": "2.0", + "info": { + "description": "后台API接口", + "version": "1.0", + "title": "后台服务API接口文档", + "contact": { + "name": "*********有限公司", + "url": "*********有限公司", + "email": "*********@qq.com" + } + }, + "host": "127.0.0.1", + "tags": [ + { + "name": "书架-我的作品接口", + "x-order": "2147483647" + }, + { + "name": "书架-读者成就相关接口", + "x-order": "2147483647" + }, + { + "name": "书架-阅读书架接口", + "x-order": "2147483647" + }, + { + "name": "我的-任务中心相关接口", + "x-order": "2147483647" + }, + { + "name": "我的-流水相关接口", + "x-order": "2147483647" + }, + { + "name": "我的-申请成为作家相关接口", + "x-order": "2147483647" + }, + { + "name": "我的-礼物订阅接口", + "x-order": "2147483647" + }, + { + "name": "我的-评论相关接口", + "x-order": "2147483647" + }, + { + "name": "授权登录", + "x-order": "2147483647" + }, + { + "name": "首页接口", + "x-order": "2147483647" + } + ], + "paths": { + "/novel-admin/all_achievement/getAchievement": { + "get": { + "tags": [ + "书架-读者成就相关接口" + ], + "summary": "根据用户标识和书籍标识查询该用户的成就等级", + "description": "根据用户标识和书籍标识查询该用户的成就等级", + "operationId": "getAchievementUsingGET", + "produces": [ + "*/*" + ], + "parameters": [ + { + "name": "bookId", + "in": "query", + "description": "bookId", + "required": false, + "type": "string" + }, + { + "name": "X-Access-Token", + "in": "header", + "description": "X-Access-Token", + "required": true, + "type": "string" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/接口返回对象«object»", + "originalRef": "接口返回对象«object»" + } + }, + "401": { + "description": "Unauthorized" + }, + "403": { + "description": "Forbidden" + }, + "404": { + "description": "Not Found" + } + }, + "security": [ + { + "X-Access-Token": [ + "global" + ] + } + ], + "x-order": "2147483647" + } + }, + "/novel-admin/all_achievement/getAchievementList": { + "get": { + "tags": [ + "书架-读者成就相关接口" + ], + "summary": "获取读者成就列表", + "description": "获取读者成就列表", + "operationId": "getAchievementListUsingGET", + "produces": [ + "*/*" + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/接口返回对象«object»", + "originalRef": "接口返回对象«object»" + } + }, + "401": { + "description": "Unauthorized" + }, + "403": { + "description": "Forbidden" + }, + "404": { + "description": "Not Found" + } + }, + "security": [ + { + "X-Access-Token": [ + "global" + ] + } + ], + "x-order": "2147483647" + } + }, + "/novel-admin/all_achievement/setAchievementName": { + "post": { + "tags": [ + "书架-读者成就相关接口" + ], + "summary": "设置读者成就等级名称", + "description": "设置读者成就等级名称", + "operationId": "setAchievementNameUsingPOST", + "consumes": [ + "application/json" + ], + "produces": [ + "*/*" + ], + "parameters": [ + { + "name": "bookId", + "in": "query", + "description": "关联书籍", + "required": false, + "type": "string" + }, + { + "name": "createBy", + "in": "query", + "description": "创建人", + "required": false, + "type": "string" + }, + { + "name": "createTime", + "in": "query", + "description": "创建日期", + "required": false, + "type": "string", + "format": "date-time" + }, + { + "name": "id", + "in": "query", + "description": "主键", + "required": false, + "type": "string" + }, + { + "name": "oneName", + "in": "query", + "description": "一级成就名称", + "required": false, + "type": "string" + }, + { + "name": "oneNum", + "in": "query", + "description": "一级达成人数", + "required": false, + "type": "integer", + "format": "int32" + }, + { + "name": "oneOldName", + "in": "query", + "description": "一级旧名称", + "required": false, + "type": "string" + }, + { + "name": "status", + "in": "query", + "description": "审核状态", + "required": false, + "type": "string" + }, + { + "name": "threeName", + "in": "query", + "description": "三级成就名称", + "required": false, + "type": "string" + }, + { + "name": "threeNum", + "in": "query", + "description": "三级达成人数", + "required": false, + "type": "integer", + "format": "int32" + }, + { + "name": "threeOldName", + "in": "query", + "description": "三级旧名称", + "required": false, + "type": "string" + }, + { + "name": "twoName", + "in": "query", + "description": "二级成就名称", + "required": false, + "type": "string" + }, + { + "name": "twoNum", + "in": "query", + "description": "二级达成人数", + "required": false, + "type": "integer", + "format": "int32" + }, + { + "name": "twoOldName", + "in": "query", + "description": "二级旧名称", + "required": false, + "type": "string" + }, + { + "name": "updateBy", + "in": "query", + "description": "更新人", + "required": false, + "type": "string" + }, + { + "name": "updateTime", + "in": "query", + "description": "更新日期", + "required": false, + "type": "string", + "format": "date-time" + }, + { + "name": "userId", + "in": "query", + "description": "关联用户", + "required": false, + "type": "string" + }, + { + "name": "X-Access-Token", + "in": "header", + "description": "X-Access-Token", + "required": true, + "type": "string" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/接口返回对象«object»", + "originalRef": "接口返回对象«object»" + } + }, + "201": { + "description": "Created" + }, + "401": { + "description": "Unauthorized" + }, + "403": { + "description": "Forbidden" + }, + "404": { + "description": "Not Found" + } + }, + "security": [ + { + "X-Access-Token": [ + "global" + ] + } + ], + "x-order": "2147483647" + } + }, + "/novel-admin/all_book/addReadBook": { + "post": { + "tags": [ + "书架-阅读书架接口" + ], + "summary": "增加我的书架阅读记录", + "description": "增加我的书架阅读记录", + "operationId": "addReadBookUsingPOST", + "consumes": [ + "application/json" + ], + "produces": [ + "*/*" + ], + "parameters": [ + { + "name": "createBy", + "in": "query", + "description": "创建人", + "required": false, + "type": "string" + }, + { + "name": "createTime", + "in": "query", + "description": "创建日期", + "required": false, + "type": "string", + "format": "date-time" + }, + { + "name": "id", + "in": "query", + "description": "主键", + "required": false, + "type": "string" + }, + { + "name": "image", + "in": "query", + "description": "主图", + "required": false, + "type": "string" + }, + { + "name": "name", + "in": "query", + "description": "书名", + "required": false, + "type": "string" + }, + { + "name": "shopId", + "in": "query", + "description": "关联小说", + "required": false, + "type": "string" + }, + { + "name": "type", + "in": "query", + "description": "类型", + "required": false, + "type": "string" + }, + { + "name": "updateBy", + "in": "query", + "description": "更新人", + "required": false, + "type": "string" + }, + { + "name": "updateTime", + "in": "query", + "description": "更新日期", + "required": false, + "type": "string", + "format": "date-time" + }, + { + "name": "userId", + "in": "query", + "description": "用户", + "required": false, + "type": "string" + }, + { + "name": "X-Access-Token", + "in": "header", + "description": "X-Access-Token", + "required": true, + "type": "string" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/接口返回对象«object»", + "originalRef": "接口返回对象«object»" + } + }, + "201": { + "description": "Created" + }, + "401": { + "description": "Unauthorized" + }, + "403": { + "description": "Forbidden" + }, + "404": { + "description": "Not Found" + } + }, + "security": [ + { + "X-Access-Token": [ + "global" + ] + } + ], + "x-order": "2147483647" + } + }, + "/novel-admin/all_book/batchRemoveReadBook": { + "get": { + "tags": [ + "书架-阅读书架接口" + ], + "summary": "批量移除我阅读过的数据根据书籍标识", + "description": "批量移除我阅读过的数据根据书籍标识", + "operationId": "batchRemoveReadBookUsingGET", + "produces": [ + "*/*" + ], + "parameters": [ + { + "name": "bookIds", + "in": "query", + "description": "bookIds", + "required": false, + "type": "string" + }, + { + "name": "X-Access-Token", + "in": "header", + "description": "X-Access-Token", + "required": true, + "type": "string" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/接口返回对象«object»", + "originalRef": "接口返回对象«object»" + } + }, + "401": { + "description": "Unauthorized" + }, + "403": { + "description": "Forbidden" + }, + "404": { + "description": "Not Found" + } + }, + "security": [ + { + "X-Access-Token": [ + "global" + ] + } + ], + "x-order": "2147483647" + } + }, + "/novel-admin/all_book/getReadBookPage": { + "get": { + "tags": [ + "书架-阅读书架接口" + ], + "summary": "获取我阅读过的书籍列表带分页", + "description": "获取我阅读过的书籍列表带分页", + "operationId": "getReadBookPageUsingGET", + "produces": [ + "*/*" + ], + "parameters": [ + { + "name": "pageNo", + "in": "query", + "description": "当前页", + "required": false, + "type": "integer", + "format": "int32" + }, + { + "name": "pageSize", + "in": "query", + "description": "显示条数", + "required": false, + "type": "integer", + "format": "int32" + }, + { + "name": "X-Access-Token", + "in": "header", + "description": "X-Access-Token", + "required": true, + "type": "string" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/接口返回对象«object»", + "originalRef": "接口返回对象«object»" + } + }, + "401": { + "description": "Unauthorized" + }, + "403": { + "description": "Forbidden" + }, + "404": { + "description": "Not Found" + } + }, + "security": [ + { + "X-Access-Token": [ + "global" + ] + } + ], + "x-order": "2147483647" + } + }, + "/novel-admin/all_book/removeReadBook": { + "get": { + "tags": [ + "书架-阅读书架接口" + ], + "summary": "移除我阅读过的书籍根据书籍标识", + "description": "移除我阅读过的书籍根据书籍标识", + "operationId": "removeReadBookUsingGET", + "produces": [ + "*/*" + ], + "parameters": [ + { + "name": "bookId", + "in": "query", + "description": "bookId", + "required": false, + "type": "string" + }, + { + "name": "X-Access-Token", + "in": "header", + "description": "X-Access-Token", + "required": true, + "type": "string" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/接口返回对象«object»", + "originalRef": "接口返回对象«object»" + } + }, + "401": { + "description": "Unauthorized" + }, + "403": { + "description": "Forbidden" + }, + "404": { + "description": "Not Found" + } + }, + "security": [ + { + "X-Access-Token": [ + "global" + ] + } + ], + "x-order": "2147483647" + } + }, + "/novel-admin/all_index/getBanner": { + "get": { + "tags": [ + "首页接口" + ], + "summary": "获取首页banner", + "description": "获取首页banner", + "operationId": "getBannerUsingGET", + "produces": [ + "*/*" + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/接口返回对象«object»", + "originalRef": "接口返回对象«object»" + } + }, + "401": { + "description": "Unauthorized" + }, + "403": { + "description": "Forbidden" + }, + "404": { + "description": "Not Found" + } + }, + "security": [ + { + "X-Access-Token": [ + "global" + ] + } + ], + "x-order": "2147483647" + } + }, + "/novel-admin/all_index/getBookAreaList": { + "get": { + "tags": [ + "首页接口" + ], + "summary": "获取书城区域列表", + "description": "获取书城区域列表", + "operationId": "getBookAreaListUsingGET", + "produces": [ + "*/*" + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/接口返回对象«object»", + "originalRef": "接口返回对象«object»" + } + }, + "401": { + "description": "Unauthorized" + }, + "403": { + "description": "Forbidden" + }, + "404": { + "description": "Not Found" + } + }, + "security": [ + { + "X-Access-Token": [ + "global" + ] + } + ], + "x-order": "2147483647" + } + }, + "/novel-admin/all_index/getBookCatalogDetail": { + "get": { + "tags": [ + "首页接口" + ], + "summary": "根据目录查询章节小说信息明细", + "description": "根据目录查询章节小说信息明细", + "operationId": "getBookCatalogDetailUsingGET", + "produces": [ + "*/*" + ], + "parameters": [ + { + "name": "id", + "in": "query", + "description": "id", + "required": false, + "type": "string" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/接口返回对象«object»", + "originalRef": "接口返回对象«object»" + } + }, + "401": { + "description": "Unauthorized" + }, + "403": { + "description": "Forbidden" + }, + "404": { + "description": "Not Found" + } + }, + "security": [ + { + "X-Access-Token": [ + "global" + ] + } + ], + "x-order": "2147483647" + } + }, + "/novel-admin/all_index/getBookCatalogList": { + "get": { + "tags": [ + "首页接口" + ], + "summary": "根据书本标识获取书本目录列表", + "description": "根据书本标识获取书本目录列表", + "operationId": "getBookCatalogListUsingGET", + "produces": [ + "*/*" + ], + "parameters": [ + { + "name": "bookId", + "in": "query", + "description": "bookId", + "required": false, + "type": "string" + }, + { + "name": "orderBy", + "in": "query", + "description": "orderBy", + "required": false, + "type": "string" + }, + { + "name": "pageNo", + "in": "query", + "description": "当前页", + "required": false, + "type": "integer", + "format": "int32" + }, + { + "name": "pageSize", + "in": "query", + "description": "显示条数", + "required": false, + "type": "integer", + "format": "int32" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/接口返回对象«object»", + "originalRef": "接口返回对象«object»" + } + }, + "401": { + "description": "Unauthorized" + }, + "403": { + "description": "Forbidden" + }, + "404": { + "description": "Not Found" + } + }, + "security": [ + { + "X-Access-Token": [ + "global" + ] + } + ], + "x-order": "2147483647" + } + }, + "/novel-admin/all_index/getBookDetail": { + "get": { + "tags": [ + "首页接口" + ], + "summary": "根据书本标识获取书本详细信息", + "description": "根据书本标识获取书本详细信息", + "operationId": "getBookDetailUsingGET", + "produces": [ + "*/*" + ], + "parameters": [ + { + "name": "id", + "in": "query", + "description": "id", + "required": false, + "type": "string" + }, + { + "name": "token", + "in": "query", + "description": "token", + "required": false, + "type": "string" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/接口返回对象«object»", + "originalRef": "接口返回对象«object»" + } + }, + "401": { + "description": "Unauthorized" + }, + "403": { + "description": "Forbidden" + }, + "404": { + "description": "Not Found" + } + }, + "security": [ + { + "X-Access-Token": [ + "global" + ] + } + ], + "x-order": "2147483647" + } + }, + "/novel-admin/all_index/getCategoryList": { + "get": { + "tags": [ + "首页接口" + ], + "summary": "获取书城分类列表", + "description": "获取书城分类列表", + "operationId": "getCategoryListUsingGET", + "produces": [ + "*/*" + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/接口返回对象«object»", + "originalRef": "接口返回对象«object»" + } + }, + "401": { + "description": "Unauthorized" + }, + "403": { + "description": "Forbidden" + }, + "404": { + "description": "Not Found" + } + }, + "security": [ + { + "X-Access-Token": [ + "global" + ] + } + ], + "x-order": "2147483647" + } + }, + "/novel-admin/all_index/getIntimacyRankList": { + "get": { + "tags": [ + "首页接口" + ], + "summary": "获取亲密度排行版", + "description": "获取亲密度排行版", + "operationId": "getIntimacyRankListUsingGET", + "produces": [ + "*/*" + ], + "parameters": [ + { + "name": "bookId", + "in": "query", + "description": "bookId", + "required": false, + "type": "string" + }, + { + "name": "pageNo", + "in": "query", + "description": "当前页", + "required": false, + "type": "integer", + "format": "int32" + }, + { + "name": "pageSize", + "in": "query", + "description": "显示条数", + "required": false, + "type": "integer", + "format": "int32" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/接口返回对象«object»", + "originalRef": "接口返回对象«object»" + } + }, + "401": { + "description": "Unauthorized" + }, + "403": { + "description": "Forbidden" + }, + "404": { + "description": "Not Found" + } + }, + "security": [ + { + "X-Access-Token": [ + "global" + ] + } + ], + "x-order": "2147483647" + } + }, + "/novel-admin/all_index/getNewList": { + "get": { + "tags": [ + "首页接口" + ], + "summary": "获取首页最新小说列表带分页", + "description": "获取首页最新小说列表带分页", + "operationId": "getNewListUsingGET", + "produces": [ + "*/*" + ], + "parameters": [ + { + "name": "pageNo", + "in": "query", + "description": "当前页", + "required": false, + "type": "integer", + "format": "int32" + }, + { + "name": "pageSize", + "in": "query", + "description": "显示条数", + "required": false, + "type": "integer", + "format": "int32" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/接口返回对象«object»", + "originalRef": "接口返回对象«object»" + } + }, + "401": { + "description": "Unauthorized" + }, + "403": { + "description": "Forbidden" + }, + "404": { + "description": "Not Found" + } + }, + "security": [ + { + "X-Access-Token": [ + "global" + ] + } + ], + "x-order": "2147483647" + } + }, + "/novel-admin/all_index/getNotice": { + "get": { + "tags": [ + "首页接口" + ], + "summary": "获取首页公告", + "description": "获取首页公告", + "operationId": "getNoticeUsingGET", + "produces": [ + "*/*" + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/接口返回对象«object»", + "originalRef": "接口返回对象«object»" + } + }, + "401": { + "description": "Unauthorized" + }, + "403": { + "description": "Forbidden" + }, + "404": { + "description": "Not Found" + } + }, + "security": [ + { + "X-Access-Token": [ + "global" + ] + } + ], + "x-order": "2147483647" + } + }, + "/novel-admin/all_index/getNoticeById": { + "get": { + "tags": [ + "首页接口" + ], + "summary": "获取公告详情", + "description": "获取公告详情", + "operationId": "getNoticeByIdUsingGET", + "produces": [ + "*/*" + ], + "parameters": [ + { + "name": "id", + "in": "query", + "description": "id", + "required": false, + "type": "string" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/接口返回对象«object»", + "originalRef": "接口返回对象«object»" + } + }, + "401": { + "description": "Unauthorized" + }, + "403": { + "description": "Forbidden" + }, + "404": { + "description": "Not Found" + } + }, + "security": [ + { + "X-Access-Token": [ + "global" + ] + } + ], + "x-order": "2147483647" + } + }, + "/novel-admin/all_index/getNoticePage": { + "get": { + "tags": [ + "首页接口" + ], + "summary": "获取公告列表带分页", + "description": "获取公告列表带分页", + "operationId": "getNoticePageUsingGET", + "produces": [ + "*/*" + ], + "parameters": [ + { + "name": "pageNo", + "in": "query", + "description": "当前页", + "required": false, + "type": "integer", + "format": "int32" + }, + { + "name": "pageSize", + "in": "query", + "description": "显示条数", + "required": false, + "type": "integer", + "format": "int32" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/接口返回对象«object»", + "originalRef": "接口返回对象«object»" + } + }, + "401": { + "description": "Unauthorized" + }, + "403": { + "description": "Forbidden" + }, + "404": { + "description": "Not Found" + } + }, + "security": [ + { + "X-Access-Token": [ + "global" + ] + } + ], + "x-order": "2147483647" + } + }, + "/novel-admin/all_index/getRecommendList": { + "get": { + "tags": [ + "首页接口" + ], + "summary": "获取首页精品推荐小说列表带分页", + "description": "获取首页精品推荐小说列表带分页", + "operationId": "getRecommendListUsingGET", + "produces": [ + "*/*" + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/接口返回对象«object»", + "originalRef": "接口返回对象«object»" + } + }, + "401": { + "description": "Unauthorized" + }, + "403": { + "description": "Forbidden" + }, + "404": { + "description": "Not Found" + } + }, + "security": [ + { + "X-Access-Token": [ + "global" + ] + } + ], + "x-order": "2147483647" + } + }, + "/novel-admin/all_index/vote": { + "get": { + "tags": [ + "首页接口" + ], + "summary": "根据书本标识进行投票", + "description": "根据书本标识进行投票", + "operationId": "voteUsingGET", + "produces": [ + "*/*" + ], + "parameters": [ + { + "name": "bookId", + "in": "query", + "description": "bookId", + "required": false, + "type": "string" + }, + { + "name": "num", + "in": "query", + "description": "num", + "required": false, + "type": "string" + }, + { + "name": "X-Access-Token", + "in": "header", + "description": "X-Access-Token", + "required": true, + "type": "string" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/接口返回对象«object»", + "originalRef": "接口返回对象«object»" + } + }, + "401": { + "description": "Unauthorized" + }, + "403": { + "description": "Forbidden" + }, + "404": { + "description": "Not Found" + } + }, + "security": [ + { + "X-Access-Token": [ + "global" + ] + } + ], + "x-order": "2147483647" + } + }, + "/novel-admin/all_login/appletLogin": { + "get": { + "tags": [ + "授权登录" + ], + "summary": "微信小程序授权登录", + "description": "微信小程序授权登录", + "operationId": "appletLoginUsingGET", + "produces": [ + "*/*" + ], + "parameters": [ + { + "name": "code", + "in": "query", + "description": "参数信息", + "required": false, + "type": "string" + }, + { + "name": "encryptedData", + "in": "query", + "description": "解密", + "required": false, + "type": "string" + }, + { + "name": "headimgurl", + "in": "query", + "description": "用户头像", + "required": false, + "type": "string" + }, + { + "name": "id", + "in": "query", + "description": "标识", + "required": false, + "type": "string" + }, + { + "name": "iv", + "in": "query", + "description": "解密标签", + "required": false, + "type": "string" + }, + { + "name": "nickName", + "in": "query", + "description": "用户姓名", + "required": false, + "type": "string" + }, + { + "name": "openid", + "in": "query", + "description": "用户唯一标识", + "required": false, + "type": "string" + }, + { + "name": "session_key", + "in": "query", + "description": "会话密钥", + "required": false, + "type": "string" + }, + { + "name": "shareId", + "in": "query", + "description": "邀请者销售标识", + "required": false, + "type": "string" + }, + { + "name": "state", + "in": "query", + "description": "类型", + "required": false, + "type": "string" + }, + { + "name": "vid", + "in": "query", + "description": "参数信息", + "required": false, + "type": "string" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/接口返回对象«object»", + "originalRef": "接口返回对象«object»" + } + }, + "401": { + "description": "Unauthorized" + }, + "403": { + "description": "Forbidden" + }, + "404": { + "description": "Not Found" + } + }, + "security": [ + { + "X-Access-Token": [ + "global" + ] + } + ], + "x-order": "2147483647" + } + }, + "/novel-admin/all_login/bindPhone": { + "get": { + "tags": [ + "授权登录" + ], + "summary": "绑定手机号码", + "description": "绑定手机号码", + "operationId": "bindPhoneUsingGET", + "produces": [ + "*/*" + ], + "parameters": [ + { + "name": "code", + "in": "query", + "description": "code", + "required": false, + "type": "string" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/接口返回对象«object»", + "originalRef": "接口返回对象«object»" + } + }, + "401": { + "description": "Unauthorized" + }, + "403": { + "description": "Forbidden" + }, + "404": { + "description": "Not Found" + } + }, + "security": [ + { + "X-Access-Token": [ + "global" + ] + } + ], + "x-order": "2147483647" + } + }, + "/novel-admin/all_login/getConfig": { + "get": { + "tags": [ + "授权登录" + ], + "summary": "获取平台基础配置信息", + "description": "获取平台基础配置信息", + "operationId": "getConfigUsingGET", + "produces": [ + "*/*" + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/接口返回对象«object»", + "originalRef": "接口返回对象«object»" + } + }, + "401": { + "description": "Unauthorized" + }, + "403": { + "description": "Forbidden" + }, + "404": { + "description": "Not Found" + } + }, + "security": [ + { + "X-Access-Token": [ + "global" + ] + } + ], + "x-order": "2147483647" + } + }, + "/novel-admin/all_login/getUserByToken": { + "get": { + "tags": [ + "授权登录" + ], + "summary": "获取用户信息", + "description": "获取用户信息", + "operationId": "getUserByTokenUsingGET", + "produces": [ + "*/*" + ], + "parameters": [ + { + "name": "X-Access-Token", + "in": "header", + "description": "X-Access-Token", + "required": true, + "type": "string" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/接口返回对象«object»", + "originalRef": "接口返回对象«object»" + } + }, + "401": { + "description": "Unauthorized" + }, + "403": { + "description": "Forbidden" + }, + "404": { + "description": "Not Found" + } + }, + "security": [ + { + "X-Access-Token": [ + "global" + ] + } + ], + "x-order": "2147483647" + } + }, + "/novel-admin/all_login/updateUserInfo": { + "post": { + "tags": [ + "授权登录" + ], + "summary": "更新用户信息", + "description": "更新用户信息", + "operationId": "updateUserInfoUsingPOST", + "consumes": [ + "application/json" + ], + "produces": [ + "*/*" + ], + "parameters": [ + { + "name": "avatarUrl", + "in": "query", + "description": "头像", + "required": false, + "type": "string" + }, + { + "name": "details", + "in": "query", + "description": "简介", + "required": false, + "type": "string" + }, + { + "name": "name", + "in": "query", + "description": "别名", + "required": false, + "type": "string" + }, + { + "name": "nickName", + "in": "query", + "description": "昵称", + "required": false, + "type": "string" + }, + { + "name": "phone", + "in": "query", + "description": "电话", + "required": false, + "type": "string" + }, + { + "name": "X-Access-Token", + "in": "header", + "description": "X-Access-Token", + "required": true, + "type": "string" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/接口返回对象«object»", + "originalRef": "接口返回对象«object»" + } + }, + "201": { + "description": "Created" + }, + "401": { + "description": "Unauthorized" + }, + "403": { + "description": "Forbidden" + }, + "404": { + "description": "Not Found" + } + }, + "security": [ + { + "X-Access-Token": [ + "global" + ] + } + ], + "x-order": "2147483647" + } + }, + "/novel-admin/all_money/getMyMoneyLogPage": { + "get": { + "tags": [ + "我的-流水相关接口" + ], + "summary": "获取我的流水列表带分页", + "description": "获取我的流水列表带分页", + "operationId": "getMyMoneyLogPageUsingGET", + "produces": [ + "*/*" + ], + "parameters": [ + { + "name": "pageNo", + "in": "query", + "description": "当前页", + "required": false, + "type": "integer", + "format": "int32" + }, + { + "name": "pageSize", + "in": "query", + "description": "显示条数", + "required": false, + "type": "integer", + "format": "int32" + }, + { + "name": "status", + "in": "query", + "description": "status", + "required": false, + "type": "integer", + "format": "int32" + }, + { + "name": "X-Access-Token", + "in": "header", + "description": "X-Access-Token", + "required": true, + "type": "string" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/接口返回对象«object»", + "originalRef": "接口返回对象«object»" + } + }, + "401": { + "description": "Unauthorized" + }, + "403": { + "description": "Forbidden" + }, + "404": { + "description": "Not Found" + } + }, + "security": [ + { + "X-Access-Token": [ + "global" + ] + } + ], + "x-order": "2147483647" + } + }, + "/novel-admin/all_money/getMyMoneyNum": { + "get": { + "tags": [ + "我的-流水相关接口" + ], + "summary": "获取我的可用积分数", + "description": "获取我的可用积分数", + "operationId": "getMyMoneyNumUsingGET", + "produces": [ + "*/*" + ], + "parameters": [ + { + "name": "X-Access-Token", + "in": "header", + "description": "X-Access-Token", + "required": true, + "type": "string" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/接口返回对象«object»", + "originalRef": "接口返回对象«object»" + } + }, + "401": { + "description": "Unauthorized" + }, + "403": { + "description": "Forbidden" + }, + "404": { + "description": "Not Found" + } + }, + "security": [ + { + "X-Access-Token": [ + "global" + ] + } + ], + "x-order": "2147483647" + } + }, + "/novel-admin/my_book/deleteMyNovel": { + "post": { + "tags": [ + "书架-我的作品接口" + ], + "summary": "删除作品章节", + "description": "删除作品章节", + "operationId": "deleteMyNovelUsingPOST", + "consumes": [ + "application/json" + ], + "produces": [ + "*/*" + ], + "parameters": [ + { + "name": "bookId", + "in": "query", + "description": "bookId", + "required": false, + "type": "string" + }, + { + "name": "id", + "in": "query", + "description": "id", + "required": false, + "type": "string" + }, + { + "name": "X-Access-Token", + "in": "header", + "description": "X-Access-Token", + "required": true, + "type": "string" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/接口返回对象«object»", + "originalRef": "接口返回对象«object»" + } + }, + "201": { + "description": "Created" + }, + "401": { + "description": "Unauthorized" + }, + "403": { + "description": "Forbidden" + }, + "404": { + "description": "Not Found" + } + }, + "security": [ + { + "X-Access-Token": [ + "global" + ] + } + ], + "x-order": "2147483647" + } + }, + "/novel-admin/my_book/deleteMyShop": { + "post": { + "tags": [ + "书架-我的作品接口" + ], + "summary": "删除我的作品", + "description": "删除我的作品", + "operationId": "deleteMyShopUsingPOST", + "consumes": [ + "application/json" + ], + "produces": [ + "*/*" + ], + "parameters": [ + { + "name": "bookId", + "in": "query", + "description": "bookId", + "required": false, + "type": "string" + }, + { + "name": "X-Access-Token", + "in": "header", + "description": "X-Access-Token", + "required": true, + "type": "string" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/接口返回对象«object»", + "originalRef": "接口返回对象«object»" + } + }, + "201": { + "description": "Created" + }, + "401": { + "description": "Unauthorized" + }, + "403": { + "description": "Forbidden" + }, + "404": { + "description": "Not Found" + } + }, + "security": [ + { + "X-Access-Token": [ + "global" + ] + } + ], + "x-order": "2147483647" + } + }, + "/novel-admin/my_book/deleteMyShopList": { + "post": { + "tags": [ + "书架-我的作品接口" + ], + "summary": "多选删除我的作品", + "description": "多选删除我的作品", + "operationId": "deleteMyShopListUsingPOST", + "consumes": [ + "application/json" + ], + "produces": [ + "*/*" + ], + "parameters": [ + { + "name": "bookIds", + "in": "query", + "description": "bookIds", + "required": false, + "type": "string" + }, + { + "name": "X-Access-Token", + "in": "header", + "description": "X-Access-Token", + "required": true, + "type": "string" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/接口返回对象«object»", + "originalRef": "接口返回对象«object»" + } + }, + "201": { + "description": "Created" + }, + "401": { + "description": "Unauthorized" + }, + "403": { + "description": "Forbidden" + }, + "404": { + "description": "Not Found" + } + }, + "security": [ + { + "X-Access-Token": [ + "global" + ] + } + ], + "x-order": "2147483647" + } + }, + "/novel-admin/my_book/getMyShopNovelPage": { + "post": { + "tags": [ + "书架-我的作品接口" + ], + "summary": "获取我的小说章节列表带分页", + "description": "获取我的小说章节列表带分页", + "operationId": "getMyShopNovelPageUsingPOST", + "consumes": [ + "application/json" + ], + "produces": [ + "*/*" + ], + "parameters": [ + { + "name": "bookId", + "in": "query", + "description": "bookId", + "required": false, + "type": "string" + }, + { + "name": "pageNo", + "in": "query", + "description": "当前页", + "required": false, + "type": "integer", + "format": "int32" + }, + { + "name": "pageSize", + "in": "query", + "description": "显示条数", + "required": false, + "type": "integer", + "format": "int32" + }, + { + "name": "reverse", + "in": "query", + "description": "reverse", + "required": false, + "type": "integer", + "format": "int32" + }, + { + "name": "status", + "in": "query", + "description": "status", + "required": false, + "type": "integer", + "format": "int32" + }, + { + "name": "X-Access-Token", + "in": "header", + "description": "X-Access-Token", + "required": true, + "type": "string" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/接口返回对象«object»", + "originalRef": "接口返回对象«object»" + } + }, + "201": { + "description": "Created" + }, + "401": { + "description": "Unauthorized" + }, + "403": { + "description": "Forbidden" + }, + "404": { + "description": "Not Found" + } + }, + "security": [ + { + "X-Access-Token": [ + "global" + ] + } + ], + "x-order": "2147483647" + } + }, + "/novel-admin/my_book/getMyShopPage": { + "get": { + "tags": [ + "书架-我的作品接口" + ], + "summary": "获取我的作品带分页", + "description": "获取我的作品带分页", + "operationId": "getMyShopPageUsingGET", + "produces": [ + "*/*" + ], + "parameters": [ + { + "name": "pageNo", + "in": "query", + "description": "当前页", + "required": false, + "type": "integer", + "format": "int32" + }, + { + "name": "pageSize", + "in": "query", + "description": "显示条数", + "required": false, + "type": "integer", + "format": "int32" + }, + { + "name": "X-Access-Token", + "in": "header", + "description": "X-Access-Token", + "required": true, + "type": "string" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/接口返回对象«object»", + "originalRef": "接口返回对象«object»" + } + }, + "401": { + "description": "Unauthorized" + }, + "403": { + "description": "Forbidden" + }, + "404": { + "description": "Not Found" + } + }, + "security": [ + { + "X-Access-Token": [ + "global" + ] + } + ], + "x-order": "2147483647" + } + }, + "/novel-admin/my_book/saveOrUpdateShop": { + "post": { + "tags": [ + "书架-我的作品接口" + ], + "summary": "添加作品或者修改作品", + "description": "添加作品或者修改作品", + "operationId": "saveOrUpdateShopUsingPOST", + "consumes": [ + "application/json" + ], + "produces": [ + "*/*" + ], + "parameters": [ + { + "name": "author", + "in": "query", + "description": "小说作者", + "required": false, + "type": "string" + }, + { + "name": "bookStatus", + "in": "query", + "description": "作品状态", + "required": false, + "type": "integer", + "format": "int32" + }, + { + "name": "createBy", + "in": "query", + "description": "创建人", + "required": false, + "type": "string" + }, + { + "name": "createTime", + "in": "query", + "description": "创建日期", + "required": false, + "type": "string", + "format": "date-time" + }, + { + "name": "details", + "in": "query", + "description": "书籍简介", + "required": false, + "type": "string" + }, + { + "name": "id", + "in": "query", + "description": "主键", + "required": false, + "type": "string" + }, + { + "name": "image", + "in": "query", + "description": "小说封面图", + "required": false, + "type": "string" + }, + { + "name": "name", + "in": "query", + "description": "小说标题", + "required": false, + "type": "string" + }, + { + "name": "qmNum", + "in": "query", + "description": "作者累积亲密值", + "required": false, + "type": "integer", + "format": "int32" + }, + { + "name": "service", + "in": "query", + "description": "标签说明", + "required": false, + "type": "string" + }, + { + "name": "shopCion", + "in": "query", + "description": "所属区域", + "required": false, + "type": "string" + }, + { + "name": "shopClass", + "in": "query", + "description": "小说分类", + "required": false, + "type": "string" + }, + { + "name": "status", + "in": "query", + "description": "完结状态", + "required": false, + "type": "integer", + "format": "int32" + }, + { + "name": "toolStatus", + "in": "query", + "description": "设置状态", + "required": false, + "type": "integer", + "format": "int32" + }, + { + "name": "tuiNum", + "in": "query", + "description": "推荐票数", + "required": false, + "type": "integer", + "format": "int32" + }, + { + "name": "updateBy", + "in": "query", + "description": "更新人", + "required": false, + "type": "string" + }, + { + "name": "updateTime", + "in": "query", + "description": "更新日期", + "required": false, + "type": "string", + "format": "date-time" + }, + { + "name": "userId", + "in": "query", + "description": "关联用户", + "required": false, + "type": "string" + }, + { + "name": "X-Access-Token", + "in": "header", + "description": "X-Access-Token", + "required": true, + "type": "string" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/接口返回对象«object»", + "originalRef": "接口返回对象«object»" + } + }, + "201": { + "description": "Created" + }, + "401": { + "description": "Unauthorized" + }, + "403": { + "description": "Forbidden" + }, + "404": { + "description": "Not Found" + } + }, + "security": [ + { + "X-Access-Token": [ + "global" + ] + } + ], + "x-order": "2147483647" + } + }, + "/novel-admin/my_book/saveOrUpdateShopNovel": { + "post": { + "tags": [ + "书架-我的作品接口" + ], + "summary": "增加或修改作品章节", + "description": "增加或修改作品章节", + "operationId": "saveOrUpdateShopNovelUsingPOST", + "consumes": [ + "application/json" + ], + "produces": [ + "*/*" + ], + "parameters": [ + { + "name": "bookId", + "in": "query", + "description": "所属小说", + "required": false, + "type": "string" + }, + { + "name": "createBy", + "in": "query", + "description": "创建人", + "required": false, + "type": "string" + }, + { + "name": "createTime", + "in": "query", + "description": "创建日期", + "required": false, + "type": "string", + "format": "date-time" + }, + { + "name": "details", + "in": "query", + "description": "章节内容", + "required": false, + "type": "string" + }, + { + "name": "id", + "in": "query", + "description": "主键", + "required": false, + "type": "string" + }, + { + "name": "isPay", + "in": "query", + "description": "是否付费章节", + "required": false, + "type": "string" + }, + { + "name": "num", + "in": "query", + "description": "字数", + "required": false, + "type": "integer", + "format": "int32" + }, + { + "name": "sort", + "in": "query", + "description": "排序", + "required": false, + "type": "integer", + "format": "int32" + }, + { + "name": "status", + "in": "query", + "description": "章节状态", + "required": false, + "type": "integer", + "format": "int32" + }, + { + "name": "title", + "in": "query", + "description": "章节名称", + "required": false, + "type": "string" + }, + { + "name": "updateBy", + "in": "query", + "description": "更新人", + "required": false, + "type": "string" + }, + { + "name": "updateTime", + "in": "query", + "description": "更新日期", + "required": false, + "type": "string", + "format": "date-time" + }, + { + "name": "userId", + "in": "query", + "description": "用户标识", + "required": false, + "type": "string" + }, + { + "name": "X-Access-Token", + "in": "header", + "description": "X-Access-Token", + "required": true, + "type": "string" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/接口返回对象«object»", + "originalRef": "接口返回对象«object»" + } + }, + "201": { + "description": "Created" + }, + "401": { + "description": "Unauthorized" + }, + "403": { + "description": "Forbidden" + }, + "404": { + "description": "Not Found" + } + }, + "security": [ + { + "X-Access-Token": [ + "global" + ] + } + ], + "x-order": "2147483647" + } + }, + "/novel-admin/my_comment/deleteComment": { + "get": { + "tags": [ + "我的-评论相关接口" + ], + "summary": "删除评论信息", + "description": "删除评论信息", + "operationId": "deleteCommentUsingGET", + "produces": [ + "*/*" + ], + "parameters": [ + { + "name": "commentId", + "in": "query", + "description": "commentId", + "required": false, + "type": "string" + }, + { + "name": "X-Access-Token", + "in": "header", + "description": "X-Access-Token", + "required": true, + "type": "string" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/接口返回对象«object»", + "originalRef": "接口返回对象«object»" + } + }, + "401": { + "description": "Unauthorized" + }, + "403": { + "description": "Forbidden" + }, + "404": { + "description": "Not Found" + } + }, + "security": [ + { + "X-Access-Token": [ + "global" + ] + } + ], + "x-order": "2147483647" + } + }, + "/novel-admin/my_comment/getCommentDetail": { + "post": { + "tags": [ + "我的-评论相关接口" + ], + "summary": "获取评论详情", + "description": "获取评论详情", + "operationId": "getCommentDetailUsingPOST", + "consumes": [ + "application/json" + ], + "produces": [ + "*/*" + ], + "parameters": [ + { + "name": "commentId", + "in": "query", + "description": "commentId", + "required": false, + "type": "string" + }, + { + "name": "X-Access-Token", + "in": "header", + "description": "X-Access-Token", + "required": true, + "type": "string" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/接口返回对象«object»", + "originalRef": "接口返回对象«object»" + } + }, + "201": { + "description": "Created" + }, + "401": { + "description": "Unauthorized" + }, + "403": { + "description": "Forbidden" + }, + "404": { + "description": "Not Found" + } + }, + "security": [ + { + "X-Access-Token": [ + "global" + ] + } + ], + "x-order": "2147483647" + } + }, + "/novel-admin/my_comment/getCommentList": { + "get": { + "tags": [ + "我的-评论相关接口" + ], + "summary": "根据书籍标识查询评论信息列表带分页", + "description": "根据书籍标识查询评论信息列表带分页", + "operationId": "getCommentListUsingGET", + "produces": [ + "*/*" + ], + "parameters": [ + { + "name": "bookId", + "in": "query", + "description": "bookId", + "required": false, + "type": "string" + }, + { + "name": "pageNo", + "in": "query", + "description": "当前页", + "required": false, + "type": "integer", + "format": "int32" + }, + { + "name": "pageSize", + "in": "query", + "description": "显示条数", + "required": false, + "type": "integer", + "format": "int32" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/接口返回对象«object»", + "originalRef": "接口返回对象«object»" + } + }, + "401": { + "description": "Unauthorized" + }, + "403": { + "description": "Forbidden" + }, + "404": { + "description": "Not Found" + } + }, + "security": [ + { + "X-Access-Token": [ + "global" + ] + } + ], + "x-order": "2147483647" + } + }, + "/novel-admin/my_comment/getMyCommentList": { + "get": { + "tags": [ + "我的-评论相关接口" + ], + "summary": "获取我的评论列表", + "description": "获取我的评论列表", + "operationId": "getMyCommentListUsingGET", + "produces": [ + "*/*" + ], + "parameters": [ + { + "name": "pageNo", + "in": "query", + "description": "当前页", + "required": false, + "type": "integer", + "format": "int32" + }, + { + "name": "pageSize", + "in": "query", + "description": "显示条数", + "required": false, + "type": "integer", + "format": "int32" + }, + { + "name": "X-Access-Token", + "in": "header", + "description": "X-Access-Token", + "required": true, + "type": "string" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/接口返回对象«object»", + "originalRef": "接口返回对象«object»" + } + }, + "401": { + "description": "Unauthorized" + }, + "403": { + "description": "Forbidden" + }, + "404": { + "description": "Not Found" + } + }, + "security": [ + { + "X-Access-Token": [ + "global" + ] + } + ], + "x-order": "2147483647" + } + }, + "/novel-admin/my_comment/getMyCommentNum": { + "get": { + "tags": [ + "我的-评论相关接口" + ], + "summary": "获取我的评论数", + "description": "获取我的评论数", + "operationId": "getMyCommentNumUsingGET", + "produces": [ + "*/*" + ], + "parameters": [ + { + "name": "X-Access-Token", + "in": "header", + "description": "X-Access-Token", + "required": true, + "type": "string" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/接口返回对象«object»", + "originalRef": "接口返回对象«object»" + } + }, + "401": { + "description": "Unauthorized" + }, + "403": { + "description": "Forbidden" + }, + "404": { + "description": "Not Found" + } + }, + "security": [ + { + "X-Access-Token": [ + "global" + ] + } + ], + "x-order": "2147483647" + } + }, + "/novel-admin/my_comment/replyComment": { + "post": { + "tags": [ + "我的-评论相关接口" + ], + "summary": "回复评论信息", + "description": "回复评论信息", + "operationId": "replyCommentUsingPOST", + "consumes": [ + "application/json" + ], + "produces": [ + "*/*" + ], + "parameters": [ + { + "name": "commentId", + "in": "query", + "description": "commentId", + "required": false, + "type": "string" + }, + { + "name": "content", + "in": "query", + "description": "content", + "required": false, + "type": "string" + }, + { + "name": "X-Access-Token", + "in": "header", + "description": "X-Access-Token", + "required": true, + "type": "string" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/接口返回对象«object»", + "originalRef": "接口返回对象«object»" + } + }, + "201": { + "description": "Created" + }, + "401": { + "description": "Unauthorized" + }, + "403": { + "description": "Forbidden" + }, + "404": { + "description": "Not Found" + } + }, + "security": [ + { + "X-Access-Token": [ + "global" + ] + } + ], + "x-order": "2147483647" + } + }, + "/novel-admin/my_comment/saveComment": { + "post": { + "tags": [ + "我的-评论相关接口" + ], + "summary": "保存评论信息", + "description": "保存评论信息", + "operationId": "saveCommentUsingPOST", + "consumes": [ + "application/json" + ], + "produces": [ + "*/*" + ], + "parameters": [ + { + "name": "bookId", + "in": "query", + "description": "bookId", + "required": false, + "type": "string" + }, + { + "name": "content", + "in": "query", + "description": "content", + "required": false, + "type": "string" + }, + { + "name": "X-Access-Token", + "in": "header", + "description": "X-Access-Token", + "required": true, + "type": "string" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/接口返回对象«object»", + "originalRef": "接口返回对象«object»" + } + }, + "201": { + "description": "Created" + }, + "401": { + "description": "Unauthorized" + }, + "403": { + "description": "Forbidden" + }, + "404": { + "description": "Not Found" + } + }, + "security": [ + { + "X-Access-Token": [ + "global" + ] + } + ], + "x-order": "2147483647" + } + }, + "/novel-admin/my_comment/updateCommentRead": { + "post": { + "tags": [ + "我的-评论相关接口" + ], + "summary": "更新评论已读状态", + "description": "更新评论已读状态", + "operationId": "updateCommentReadUsingPOST", + "consumes": [ + "application/json" + ], + "produces": [ + "*/*" + ], + "parameters": [ + { + "name": "commentId", + "in": "query", + "description": "commentId", + "required": false, + "type": "string" + }, + { + "name": "X-Access-Token", + "in": "header", + "description": "X-Access-Token", + "required": true, + "type": "string" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/接口返回对象«object»", + "originalRef": "接口返回对象«object»" + } + }, + "201": { + "description": "Created" + }, + "401": { + "description": "Unauthorized" + }, + "403": { + "description": "Forbidden" + }, + "404": { + "description": "Not Found" + } + }, + "security": [ + { + "X-Access-Token": [ + "global" + ] + } + ], + "x-order": "2147483647" + } + }, + "/novel-admin/my_order/createOrder": { + "post": { + "tags": [ + "我的-礼物订阅接口" + ], + "summary": "创建订单", + "description": "创建订单", + "operationId": "createOrderUsingPOST", + "consumes": [ + "application/json" + ], + "produces": [ + "*/*" + ], + "parameters": [ + { + "name": "giftId", + "in": "query", + "description": "giftId", + "required": false, + "type": "string" + }, + { + "name": "num", + "in": "query", + "description": "num", + "required": false, + "type": "integer", + "format": "int32" + }, + { + "name": "token", + "in": "query", + "description": "token", + "required": false, + "type": "string" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/接口返回对象«object»", + "originalRef": "接口返回对象«object»" + } + }, + "201": { + "description": "Created" + }, + "401": { + "description": "Unauthorized" + }, + "403": { + "description": "Forbidden" + }, + "404": { + "description": "Not Found" + } + }, + "security": [ + { + "X-Access-Token": [ + "global" + ] + } + ], + "x-order": "2147483647" + } + }, + "/novel-admin/my_order/getGiftDetail": { + "get": { + "tags": [ + "我的-礼物订阅接口" + ], + "summary": "查询礼物详情", + "description": "查询礼物详情", + "operationId": "getGiftDetailUsingGET", + "produces": [ + "*/*" + ], + "parameters": [ + { + "name": "giftId", + "in": "query", + "description": "giftId", + "required": false, + "type": "string" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/接口返回对象«object»", + "originalRef": "接口返回对象«object»" + } + }, + "401": { + "description": "Unauthorized" + }, + "403": { + "description": "Forbidden" + }, + "404": { + "description": "Not Found" + } + }, + "security": [ + { + "X-Access-Token": [ + "global" + ] + } + ], + "x-order": "2147483647" + } + }, + "/novel-admin/my_order/getInteractionGiftList": { + "get": { + "tags": [ + "我的-礼物订阅接口" + ], + "summary": "查询互动打赏礼物信息列表", + "description": "查询互动打赏礼物信息列表", + "operationId": "getInteractionGiftListUsingGET", + "produces": [ + "*/*" + ], + "parameters": [ + { + "name": "pageNo", + "in": "query", + "description": "当前页", + "required": false, + "type": "integer", + "format": "int32" + }, + { + "name": "pageSize", + "in": "query", + "description": "显示条数", + "required": false, + "type": "integer", + "format": "int32" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/接口返回对象«object»", + "originalRef": "接口返回对象«object»" + } + }, + "401": { + "description": "Unauthorized" + }, + "403": { + "description": "Forbidden" + }, + "404": { + "description": "Not Found" + } + }, + "security": [ + { + "X-Access-Token": [ + "global" + ] + } + ], + "x-order": "2147483647" + } + }, + "/novel-admin/my_order/getMyGiftList": { + "get": { + "tags": [ + "我的-礼物订阅接口" + ], + "summary": "查询我的礼物包订单列表", + "description": "查询我的礼物包订单列表", + "operationId": "getMyGiftListUsingGET", + "produces": [ + "*/*" + ], + "parameters": [ + { + "name": "pageNo", + "in": "query", + "description": "当前页", + "required": false, + "type": "integer", + "format": "int32" + }, + { + "name": "pageSize", + "in": "query", + "description": "显示条数", + "required": false, + "type": "integer", + "format": "int32" + }, + { + "name": "token", + "in": "query", + "description": "token", + "required": false, + "type": "string" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/接口返回对象«object»", + "originalRef": "接口返回对象«object»" + } + }, + "401": { + "description": "Unauthorized" + }, + "403": { + "description": "Forbidden" + }, + "404": { + "description": "Not Found" + } + }, + "security": [ + { + "X-Access-Token": [ + "global" + ] + } + ], + "x-order": "2147483647" + } + }, + "/novel-admin/my_order/payOrder": { + "post": { + "tags": [ + "我的-礼物订阅接口" + ], + "summary": "支付订单", + "description": "支付订单", + "operationId": "payOrderUsingPOST", + "consumes": [ + "application/json" + ], + "produces": [ + "*/*" + ], + "parameters": [ + { + "name": "orderId", + "in": "query", + "description": "orderId", + "required": false, + "type": "string" + }, + { + "name": "token", + "in": "query", + "description": "token", + "required": false, + "type": "string" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/接口返回对象«object»", + "originalRef": "接口返回对象«object»" + } + }, + "201": { + "description": "Created" + }, + "401": { + "description": "Unauthorized" + }, + "403": { + "description": "Forbidden" + }, + "404": { + "description": "Not Found" + } + }, + "security": [ + { + "X-Access-Token": [ + "global" + ] + } + ], + "x-order": "2147483647" + } + }, + "/novel-admin/my_order/paySuccess": { + "post": { + "tags": [ + "我的-礼物订阅接口" + ], + "summary": "支付成功", + "description": "支付成功", + "operationId": "paySuccessUsingPOST", + "consumes": [ + "application/json" + ], + "produces": [ + "*/*" + ], + "parameters": [ + { + "name": "orderId", + "in": "query", + "description": "orderId", + "required": false, + "type": "string" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/接口返回对象«object»", + "originalRef": "接口返回对象«object»" + } + }, + "201": { + "description": "Created" + }, + "401": { + "description": "Unauthorized" + }, + "403": { + "description": "Forbidden" + }, + "404": { + "description": "Not Found" + } + }, + "security": [ + { + "X-Access-Token": [ + "global" + ] + } + ], + "x-order": "2147483647" + } + }, + "/novel-admin/my_task/clickMoreTask": { + "post": { + "tags": [ + "我的-任务中心相关接口" + ], + "summary": "点击更多任务", + "description": "点击更多任务", + "operationId": "clickMoreTaskUsingPOST", + "consumes": [ + "application/json" + ], + "produces": [ + "*/*" + ], + "parameters": [ + { + "name": "taskId", + "in": "query", + "description": "taskId", + "required": false, + "type": "string" + }, + { + "name": "X-Access-Token", + "in": "header", + "description": "X-Access-Token", + "required": true, + "type": "string" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/接口返回对象«object»", + "originalRef": "接口返回对象«object»" + } + }, + "201": { + "description": "Created" + }, + "401": { + "description": "Unauthorized" + }, + "403": { + "description": "Forbidden" + }, + "404": { + "description": "Not Found" + } + }, + "security": [ + { + "X-Access-Token": [ + "global" + ] + } + ], + "x-order": "2147483647" + } + }, + "/novel-admin/my_task/clickSignTask": { + "get": { + "tags": [ + "我的-任务中心相关接口" + ], + "summary": "点击签到任务", + "description": "点击签到任务", + "operationId": "clickSignTaskUsingGET", + "produces": [ + "*/*" + ], + "parameters": [ + { + "name": "taskId", + "in": "query", + "description": "taskId", + "required": false, + "type": "string" + }, + { + "name": "X-Access-Token", + "in": "header", + "description": "X-Access-Token", + "required": true, + "type": "string" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/接口返回对象«object»", + "originalRef": "接口返回对象«object»" + } + }, + "401": { + "description": "Unauthorized" + }, + "403": { + "description": "Forbidden" + }, + "404": { + "description": "Not Found" + } + }, + "security": [ + { + "X-Access-Token": [ + "global" + ] + } + ], + "x-order": "2147483647" + } + }, + "/novel-admin/my_task/getMoreTaskList": { + "get": { + "tags": [ + "我的-任务中心相关接口" + ], + "summary": "获取更多任务列表", + "description": "获取更多任务列表", + "operationId": "getMoreTaskListUsingGET", + "produces": [ + "*/*" + ], + "parameters": [ + { + "name": "token", + "in": "query", + "description": "token", + "required": false, + "type": "string" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/接口返回对象«object»", + "originalRef": "接口返回对象«object»" + } + }, + "401": { + "description": "Unauthorized" + }, + "403": { + "description": "Forbidden" + }, + "404": { + "description": "Not Found" + } + }, + "security": [ + { + "X-Access-Token": [ + "global" + ] + } + ], + "x-order": "2147483647" + } + }, + "/novel-admin/my_task/getMoreTaskRecordPage": { + "get": { + "tags": [ + "我的-任务中心相关接口" + ], + "summary": "获取更多任务记录列表", + "description": "获取更多任务记录列表", + "operationId": "getMoreTaskRecordPageUsingGET", + "produces": [ + "*/*" + ], + "parameters": [ + { + "name": "pageNo", + "in": "query", + "description": "当前页", + "required": false, + "type": "integer", + "format": "int32" + }, + { + "name": "pageSize", + "in": "query", + "description": "显示条数", + "required": false, + "type": "integer", + "format": "int32" + }, + { + "name": "X-Access-Token", + "in": "header", + "description": "X-Access-Token", + "required": true, + "type": "string" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/接口返回对象«object»", + "originalRef": "接口返回对象«object»" + } + }, + "401": { + "description": "Unauthorized" + }, + "403": { + "description": "Forbidden" + }, + "404": { + "description": "Not Found" + } + }, + "security": [ + { + "X-Access-Token": [ + "global" + ] + } + ], + "x-order": "2147483647" + } + }, + "/novel-admin/my_task/getMyRecommendTicketNum": { + "get": { + "tags": [ + "我的-任务中心相关接口" + ], + "summary": "获取我的推荐票数", + "description": "获取我的推荐票数", + "operationId": "getMyRecommendTicketNumUsingGET", + "produces": [ + "*/*" + ], + "parameters": [ + { + "name": "X-Access-Token", + "in": "header", + "description": "X-Access-Token", + "required": true, + "type": "string" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/接口返回对象«object»", + "originalRef": "接口返回对象«object»" + } + }, + "401": { + "description": "Unauthorized" + }, + "403": { + "description": "Forbidden" + }, + "404": { + "description": "Not Found" + } + }, + "security": [ + { + "X-Access-Token": [ + "global" + ] + } + ], + "x-order": "2147483647" + } + }, + "/novel-admin/my_task/getSignTaskList": { + "get": { + "tags": [ + "我的-任务中心相关接口" + ], + "summary": "获取我的推荐任务列表", + "description": "获取我的推荐任务列表", + "operationId": "getSignTaskListUsingGET", + "produces": [ + "*/*" + ], + "parameters": [ + { + "name": "token", + "in": "query", + "description": "token", + "required": false, + "type": "string" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/接口返回对象«object»", + "originalRef": "接口返回对象«object»" + } + }, + "401": { + "description": "Unauthorized" + }, + "403": { + "description": "Forbidden" + }, + "404": { + "description": "Not Found" + } + }, + "security": [ + { + "X-Access-Token": [ + "global" + ] + } + ], + "x-order": "2147483647" + } + }, + "/novel-admin/my_task/getSignTaskRecordPage": { + "get": { + "tags": [ + "我的-任务中心相关接口" + ], + "summary": "获取我的推荐任务记录列表", + "description": "获取我的推荐任务记录列表", + "operationId": "getSignTaskRecordPageUsingGET", + "produces": [ + "*/*" + ], + "parameters": [ + { + "name": "pageNo", + "in": "query", + "description": "当前页", + "required": false, + "type": "integer", + "format": "int32" + }, + { + "name": "pageSize", + "in": "query", + "description": "显示条数", + "required": false, + "type": "integer", + "format": "int32" + }, + { + "name": "X-Access-Token", + "in": "header", + "description": "X-Access-Token", + "required": true, + "type": "string" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/接口返回对象«object»", + "originalRef": "接口返回对象«object»" + } + }, + "401": { + "description": "Unauthorized" + }, + "403": { + "description": "Forbidden" + }, + "404": { + "description": "Not Found" + } + }, + "security": [ + { + "X-Access-Token": [ + "global" + ] + } + ], + "x-order": "2147483647" + } + }, + "/novel-admin/my_writer/getMyWriter": { + "get": { + "tags": [ + "我的-申请成为作家相关接口" + ], + "summary": "查询我的笔名以及简介", + "description": "查询我的笔名以及简介", + "operationId": "getMyWriterUsingGET", + "produces": [ + "*/*" + ], + "parameters": [ + { + "name": "X-Access-Token", + "in": "header", + "description": "X-Access-Token", + "required": true, + "type": "string" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/接口返回对象«object»", + "originalRef": "接口返回对象«object»" + } + }, + "401": { + "description": "Unauthorized" + }, + "403": { + "description": "Forbidden" + }, + "404": { + "description": "Not Found" + } + }, + "security": [ + { + "X-Access-Token": [ + "global" + ] + } + ], + "x-order": "2147483647" + } + }, + "/novel-admin/my_writer/saveOrUpdateWriter": { + "post": { + "tags": [ + "我的-申请成为作家相关接口" + ], + "summary": "填写或修改笔名以及简介成为作家", + "description": "填写或修改笔名以及简介成为作家", + "operationId": "saveOrUpdateWriterUsingPOST", + "consumes": [ + "application/json" + ], + "produces": [ + "*/*" + ], + "parameters": [ + { + "name": "details", + "in": "query", + "description": "details", + "required": false, + "type": "string" + }, + { + "name": "penName", + "in": "query", + "description": "penName", + "required": false, + "type": "string" + }, + { + "name": "X-Access-Token", + "in": "header", + "description": "X-Access-Token", + "required": true, + "type": "string" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/接口返回对象«object»", + "originalRef": "接口返回对象«object»" + } + }, + "201": { + "description": "Created" + }, + "401": { + "description": "Unauthorized" + }, + "403": { + "description": "Forbidden" + }, + "404": { + "description": "Not Found" + } + }, + "security": [ + { + "X-Access-Token": [ + "global" + ] + } + ], + "x-order": "2147483647" + } + } + }, + "securityDefinitions": { + "X-Access-Token": { + "type": "apiKey", + "name": "X-Access-Token", + "in": "header" + } + }, + "definitions": { + "接口返回对象«object»": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32", + "description": "返回代码" + }, + "message": { + "type": "string", + "description": "返回处理消息" + }, + "result": { + "type": "object", + "description": "返回数据对象" + }, + "success": { + "type": "boolean", + "description": "成功标志" + }, + "timestamp": { + "type": "integer", + "format": "int64", + "description": "时间戳" + } + }, + "title": "接口返回对象«object»", + "description": "接口返回对象" + } + } +} \ No newline at end of file diff --git a/src/api/auth.js b/src/api/auth.js new file mode 100644 index 0000000..cb092f6 --- /dev/null +++ b/src/api/auth.js @@ -0,0 +1,200 @@ +import api from './index.js'; + +/** + * 授权登录相关接口 + */ +export const authApi = { + /** + * 微信小程序授权登录 + * @param {Object} params 登录参数 + * @param {string} params.code 参数信息 + * @param {string} params.encryptedData 解密 + * @param {string} params.headimgurl 用户头像 + * @param {string} params.id 标识 + * @param {string} params.iv 解密标签 + * @param {string} params.nickName 用户姓名 + * @param {string} params.openid 用户唯一标识 + * @param {string} params.session_key 会话密钥 + * @param {string} params.shareId 邀请者销售标识 + * @param {string} params.state 类型 + * @param {string} params.vid 参数信息 + */ + async appletLogin(params) { + try { + const response = await api.get('/all_login/appletLogin', { params }); + + // 登录成功后自动保存token和用户信息 + if (response.success && response.result) { + const { token, userInfo } = response.result; + + if (token) { + // 保存认证token + localStorage.setItem('X-Access-Token', token); + localStorage.setItem('token', token); + + console.log('[Auth] 登录成功,token已保存'); + } + + if (userInfo) { + // 保存用户信息 + localStorage.setItem('user', JSON.stringify(userInfo)); + + // 更新store状态 + try { + import('../store/index.js').then(({ useMainStore }) => { + const store = useMainStore(); + store.user = userInfo; + store.isLoggedIn = true; + store.token = token; + store.isAuthor = userInfo.isAuthor || false; + + // 同步到localStorage + localStorage.setItem('isAuthor', userInfo.isAuthor || false); + + console.log('[Auth] Store状态已更新'); + }); + } catch (err) { + console.warn('[Auth] 无法更新store状态:', err); + } + } + } + + return response; + } catch (error) { + console.error('[Auth] 登录失败:', error); + throw error; + } + }, + + /** + * 绑定手机号码 + * @param {string} code 授权码 + */ + bindPhone(code) { + return api.get('/all_login/bindPhone', { + params: { code } + }); + }, + + /** + * 获取平台基础配置信息 + */ + getConfig() { + return api.get('/all_login/getConfig'); + }, + + /** + * 获取用户信息 + */ + async getUserByToken() { + try { + const response = await api.get('/all_login/getUserByToken'); + + // 更新本地用户信息 + if (response.success && response.result) { + localStorage.setItem('user', JSON.stringify(response.result)); + + // 更新store + try { + import('../store/index.js').then(({ useMainStore }) => { + const store = useMainStore(); + store.user = response.result; + store.isAuthor = response.result.isAuthor || false; + localStorage.setItem('isAuthor', response.result.isAuthor || false); + }); + } catch (err) { + console.warn('[Auth] 无法更新store状态:', err); + } + } + + return response; + } catch (error) { + console.error('[Auth] 获取用户信息失败:', error); + throw error; + } + }, + + /** + * 更新用户信息 + * @param {Object} userInfo 用户信息 + * @param {string} userInfo.avatarUrl 头像 + * @param {string} userInfo.details 简介 + * @param {string} userInfo.name 别名 + * @param {string} userInfo.nickName 昵称 + * @param {string} userInfo.phone 电话 + */ + async updateUserInfo(userInfo) { + try { + const response = await api.post('/all_login/updateUserInfo', null, { + params: userInfo + }); + + // 更新成功后重新获取用户信息 + if (response.success) { + await this.getUserByToken(); + } + + return response; + } catch (error) { + console.error('[Auth] 更新用户信息失败:', error); + throw error; + } + }, + + /** + * 手动登出 + * 清除所有登录状态和用户数据 + */ + logout() { + console.log('[Auth] 手动登出'); + + // 清除本地存储 + localStorage.removeItem('X-Access-Token'); + localStorage.removeItem('token'); + localStorage.removeItem('user'); + localStorage.removeItem('isAuthor'); + localStorage.removeItem('bookshelf'); + + // 清除store状态 + try { + import('../store/index.js').then(({ useMainStore }) => { + const store = useMainStore(); + store.logout(); + console.log('[Auth] Store状态已清除'); + }); + } catch (err) { + console.warn('[Auth] 无法清除store状态:', err); + } + + // 跳转到首页 + if (window.location.pathname !== '/') { + window.location.href = '/'; + } + }, + + /** + * 检查当前登录状态 + */ + checkLoginStatus() { + const token = localStorage.getItem('X-Access-Token'); + const user = localStorage.getItem('user'); + + try { + const userInfo = user ? JSON.parse(user) : null; + return { + isLoggedIn: !!(token && userInfo), + token, + user: userInfo, + isAuthor: userInfo?.isAuthor || localStorage.getItem('isAuthor') === 'true' + }; + } catch (err) { + console.warn('[Auth] 解析用户信息失败:', err); + return { + isLoggedIn: false, + token: null, + user: null, + isAuthor: false + }; + } + } +}; \ No newline at end of file diff --git a/src/api/bookshelf.js b/src/api/bookshelf.js new file mode 100644 index 0000000..eb849ac --- /dev/null +++ b/src/api/bookshelf.js @@ -0,0 +1,156 @@ +import api from './index.js'; + +/** + * 书架-阅读书架相关接口 + */ +export const readBookApi = { + /** + * 增加我的书架阅读记录 + * @param {Object} bookData 书籍数据 + */ + addReadBook(bookData) { + return api.post('/all_book/addReadBook', null, { + params: bookData + }); + }, + + /** + * 批量移除我阅读过的数据根据书籍标识 + * @param {string} bookIds 书籍ID列表,逗号分隔 + */ + batchRemoveReadBook(bookIds) { + return api.get('/all_book/batchRemoveReadBook', { + params: { bookIds } + }); + }, + + /** + * 获取我阅读过的书籍列表带分页 + * @param {Object} params 分页参数 + * @param {number} params.pageNo 当前页 + * @param {number} params.pageSize 显示条数 + */ + getReadBookPage(params) { + return api.get('/all_book/getReadBookPage', { params }); + }, + + /** + * 移除我阅读过的书籍根据书籍标识 + * @param {string} bookId 书籍ID + */ + removeReadBook(bookId) { + return api.get('/all_book/removeReadBook', { + params: { bookId } + }); + } +}; + +/** + * 书架-我的作品相关接口 + */ +export const myBookApi = { + /** + * 删除作品章节 + * @param {Object} params 删除参数 + * @param {string} params.bookId 书籍ID + * @param {string} params.id 章节ID + */ + deleteMyNovel(params) { + return api.post('/my_book/deleteMyNovel', null, { params }); + }, + + /** + * 删除我的作品 + * @param {string} bookId 书籍ID + */ + deleteMyShop(bookId) { + return api.post('/my_book/deleteMyShop', null, { + params: { bookId } + }); + }, + + /** + * 多选删除我的作品 + * @param {string} bookIds 书籍ID列表,逗号分隔 + */ + deleteMyShopList(bookIds) { + return api.post('/my_book/deleteMyShopList', null, { + params: { bookIds } + }); + }, + + /** + * 获取我的小说章节列表带分页 + * @param {Object} params 查询参数 + * @param {string} params.bookId 书籍ID + * @param {number} params.pageNo 当前页 + * @param {number} params.pageSize 显示条数 + * @param {number} params.reverse 是否倒序 + * @param {number} params.status 状态 + */ + getMyShopNovelPage(params) { + return api.post('/my_book/getMyShopNovelPage', null, { params }); + }, + + /** + * 获取我的作品带分页 + * @param {Object} params 分页参数 + * @param {number} params.pageNo 当前页 + * @param {number} params.pageSize 显示条数 + */ + getMyShopPage(params) { + return api.get('/my_book/getMyShopPage', { params }); + }, + + /** + * 添加作品或者修改作品 + * @param {Object} shopData 作品数据 + */ + saveOrUpdateShop(shopData) { + return api.post('/my_book/saveOrUpdateShop', null, { + params: shopData + }); + }, + + /** + * 增加或修改作品章节 + * @param {Object} novelData 章节数据 + */ + saveOrUpdateShopNovel(novelData) { + return api.post('/my_book/saveOrUpdateShopNovel', null, { + params: novelData + }); + } +}; + +/** + * 书架-读者成就相关接口 + */ +export const achievementApi = { + /** + * 根据用户标识和书籍标识查询该用户的成就等级 + * @param {string} bookId 书籍ID + */ + getAchievement(bookId) { + return api.get('/all_achievement/getAchievement', { + params: { bookId } + }); + }, + + /** + * 获取读者成就列表 + */ + getAchievementList() { + return api.get('/all_achievement/getAchievementList'); + }, + + /** + * 设置读者成就等级名称 + * @param {Object} achievementData 成就数据 + */ + setAchievementName(achievementData) { + return api.post('/all_achievement/setAchievementName', null, { + params: achievementData + }); + } +}; \ No newline at end of file diff --git a/src/api/example.js b/src/api/example.js new file mode 100644 index 0000000..318ae17 --- /dev/null +++ b/src/api/example.js @@ -0,0 +1,321 @@ +/** + * API使用示例 + * 展示如何在Vue组件中使用这些API接口 + */ + +// 导入方式1:按需导入 +import { authApi, homeApi, commentApi, checkAuthStatus, clearAuthStatus } from './modules.js'; + +// 导入方式2:全量导入 +import api from './modules.js'; + +// 使用示例 +export const apiExamples = { + // 1. 用户登录示例 + async userLogin() { + try { + const loginData = { + code: 'wx_auth_code', + nickName: '用户昵称', + headimgurl: 'http://avatar.url', + openid: 'wx_openid' + }; + + const response = await authApi.appletLogin(loginData); + if (response.success) { + console.log('登录成功:', response.result); + // token和用户信息已自动保存,store状态已更新 + return response.result; + } + } catch (error) { + console.error('登录失败:', error.message); + throw error; + } + }, + + // 2. 检查登录状态示例 + checkUserLoginStatus() { + // 使用辅助函数检查登录状态 + const authStatus = authApi.checkLoginStatus(); + console.log('当前登录状态:', authStatus); + + if (authStatus.isLoggedIn) { + console.log('用户已登录:', authStatus.user); + console.log('是否为作家:', authStatus.isAuthor); + } else { + console.log('用户未登录'); + } + + return authStatus; + }, + + // 3. 处理需要认证的API调用 + async callProtectedApi() { + try { + // 首先检查登录状态 + if (!checkAuthStatus()) { + throw new Error('用户未登录'); + } + + // 调用需要认证的接口 + const response = await api.myBook.getMyShopPage({ pageNo: 1, pageSize: 10 }); + return response.result; + } catch (error) { + if (error.message.includes('401') || error.message.includes('未授权')) { + console.log('认证失败,已自动处理登录状态'); + // 401错误已经被自动处理,这里可以提示用户重新登录 + return null; + } + throw error; + } + }, + + // 4. 获取首页数据示例 + async getHomeData() { + try { + // 并行请求多个接口 + const [banner, categories, newBooks] = await Promise.all([ + homeApi.getBanner(), + homeApi.getCategoryList(), + homeApi.getNewList({ pageNo: 1, pageSize: 10 }) + ]); + + return { + banner: banner.result, + categories: categories.result, + newBooks: newBooks.result + }; + } catch (error) { + console.error('获取首页数据失败:', error.message); + throw error; + } + }, + + // 5. 获取书籍详情示例 + async getBookDetail(bookId) { + try { + const response = await homeApi.getBookDetail({ id: bookId }); + return response.result; + } catch (error) { + console.error('获取书籍详情失败:', error.message); + throw error; + } + }, + + // 6. 发表评论示例(需要登录) + async postComment(bookId, content) { + try { + // 检查登录状态 + if (!checkAuthStatus()) { + throw new Error('请先登录后再发表评论'); + } + + const response = await commentApi.saveComment({ + bookId, + content + }); + + if (response.success) { + console.log('评论发表成功'); + return response.result; + } + } catch (error) { + console.error('发表评论失败:', error.message); + throw error; + } + }, + + // 7. 分页获取数据示例 + async getMyBooks(page = 1, size = 10) { + try { + const response = await api.myBook.getMyShopPage({ + pageNo: page, + pageSize: size + }); + + return { + list: response.result.records, + total: response.result.total, + current: response.result.current + }; + } catch (error) { + console.error('获取我的作品失败:', error.message); + throw error; + } + }, + + // 8. 手动登出示例 + async logout() { + try { + // 调用登出API + authApi.logout(); + console.log('已登出'); + } catch (error) { + console.error('登出失败:', error.message); + // 即使API调用失败,也要清除本地状态 + clearAuthStatus(); + } + }, + + // 9. 文件上传示例(如果需要) + async uploadImage(file) { + try { + // 检查登录状态 + if (!checkAuthStatus()) { + throw new Error('请先登录'); + } + + const formData = new FormData(); + formData.append('file', file); + + // 注意:这里需要根据实际的上传接口调整 + const response = await fetch('/api/upload', { + method: 'POST', + headers: { + 'X-Access-Token': localStorage.getItem('X-Access-Token') + }, + body: formData + }); + + if (response.status === 401) { + // 401错误会被axios拦截器处理 + throw new Error('认证失败'); + } + + return await response.json(); + } catch (error) { + console.error('文件上传失败:', error.message); + throw error; + } + } +}; + +// Vue 3 Composition API 使用示例 +export function useApiExamples() { + const { authApi, homeApi, commentApi } = api; + + // 响应式数据 + const loading = ref(false); + const error = ref(null); + const authStatus = ref(authApi.checkLoginStatus()); + + // 封装API调用 + const callApi = async (apiFunction, ...args) => { + loading.value = true; + error.value = null; + + try { + const result = await apiFunction(...args); + return result; + } catch (err) { + error.value = err.message; + throw err; + } finally { + loading.value = false; + } + }; + + // 带认证检查的API调用 + const callProtectedApi = async (apiFunction, ...args) => { + // 检查登录状态 + const currentAuthStatus = authApi.checkLoginStatus(); + authStatus.value = currentAuthStatus; + + if (!currentAuthStatus.isLoggedIn) { + error.value = '请先登录'; + throw new Error('请先登录'); + } + + return callApi(apiFunction, ...args); + }; + + // 监听认证状态变化 + const refreshAuthStatus = () => { + authStatus.value = authApi.checkLoginStatus(); + }; + + // 登录方法 + const login = async (...args) => { + const result = await callApi(authApi.appletLogin, ...args); + refreshAuthStatus(); // 登录后刷新状态 + return result; + }; + + // 登出方法 + const logout = () => { + authApi.logout(); + refreshAuthStatus(); // 登出后刷新状态 + }; + + return { + loading, + error, + authStatus, + callApi, + callProtectedApi, + refreshAuthStatus, + + // 具体的API方法 + login, + logout, + getBanner: (...args) => callApi(homeApi.getBanner, ...args), + postComment: (...args) => callProtectedApi(commentApi.saveComment, ...args), + getMyBooks: (...args) => callProtectedApi(api.myBook.getMyShopPage, ...args) + }; +} + +// 错误处理最佳实践示例 +export const errorHandlingExamples = { + // 标准错误处理模式 + async standardErrorHandling() { + try { + const response = await homeApi.getBanner(); + return response.result; + } catch (error) { + // 根据错误类型进行不同处理 + if (error.message.includes('网络')) { + // 网络错误 + console.error('网络连接失败,请检查网络设置'); + } else if (error.message.includes('401')) { + // 认证错误(已被自动处理) + console.error('认证失败,请重新登录'); + } else if (error.message.includes('403')) { + // 权限错误 + console.error('没有权限访问此资源'); + } else { + // 其他错误 + console.error('请求失败:', error.message); + } + throw error; + } + }, + + // 重试机制示例 + async withRetry(apiFunction, maxRetries = 3, delay = 1000) { + let lastError; + + for (let i = 0; i < maxRetries; i++) { + try { + return await apiFunction(); + } catch (error) { + lastError = error; + + // 401错误不重试 + if (error.message.includes('401')) { + throw error; + } + + // 最后一次重试失败 + if (i === maxRetries - 1) { + throw error; + } + + // 等待后重试 + await new Promise(resolve => setTimeout(resolve, delay)); + console.log(`第${i + 1}次重试...`); + } + } + + throw lastError; + } +}; \ No newline at end of file diff --git a/src/api/home.js b/src/api/home.js new file mode 100644 index 0000000..9aeb677 --- /dev/null +++ b/src/api/home.js @@ -0,0 +1,157 @@ +import api from './index.js'; + +/** + * 首页相关接口 + */ +export const homeApi = { + /** + * 获取首页banner + */ + getBanner() { + return api.get('/all_index/getBanner'); + }, + + /** + * 获取书城区域列表 + */ + getBookAreaList() { + return api.get('/all_index/getBookAreaList'); + }, + + /** + * 根据目录查询章节小说信息明细 + * @param {string} id 目录ID + */ + getBookCatalogDetail(id) { + return api.get('/all_index/getBookCatalogDetail', { + params: { id } + }); + }, + + /** + * 根据书本标识获取书本目录列表 + * @param {Object} params 查询参数 + * @param {string} params.bookId 书本ID + * @param {string} params.orderBy 排序方式 + * @param {number} params.pageNo 当前页 + * @param {number} params.pageSize 显示条数 + */ + getBookCatalogList(params) { + return api.get('/all_index/getBookCatalogList', { params }); + }, + + /** + * 根据书本标识获取书本详细信息 + * @param {Object} params 查询参数 + * @param {string} params.id 书本ID + * @param {string} params.token token + */ + getBookDetail(params) { + return api.get('/all_index/getBookDetail', { params }); + }, + + /** + * 获取书城分类列表 + */ + getCategoryList() { + return api.get('/all_index/getCategoryList'); + }, + + /** + * 获取亲密度排行版 + * @param {Object} params 查询参数 + * @param {string} params.bookId 书本ID + * @param {number} params.pageNo 当前页 + * @param {number} params.pageSize 显示条数 + */ + getIntimacyRankList(params) { + return api.get('/all_index/getIntimacyRankList', { params }); + }, + + /** + * 获取首页最新小说列表带分页 + * @param {Object} params 分页参数 + * @param {number} params.pageNo 当前页 + * @param {number} params.pageSize 显示条数 + */ + getNewList(params) { + return api.get('/all_index/getNewList', { params }); + }, + + /** + * 获取首页公告 + */ + getNotice() { + return api.get('/all_index/getNotice'); + }, + + /** + * 获取公告详情 + * @param {string} id 公告ID + */ + getNoticeById(id) { + return api.get('/all_index/getNoticeById', { + params: { id } + }); + }, + + /** + * 获取公告列表带分页 + * @param {Object} params 分页参数 + * @param {number} params.pageNo 当前页 + * @param {number} params.pageSize 显示条数 + */ + getNoticePage(params) { + return api.get('/all_index/getNoticePage', { params }); + }, + + /** + * 获取首页精品推荐小说列表带分页 + */ + getRecommendList(params) { + return api.get('/all_index/getRecommendList', { params }); + }, + + /** + * 根据书本标识进行投票 + * @param {Object} params 投票参数 + * @param {string} params.bookId 书本ID + * @param {string} params.num 投票数 + */ + vote(params) { + return api.get('/all_index/vote', { params }); + }, + + /** + * 获取排行榜数据 - 根据不同榜单类型和分类获取书籍列表 + * @param {Object} params 查询参数 + * @param {string} params.rankType 榜单类型 (1:推荐榜 2:完本榜 3:阅读榜 4:口碑榜 5:新书榜 6:高分榜) + * @param {string} params.categoryId 分类ID + * @param {number} params.pageNo 当前页 + * @param {number} params.pageSize 显示条数 + */ + getRankingList(params) { + const { rankType, categoryId, pageNo = 1, pageSize = 20 } = params; + + // 根据不同的榜单类型调用不同的接口 + switch (rankType) { + case '1': // 推荐榜 + return api.get('/all_index/getRecommendList', { + params: { pageNo, pageSize, categoryId } + }); + case '5': // 新书榜 + return api.get('/all_index/getNewList', { + params: { pageNo, pageSize, categoryId } + }); + case '3': // 阅读榜 (使用亲密度排行榜作为替代) + return api.get('/all_index/getIntimacyRankList', { + params: { pageNo, pageSize, bookId: categoryId } + }); + default: + // 其他榜单暂时使用推荐列表作为占位 + return api.get('/all_index/getRecommendList', { + params: { pageNo, pageSize, categoryId } + }); + } + } +}; \ No newline at end of file diff --git a/src/api/index.js b/src/api/index.js index aadd9e7..389101b 100644 --- a/src/api/index.js +++ b/src/api/index.js @@ -1,7 +1,8 @@ import axios from 'axios'; const api = axios.create({ - baseURL: import.meta.env.VITE_API_BASE_URL || '/api', + baseURL: 'https://prod-api.budingxiaoshuo.com/novel-admin', + // baseURL: import.meta.env.VITE_API_BASE_URL || 'http://127.0.0.1', timeout: 10000, headers: { 'Content-Type': 'application/json' @@ -11,9 +12,9 @@ const api = axios.create({ // 请求拦截器 api.interceptors.request.use( config => { - const token = localStorage.getItem('token'); + const token = localStorage.getItem('X-Access-Token'); if (token) { - config.headers.Authorization = `Bearer ${token}`; + config.headers['X-Access-Token'] = token; } return config; }, @@ -25,15 +26,149 @@ api.interceptors.request.use( // 响应拦截器 api.interceptors.response.use( response => { - return response.data; + const { data } = response; + // 根据API文档的统一返回格式处理 + if (data.success === false) { + return Promise.reject(new Error(data.message || '请求失败')); + } + return data; }, error => { if (error.response && error.response.status === 401) { - // 处理未授权的情况 - // 可以在这里触发退出登录或跳转到登录页 + console.log('[API] 401 未授权,清除登录状态'); + + // 清除所有登录相关的本地存储 + localStorage.removeItem('X-Access-Token'); + localStorage.removeItem('token'); + localStorage.removeItem('user'); + localStorage.removeItem('isAuthor'); + localStorage.removeItem('bookshelf'); + + // 尝试获取store实例并清除状态 + try { + // 使用动态导入并通过Promise处理 + import('../store/index.js').then(({ useMainStore }) => { + const store = useMainStore(); + store.logout(); + console.log('[API] Store状态已清除'); + }).catch(err => { + console.warn('[API] 无法访问store:', err); + }); + } catch (err) { + console.warn('[API] 导入store模块失败:', err); + } + + // 获取当前路由信息 + const currentPath = window.location.pathname; + const isProtectedRoute = currentPath.includes('/bookshelf') || + currentPath.includes('/task-center') || + currentPath.includes('/gift-box') || + currentPath.includes('/messages') || + currentPath.includes('/author'); + + // 如果当前在受保护的路由上,触发登录弹窗 + if (isProtectedRoute) { + console.log('[API] 当前在受保护路由,尝试触发登录弹窗'); + + // 延迟执行,确保DOM已就绪 + setTimeout(() => { + // 尝试调用全局的登录弹窗 + const authContext = window.$authContext; + if (authContext && typeof authContext.openLogin === 'function') { + authContext.openLogin(() => { + console.log('[API] 登录成功回调'); + // 登录成功后可以重新发起原来的请求 + window.location.reload(); + }); + } else { + // 如果没有全局登录弹窗,使用路由事件 + const { routerEvents } = window.$router || {}; + if (routerEvents) { + routerEvents.triggerLogin = () => { + const context = window.$authContext; + if (context && typeof context.openLogin === 'function') { + context.openLogin(() => { + window.location.reload(); + }); + } + }; + } + + // 如果都不可用,跳转到首页 + console.log('[API] 无法触发登录弹窗,跳转到首页'); + window.location.href = '/'; + } + }, 100); + } else { + // 如果在公开页面,只是清除状态,不跳转 + console.log('[API] 当前在公开页面,只清除状态'); + } + } else if (error.response) { + // 处理其他HTTP错误 + const { status, data } = error.response; + console.error(`[API] HTTP错误 ${status}:`, data); + + // 根据不同状态码提供更友好的错误信息 + let errorMessage = '网络请求失败'; + switch (status) { + case 400: + errorMessage = data?.message || '请求参数错误'; + break; + case 403: + errorMessage = '没有权限访问'; + break; + case 404: + errorMessage = '请求的资源不存在'; + break; + case 500: + errorMessage = '服务器内部错误'; + break; + case 502: + case 503: + case 504: + errorMessage = '服务器暂时不可用,请稍后重试'; + break; + default: + errorMessage = data?.message || `请求失败 (${status})`; + } + + return Promise.reject(new Error(errorMessage)); + } else if (error.request) { + // 网络错误 + console.error('[API] 网络错误:', error.request); + return Promise.reject(new Error('网络连接失败,请检查网络设置')); + } else { + // 其他错误 + console.error('[API] 请求错误:', error.message); + return Promise.reject(error); } - return Promise.reject(error); } ); +// 导出一个辅助函数,用于检查当前登录状态 +export const checkAuthStatus = () => { + const token = localStorage.getItem('X-Access-Token'); + const user = localStorage.getItem('user'); + return !!(token && user); +}; + +// 导出一个辅助函数,用于手动清除登录状态 +export const clearAuthStatus = () => { + localStorage.removeItem('X-Access-Token'); + localStorage.removeItem('token'); + localStorage.removeItem('user'); + localStorage.removeItem('isAuthor'); + localStorage.removeItem('bookshelf'); + + // 如果可以访问store,也清除store状态 + try { + import('../store/index.js').then(({ useMainStore }) => { + const store = useMainStore(); + store.logout(); + }); + } catch (err) { + console.warn('[API] 无法清除store状态:', err); + } +}; + export default api; \ No newline at end of file diff --git a/src/api/modules.js b/src/api/modules.js new file mode 100644 index 0000000..bce9425 --- /dev/null +++ b/src/api/modules.js @@ -0,0 +1,41 @@ +// 统一导出所有API模块 +export { authApi } from './auth.js'; +export { homeApi } from './home.js'; +export { readBookApi, myBookApi, achievementApi } from './bookshelf.js'; +export { moneyApi, commentApi, taskApi, writerApi, orderApi } from './user.js'; + +// 导出辅助函数 +export { checkAuthStatus, clearAuthStatus } from './index.js'; + +// 默认导出,方便直接使用 +import { authApi } from './auth.js'; +import { homeApi } from './home.js'; +import { readBookApi, myBookApi, achievementApi } from './bookshelf.js'; +import { moneyApi, commentApi, taskApi, writerApi, orderApi } from './user.js'; +import { checkAuthStatus, clearAuthStatus } from './index.js'; + +export default { + // 授权登录 + auth: authApi, + + // 首页 + home: homeApi, + + // 书架相关 + readBook: readBookApi, + myBook: myBookApi, + achievement: achievementApi, + + // 用户相关 + money: moneyApi, + comment: commentApi, + task: taskApi, + writer: writerApi, + order: orderApi, + + // 辅助工具 + utils: { + checkAuthStatus, + clearAuthStatus + } +}; \ No newline at end of file diff --git a/src/api/types.ts b/src/api/types.ts new file mode 100644 index 0000000..06fc4c7 --- /dev/null +++ b/src/api/types.ts @@ -0,0 +1,144 @@ +/** + * API接口类型定义 + */ + +// 基础响应类型 +export interface ApiResponse { + code: number; + message: string; + result: T; + success: boolean; + timestamp: number; +} + +// 分页参数 +export interface PaginationParams { + pageNo?: number; + pageSize?: number; +} + +// 分页响应 +export interface PaginationResponse { + records: T[]; + total: number; + current: number; + size: number; + pages: number; +} + +// 用户登录参数 +export interface LoginParams { + code?: string; + encryptedData?: string; + headimgurl?: string; + id?: string; + iv?: string; + nickName?: string; + openid?: string; + session_key?: string; + shareId?: string; + state?: string; + vid?: string; +} + +// 用户信息 +export interface UserInfo { + avatarUrl?: string; + details?: string; + name?: string; + nickName?: string; + phone?: string; +} + +// 书籍信息 +export interface BookInfo { + id: string; + name: string; + author: string; + image: string; + details: string; + shopClass: string; + shopCion: string; + status: number; + bookStatus: number; + tuiNum: number; + qmNum: number; +} + +// 章节信息 +export interface ChapterInfo { + id: string; + bookId: string; + title: string; + details: string; + num: number; + sort: number; + status: number; + isPay: string; +} + +// 评论信息 +export interface CommentInfo { + id: string; + bookId: string; + content: string; + userId: string; + createTime: string; +} + +// 任务信息 +export interface TaskInfo { + id: string; + name: string; + description: string; + reward: number; + status: number; +} + +// 礼物信息 +export interface GiftInfo { + id: string; + name: string; + price: number; + image: string; + description: string; +} + +// 订单信息 +export interface OrderInfo { + id: string; + giftId: string; + num: number; + totalPrice: number; + status: number; + createTime: string; +} + +// 成就信息 +export interface AchievementInfo { + id: string; + bookId: string; + userId: string; + oneName: string; + twoName: string; + threeName: string; + oneNum: number; + twoNum: number; + threeNum: number; +} + +// 作家信息 +export interface WriterInfo { + penName: string; + details: string; +} + +// 流水记录 +export interface MoneyLogInfo { + id: string; + amount: number; + type: string; + description: string; + createTime: string; + status: number; +} \ No newline at end of file diff --git a/src/api/user.js b/src/api/user.js new file mode 100644 index 0000000..2e2b987 --- /dev/null +++ b/src/api/user.js @@ -0,0 +1,268 @@ +import api from './index.js'; + +/** + * 我的-流水相关接口 + */ +export const moneyApi = { + /** + * 获取我的流水列表带分页 + * @param {Object} params 查询参数 + * @param {number} params.pageNo 当前页 + * @param {number} params.pageSize 显示条数 + * @param {number} params.status 状态 + */ + getMyMoneyLogPage(params) { + return api.get('/all_money/getMyMoneyLogPage', { params }); + }, + + /** + * 获取我的可用积分数 + */ + getMyMoneyNum() { + return api.get('/all_money/getMyMoneyNum'); + } +}; + +/** + * 我的-评论相关接口 + */ +export const commentApi = { + /** + * 删除评论信息 + * @param {string} commentId 评论ID + */ + deleteComment(commentId) { + return api.get('/my_comment/deleteComment', { + params: { commentId } + }); + }, + + /** + * 获取评论详情 + * @param {string} commentId 评论ID + */ + getCommentDetail(commentId) { + return api.post('/my_comment/getCommentDetail', null, { + params: { commentId } + }); + }, + + /** + * 根据书籍标识查询评论信息列表带分页 + * @param {Object} params 查询参数 + * @param {string} params.bookId 书籍ID + * @param {number} params.pageNo 当前页 + * @param {number} params.pageSize 显示条数 + */ + getCommentList(params) { + return api.get('/my_comment/getCommentList', { params }); + }, + + /** + * 获取我的评论列表 + * @param {Object} params 分页参数 + * @param {number} params.pageNo 当前页 + * @param {number} params.pageSize 显示条数 + */ + getMyCommentList(params) { + return api.get('/my_comment/getMyCommentList', { params }); + }, + + /** + * 获取我的评论数 + */ + getMyCommentNum() { + return api.get('/my_comment/getMyCommentNum'); + }, + + /** + * 回复评论信息 + * @param {Object} params 回复参数 + * @param {string} params.commentId 评论ID + * @param {string} params.content 回复内容 + */ + replyComment(params) { + return api.post('/my_comment/replyComment', null, { params }); + }, + + /** + * 保存评论信息 + * @param {Object} params 评论参数 + * @param {string} params.bookId 书籍ID + * @param {string} params.content 评论内容 + */ + saveComment(params) { + return api.post('/my_comment/saveComment', null, { params }); + }, + + /** + * 更新评论已读状态 + * @param {string} commentId 评论ID + */ + updateCommentRead(commentId) { + return api.post('/my_comment/updateCommentRead', null, { + params: { commentId } + }); + } +}; + +/** + * 我的-任务中心相关接口 + */ +export const taskApi = { + /** + * 点击更多任务 + * @param {string} taskId 任务ID + */ + clickMoreTask(taskId) { + return api.post('/my_task/clickMoreTask', null, { + params: { taskId } + }); + }, + + /** + * 点击签到任务 + * @param {string} taskId 任务ID + */ + clickSignTask(taskId) { + return api.get('/my_task/clickSignTask', { + params: { taskId } + }); + }, + + /** + * 获取更多任务列表 + * @param {string} token token + */ + getMoreTaskList(token) { + return api.get('/my_task/getMoreTaskList', { + params: { token } + }); + }, + + /** + * 获取更多任务记录列表 + * @param {Object} params 分页参数 + * @param {number} params.pageNo 当前页 + * @param {number} params.pageSize 显示条数 + */ + getMoreTaskRecordPage(params) { + return api.get('/my_task/getMoreTaskRecordPage', { params }); + }, + + /** + * 获取我的推荐票数 + */ + getMyRecommendTicketNum() { + return api.get('/my_task/getMyRecommendTicketNum'); + }, + + /** + * 获取我的推荐任务列表 + * @param {string} token token + */ + getSignTaskList(token) { + return api.get('/my_task/getSignTaskList', { + params: { token } + }); + }, + + /** + * 获取我的推荐任务记录列表 + * @param {Object} params 分页参数 + * @param {number} params.pageNo 当前页 + * @param {number} params.pageSize 显示条数 + */ + getSignTaskRecordPage(params) { + return api.get('/my_task/getSignTaskRecordPage', { params }); + } +}; + +/** + * 我的-申请成为作家相关接口 + */ +export const writerApi = { + /** + * 查询我的笔名以及简介 + */ + getMyWriter() { + return api.get('/my_writer/getMyWriter'); + }, + + /** + * 填写或修改笔名以及简介成为作家 + * @param {Object} params 作家信息 + * @param {string} params.details 简介 + * @param {string} params.penName 笔名 + */ + saveOrUpdateWriter(params) { + return api.post('/my_writer/saveOrUpdateWriter', null, { params }); + } +}; + +/** + * 我的-礼物订阅接口 + */ +export const orderApi = { + /** + * 创建订单 + * @param {Object} params 订单参数 + * @param {string} params.giftId 礼物ID + * @param {number} params.num 数量 + * @param {string} params.token token + */ + createOrder(params) { + return api.post('/my_order/createOrder', null, { params }); + }, + + /** + * 查询礼物详情 + * @param {string} giftId 礼物ID + */ + getGiftDetail(giftId) { + return api.get('/my_order/getGiftDetail', { + params: { giftId } + }); + }, + + /** + * 查询互动打赏礼物信息列表 + * @param {Object} params 分页参数 + * @param {number} params.pageNo 当前页 + * @param {number} params.pageSize 显示条数 + */ + getInteractionGiftList(params) { + return api.get('/my_order/getInteractionGiftList', { params }); + }, + + /** + * 查询我的礼物包订单列表 + * @param {Object} params 查询参数 + * @param {number} params.pageNo 当前页 + * @param {number} params.pageSize 显示条数 + * @param {string} params.token token + */ + getMyGiftList(params) { + return api.get('/my_order/getMyGiftList', { params }); + }, + + /** + * 支付订单 + * @param {Object} params 支付参数 + * @param {string} params.orderId 订单ID + * @param {string} params.token token + */ + payOrder(params) { + return api.post('/my_order/payOrder', null, { params }); + }, + + /** + * 支付成功 + * @param {string} orderId 订单ID + */ + paySuccess(orderId) { + return api.post('/my_order/paySuccess', null, { + params: { orderId } + }); + } +}; \ No newline at end of file diff --git a/src/components/book/BookCatalog.vue b/src/components/book/BookCatalog.vue index 19991d6..beb7101 100644 --- a/src/components/book/BookCatalog.vue +++ b/src/components/book/BookCatalog.vue @@ -4,7 +4,8 @@

目录

- + +
@@ -17,7 +18,24 @@
-