hookehuyr

feat(api): 添加学校、品牌和车型相关API接口

添加新的API模块用于获取学校列表、品牌列表和车品牌列表
修改车辆销售表单字段名maxSpeed为max_speed_kmh
简化图片上传验证逻辑,仅需正面照
1 +import { fn, fetch } from '@/api/fn';
2 +
3 +const Api = {
4 + GET_SCHOOLS: '/srv/?a=common&t=get_schools',
5 + GET_BRANDS_MODELS: '/srv/?a=common&t=get_brands_models',
6 + GET_VEHICLE_BRANDS: '/srv/?a=common&t=get_vehicle_brands',
7 +}
8 +
9 +/**
10 + * @description: 获取学校列表
11 + * @param {*} params
12 + * @returns
13 + */
14 +export const getSchoolsAPI = (params) => fn(fetch.get(Api.GET_SCHOOLS, params));
15 +
16 +/**
17 + * @description: 获取品牌列表
18 + * @param {*} params
19 + * @returns
20 + */
21 +export const getBrandsModelsAPI = (params) => fn(fetch.get(Api.GET_BRANDS_MODELS, params));
22 +
23 +/**
24 + * @description: 获取车品牌列表
25 + * @param {*} params
26 + * @returns
27 + */
28 +export const getVehicleBrandsAPI = (params) => fn(fetch.get(Api.GET_VEHICLE_BRANDS, params));
...@@ -166,8 +166,8 @@ ...@@ -166,8 +166,8 @@
166 </nut-form-item> 166 </nut-form-item>
167 167
168 <!-- 最高时速 --> 168 <!-- 最高时速 -->
169 - <nut-form-item label="最高时速" prop="maxSpeed"> 169 + <nut-form-item label="最高时速" prop="max_speed_kmh">
170 - <nut-input v-model="formData.maxSpeed" placeholder="25" type="number" input-align="right"> 170 + <nut-input v-model="formData.max_speed_kmh" placeholder="25" type="number" input-align="right">
171 <template #right> 171 <template #right>
172 <text class="unit">km/h</text> 172 <text class="unit">km/h</text>
173 </template> 173 </template>
...@@ -324,6 +324,7 @@ import './index.less' ...@@ -324,6 +324,7 @@ import './index.less'
324 324
325 // 导入接口 325 // 导入接口
326 import { addVehicleAPI, editVehicleAPI, getVehicleDetailAPI } from '@/api/car'; 326 import { addVehicleAPI, editVehicleAPI, getVehicleDetailAPI } from '@/api/car';
327 +import { getSchoolsAPI, getBrandsModelsAPI } from '@/api/other';
327 328
328 const themeVars = ref({ 329 const themeVars = ref({
329 navbarBackground: '#fb923c', 330 navbarBackground: '#fb923c',
...@@ -375,7 +376,7 @@ const formData = reactive({ ...@@ -375,7 +376,7 @@ const formData = reactive({
375 new_level: '', 376 new_level: '',
376 total_mileage_km: '1200', 377 total_mileage_km: '1200',
377 range_km: '60', 378 range_km: '60',
378 - maxSpeed: '25', 379 + max_speed_kmh: '25',
379 battery_capacity_ah: '20', 380 battery_capacity_ah: '20',
380 // batteryWear: '', 381 // batteryWear: '',
381 brake_wear_level: '', 382 brake_wear_level: '',
...@@ -387,7 +388,8 @@ const formData = reactive({ ...@@ -387,7 +388,8 @@ const formData = reactive({
387 front_photo: '', 388 front_photo: '',
388 left_photo: '', 389 left_photo: '',
389 right_photo: '', 390 right_photo: '',
390 - other_photo: '' 391 + other_photo: '',
392 + verification_status: ''
391 }) 393 })
392 394
393 // 选择器显示状态 395 // 选择器显示状态
...@@ -846,9 +848,11 @@ const onPublish = async () => { ...@@ -846,9 +848,11 @@ const onPublish = async () => {
846 */ 848 */
847 const validateForm = () => { 849 const validateForm = () => {
848 // 检查是否至少上传了一张图片 850 // 检查是否至少上传了一张图片
849 - const hasImages = formData.front_photo || formData.left_photo || formData.right_photo || formData.other_photo 851 + // const hasImages = formData.front_photo || formData.left_photo || formData.right_photo || formData.other_photo
852 + const hasImages = formData.front_photo
850 if (!hasImages) { 853 if (!hasImages) {
851 - Taro.showToast({ title: '请上传车辆图片', icon: 'none' }) 854 + // Taro.showToast({ title: '请上传车辆图片', icon: 'none' })
855 + Taro.showToast({ title: '请上传车辆正面照', icon: 'none' })
852 return false 856 return false
853 } 857 }
854 858
...@@ -901,14 +905,15 @@ const loadCarData = async () => { ...@@ -901,14 +905,15 @@ const loadCarData = async () => {
901 new_level: typeof carData.new_level === 'number' ? convertScoreToText(carData.new_level, 'condition') : carData.new_level, 905 new_level: typeof carData.new_level === 'number' ? convertScoreToText(carData.new_level, 'condition') : carData.new_level,
902 total_mileage_km: carData.total_mileage_km, 906 total_mileage_km: carData.total_mileage_km,
903 range_km: carData.range_km, 907 range_km: carData.range_km,
904 - maxSpeed: carData.maxSpeed, 908 + max_speed_kmh: carData.max_speed_kmh,
905 battery_capacity_ah: carData.battery_capacity_ah, 909 battery_capacity_ah: carData.battery_capacity_ah,
906 // batteryWear: carData.batteryWear, 910 // batteryWear: carData.batteryWear,
907 brake_wear_level: typeof carData.brake_wear_level === 'number' ? convertScoreToText(carData.brake_wear_level, 'wear') : carData.brake_wear_level, 911 brake_wear_level: typeof carData.brake_wear_level === 'number' ? convertScoreToText(carData.brake_wear_level, 'wear') : carData.brake_wear_level,
908 tire_wear_level: typeof carData.tire_wear_level === 'number' ? convertScoreToText(carData.tire_wear_level, 'wear') : carData.tire_wear_level, 912 tire_wear_level: typeof carData.tire_wear_level === 'number' ? convertScoreToText(carData.tire_wear_level, 'wear') : carData.tire_wear_level,
909 price: carData.price, 913 price: carData.price,
910 market_price: carData.market_price, 914 market_price: carData.market_price,
911 - note: carData.note 915 + note: carData.note,
916 + verification_status: carData.verification_status
912 }) 917 })
913 918
914 // 填充图片数据 919 // 填充图片数据
......