Commit 586eb745 by Lin

feature(FinishStep、HomeFrame、boutique):改进表单处理和接收逻辑

- 更新了 FinishStep.vue,通过新增方法优化字段禁用逻辑。
- 在 HomeFrame.vue 中移除了未使用的事件监听器,以提升性能。
- 优化了精品页面的接待处理功能,包括客户数据管理以及个人资料接待时的事件发射。
- 改进 CustomerSide 组件的样式设计,以更好地处理文本溢出问题。
- 重构接待逻辑,确保在接待过程中正确传递和处理客户数据。
1 parent e3d6f1b6
......@@ -33,7 +33,7 @@
:key="index"
>
<view :class="['label', { required: i.required }]">{{ i.label }}</view>
<view :class="['value', { error: showError(i.key) && i.required }, { disabled: customerType == 0 || i.disabled }]">
<view :class="['value', { error: showError(i.key) && i.required }, { disabled: isFieldDisabled(i) }]">
<template v-if="i.type == 'input'">
<input
:type="i.inputType"
......@@ -41,7 +41,7 @@
v-model="formData[i.key]"
class="input"
:placeholder="i.placeholder"
:disabled="customerType == 0"
:disabled="isFieldDisabled(i)"
@input="inputCustomer"
placeholder-style="color:#c9c9c9;"
/>
......@@ -252,10 +252,15 @@ export default {
if (key == 'phoneNumber' && this.formData[key]) flag = !phoneRex.test(this.formData[key])
return this.errorTip && flag
},
showPopup ({ popKey, disabled }) {
let { customerType } = this
if (customerType == 0 || disabled) return
this.$refs[popKey].open();
isFieldDisabled (field) {
if (this.customerType == 0) return true
if (field.disabled) return true
if (this.formData.profilePrefilled && field.key === 'carModel') return true
return false
},
showPopup (field) {
if (this.isFieldDisabled(field)) return
this.$refs[field.popKey].open();
},
// 取消
cancel () {
......@@ -310,6 +315,7 @@ export default {
}
},
success (receptionStatus) {
this.$store.dispatch('setCustomerInfo', this.formData)
this.$refs.successRef.open();
this.$emit('submit', receptionStatus)
},
......@@ -342,6 +348,8 @@ export default {
this.$emit('back')
return
}
} else if (customerInfo.profilePrefilled) {
step = 1
}
if (step == 2 && !this.check()) {
this.errorTip = true
......
......@@ -421,7 +421,11 @@ export default {
line-height: 22px;
font-weight: 500;
color: #1A1A2E;
flex-shrink: 0;
min-width: 0;
flex: 1;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.customer-item-car-tag {
......
......@@ -396,7 +396,6 @@ export default {
uni.$off('levelStudyPopup')
uni.$off('pageBack')
uni.$off('refreshCustomerProfileGroupInfo')
uni.$off('startReceptionFromCustomerDetail')
},
async mounted() {
console.log('sessionId**', uni.$storage.get('sessionId'))
......@@ -499,9 +498,6 @@ export default {
uni.$on('refreshCustomerProfileGroupInfo', () => {
this.getCustomerProfileGroupInfo()
})
uni.$on('startReceptionFromCustomerDetail', () => {
this.start()
})
/**
* 获取员工场景小分类
*/
......
......@@ -223,11 +223,9 @@ export default {
},
/**是否有选装项目 */
hasOptionals() {
let flag = false
if (this.show) {
flag = this.boutiqueMediaConfig[this.currentCarId].optionals && this.boutiqueMediaConfig[this.currentCarId].optionals.length
}
return flag
if (!this.show || !this.currentCarId) return false
const optionals = this.boutiqueMediaConfig?.[this.currentCarId]?.optionals
return !!(optionals && optionals.length)
},
carList() {
return this.$store.state.user.boutiqueCarList
......
......@@ -175,7 +175,9 @@ export default {
}
]),
loadComplete: false,
requested: false
requested: false,
profileReceptionCustomer: null,
profileReceptionProcessing: false
}
},
onBackPress (options) {
......@@ -195,6 +197,10 @@ export default {
this.requested = true
this.$refs.home.updateApp(true)
this.getMerchantCarBrand()
uni.$on('startProfileReception', this.handleProfileReception)
},
onUnload () {
uni.$off('startProfileReception', this.handleProfileReception)
},
async onShow () {
const userInfo = uni.$storage.get("userInfo")
......@@ -208,6 +214,7 @@ export default {
}
if (this.requested && !this.id) this.$refs.home.updateApp()
this.getBoutiquePackageList() //套餐列表
this.tryStartPendingProfileReception()
},
computed: {
},
......@@ -362,6 +369,7 @@ export default {
this.currentCarId = ''
this.bannerAutoplay = true
this.customerType = -1
this.profileReceptionCustomer = null
this.clearHistory();
this.recording = false
this.setReceptionStatus(-1);
......@@ -369,12 +377,73 @@ export default {
if (this.requested) this.$refs.home.updateApp()
this.getBoutiquePackageList() //套餐列表
},
handleProfileReception (customer) {
const pendingCustomer = customer || uni.$storage.get('pendingProfileReception')
if (!pendingCustomer || this.profileReceptionProcessing) return
this.profileReceptionProcessing = true
uni.$storage.rm('pendingProfileReception')
this.$nextTick(async () => {
try {
await this.startReceptionFromProfile(pendingCustomer)
} finally {
this.profileReceptionProcessing = false
}
})
},
tryStartPendingProfileReception () {
let customer = ''
try {
customer = uni.$storage.get('pendingProfileReception')
} catch (e) {
return
}
if (!customer) return
this.handleProfileReception()
},
waitForHomeRef (retry = 20) {
return new Promise(resolve => {
const check = (count) => {
if (this.$refs.home) resolve(true)
else if (count >= retry) resolve(false)
else setTimeout(() => check(count + 1), 50)
}
check(0)
})
},
async startReceptionFromProfile (customer) {
if (!customer) return
const homeReady = await this.waitForHomeRef()
if (!homeReady) {
uni.$storage.set('pendingProfileReception', customer)
uni.showToast({
title: '页面未就绪,请重试',
icon: 'none'
})
return
}
if (!this.moduleList.length) {
await this.getSoure()
}
uni.$track.add({ eventCode: 'app_reception_begins' })
const isReturnCustomer = !!customer.customerCouponId
this.customerType = isReturnCustomer ? 0 : 1
this.clearHistory()
this.jumpPage()
this.fillReceptionCustomer(customer)
const flag = await this.start(false)
if (!flag) return
this.recording = true
setTimeout(() => {
this.setReceptionStatus(1)
}, 1000)
},
async start (before = true) {
const isPermision = await this.$refs.home.isPermission()
if (!isPermision) return false
uni.$logger.local.info('〖接待管理Recorder〗 == 开始接待 ')
if (before) this.clearHistory();
this.$refs.home.startAudio(false)
const started = await this.$refs.home.startAudio(false)
if (!started) return false
this.recording = true
return true
},
......@@ -382,9 +451,9 @@ export default {
let { carBannerList } = this,
carIndex = carBannerList.findIndex(e => e.carModelId == this.defaultCarId)
if (carBannerList.length == 1 || carIndex < 0) carIndex = 0 //只有一个车型或者默认车型没有时
this.id = id ? id : this.moduleList[0].id
this.id = id || (this.moduleList[0] && this.moduleList[0].id) || 1
this.tabId = 1
this.currentCarId = carBannerList[carIndex].carModelId
this.currentCarId = carBannerList[carIndex]?.carModelId || ''
this.type = "edit"
},
clearHistory () {
......@@ -402,17 +471,29 @@ export default {
if (!flag) return
this.customerType = index
if (index == 0) {
this.profileReceptionCustomer = null
const { id } = moduleList[2]
this.jumpPage(id)
} else {
this.jumpPage()
if (this.profileReceptionCustomer) {
this.fillReceptionCustomer(this.profileReceptionCustomer)
this.profileReceptionCustomer = null
}
}
else this.jumpPage()
setTimeout(() => {
this.setReceptionStatus(1);
}, 1000);
},
async done (e) {
this.$refs.home.finishRef.close();
if (this.recording) await this.$refs.home.stopAudio();
if (this.recording) {
if (e !== undefined && e !== null && e !== -1) {
this.setReceptionStatus(e)
}
this.$refs.home.updateCustomerInfo(this.$store.state.user.customerInfo)
await this.$refs.home.stopAudio();
}
this.recording = false
setTimeout(() => {
this.id = "";
......@@ -420,26 +501,20 @@ export default {
this.currentCarId = ''
this.bannerAutoplay = true
this.customerType = -1
this.profileReceptionCustomer = null
this.$store.dispatch("clearHistory")
this.$store.dispatch('clearReceptionTrack')
this.getBoutiquePackageList() //套餐列表
this.setReceptionStatus(-1);
}, 1500);
},
/**客户邀约接待 */
reception (customer) {
this.currentCarId = ''
this.$nextTick(async () => {
let { customerType } = this
if (customerType == -1) {
const flag = await this.start(false)
if (!flag) return
} //开始接待
this.customerType = 0
this.jumpPage()
uni.$logger.local.info('index-reception:回店客户〗 == ' + JSON.stringify(customer))
this.$refs.home.updateCustomerInfo(customer)
this.$nextTick(() => this.$store.dispatch('setCustomerInfo', customer))
fillReceptionCustomer (customer) {
this.$nextTick(() => {
uni.$logger.local.info('index-reception:客户接待回填〗 == ' + JSON.stringify(customer))
this.$store.dispatch('setCustomerInfo', customer)
this.$nextTick(() => {
this.$refs.home.updateCustomerInfo(customer)
})
let { carBannerList } = this,
currentCarId = '',
carIndex = carBannerList.findIndex(e => e.carModelId == this.defaultCarId)
......@@ -452,6 +527,19 @@ export default {
this.currentCarId = currentCarId
})
},
/**客户邀约接待 */
reception (customer) {
this.$nextTick(async () => {
let { customerType } = this
if (customerType == -1) {
const flag = await this.start(false)
if (!flag) return
} //开始接待
this.customerType = 0
this.jumpPage()
this.fillReceptionCustomer(customer)
})
},
swiperChange (e) {
this.currentIndex = e.detail.current
this.bannerTabId = `car-banner-${e.detail.current}`
......
......@@ -232,6 +232,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'
import RecordService from '@/utils/recordManager/RecordService'
const phoneRex = /^[1]([3-9])[0-9]{9}$/,
default_customerForm = [{
label: '车主姓名',
......@@ -327,7 +328,7 @@ const phoneRex = /^[1]([3-9])[0-9]{9}$/,
placeholder: '请选择群成员'
},
{
label: '备注',
label: '订单备注',
valueKey: 'remark',
key: 'remark',
type: 'input',
......@@ -719,7 +720,7 @@ export default {
}
this.syncInviteDateFromDelivery()
this.syncDisplayInfo(this.customerInfo)
console.log('findVisitsInfo**customerInfo*', this.customerInfo)
console.log('客户详情**customerInfo*', this.customerInfo)
await this.getCustomerGroupInfo()
},
backPage () {
......@@ -739,8 +740,45 @@ export default {
}
this.submitCustomerProfileAPI()
},
buildReceptionCustomer () {
const item = this.customerInfo
const { customerInviteRecordDTO = {} } = item
const { customerCouponId, customerCoupon = {} } = customerInviteRecordDTO
console.log('跳转开始接待**item*', item);
console.log('跳转开始接待**customerInviteRecordDTO*', customerCoupon.createdDate);
console.log('跳转开始接待**customerCouponId*', customerCouponId);
// let customer = {
// customerName: item.customerName,
// carModel: item.carSeriesName || '',
// phoneNumber: item.customerPhone,
// salesUuid: item.userId,
// staffName: item.employeeName,
// receiveCouponDate: item.receiveCouponDate,
// customerCouponId: item.customerCouponId,
// carSeriesId: item.carSeriesId || '',
// carBrand: item.carChildsBrandName || '',
// carBrandId: item.carChildsBrandId || '',
// oneCarBrand: item.carBrand || '',
// oneCarBrandId: item.carBrandId || ''
// }
return {
customerName: item.customerName,
carModel: item.carSeriesName || item.carChildsBrandName || '',
phoneNumber: item.customerPhone,
salesUuid: item.userId,
staffName: item.employeeName,
carSeriesId: item.carSeriesId || '',
carBrand: item.carChildsBrandName || '',
carBrandId: item.carChildsBrandId || '',
oneCarBrand: item.carBrand || '',
oneCarBrandId: item.carBrandId || '',
receiveCouponDate: customerCoupon.createdDate,
customerCouponId,
profilePrefilled: true
}
},
async startReception () {
const { sceneType, customerInfo } = this
const { sceneType } = this
if (sceneType == 7) return // 二手车无接待功能
if (this.isRequiredFormIncomplete) {
uni.showToast({
......@@ -750,14 +788,19 @@ export default {
return
}
if (this.isStartReceptionDisabled) return
const recordService = RecordService.getInstance()
const hasPermission = await recordService.isPermission()
if (!hasPermission) return
const submitted = await this.submitCustomerProfileAPI({ fromReception: true })
if (!submitted) return
const customer = this.buildReceptionCustomer()
uni.$storage.set('pendingProfileReception', customer)
uni.navigateBack({
delta: 1,
animationType: 'pop-out',
animationDuration: 100,
success: () => {
uni.$emit('startReceptionFromCustomerDetail')
uni.$emit('startProfileReception', customer)
}
})
},
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!