feat(api): 添加车辆相关API接口并更新订单API文档
更新订单API的文档格式和最后编辑信息 新增car.js文件实现车辆相关的API接口功能
Showing
3 changed files
with
120 additions
and
9 deletions
src/api/car.js
0 → 100644
| 1 | +/* | ||
| 2 | + * @Date: 2025-07-09 14:58:51 | ||
| 3 | + * @LastEditors: hookehuyr hookehuyr@gmail.com | ||
| 4 | + * @LastEditTime: 2025-07-09 15:55:25 | ||
| 5 | + * @FilePath: /jgdl/src/api/car.js | ||
| 6 | + * @Description: 车辆相关API接口 | ||
| 7 | + */ | ||
| 8 | +import { fn, fetch } from './fn'; | ||
| 9 | + | ||
| 10 | +const Api = { | ||
| 11 | + ADD_VEHICLE: '/srv/?a=vehicle&t=add', | ||
| 12 | + EDIT_VEHICLE: '/srv/?a=vehicle&t=edit', | ||
| 13 | + RECOMMEND_VEHICLE: '/srv/?a=vehicle&t=recommendation', | ||
| 14 | + LIST_VEHICLE: '/srv/?a=vehicle&t=list', | ||
| 15 | + DETAIL_VEHICLE: '/srv/?a=vehicle&t=detail', | ||
| 16 | + MY_LISTING_VEHICLE: '/srv/?a=vehicle&t=my_listings', | ||
| 17 | + CHANGE_STATUS_VEHICLE: '/srv/?a=vehicle&t=change_status', | ||
| 18 | +} | ||
| 19 | + | ||
| 20 | +/** | ||
| 21 | + * @description: 添加车辆 | ||
| 22 | + * @param id 车辆ID(编辑时必填) | ||
| 23 | + * @param title 标题 | ||
| 24 | + * @param brand 品牌 | ||
| 25 | + * @param model 型号 | ||
| 26 | + * @param manufacture_year 出厂年份 | ||
| 27 | + * @param new_level 新旧程度;1到5分 | ||
| 28 | + * @param range_km 续航里程 | ||
| 29 | + * @param total_mileage_km 总里程 | ||
| 30 | + * @param max_speed_kmh 最大车速 | ||
| 31 | + * @param battery_capacity_ah 电池容量 | ||
| 32 | + * @param brake_wear_level 制动磨损程度;1到5分 | ||
| 33 | + * @param price 出让价格 | ||
| 34 | + * @param market_price 市场价格 | ||
| 35 | + * @param verification_status 认证状态(1=不认证, 3=认证待审核, 5=已认证, 7=认证失败) | ||
| 36 | + * @param note 车辆描述 | ||
| 37 | + * @param photo_meta_ids 照片的附件ID数组(编辑时可选) | ||
| 38 | + * @returns | ||
| 39 | + */ | ||
| 40 | + | ||
| 41 | +export const addVehicleAPI = (params) => fn(fetch.post(Api.ADD_VEHICLE, params)); | ||
| 42 | + | ||
| 43 | +/** | ||
| 44 | + * @description: 编辑车辆 | ||
| 45 | + * @param id 车辆ID(编辑时必填) | ||
| 46 | + * @param title 标题 | ||
| 47 | + * @param brand 品牌 | ||
| 48 | + * @param model 型号 | ||
| 49 | + * @param manufacture_year 出厂年份 | ||
| 50 | + * @param new_level 新旧程度;1到5分 | ||
| 51 | + * @param range_km 续航里程 | ||
| 52 | + * @param total_mileage_km 总里程 | ||
| 53 | + * @param max_speed_kmh 最大车速 | ||
| 54 | + * @param battery_capacity_ah 电池容量 | ||
| 55 | + * @param brake_wear_level 制动磨损程度;1到5分 | ||
| 56 | + * @param price 出让价格 | ||
| 57 | + * @param market_price 市场价格 | ||
| 58 | + * @param verification_status 认证状态(1=不认证, 3=认证待审核, 5=已认证, 7=认证失败) | ||
| 59 | + * @param note 车辆描述 | ||
| 60 | + * @param photo_meta_ids 照片的附件ID数组(编辑时可选) | ||
| 61 | + * @returns | ||
| 62 | + */ | ||
| 63 | + | ||
| 64 | +export const editVehicleAPI = (params) => fn(fetch.post(Api.EDIT_VEHICLE, params)); | ||
| 65 | + | ||
| 66 | +/** | ||
| 67 | + * @description: 首页轮播/最新上架/特价好车 | ||
| 68 | + * @param section 推荐的位置,1=首页轮播, 2=特价好车, 3=精品推荐 | ||
| 69 | + * @returns data[{ id, seller_id, school_id, school_name, title, brand, model, manufacture_year, new_level, range_km, total_mileage_km, max_speed_kmh, battery_capacity_ah, brake_wear_level, tire_wear_level, price, market_price, verification_status, rejection_reason, note, photos, is_favorite }] | ||
| 70 | + */ | ||
| 71 | + | ||
| 72 | +export const getRecommendVehicleAPI = (params) => fn(fetch.get(Api.RECOMMEND_VEHICLE, params)); | ||
| 73 | + | ||
| 74 | +/** | ||
| 75 | + * @description: 车辆列表/认证车源 | ||
| 76 | + * @param school_id 学校ID | ||
| 77 | + * @param brand 品牌 | ||
| 78 | + * @param manufacture_year 出厂年份 | ||
| 79 | + * @param verification_status 认证状态(1=不认证, 3=认证待审核, 5=已认证, 7=认证失败) | ||
| 80 | + * @param keyword 搜索关键字(品牌/型号/描述) | ||
| 81 | + * @param page 页码 | ||
| 82 | + * @param limit 每页数量 | ||
| 83 | + * @returns data[{ id, seller_id, school_id, school_name, title, brand, model, manufacture_year, new_level, range_km, total_mileage_km, max_speed_kmh, battery_capacity_ah, brake_wear_level, tire_wear_level, price, market_price, verification_status, rejection_reason, note, photos, is_favorite }] | ||
| 84 | + */ | ||
| 85 | + | ||
| 86 | +export const getVehicleListAPI = (params) => fn(fetch.get(Api.LIST_VEHICLE, params)); | ||
| 87 | + | ||
| 88 | +/** | ||
| 89 | + * @description: 获取我卖的车 | ||
| 90 | + * @param page 页码 | ||
| 91 | + * @param limit 每页数量 | ||
| 92 | + * @returns data[{ id, seller_id, school_id, school_name, title, brand, model, manufacture_year, new_level, range_km, total_mileage_km, max_speed_kmh, battery_capacity_ah, brake_wear_level, tire_wear_level, price, market_price, verification_status, rejection_reason, note, photos, is_favorite }] | ||
| 93 | + */ | ||
| 94 | +export const getMyListingVehicleAPI = (params) => fn(fetch.get(Api.MY_LISTING_VEHICLE, params)); | ||
| 95 | + | ||
| 96 | +/** | ||
| 97 | + * @description: 获取车辆详情 | ||
| 98 | + * @param id 车辆ID | ||
| 99 | + * @returns data{ id, seller_id, school_id, school_name, title, brand, model, manufacture_year, new_level, range_km, total_mileage_km, max_speed_kmh, battery_capacity_ah, brake_wear_level, tire_wear_level, price, market_price, verification_status, rejection_reason, note, photos, is_favorite, seller { id, name, avatar, school_id, school_name, phone, email } } | ||
| 100 | + */ | ||
| 101 | +export const getVehicleDetailAPI = (params) => fn(fetch.get(Api.DETAIL_VEHICLE, params)); | ||
| 102 | + | ||
| 103 | + | ||
| 104 | +/** | ||
| 105 | + * @description: 下架/上架车辆 | ||
| 106 | + * @param id 车辆ID | ||
| 107 | + * @param status 状态(3=待审核, 7=上架, 9=下架) | ||
| 108 | + * @returns data[{ id, seller_id, school_id, school_name, title, brand, model, manufacture_year, new_level, range_km, total_mileage_km, max_speed_kmh, battery_capacity_ah, brake_wear_level, tire_wear_level, price, market_price, verification_status, rejection_reason, note, photos, is_favorite }] | ||
| 109 | + */ | ||
| 110 | + | ||
| 111 | +export const changeVehicleStatusAPI = (params) => fn(fetch.post(Api.CHANGE_STATUS_VEHICLE, params)); |
| 1 | /* | 1 | /* |
| 2 | * @Date: 2023-12-22 10:29:37 | 2 | * @Date: 2023-12-22 10:29:37 |
| 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com | 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com |
| 4 | - * @LastEditTime: 2025-07-08 20:22:08 | 4 | + * @LastEditTime: 2025-07-09 15:55:52 |
| 5 | * @FilePath: /jgdl/src/api/index.js | 5 | * @FilePath: /jgdl/src/api/index.js |
| 6 | - * @Description: 文件描述 | 6 | + * @Description: 用户相关API接口 |
| 7 | */ | 7 | */ |
| 8 | import { fn, fetch } from './fn'; | 8 | import { fn, fetch } from './fn'; |
| 9 | 9 | ... | ... |
| 1 | /* | 1 | /* |
| 2 | * @Date: 2024-01-01 00:00:00 | 2 | * @Date: 2024-01-01 00:00:00 |
| 3 | - * @LastEditors: | 3 | + * @LastEditors: hookehuyr hookehuyr@gmail.com |
| 4 | - * @LastEditTime: 2024-01-01 00:00:00 | 4 | + * @LastEditTime: 2025-07-09 15:00:24 |
| 5 | * @FilePath: /jgdl/src/api/orders.js | 5 | * @FilePath: /jgdl/src/api/orders.js |
| 6 | * @Description: 车辆订单相关API接口 | 6 | * @Description: 车辆订单相关API接口 |
| 7 | */ | 7 | */ |
| ... | @@ -55,7 +55,7 @@ export const getOrderDetailAPI = (params) => { | ... | @@ -55,7 +55,7 @@ export const getOrderDetailAPI = (params) => { |
| 55 | * @param {Object} params | 55 | * @param {Object} params |
| 56 | * @param {string} params.orderId - 订单ID | 56 | * @param {string} params.orderId - 订单ID |
| 57 | * @returns {Promise} | 57 | * @returns {Promise} |
| 58 | - * | 58 | + * |
| 59 | * @example | 59 | * @example |
| 60 | * // 使用示例: | 60 | * // 使用示例: |
| 61 | * try { | 61 | * try { |
| ... | @@ -66,7 +66,7 @@ export const getOrderDetailAPI = (params) => { | ... | @@ -66,7 +66,7 @@ export const getOrderDetailAPI = (params) => { |
| 66 | * } catch (error) { | 66 | * } catch (error) { |
| 67 | * console.error('删除失败:', error.message); | 67 | * console.error('删除失败:', error.message); |
| 68 | * } | 68 | * } |
| 69 | - * | 69 | + * |
| 70 | * @apiResponse | 70 | * @apiResponse |
| 71 | * { | 71 | * { |
| 72 | * success: true, | 72 | * success: true, |
| ... | @@ -115,7 +115,7 @@ export const confirmOrderAPI = (params) => { | ... | @@ -115,7 +115,7 @@ export const confirmOrderAPI = (params) => { |
| 115 | * @param {string} params.comment - 评价内容 | 115 | * @param {string} params.comment - 评价内容 |
| 116 | * @param {Array} params.images - 评价图片(可选) | 116 | * @param {Array} params.images - 评价图片(可选) |
| 117 | * @returns {Promise} | 117 | * @returns {Promise} |
| 118 | - * | 118 | + * |
| 119 | * @example | 119 | * @example |
| 120 | * // 使用示例: | 120 | * // 使用示例: |
| 121 | * try { | 121 | * try { |
| ... | @@ -131,7 +131,7 @@ export const confirmOrderAPI = (params) => { | ... | @@ -131,7 +131,7 @@ export const confirmOrderAPI = (params) => { |
| 131 | * } catch (error) { | 131 | * } catch (error) { |
| 132 | * console.error('评价提交失败:', error.message); | 132 | * console.error('评价提交失败:', error.message); |
| 133 | * } | 133 | * } |
| 134 | - * | 134 | + * |
| 135 | * @apiResponse | 135 | * @apiResponse |
| 136 | * { | 136 | * { |
| 137 | * success: true, | 137 | * success: true, |
| ... | @@ -176,4 +176,4 @@ export default { | ... | @@ -176,4 +176,4 @@ export default { |
| 176 | confirmOrderAPI, | 176 | confirmOrderAPI, |
| 177 | submitReviewAPI, | 177 | submitReviewAPI, |
| 178 | requestRefundAPI, | 178 | requestRefundAPI, |
| 179 | -}; | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 179 | +}; | ... | ... |
-
Please register or login to post a comment