Commit cb6d69b6 by Lin

feat(prelearnBridge):增强后退导航逻辑并改进错误处理

- 将 entrySource 的初始化更新为空字符串。
- 增加了对包详情和首页弹窗返回导航的处理。
- 实现了在包详情返回导航时调用 API 获取预学习脚本板状态的功能。
- 改进错误处理,对 API 失败情况添加了控制台日志记录。
1 parent 5e92fef8
...@@ -217,8 +217,8 @@ const phoneRex = /^[1]([3-9])[0-9]{9}$/, ...@@ -217,8 +217,8 @@ const phoneRex = /^[1]([3-9])[0-9]{9}$/,
}, },
{ {
label: '到店日期', label: '到店日期',
valueKey: 'arrivalDate', valueKey: 'inviteDate',
key: 'arrivalDate', key: 'inviteDate',
type: 'date' type: 'date'
}, },
{ {
...@@ -260,7 +260,8 @@ export default { ...@@ -260,7 +260,8 @@ export default {
startDate: '', startDate: '',
endDate: '', endDate: '',
validateState: true, validateState: true,
employeeSelectKey: '' employeeSelectKey: '',
inviteDateTouched: false
} }
}, },
onLoad (options) { onLoad (options) {
...@@ -298,8 +299,10 @@ export default { ...@@ -298,8 +299,10 @@ export default {
merchantName: '', merchantName: '',
sellerName: '', sellerName: '',
sellerUserId: '', sellerUserId: '',
inviteDate: '',
filingDate: '' filingDate: ''
} }
this.inviteDateTouched = false
if (this.customerId) this.findVisitsInfo() if (this.customerId) this.findVisitsInfo()
}, },
async findVisitsInfo () { async findVisitsInfo () {
...@@ -307,8 +310,10 @@ export default { ...@@ -307,8 +310,10 @@ export default {
id: this.customerId id: this.customerId
}) })
if (res.arrivalDate) res.arrivalDate = dayjs(res.arrivalDate).format("YYYY-MM-DD") if (res.arrivalDate) res.arrivalDate = dayjs(res.arrivalDate).format("YYYY-MM-DD")
if (res.inviteDate) res.inviteDate = dayjs(res.inviteDate).format("YYYY-MM-DD")
if (res.filingDate) res.filingDate = dayjs(res.filingDate).format("YYYY-MM-DD") if (res.filingDate) res.filingDate = dayjs(res.filingDate).format("YYYY-MM-DD")
this.customerInfo = res this.customerInfo = res
this.inviteDateTouched = !!res.inviteDate
}, },
backPage () { backPage () {
uni.navigateBack({ uni.navigateBack({
...@@ -357,7 +362,14 @@ export default { ...@@ -357,7 +362,14 @@ export default {
} }
}, },
bindDateChange (e, valueKey) { bindDateChange (e, valueKey) {
this.customerInfo[valueKey] = e.detail.value const value = e.detail.value
this.customerInfo[valueKey] = value
if (valueKey === 'arrivalDate' && !this.inviteDateTouched) {
this.customerInfo.inviteDate = value
}
if (valueKey === 'inviteDate') {
this.inviteDateTouched = true
}
}, },
inputBlur (e, val) { inputBlur (e, val) {
const standNoVal = this.customerInfo.standNo const standNoVal = this.customerInfo.standNo
...@@ -435,6 +447,8 @@ export default { ...@@ -435,6 +447,8 @@ export default {
merchantId:params.merchantId, merchantId:params.merchantId,
employeeName:params.employeeName, employeeName:params.employeeName,
sellerMerchantId:params.sellerMerchantId, sellerMerchantId:params.sellerMerchantId,
sellerUserId: params.sellerUserId,
sellerName: customerInfo.sellerName,
preliminaryOrders: [ preliminaryOrders: [
{ {
sceneType:1, sceneType:1,
...@@ -451,7 +465,7 @@ export default { ...@@ -451,7 +465,7 @@ export default {
employeeName:params.employeeName, employeeName:params.employeeName,
userId:params.userId, userId:params.userId,
deliveryDate: params.arrivalDate ? params.arrivalDate + ' 00:00:00' : params.arrivalDate, //交付日期 deliveryDate: params.arrivalDate ? params.arrivalDate + ' 00:00:00' : params.arrivalDate, //交付日期
inviteDate: params.filingDate ? params.filingDate + ' 00:00:00' : params.filingDate, //到店日期 inviteDate: params.inviteDate ? params.inviteDate + ' 00:00:00' : params.inviteDate, //到店日期
createdDate: params.filingDate, //建档日期 createdDate: params.filingDate, //建档日期
sellerUserld: params.sellerUserId, sellerUserld: params.sellerUserId,
sellerName: customerInfo.sellerName, sellerName: customerInfo.sellerName,
......
...@@ -53,6 +53,7 @@ ...@@ -53,6 +53,7 @@
placeholder="请选择" placeholder="请选择"
placeholder-style="color:rgba(51, 51, 51, 0.2);" placeholder-style="color:rgba(51, 51, 51, 0.2);"
confirm-type="done" confirm-type="done"
@blur="inputBlur($event, i)"
/> />
</template> </template>
<template v-else-if="i.type == 'date'"> <template v-else-if="i.type == 'date'">
...@@ -97,6 +98,7 @@ ...@@ -97,6 +98,7 @@
placeholder="请选择" placeholder="请选择"
placeholder-style="color:rgba(51, 51, 51, 0.2);" placeholder-style="color:rgba(51, 51, 51, 0.2);"
confirm-type="done" confirm-type="done"
@blur="inputBlur($event, i)"
/> />
</template> </template>
<template v-else-if="i.type == 'date'"> <template v-else-if="i.type == 'date'">
...@@ -221,6 +223,7 @@ ...@@ -221,6 +223,7 @@
import dayjs from 'dayjs' import dayjs from 'dayjs'
import ReceptionSence from '@/components/HomeFrame/components/ReceptionCenter/ReceptionSence.vue' import ReceptionSence from '@/components/HomeFrame/components/ReceptionCenter/ReceptionSence.vue'
import Employee from '@/components/Employee.vue' import Employee from '@/components/Employee.vue'
import { validateVin, formatVinInput } from '@/utils/vinVaildate'
const phoneRex = /^[1]([3-9])[0-9]{9}$/, const phoneRex = /^[1]([3-9])[0-9]{9}$/,
default_customerForm = [{ default_customerForm = [{
...@@ -373,7 +376,8 @@ ...@@ -373,7 +376,8 @@
}, },
groupMemberList: [], groupMemberList: [],
startDate: '', startDate: '',
endDate: '' endDate: '',
validateState: true
} }
}, },
onLoad (options) { onLoad (options) {
...@@ -434,6 +438,24 @@ ...@@ -434,6 +438,24 @@
} }
return false return false
} }
const carVin = this.customerInfo.standNo
if (carVin) {
this.customerInfo.standNo = formatVinInput(carVin)
if (this.customerInfo.standNo.length !== 17) {
uni.showToast({
title: '请输入 17 位有效字符(支持大写 A-H/J-N/P-Z、0-9)',
icon: 'none'
})
return false
}
if (!this.validateState) {
uni.showToast({
title: '车架号校验不匹配,请核对后重新输入',
icon: 'none'
})
return false
}
}
const requestParams = { const requestParams = {
id: this.customerInfo.id, id: this.customerInfo.id,
customerName: this.customerInfo.customerName, customerName: this.customerInfo.customerName,
...@@ -599,6 +621,7 @@ ...@@ -599,6 +621,7 @@
deliveryDate: '', deliveryDate: '',
receptionSceneName: '', receptionSceneName: '',
standNo: '', standNo: '',
inviteDate: '',
createdDate: '', createdDate: '',
employeeName: '', employeeName: '',
userId: '', userId: '',
...@@ -681,6 +704,22 @@ ...@@ -681,6 +704,22 @@
bindDateChange (e, valueKey) { bindDateChange (e, valueKey) {
this.customerInfo[valueKey] = e.detail.value this.customerInfo[valueKey] = e.detail.value
}, },
inputBlur (e, val) {
const standNoVal = this.customerInfo.standNo
if (val.key === 'standNo' && standNoVal) {
this.customerInfo.standNo = formatVinInput(standNoVal)
validateVin(this.customerInfo.standNo)
.then(result => {
const { valid } = result.data
this.validateState = valid
})
.catch(() => {
this.validateState = false
})
} else if (val.key === 'standNo') {
this.validateState = true
}
},
formatDateTime (value) { formatDateTime (value) {
if (!value) return value if (!value) return value
return dayjs(value).format('YYYY-MM-DD HH:mm:ss') return dayjs(value).format('YYYY-MM-DD HH:mm:ss')
......
...@@ -71,7 +71,7 @@ export default { ...@@ -71,7 +71,7 @@ export default {
staffUuid: uni.$storage.get('userInfo').uuid, staffUuid: uni.$storage.get('userInfo').uuid,
staffName: uni.$storage.get('userInfo').name, staffName: uni.$storage.get('userInfo').name,
merchantId: String(uni.$storage.get('userInfo').merchantId ?? ''), merchantId: String(uni.$storage.get('userInfo').merchantId ?? ''),
entrySource: 'home_popup', entrySource: '',
skipCount: 0, skipCount: 0,
}, },
pendingAppBackTimer: null, pendingAppBackTimer: null,
...@@ -736,6 +736,36 @@ export default { ...@@ -736,6 +736,36 @@ export default {
// #endif // #endif
}, },
async back() { async back() {
if (this.prelearnContext.entrySource === 'package_detail') {
await this.backFromPackageDetail()
return
}
await this.backFromHomePopup()
},
async backFromPackageDetail() {
try {
const res = await uni.$api.activityApi.getPrelearnScriptBoardAPI({
activityId: this.prelearnContext.activityId || this.goodsInfo.activityId,
activityProductId: this.prelearnContext.activityProductId || this.goodsInfo.productId,
})
console.log('[prelearnBridge] getPrelearnScriptBoardAPI res:', res)
if (Number(res?.staffLearnStatus) === 1) {
this.navigateBack()
return
}
if (res?.activityId != null) {
this.prelearnContext.activityId = String(res.activityId)
}
this.prelearnContext.skipCount = res?.remainingSkipCount ?? 0
this.showBackPopup = true
} catch (error) {
console.error('[prelearnBridge] 预学习返回剧本状态查询失败:', error)
this.showBackPopup = true
}
},
async backFromHomePopup() {
try { try {
const res = await uni.$api.commonApi.getPrelernHomePopupAPI() const res = await uni.$api.commonApi.getPrelernHomePopupAPI()
console.log('[prelearnBridge] getPrelernHomePopupAPI res:', res) console.log('[prelearnBridge] getPrelernHomePopupAPI res:', res)
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!