Commit 78cab289 by Lin

feat(customerApi, HomeFrame, PreBackPopup, prelearnBridge):重构客户资料提交流程并增强数据处理能力

- 更新 customerApi,新增 submitPreliminaryOrderAPI 以支持批量订单提交。
- 重构 HomeFrame 和 PreBackPopup,优化跳过次数扣除逻辑,确保活动处理准确。
- 增强 prelearnBridge,新增管理活动完成状态的方法,并注入脚本以提升 H5 兼容性。
- 在 addFiles.vue 中添加到达日期字段,并改进客户群组信息获取逻辑。
1 parent 4aea790b
......@@ -167,11 +167,22 @@ module.exports = {
...data
})
},
/**
/**
* 轻改业务改版
* 2、客户建档提交
*/
csubmitCustomerProfileAPI(data) {
submitPreliminaryOrderAPI(data) {
return http.post({
method: 'dj.api.smartcarlife.order.preliminaryOrder.batch',
projectName: 'pad',
...data
})
},
/**
* 轻改业务改版
* 3、客户建档提交
*/
submitCustomerProfileAPI(data) {
return http.post({
method: 'dj.api.smartcarlife.order.submitCustomerProfile',
projectName: 'pad',
......
......@@ -709,12 +709,13 @@ export default {
* 查询策略首页数据状态(营销活动和客户列表是否有数据)
*/
async getStrategyStatus() {
const res = await uni.$api.activityApi.getActivityStatusAPI()
// const res = await uni.$api.activityApi.getActivityStatusAPI()
// console.log('查询策略首页数据状态(营销活动和客户列表是否有数据):', res)
// const res = {
// marketingActivityHasData: true,
// customerListHasData: true
// }
const res = {
marketingActivityHasData: true,
customerListHasData: true
}
console.log('%c查询策略首页数据状态(营销活动和客户列表是否有数据):', 'color: green;', res)
if (!res) return
this.marketingActivityHasData = !!res.marketingActivityHasData
......@@ -829,31 +830,31 @@ export default {
* 查询客户建档分页查询-月按天分组
*/
async getCustomerProfileGroupInfo() {
// const res = await uni.$api.customerApi.getCustomerProfileGroupInfoAPI({})
// console.log('查询客户建档分页查询-月按天分组:', res)
const res = await uni.$api.customerApi.getCustomerProfileGroupInfoAPI({merchantId: 44211227})
console.log('查询客户建档分页查询-月按天分组:', res)
},
/**
* 查询预学习首页弹框信息
*/
async getPrelearnHome() {
// const res = await uni.$api.commonApi.getPrelernHomePopupAPI()
const res = {
"activityId": 22,
"activityName": "618年中促活动A",
"packages": [
{
"activityProductId": "15",
"packageName": "tttttttt",
"includes": [],
"learnStatus": "NOT_STUDY",
"scriptReady": true
}
],
"remainingSkipCount": 3,
"shouldPopup": true,
"muteReason": null,
"remainingActivityCount": null
}
const res = await uni.$api.commonApi.getPrelernHomePopupAPI()
// const res = {
// "activityId": 22,
// "activityName": "618年中促活动A",
// "packages": [
// {
// "activityProductId": "15",
// "packageName": "tttttttt",
// "includes": [],
// "learnStatus": "NOT_STUDY",
// "scriptReady": true
// }
// ],
// "remainingSkipCount": 3,
// "shouldPopup": true,
// "muteReason": null,
// "remainingActivityCount": null
// }
console.log('查询预学习首页弹框信息:', res)
if (res) {
this.prelearnData = res
......@@ -863,8 +864,10 @@ export default {
},
async deductSkipCount() {
let requestParams = {
activityId:this.prelearnData.getActivityMessagePopUpWindow
activityId:this.prelearnData.activityId
}
console.log('requestParams***', requestParams);
const res = await uni.$api.commonApi.deductSkipCountAPI(requestParams)
console.log('deductSkipCountAPI***', res);
if (res) {
......
......@@ -38,7 +38,7 @@ export default {
},
async deductSkipCount() {
let requestParams = {
activityId:this.prelearnContext.getActivityMessagePopUpWindow
activityId:this.prelearnContext.activityId
}
const res = await uni.$api.commonApi.deductSkipCountAPI(requestParams)
console.log('deductSkipCountAPI***', res);
......
......@@ -182,19 +182,19 @@ const phoneRex = /^[1]([3-9])[0-9]{9}$/,
popKey: 'carBrandVisible'
},
{
label: '交付日期',
valueKey: 'arrivalDate',
key: 'arrivalDate',
required: true,
type: 'date'
},
{
label: '流量来源',
valueKey: 'residentSaleName',
key: 'residentSaleId',
type: 'select',
required: true,
popKey: 'residentSaleVisible'
},
{
label: '交付日期',
valueKey: 'arrivalDate',
key: 'arrivalDate',
required: true,
type: 'date'
}
// {
// label: '接待场景',
......@@ -269,6 +269,10 @@ export default {
this.endDate = dayjs(dayjs().add(30, 'day')).format("YYYY-MM-DD")
},
methods: {
async getCustomerGroupInfo() {
const res = await uni.$api.customerApi.getCustomerGroupInfoAPI({merchantId: 44211227})
console.log('getCustomerGroupInfoAPI***', res)
},
initForm () {
const { sceneType } = uni.$storage.get("userInfo")
default_customerForm[0].maxlength = sceneType == 1 ? 20 : 50
......@@ -373,7 +377,7 @@ export default {
})
let { customerInfo, customerForm, optionalForm } = this,
{ shopMerchantId, sceneType } = uni.$storage.get("userInfo"),
targetApi = customerInfo.id ? 'updateVisitsInfo' : 'saveVisitsInfo',
targetApi = customerInfo.id ? 'submitCustomerProfileAPI' : 'submitCustomerProfileAPI',
params = {
merchantId: shopMerchantId,
bussinessScene: sceneType == 0 ? 1 : 2
......@@ -400,9 +404,50 @@ export default {
mask: true
})
console.log('params**', params)
// const res = await uni.$api.customerApi[targetApi](params),
const res = await uni.$api.customerApi.submitCustomerProfileAPI([params]),
// {
// "merchantId": 44211227,
// "bussinessScene": 2,
// "customerName": "linl",
// "customerPhone": "13588008885",
// "carTypeName": "问界M7",
// "arrivalDate": "2026-06-25",
// "residentSaleId": "997c9fbb64b046ac900d751d99d0273d",
// "standNo": "",
// "filingDate": "",
// "carTypeId": 1149147,
// "carBrand": "AITO 问界",
// "carBrandId": 3454,
// "oneCarBrand": "鸿蒙智行",
// "oneCarBrandId": 2978,
// "employeeName": "成威2号",
// "userId": "e77729f1a544442a8f43e587e1f6d20a",
// "sellerMerchantId": 44209880
// }
let requestParams = {
userId:params.userId,
merchantId:params.merchantId,
employeeName:params.employeeName,
sellerMerchantId:params.sellerMerchantId,
preliminaryOrders: [
{
customerName:params.customerName,
customerPhone:params.customerPhone,
carBrand:params.carBrand,
carBrandId:params.carBrandId,
carChildsBrandId:'',
carChildsBrandName:'',
carSeriesId:params.carTypeId,
carSeriesName:params.carTypeName,
deliveryDate:params.arrivalDate, //交付日期
inviteDate:'', //到店日期
createdDate:'', //建档日期
}
]
}
console.log('requestParams**', requestParams)
const res = await uni.$api.customerApi[targetApi](requestParams),
_this = this
console.log('submitCustomerProfileAPI res**', res)
if (res) {
if (res == '1') {
this.$refs.successRef.open()
......@@ -428,8 +473,10 @@ export default {
uni.hideLoading()
}
} catch (error) {
let index = this.customerForm.findIndex(e => e.key == error)
this.customerForm[index].error = true
const index = this.customerForm.findIndex(e => e.key == error)
if (index !== -1) {
this.customerForm[index].error = true
}
uni.hideLoading()
}
}
......
......@@ -70,7 +70,7 @@ export default {
activityProductId: '16',
staffUuid: uni.$storage.get('userInfo').uuid,
staffName: uni.$storage.get('userInfo').name,
merchantId: '44209880',
merchantId: uni.$storage.get('userInfo').merchantId,
entrySource: 'home_popup',
},
pendingAppBackTimer: null,
......@@ -176,6 +176,7 @@ export default {
console.log('[prelearnBridge] open url:', this.webviewUrl)
},
onReady() {
this.registerCompleteActivityHandler()
this.captureChildWebview()
this.initBrowserBridge()
this.createNavBackHotArea()
......@@ -190,6 +191,7 @@ export default {
onUnload() {
this.clearPendingAppBack()
this.destroyNavBackHotArea()
this.unregisterCompleteActivityHandler()
// #ifdef H5
window.removeEventListener('message', this.handleBrowserMessage)
// #endif
......@@ -249,11 +251,87 @@ export default {
initBrowserBridge() {
// #ifdef H5
window.addEventListener('message', this.handleBrowserMessage)
setTimeout(() => this.injectH5CompleteActivity(), 600)
setTimeout(() => this.injectH5CompleteActivity(), 1500)
setTimeout(() => this.pushPrelearnSessionByBrowserMessage(), 600)
setTimeout(() => this.pushPrelearnSessionByBrowserMessage(), 1500)
setTimeout(() => this.pushPrelearnSessionByBrowserMessage(), 3000)
// #endif
},
registerCompleteActivityHandler() {
window.completeActivity = (payload) => {
this.handleCompleteActivity(payload)
}
},
unregisterCompleteActivityHandler() {
if (window.completeActivity) {
delete window.completeActivity
}
},
buildH5CompleteActivityInjectScript() {
return `
(function() {
window.completeActivity = function(payload) {
payload = payload || {};
try {
if (typeof uni !== 'undefined' && uni.postMessage) {
uni.postMessage({ data: { type: 'COMPLETE_ACTIVITY', payload: payload } });
return;
}
} catch (e) {}
try {
if (typeof plus !== 'undefined' && plus.webview) {
var pwv = plus.webview.currentWebview();
var parent = pwv && pwv.parent && pwv.parent();
if (parent && parent.evalJS) {
parent.evalJS('window.completeActivity && window.completeActivity(' + JSON.stringify(payload) + ')');
return;
}
}
} catch (e) {}
try {
if (window.parent && window.parent !== window) {
window.parent.postMessage({
source: 'prelearn-h5',
type: 'COMPLETE_ACTIVITY',
payload: payload
}, '*');
}
} catch (e) {}
};
})();
`
},
injectH5CompleteActivity() {
const script = this.buildH5CompleteActivityInjectScript()
// #ifdef APP-PLUS
if (this.childWebview && this.childWebview.evalJS) {
this.childWebview.evalJS(script)
console.log('[prelearnBridge] injected window.completeActivity into child webview')
return
}
// #endif
// #ifdef H5
const iframe = document.querySelector('iframe')
if (!iframe || !iframe.contentWindow) {
console.log('[prelearnBridge] browser iframe missing, skip completeActivity inject')
return
}
try {
iframe.contentWindow.eval(script)
console.log('[prelearnBridge] injected window.completeActivity into browser iframe')
} catch (error) {
console.log('[prelearnBridge] inject completeActivity into iframe failed:', error)
}
// #endif
},
handleCompleteActivity(payload) {
console.log('[prelearnBridge] H5 completeActivity:', payload)
this.clearPendingAppBack()
this.navigateBack()
},
handleBrowserMessage(event) {
const message = event && event.data
if (!message || message.source !== 'prelearn-h5') return
......@@ -274,6 +352,10 @@ export default {
if (message.type === 'PRELEARN_APP_BACK_HANDLED') {
this.handleH5BackHandled(message)
}
if (message.type === 'COMPLETE_ACTIVITY') {
this.handleCompleteActivity(message.payload || message.data)
}
},
captureChildWebview() {
// #ifdef APP-PLUS
......@@ -286,8 +368,11 @@ export default {
console.log('[prelearn bridge demo] child webview ready')
this.applyWebviewInset()
this.createNavBackHotArea()
this.injectH5CompleteActivity()
this.pushPrelearnSessionToH5()
setTimeout(() => this.injectH5CompleteActivity(), 600)
setTimeout(() => this.pushPrelearnSessionToH5(), 600)
setTimeout(() => this.injectH5CompleteActivity(), 1500)
setTimeout(() => this.pushPrelearnSessionToH5(), 1500)
return
}
......@@ -320,6 +405,10 @@ export default {
if (message.type === 'PRELEARN_APP_BACK_HANDLED') {
this.handleH5BackHandled(message)
}
if (message.type === 'COMPLETE_ACTIVITY') {
this.handleCompleteActivity(message.payload || message.data)
}
})
},
normalizeMessages(event) {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!