Commit cb6d69b6 by Lin

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

- 将 entrySource 的初始化更新为空字符串。
- 增加了对包详情和首页弹窗返回导航的处理。
- 实现了在包详情返回导航时调用 API 获取预学习脚本板状态的功能。
- 改进错误处理,对 API 失败情况添加了控制台日志记录。
1 parent 5e92fef8
......@@ -217,8 +217,8 @@ const phoneRex = /^[1]([3-9])[0-9]{9}$/,
},
{
label: '到店日期',
valueKey: 'arrivalDate',
key: 'arrivalDate',
valueKey: 'inviteDate',
key: 'inviteDate',
type: 'date'
},
{
......@@ -260,7 +260,8 @@ export default {
startDate: '',
endDate: '',
validateState: true,
employeeSelectKey: ''
employeeSelectKey: '',
inviteDateTouched: false
}
},
onLoad (options) {
......@@ -298,8 +299,10 @@ export default {
merchantName: '',
sellerName: '',
sellerUserId: '',
inviteDate: '',
filingDate: ''
}
this.inviteDateTouched = false
if (this.customerId) this.findVisitsInfo()
},
async findVisitsInfo () {
......@@ -307,8 +310,10 @@ export default {
id: this.customerId
})
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")
this.customerInfo = res
this.inviteDateTouched = !!res.inviteDate
},
backPage () {
uni.navigateBack({
......@@ -357,7 +362,14 @@ export default {
}
},
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) {
const standNoVal = this.customerInfo.standNo
......@@ -435,6 +447,8 @@ export default {
merchantId:params.merchantId,
employeeName:params.employeeName,
sellerMerchantId:params.sellerMerchantId,
sellerUserId: params.sellerUserId,
sellerName: customerInfo.sellerName,
preliminaryOrders: [
{
sceneType:1,
......@@ -451,7 +465,7 @@ export default {
employeeName:params.employeeName,
userId:params.userId,
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, //建档日期
sellerUserld: params.sellerUserId,
sellerName: customerInfo.sellerName,
......
......@@ -53,6 +53,7 @@
placeholder="请选择"
placeholder-style="color:rgba(51, 51, 51, 0.2);"
confirm-type="done"
@blur="inputBlur($event, i)"
/>
</template>
<template v-else-if="i.type == 'date'">
......@@ -97,6 +98,7 @@
placeholder="请选择"
placeholder-style="color:rgba(51, 51, 51, 0.2);"
confirm-type="done"
@blur="inputBlur($event, i)"
/>
</template>
<template v-else-if="i.type == 'date'">
......@@ -221,6 +223,7 @@
import dayjs from 'dayjs'
import ReceptionSence from '@/components/HomeFrame/components/ReceptionCenter/ReceptionSence.vue'
import Employee from '@/components/Employee.vue'
import { validateVin, formatVinInput } from '@/utils/vinVaildate'
const phoneRex = /^[1]([3-9])[0-9]{9}$/,
default_customerForm = [{
......@@ -373,7 +376,8 @@
},
groupMemberList: [],
startDate: '',
endDate: ''
endDate: '',
validateState: true
}
},
onLoad (options) {
......@@ -434,6 +438,24 @@
}
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 = {
id: this.customerInfo.id,
customerName: this.customerInfo.customerName,
......@@ -599,6 +621,7 @@
deliveryDate: '',
receptionSceneName: '',
standNo: '',
inviteDate: '',
createdDate: '',
employeeName: '',
userId: '',
......@@ -681,6 +704,22 @@
bindDateChange (e, valueKey) {
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) {
if (!value) return value
return dayjs(value).format('YYYY-MM-DD HH:mm:ss')
......
......@@ -71,7 +71,7 @@ export default {
staffUuid: uni.$storage.get('userInfo').uuid,
staffName: uni.$storage.get('userInfo').name,
merchantId: String(uni.$storage.get('userInfo').merchantId ?? ''),
entrySource: 'home_popup',
entrySource: '',
skipCount: 0,
},
pendingAppBackTimer: null,
......@@ -736,6 +736,36 @@ export default {
// #endif
},
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 {
const res = await uni.$api.commonApi.getPrelernHomePopupAPI()
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!