Commit af613b50 by cen

fix: 车型

1 parent a6fd67d4
...@@ -37,11 +37,28 @@ export default { ...@@ -37,11 +37,28 @@ export default {
dateValues: [], dateValues: [],
hourValues: [], hourValues: [],
minuteValues: [], minuteValues: [],
loading: true loading: true,
currentDate: '',
currentHour: '',
currentMinute: ''
} }
}, },
props: { props: {
// 开始时间,格式:YYYY/MM/DD
startTime: {
type: String,
default: '2019/01/01'
},
// 结束时间,格式:YYYY/MM/DD
endTime: {
type: String,
default: '2029/01/01'
},
// 默认选中的时间,格式:YYYY/MM/DD HH:mm:ss
defaultTime: {
type: String,
default: ''
}
}, },
mounted () { mounted () {
...@@ -53,8 +70,7 @@ export default { ...@@ -53,8 +70,7 @@ export default {
this.dateValues = [] this.dateValues = []
this.hourValues = [] this.hourValues = []
this.minuteValues = [] this.minuteValues = []
const today = new Date() this.getDateList(this.startTime, this.endTime)
this.getDateList('2019/01/01','2029/01/01')
}, },
getDateList (starDay, endDay) { getDateList (starDay, endDay) {
const arr = []; const arr = [];
...@@ -66,7 +82,8 @@ export default { ...@@ -66,7 +82,8 @@ export default {
// 获取两个日期GTM时间 // 获取两个日期GTM时间
const s = db.getTime() - 24 * 60 * 60 * 1000; const s = db.getTime() - 24 * 60 * 60 * 1000;
const d = de.getTime() - 24 * 60 * 60 * 1000; const d = de.getTime() - 24 * 60 * 60 * 1000;
console.log(db,de) console.log(db,de)
// 获取到两个日期之间的每一天的毫秒数 // 获取到两个日期之间的每一天的毫秒数
for (let i = s; i <= d;) { for (let i = s; i <= d;) {
i = i + 24 * 60 * 60 * 1000; i = i + 24 * 60 * 60 * 1000;
...@@ -98,28 +115,50 @@ console.log(db,de) ...@@ -98,28 +115,50 @@ console.log(db,de)
for (let minute = 0; minute < today.getMinutes() + 1; minute++) { for (let minute = 0; minute < today.getMinutes() + 1; minute++) {
minutes.push(minute.toString().padStart(2, '0')); minutes.push(minute.toString().padStart(2, '0'));
} }
// 设置默认时间
let { dateValues, hourValues, minuteValues } = this
const HOUR_STR = today.getHours().toString().padStart(2, '0')
const MUNTUE_STR = today.getMinutes().toString().padStart(2, '0')
// const defalutHIndex = hours.indexOf(HOUR_STR)
// const defalutMIndex = minutes.indexOf(MUNTUE_STR)
dateValues.push(days.length + 1)
hourValues.push(hours.length + 1)
minuteValues.push(minutes.length + 1)
this.currentDate = dayjs().format('YYYY/MM/DD')
this.currentHour = HOUR_STR
this.currentMinute = MUNTUE_STR
this.hours = hours this.hours = hours
this.days = days this.days = days
this.minutes = minutes this.minutes = minutes
this.dateValues = dateValues
this.hourValues = hourValues // 设置默认时间
this.minuteValues = minuteValues if (this.defaultTime) {
// 如果有传入默认时间,则使用传入的时间
const defaultDate = this.defaultTime.split(' ')[0]
const defaultTime = this.defaultTime.split(' ')[1]
const defaultHour = defaultTime.split(':')[0]
const defaultMinute = defaultTime.split(':')[1]
this.currentDate = defaultDate
this.currentHour = defaultHour
this.currentMinute = defaultMinute
// 设置选中索引
this.dateValues = [days.indexOf(defaultDate) || 0]
this.hourValues = [hours.indexOf(defaultHour) || 0]
this.minuteValues = [minutes.indexOf(defaultMinute) || 0]
} else {
// 否则使用当前时间
const HOUR_STR = today.getHours().toString().padStart(2, '0')
const MINUTE_STR = today.getMinutes().toString().padStart(2, '0')
const TODAY_STR = dayjs().format('YYYY/MM/DD')
this.currentDate = TODAY_STR
this.currentHour = HOUR_STR
this.currentMinute = MINUTE_STR
// 设置选中索引
const todayIndex = days.indexOf(TODAY_STR)
const hourIndex = hours.indexOf(HOUR_STR)
const minuteIndex = minutes.indexOf(MINUTE_STR)
this.dateValues = [todayIndex >= 0 ? todayIndex : 0]
this.hourValues = [hourIndex >= 0 ? hourIndex : 0]
this.minuteValues = [minuteIndex >= 0 ? minuteIndex : 0]
}
this.loading = false this.loading = false
setTimeout(() => { setTimeout(() => {
this.minuteValues = minuteValues this.minuteValues = this.minuteValues
this.loading = false this.loading = false
}, 100) }, 100)
this.$emit('onComplete') this.$emit('onComplete')
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
</template> </template>
<view :class="['popup-body', { 'hide-search': componentObject[popupType].hideSearch }]"> <view :class="['popup-body', { 'hide-search': componentObject[popupType].hideSearch }]">
<scroll-view scroll-y :class="['popup-scroll-view', { show: componentObject[popupType].loadComplete }]"> <scroll-view scroll-y :class="['popup-scroll-view', { show: componentObject[popupType].loadComplete }]">
<component :is="componentObject[popupType].name" :params.sync="componentObject[popupType]" :data="data" :dataKey="dataKey" :isDefeatOrder="isDefeatOrder" :positionTypeList="positionTypeList" ref="componentRef" @choose="chooseContent = $event" @openSkuPopup="openSkuPopup" @onComplete="componentObject[popupType].loadComplete = true"></component> <component :is="componentObject[popupType].name" :params.sync="componentObject[popupType]" :data="data" :dataKey="dataKey" :isDefeatOrder="isDefeatOrder" :defaultTime="defaultTime" :positionTypeList="positionTypeList" ref="componentRef" @choose="chooseContent = $event" @openSkuPopup="openSkuPopup" @onComplete="componentObject[popupType].loadComplete = true"></component>
<template v-if="componentObject[popupType].noData"> <template v-if="componentObject[popupType].noData">
<view class="nothing flex">暂无数据</view> <view class="nothing flex">暂无数据</view>
</template> </template>
...@@ -79,7 +79,8 @@ export default { ...@@ -79,7 +79,8 @@ export default {
isDefeatOrder: { isDefeatOrder: {
type: Boolean, type: Boolean,
default: false default: false
} },
defaultTime: String
}, },
provide () { provide () {
......
...@@ -79,7 +79,7 @@ ...@@ -79,7 +79,7 @@
<!-- 弹窗 --> <!-- 弹窗 -->
<OrderPopup ref="orderPopup" :data="displayData" :isDefeatOrder="true" :externalData="[]" @onConfirm="onConfirm" :popupType="0" /> <OrderPopup ref="orderPopup" :data="displayData" :isDefeatOrder="true" :externalData="[]" @onConfirm="onConfirm" :popupType="0" />
<SelectCar ref="selectCar" title="选择车型" @car-selected="handleCarSelected" /> <SelectCar ref="selectCar" title="选择车型" :car-brand-data="carBrandData" @car-selected="handleCarSelected" :on-load-year-data="loadYearDataForModel" />
<SelectCity <SelectCity
ref="selectCity" ref="selectCity"
title="选择城市" title="选择城市"
...@@ -149,6 +149,7 @@ import NoticePopup from '@/components/NoticePopup.vue' ...@@ -149,6 +149,7 @@ import NoticePopup from '@/components/NoticePopup.vue'
import { debounce } from 'lodash' import { debounce } from 'lodash'
import dayjs from 'dayjs' import dayjs from 'dayjs'
import permision from '@/js_sdk/wa-permission/permission.js' import permision from '@/js_sdk/wa-permission/permission.js'
import { sign, md532, md516 } from 'utils/common'
export default { export default {
name: 'AddEvaluationFrom', name: 'AddEvaluationFrom',
components: { components: {
...@@ -175,6 +176,13 @@ export default { ...@@ -175,6 +176,13 @@ export default {
data() { data() {
return { return {
bg: require('@/assets/images/boutique/tipsPopupBg.png'), bg: require('@/assets/images/boutique/tipsPopupBg.png'),
carBrandData: [],
loadingCarData: false,
// 缓存数据
dataCache: null,
cacheTimestamp: null,
// 缓存有效期(10分钟)
CACHE_EXPIRE_TIME: 10 * 60 * 1000,
pickerArray: [], pickerArray: [],
index: 0, index: 0,
carList: [], carList: [],
...@@ -555,6 +563,7 @@ export default { ...@@ -555,6 +563,7 @@ export default {
return false return false
}, },
mounted() { mounted() {
this.loadCarData()
console.log(this.query) console.log(this.query)
if (this.query.type == 'edit') { if (this.query.type == 'edit') {
this.title = '编辑评估单' this.title = '编辑评估单'
...@@ -570,6 +579,139 @@ export default { ...@@ -570,6 +579,139 @@ export default {
uni.$track.add({ eventCode: 'app_add_evaluation_from' }) uni.$track.add({ eventCode: 'app_add_evaluation_from' })
}, },
methods: { methods: {
loadCachedData() {
try {
const cachedData = uni.getStorageSync('carBrandData')
const timestamp = uni.getStorageSync('carBrandDataTimestamp')
if (cachedData && timestamp) {
const now = Date.now()
// 检查缓存是否过期
if (now - timestamp < this.CACHE_EXPIRE_TIME) {
this.carBrandData = JSON.parse(cachedData)
this.dataCache = this.carBrandData
this.cacheTimestamp = timestamp
return true
}
}
return false
} catch (e) {
console.error('加载缓存数据失败:', e)
return false
}
},
saveDataToCache(data) {
try {
const timestamp = Date.now()
uni.setStorageSync('carBrandData', JSON.stringify(data))
uni.setStorageSync('carBrandDataTimestamp', timestamp)
this.dataCache = data
this.cacheTimestamp = timestamp
} catch (e) {
console.error('保存数据到缓存失败:', e)
}
},
loadCarData() {
// 先尝试从缓存加载
if (this.loadCachedData()) {
return
}
this.loadingCarData = true
// 异步加载数据,避免阻塞UI
setTimeout(() => {
const params = {
app_key: '48e5e13229b82c1b4e6e8c96151f0637',
v: '1.0.0',
timestamp: '1234567890',
source: 'dev_author',
method: 'glsx.accounts.base.car.brand.complete',
format: 'json'
}
const secret = 'c24619ed7fef02a0ae16328146bca5f97cc6493957a2137b'
const signature = sign(params, secret)
uni.request({
url: 'http://qcdidicb.glsx.com.cn/router?method=glsx.accounts.base.car.brand.complete',
method: 'GET',
dataType: 'json',
data: {
sign: signature,
...params
},
success: result => {
if (result.data && result.data.code === '0' && result.data.data && result.data.data.carinfos) {
this.carBrandData = result.data.data.carinfos
// 保存到缓存
this.saveDataToCache(this.carBrandData)
} else {
console.error('Invalid car data format:', result)
}
},
fail: error => {
console.log(error, 'error')
},
complete: () => {
this.loadingCarData = false
}
})
}, 100)
},
loadYearDataForModel(modelId) {
return new Promise((resolve, reject) => {
const params = {
app_key: '48e5e13229b82c1b4e6e8c96151f0637',
v: '1.0.0',
timestamp: '1234567890',
source: 'dev_author',
method: 'glsx.accounts.base.car.types',
format: 'json',
csId: modelId
}
const secret = 'c24619ed7fef02a0ae16328146bca5f97cc6493957a2137b'
const signature = sign(params, secret)
// 优化请求方式,避免重复请求
setTimeout(() => {
uni.request({
url: 'http://qcdidicb.glsx.com.cn/router?method=glsx.accounts.base.car.types',
method: 'GET',
dataType: 'json',
data: {
sign: signature,
csId: modelId,
...params
},
success: result => {
if (result.data && result.data.code === '0' && result.data.data && result.data.data.carinfos) {
resolve(result.data.data.carinfos || [])
} else {
console.error('无效的车型数据格式:', result)
resolve([])
}
},
fail: error => {
console.log(error, 'error')
resolve([])
}
})
}, 10)
})
},
openSelectCar(carInfo = null) {
this.loadCarData()
let openData = carInfo
if (carInfo === null && this.currentIdentifiedBrandName) {
openData = this.currentIdentifiedBrandName
this.currentIdentifiedBrandName = null
} else if (carInfo === null && !this.currentIdentifiedBrandName && this.selectedCarInfo) {
openData = this.selectedCarInfo
}
// 即使数据正在加载中也打开弹窗,让用户看到加载状态
this.$refs.selectCar.open(openData)
},
init(options) { init(options) {
console.log('options:', options) console.log('options:', options)
this.query = options this.query = options
...@@ -834,16 +976,9 @@ export default { ...@@ -834,16 +976,9 @@ export default {
}, },
handleCell(field) { handleCell(field) {
const that = this const that = this
if (field.isCar) { if (field.isCar) {
// 处理车型选择 this.openSelectCar()
if (this.currentIdentifiedBrandName) {
// 识别场景:传入品牌名称
this.$refs.selectCar.open(this.currentIdentifiedBrandName)
this.currentIdentifiedBrandName = null
} else {
// 新增/编辑场景:传入完整车型信息或null
this.$refs.selectCar.open(this.selectedCarInfo || null)
}
} else if (field.isCity) { } else if (field.isCity) {
// 处理城市选择 // 处理城市选择
this.$refs.selectCity.open() this.$refs.selectCity.open()
...@@ -870,17 +1005,17 @@ export default { ...@@ -870,17 +1005,17 @@ export default {
this.$refs.orderPopup.open() this.$refs.orderPopup.open()
} }
}, },
handleCarSelected(date) { handleCarSelected(carInfo) {
console.log('handleCarSelected', date) console.log('handleCarSelected', carInfo)
this.selectedCarInfo = date this.selectedCarInfo = carInfo
this.$set(this.formData.carBaseReqDTO, 'carBrandId', date.brand.id) this.$set(this.formData.carBaseReqDTO, 'carBrandId', carInfo.brand.id)
this.$set(this.formData.carBaseReqDTO, 'carBrand', date.brand.name) this.$set(this.formData.carBaseReqDTO, 'carBrand', carInfo.brand.name)
this.$set(this.formData.carBaseReqDTO, 'carChildsBrandId', date.series.id) this.$set(this.formData.carBaseReqDTO, 'carChildsBrandId', carInfo.series.id)
this.$set(this.formData.carBaseReqDTO, 'carChildsBrandName', date.series.name) this.$set(this.formData.carBaseReqDTO, 'carChildsBrandName', carInfo.series.name)
this.$set(this.formData.carBaseReqDTO, 'carSeriesId', date.model.id) this.$set(this.formData.carBaseReqDTO, 'carSeriesId', carInfo.model.id)
this.$set(this.formData.carBaseReqDTO, 'carSeriesName', date.model.name) this.$set(this.formData.carBaseReqDTO, 'carSeriesName', carInfo.model.name)
this.$set(this.formData.carBaseReqDTO, 'carTypeId', date.year.id) this.$set(this.formData.carBaseReqDTO, 'carTypeId', carInfo.year.id)
this.$set(this.formData.carBaseReqDTO, 'carTypeName', date.year.name) this.$set(this.formData.carBaseReqDTO, 'carTypeName', carInfo.year.name)
}, },
handleCitySelected(date) { handleCitySelected(date) {
this.$set(this.formData.carBaseReqDTO, 'registrationProvinceId', date.province.code) this.$set(this.formData.carBaseReqDTO, 'registrationProvinceId', date.province.code)
...@@ -1334,7 +1469,7 @@ export default { ...@@ -1334,7 +1469,7 @@ export default {
} }
} }
} }
}, 500), }, 1500),
processMediaData(mediaData, fileType) { processMediaData(mediaData, fileType) {
if (!mediaData || typeof mediaData !== 'object') { if (!mediaData || typeof mediaData !== 'object') {
......
...@@ -6,8 +6,8 @@ ...@@ -6,8 +6,8 @@
<text class="requiredLabel" v-if="field.required">*</text> <text class="requiredLabel" v-if="field.required">*</text>
</view> </view>
<template v-if="field.type === 'input'" class="flex align-center"> <template v-if="field.type === 'input'" class="flex align-center">
<input class="formInput" :min="field.min" :max="field.max" v-if="field.targetObj" :type="field.inputType || 'text'" :disabled="field.disabled" type="text" :placeholder="'请输入'" :maxlength="field.maxlength || 100" v-model="formData[field.targetObj][field.targetKey]" :pattern="field.pattern || ''" @input="e => handleInput(e, field)" @blur="e => handleBlur(e, field)" /> <input class="formInput" :class="field.disabled ? 'formInputDisabled' : ''" :min="field.min" :max="field.max" v-if="field.targetObj" :type="field.inputType || 'text'" :disabled="field.disabled" type="text" :placeholder="'请输入'" :maxlength="field.maxlength || 100" v-model="formData[field.targetObj][field.targetKey]" :pattern="field.pattern || ''" @input="e => handleInput(e, field)" @blur="e => handleBlur(e, field)" />
<input class="formInput" :min="field.min" :max="field.max" v-else type="text" :type="field.inputType || 'text'" :disabled="field.disabled" :placeholder="'请输入'" v-model="formData[field.targetKey]" :maxlength="field.maxlength || 100" :pattern="field.pattern || ''" @input="e => handleInput(e, field)" @blur="e => handleBlur(e, field)" /> <input class="formInput" :class="field.disabled ? 'formInputDisabled' : ''" :min="field.min" :max="field.max" v-else type="text" :type="field.inputType || 'text'" :disabled="field.disabled" :placeholder="'请输入'" v-model="formData[field.targetKey]" :maxlength="field.maxlength || 100" :pattern="field.pattern || ''" @input="e => handleInput(e, field)" @blur="e => handleBlur(e, field)" />
<view v-if="field.isScan" class="flex align-center scanBtn justify-center" @click.stop="scan('vinOcr')"> <view v-if="field.isScan" class="flex align-center scanBtn justify-center" @click.stop="scan('vinOcr')">
<view class="sprite-icon icon-scanIconX"></view> <view class="sprite-icon icon-scanIconX"></view>
</view> </view>
...@@ -296,6 +296,9 @@ export default { ...@@ -296,6 +296,9 @@ export default {
.formInput:disabled { .formInput:disabled {
color: #999999; color: #999999;
} }
.formInputDisabled {
color: #999999;
}
.cellLabel { .cellLabel {
color: #333333; color: #333333;
font-size: toRpx(28); font-size: toRpx(28);
......
...@@ -339,7 +339,7 @@ export default { ...@@ -339,7 +339,7 @@ export default {
} }
} }
this.$refs.tipsPopup.open() this.$refs.tipsPopup.open()
}, 500), }, 1500),
async confirmTips() { async confirmTips() {
// this.uploadedImages // this.uploadedImages
......
...@@ -270,7 +270,7 @@ export default { ...@@ -270,7 +270,7 @@ export default {
const userInfo = uni.$storage.get('userInfo'), const userInfo = uni.$storage.get('userInfo'),
{ shopMerchantId } = userInfo { shopMerchantId } = userInfo
const res = await uni.$api.evaluationApi.evalOrderList({ const res = await uni.$api.evaluationApi.evalOrderList({
t: { ...this.searchValue, status: this.typeList[this.tabIndex].key, sellerMerchantId: shopMerchantId.toString() }, t: { ...this.searchValue, status: this.typeList[this.tabIndex].key, sellerMerchantId: shopMerchantId },
currentPage: pageNo, currentPage: pageNo,
pageSize: 10 pageSize: 10
}) })
......
...@@ -258,7 +258,7 @@ ...@@ -258,7 +258,7 @@
</view> </view>
</view> </view>
</view> </view>
<order-popup ref="openDate" popupType="15" @onConfirm="confirmDate" /> <order-popup ref="openDate" popupType="15" :defaultTime="defaultTime" @onConfirm="confirmDate" />
<NoticePopup ref="notice" title="重要提示" text="当前页面暂未保存,是否确认退出" type="warning"></NoticePopup> <NoticePopup ref="notice" title="重要提示" text="当前页面暂未保存,是否确认退出" type="warning"></NoticePopup>
</view> </view>
</template> </template>
...@@ -286,6 +286,7 @@ export default { ...@@ -286,6 +286,7 @@ export default {
title: '签约信息', title: '签约信息',
selectDate: '', selectDate: '',
current: null, current: null,
defaultTime: dayjs().format('YYYY-MM-DD HH:mm:ss'),
endDate: dayjs().format('YYYY-MM-DD'), endDate: dayjs().format('YYYY-MM-DD'),
selectedItemsText: '机动车登记本, 机动车行驶证, 交管12123截图, 交强险, 车钥匙', selectedItemsText: '机动车登记本, 机动车行驶证, 交管12123截图, 交强险, 车钥匙',
noDataBg: require('@/assets/images/common/sign-no-data.png'), noDataBg: require('@/assets/images/common/sign-no-data.png'),
...@@ -1063,7 +1064,7 @@ export default { ...@@ -1063,7 +1064,7 @@ export default {
}) })
} }
}) })
}, 500), }, 1500),
// 计算尾款:尾款 = 评估价 - 定金 // 计算尾款:尾款 = 评估价 - 定金
calculateFinalPrice() { calculateFinalPrice() {
console.log(' 计算尾款:尾款 = 评估价 - 定金', this.formData) console.log(' 计算尾款:尾款 = 评估价 - 定金', this.formData)
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!