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 = { ...@@ -167,11 +167,22 @@ module.exports = {
...data ...data
}) })
}, },
/** /**
* 轻改业务改版 * 轻改业务改版
* 2、客户建档提交 * 2、客户建档提交
*/ */
csubmitCustomerProfileAPI(data) { submitPreliminaryOrderAPI(data) {
return http.post({
method: 'dj.api.smartcarlife.order.preliminaryOrder.batch',
projectName: 'pad',
...data
})
},
/**
* 轻改业务改版
* 3、客户建档提交
*/
submitCustomerProfileAPI(data) {
return http.post({ return http.post({
method: 'dj.api.smartcarlife.order.submitCustomerProfile', method: 'dj.api.smartcarlife.order.submitCustomerProfile',
projectName: 'pad', projectName: 'pad',
......
...@@ -709,12 +709,13 @@ export default { ...@@ -709,12 +709,13 @@ export default {
* 查询策略首页数据状态(营销活动和客户列表是否有数据) * 查询策略首页数据状态(营销活动和客户列表是否有数据)
*/ */
async getStrategyStatus() { async getStrategyStatus() {
const res = await uni.$api.activityApi.getActivityStatusAPI() // const res = await uni.$api.activityApi.getActivityStatusAPI()
// console.log('查询策略首页数据状态(营销活动和客户列表是否有数据):', res) // console.log('查询策略首页数据状态(营销活动和客户列表是否有数据):', res)
// const res = { const res = {
// marketingActivityHasData: true, marketingActivityHasData: true,
// customerListHasData: true customerListHasData: true
// } }
console.log('%c查询策略首页数据状态(营销活动和客户列表是否有数据):', 'color: green;', res)
if (!res) return if (!res) return
this.marketingActivityHasData = !!res.marketingActivityHasData this.marketingActivityHasData = !!res.marketingActivityHasData
...@@ -829,31 +830,31 @@ export default { ...@@ -829,31 +830,31 @@ export default {
* 查询客户建档分页查询-月按天分组 * 查询客户建档分页查询-月按天分组
*/ */
async getCustomerProfileGroupInfo() { async getCustomerProfileGroupInfo() {
// const res = await uni.$api.customerApi.getCustomerProfileGroupInfoAPI({}) const res = await uni.$api.customerApi.getCustomerProfileGroupInfoAPI({merchantId: 44211227})
// console.log('查询客户建档分页查询-月按天分组:', res) console.log('查询客户建档分页查询-月按天分组:', res)
}, },
/** /**
* 查询预学习首页弹框信息 * 查询预学习首页弹框信息
*/ */
async getPrelearnHome() { async getPrelearnHome() {
// const res = await uni.$api.commonApi.getPrelernHomePopupAPI() const res = await uni.$api.commonApi.getPrelernHomePopupAPI()
const res = { // const res = {
"activityId": 22, // "activityId": 22,
"activityName": "618年中促活动A", // "activityName": "618年中促活动A",
"packages": [ // "packages": [
{ // {
"activityProductId": "15", // "activityProductId": "15",
"packageName": "tttttttt", // "packageName": "tttttttt",
"includes": [], // "includes": [],
"learnStatus": "NOT_STUDY", // "learnStatus": "NOT_STUDY",
"scriptReady": true // "scriptReady": true
} // }
], // ],
"remainingSkipCount": 3, // "remainingSkipCount": 3,
"shouldPopup": true, // "shouldPopup": true,
"muteReason": null, // "muteReason": null,
"remainingActivityCount": null // "remainingActivityCount": null
} // }
console.log('查询预学习首页弹框信息:', res) console.log('查询预学习首页弹框信息:', res)
if (res) { if (res) {
this.prelearnData = res this.prelearnData = res
...@@ -863,8 +864,10 @@ export default { ...@@ -863,8 +864,10 @@ export default {
}, },
async deductSkipCount() { async deductSkipCount() {
let requestParams = { let requestParams = {
activityId:this.prelearnData.getActivityMessagePopUpWindow activityId:this.prelearnData.activityId
} }
console.log('requestParams***', requestParams);
const res = await uni.$api.commonApi.deductSkipCountAPI(requestParams) const res = await uni.$api.commonApi.deductSkipCountAPI(requestParams)
console.log('deductSkipCountAPI***', res); console.log('deductSkipCountAPI***', res);
if (res) { if (res) {
......
...@@ -38,7 +38,7 @@ export default { ...@@ -38,7 +38,7 @@ export default {
}, },
async deductSkipCount() { async deductSkipCount() {
let requestParams = { let requestParams = {
activityId:this.prelearnContext.getActivityMessagePopUpWindow activityId:this.prelearnContext.activityId
} }
const res = await uni.$api.commonApi.deductSkipCountAPI(requestParams) const res = await uni.$api.commonApi.deductSkipCountAPI(requestParams)
console.log('deductSkipCountAPI***', res); console.log('deductSkipCountAPI***', res);
......
...@@ -182,19 +182,19 @@ const phoneRex = /^[1]([3-9])[0-9]{9}$/, ...@@ -182,19 +182,19 @@ const phoneRex = /^[1]([3-9])[0-9]{9}$/,
popKey: 'carBrandVisible' popKey: 'carBrandVisible'
}, },
{ {
label: '交付日期',
valueKey: 'arrivalDate',
key: 'arrivalDate',
required: true,
type: 'date'
},
{
label: '流量来源', label: '流量来源',
valueKey: 'residentSaleName', valueKey: 'residentSaleName',
key: 'residentSaleId', key: 'residentSaleId',
type: 'select', type: 'select',
required: true, required: true,
popKey: 'residentSaleVisible' popKey: 'residentSaleVisible'
},
{
label: '交付日期',
valueKey: 'arrivalDate',
key: 'arrivalDate',
required: true,
type: 'date'
} }
// { // {
// label: '接待场景', // label: '接待场景',
...@@ -269,6 +269,10 @@ export default { ...@@ -269,6 +269,10 @@ export default {
this.endDate = dayjs(dayjs().add(30, 'day')).format("YYYY-MM-DD") this.endDate = dayjs(dayjs().add(30, 'day')).format("YYYY-MM-DD")
}, },
methods: { methods: {
async getCustomerGroupInfo() {
const res = await uni.$api.customerApi.getCustomerGroupInfoAPI({merchantId: 44211227})
console.log('getCustomerGroupInfoAPI***', res)
},
initForm () { initForm () {
const { sceneType } = uni.$storage.get("userInfo") const { sceneType } = uni.$storage.get("userInfo")
default_customerForm[0].maxlength = sceneType == 1 ? 20 : 50 default_customerForm[0].maxlength = sceneType == 1 ? 20 : 50
...@@ -373,7 +377,7 @@ export default { ...@@ -373,7 +377,7 @@ export default {
}) })
let { customerInfo, customerForm, optionalForm } = this, let { customerInfo, customerForm, optionalForm } = this,
{ shopMerchantId, sceneType } = uni.$storage.get("userInfo"), { shopMerchantId, sceneType } = uni.$storage.get("userInfo"),
targetApi = customerInfo.id ? 'updateVisitsInfo' : 'saveVisitsInfo', targetApi = customerInfo.id ? 'submitCustomerProfileAPI' : 'submitCustomerProfileAPI',
params = { params = {
merchantId: shopMerchantId, merchantId: shopMerchantId,
bussinessScene: sceneType == 0 ? 1 : 2 bussinessScene: sceneType == 0 ? 1 : 2
...@@ -400,9 +404,50 @@ export default { ...@@ -400,9 +404,50 @@ export default {
mask: true mask: true
}) })
console.log('params**', params) 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 _this = this
console.log('submitCustomerProfileAPI res**', res)
if (res) { if (res) {
if (res == '1') { if (res == '1') {
this.$refs.successRef.open() this.$refs.successRef.open()
...@@ -428,8 +473,10 @@ export default { ...@@ -428,8 +473,10 @@ export default {
uni.hideLoading() uni.hideLoading()
} }
} catch (error) { } catch (error) {
let index = this.customerForm.findIndex(e => e.key == error) const index = this.customerForm.findIndex(e => e.key == error)
this.customerForm[index].error = true if (index !== -1) {
this.customerForm[index].error = true
}
uni.hideLoading() uni.hideLoading()
} }
} }
......
...@@ -70,7 +70,7 @@ export default { ...@@ -70,7 +70,7 @@ export default {
activityProductId: '16', activityProductId: '16',
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: '44209880', merchantId: uni.$storage.get('userInfo').merchantId,
entrySource: 'home_popup', entrySource: 'home_popup',
}, },
pendingAppBackTimer: null, pendingAppBackTimer: null,
...@@ -176,6 +176,7 @@ export default { ...@@ -176,6 +176,7 @@ export default {
console.log('[prelearnBridge] open url:', this.webviewUrl) console.log('[prelearnBridge] open url:', this.webviewUrl)
}, },
onReady() { onReady() {
this.registerCompleteActivityHandler()
this.captureChildWebview() this.captureChildWebview()
this.initBrowserBridge() this.initBrowserBridge()
this.createNavBackHotArea() this.createNavBackHotArea()
...@@ -190,6 +191,7 @@ export default { ...@@ -190,6 +191,7 @@ export default {
onUnload() { onUnload() {
this.clearPendingAppBack() this.clearPendingAppBack()
this.destroyNavBackHotArea() this.destroyNavBackHotArea()
this.unregisterCompleteActivityHandler()
// #ifdef H5 // #ifdef H5
window.removeEventListener('message', this.handleBrowserMessage) window.removeEventListener('message', this.handleBrowserMessage)
// #endif // #endif
...@@ -249,11 +251,87 @@ export default { ...@@ -249,11 +251,87 @@ export default {
initBrowserBridge() { initBrowserBridge() {
// #ifdef H5 // #ifdef H5
window.addEventListener('message', this.handleBrowserMessage) window.addEventListener('message', this.handleBrowserMessage)
setTimeout(() => this.injectH5CompleteActivity(), 600)
setTimeout(() => this.injectH5CompleteActivity(), 1500)
setTimeout(() => this.pushPrelearnSessionByBrowserMessage(), 600) setTimeout(() => this.pushPrelearnSessionByBrowserMessage(), 600)
setTimeout(() => this.pushPrelearnSessionByBrowserMessage(), 1500) setTimeout(() => this.pushPrelearnSessionByBrowserMessage(), 1500)
setTimeout(() => this.pushPrelearnSessionByBrowserMessage(), 3000) setTimeout(() => this.pushPrelearnSessionByBrowserMessage(), 3000)
// #endif // #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) { handleBrowserMessage(event) {
const message = event && event.data const message = event && event.data
if (!message || message.source !== 'prelearn-h5') return if (!message || message.source !== 'prelearn-h5') return
...@@ -274,6 +352,10 @@ export default { ...@@ -274,6 +352,10 @@ export default {
if (message.type === 'PRELEARN_APP_BACK_HANDLED') { if (message.type === 'PRELEARN_APP_BACK_HANDLED') {
this.handleH5BackHandled(message) this.handleH5BackHandled(message)
} }
if (message.type === 'COMPLETE_ACTIVITY') {
this.handleCompleteActivity(message.payload || message.data)
}
}, },
captureChildWebview() { captureChildWebview() {
// #ifdef APP-PLUS // #ifdef APP-PLUS
...@@ -286,8 +368,11 @@ export default { ...@@ -286,8 +368,11 @@ export default {
console.log('[prelearn bridge demo] child webview ready') console.log('[prelearn bridge demo] child webview ready')
this.applyWebviewInset() this.applyWebviewInset()
this.createNavBackHotArea() this.createNavBackHotArea()
this.injectH5CompleteActivity()
this.pushPrelearnSessionToH5() this.pushPrelearnSessionToH5()
setTimeout(() => this.injectH5CompleteActivity(), 600)
setTimeout(() => this.pushPrelearnSessionToH5(), 600) setTimeout(() => this.pushPrelearnSessionToH5(), 600)
setTimeout(() => this.injectH5CompleteActivity(), 1500)
setTimeout(() => this.pushPrelearnSessionToH5(), 1500) setTimeout(() => this.pushPrelearnSessionToH5(), 1500)
return return
} }
...@@ -320,6 +405,10 @@ export default { ...@@ -320,6 +405,10 @@ export default {
if (message.type === 'PRELEARN_APP_BACK_HANDLED') { if (message.type === 'PRELEARN_APP_BACK_HANDLED') {
this.handleH5BackHandled(message) this.handleH5BackHandled(message)
} }
if (message.type === 'COMPLETE_ACTIVITY') {
this.handleCompleteActivity(message.payload || message.data)
}
}) })
}, },
normalizeMessages(event) { normalizeMessages(event) {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!