Commit 1c2f6af7 by 前端

Merge branch 'SAAS+V5.5.1' into 'master'

上线合并

See merge request !55
2 parents 0ffe837c dcd5b583
......@@ -238,5 +238,15 @@ module.exports = {
.map(key => `${encodeURIComponent(key)}=${encodeURIComponent(data[key])}`)
.join('&')
return gscPost(`/evalOrder/apiRegion/search${queryString ? '?' + queryString : ''}`, { ...data }, { returnAll: true })
},
/** 撤销合同 */
revokeSaleContract(data) {
return gscPost(
`/evalOrder/revokeSaleContract`,
{
...data
},
{ returnAll: true }
)
}
}
......@@ -3,22 +3,19 @@ module.exports = {
gscPost: (url, data, _config = {}) => {
return new Promise((resolve, reject) => {
uni.getNetworkType({
success (res) {
success(res) {
if (['none'].includes(res.networkType)) {
uni.hideLoading();
uni.hideLoading()
uni.showToast({
title: '网络异常',
icon: "none",
});
return;
icon: 'none'
})
return
}
if (!uni.$signHttp) uni.$signHttp = new Request(uni.signHttpConfig)
data.source = 1
resolve(uni.$signHttp.post(url, data, _config))
}
})
})
}
}
......@@ -48,9 +48,9 @@
.icon-change-account { width: calc(100vmin * (1173 / 768) * 0.013640238704177323); height: calc(100vmin * (1173 / 768) * 0.013640238704177323);
background-position: calc(100vmin * (1173 / 768) * -0.34654731457800514) calc(100vmin * (1173 / 768) * -0.3052003410059676);}
.icon-clone { width: calc(100vmin * (1173 / 768) * 0.010230179028132993); height: calc(100vmin * (1173 / 768) * 0.010230179028132993);
background-position: calc(100vmin * (1173 / 768) * -0.4462915601023018) calc(100vmin * (1173 / 768) * -0.6986359761295823);}
background-position: calc(100vmin * (1173 / 768) * -0.4663256606990622) calc(100vmin * (1173 / 768) * -0.6986359761295823);}
.icon-collapse-all { width: calc(100vmin * (1173 / 768) * 0.010230179028132993); height: calc(100vmin * (1173 / 768) * 0.010230179028132993);
background-position: calc(100vmin * (1173 / 768) * -0.4629156010230179) calc(100vmin * (1173 / 768) * -0.6986359761295823);}
background-position: calc(100vmin * (1173 / 768) * -0.48294970161977835) calc(100vmin * (1173 / 768) * -0.6986359761295823);}
.icon-coupon-arrow { width: calc(100vmin * (1173 / 768) * 0.013640238704177323); height: calc(100vmin * (1173 / 768) * 0.013640238704177323);
background-position: calc(100vmin * (1173 / 768) * -0.34654731457800514) calc(100vmin * (1173 / 768) * -0.32608695652173914);}
.icon-coupon { width: calc(100vmin * (1173 / 768) * 0.04092071611253197); height: calc(100vmin * (1173 / 768) * 0.015345268542199489);
......@@ -108,7 +108,7 @@
.icon-equity-order { width: calc(100vmin * (1173 / 768) * 0.04092071611253197); height: calc(100vmin * (1173 / 768) * 0.04092071611253197);
background-position: calc(100vmin * (1173 / 768) * 0) calc(100vmin * (1173 / 768) * -0.5907928388746803);}
.icon-equityClose { width: calc(100vmin * (1173 / 768) * 0.010230179028132993); height: calc(100vmin * (1173 / 768) * 0.010230179028132993);
background-position: calc(100vmin * (1173 / 768) * -0.479539641943734) calc(100vmin * (1173 / 768) * -0.6986359761295823);}
background-position: calc(100vmin * (1173 / 768) * -0.49957374254049447) calc(100vmin * (1173 / 768) * -0.6986359761295823);}
.icon-equityTip { width: calc(100vmin * (1173 / 768) * 0.013640238704177323); height: calc(100vmin * (1173 / 768) * 0.013640238704177323);
background-position: calc(100vmin * (1173 / 768) * -0.4752770673486786) calc(100vmin * (1173 / 768) * -0.4113384484228474);}
.icon-evaluation-management { width: calc(100vmin * (1173 / 768) * 0.04092071611253197); height: calc(100vmin * (1173 / 768) * 0.04092071611253197);
......@@ -134,7 +134,7 @@
.icon-feedback { width: calc(100vmin * (1173 / 768) * 0.027280477408354646); height: calc(100vmin * (1173 / 768) * 0.027280477408354646);
background-position: calc(100vmin * (1173 / 768) * -0.3537936913895993) calc(100vmin * (1173 / 768) * -0.6381074168797954);}
.icon-feedbackIcon { width: calc(100vmin * (1173 / 768) * 0.011082693947144074); height: calc(100vmin * (1173 / 768) * 0.011082693947144074);
background-position: calc(100vmin * (1173 / 768) * -0.41048593350383633) calc(100vmin * (1173 / 768) * -0.6986359761295823);}
background-position: calc(100vmin * (1173 / 768) * -0.43052003410059675) calc(100vmin * (1173 / 768) * -0.6986359761295823);}
.icon-ffdyj-icon { width: calc(100vmin * (1173 / 768) * 0.017050298380221655); height: calc(100vmin * (1173 / 768) * 0.017050298380221655);
background-position: calc(100vmin * (1173 / 768) * -0.7020460358056266) calc(100vmin * (1173 / 768) * -0.6300085251491901);}
.icon-filter { width: calc(100vmin * (1173 / 768) * 0.013640238704177323); height: calc(100vmin * (1173 / 768) * 0.013640238704177323);
......@@ -209,12 +209,14 @@
background-position: calc(100vmin * (1173 / 768) * -0.15302642796248933) calc(100vmin * (1173 / 768) * -0.13256606990622335);}
.icon-level { width: calc(100vmin * (1173 / 768) * 0.027280477408354646); height: calc(100vmin * (1173 / 768) * 0.027280477408354646);
background-position: calc(100vmin * (1173 / 768) * -0.42114236999147486) calc(100vmin * (1173 / 768) * -0.6381074168797954);}
.icon-location { width: calc(100vmin * (1173 / 768) * 0.013640238704177323); height: calc(100vmin * (1173 / 768) * 0.013640238704177323);
background-position: calc(100vmin * (1173 / 768) * -0.5754475703324808) calc(100vmin * (1173 / 768) * -0.6751918158567775);}
.icon-locker-icon { width: calc(100vmin * (1173 / 768) * 0.1466325660699062); height: calc(100vmin * (1173 / 768) * 0.20119352088661552);
background-position: calc(100vmin * (1173 / 768) * 0) calc(100vmin * (1173 / 768) * 0);}
.icon-logo { width: calc(100vmin * (1173 / 768) * 0.06820119352088662); height: calc(100vmin * (1173 / 768) * 0.06820119352088662);
background-position: calc(100vmin * (1173 / 768) * -0.5647911338448423) calc(100vmin * (1173 / 768) * -0.10017050298380221);}
.icon-lssl-icon { width: calc(100vmin * (1173 / 768) * 0.011935208866155157); height: calc(100vmin * (1173 / 768) * 0.011935208866155157);
background-position: calc(100vmin * (1173 / 768) * -0.30051150895140666) calc(100vmin * (1173 / 768) * -0.6986359761295823);}
background-position: calc(100vmin * (1173 / 768) * -0.3205456095481671) calc(100vmin * (1173 / 768) * -0.6986359761295823);}
.icon-mask-del { width: calc(100vmin * (1173 / 768) * 0.03410059676044331); height: calc(100vmin * (1173 / 768) * 0.03410059676044331);
background-position: calc(100vmin * (1173 / 768) * -0.6547314578005116) calc(100vmin * (1173 / 768) * -0.3614663256606991);}
.icon-mask-edit { width: calc(100vmin * (1173 / 768) * 0.03410059676044331); height: calc(100vmin * (1173 / 768) * 0.03410059676044331);
......@@ -232,13 +234,13 @@
.icon-no-picture { width: calc(100vmin * (1173 / 768) * 0.021312872975277068); height: calc(100vmin * (1173 / 768) * 0.021312872975277068);
background-position: calc(100vmin * (1173 / 768) * -0.7020460358056266) calc(100vmin * (1173 / 768) * -0.14791133844842286);}
.icon-normal { width: calc(100vmin * (1173 / 768) * 0.011935208866155157); height: calc(100vmin * (1173 / 768) * 0.011935208866155157);
background-position: calc(100vmin * (1173 / 768) * -0.3188405797101449) calc(100vmin * (1173 / 768) * -0.6986359761295823);}
background-position: calc(100vmin * (1173 / 768) * -0.3388746803069054) calc(100vmin * (1173 / 768) * -0.6986359761295823);}
.icon-notice-script { width: calc(100vmin * (1173 / 768) * 0.04092071611253197); height: calc(100vmin * (1173 / 768) * 0.04092071611253197);
background-position: calc(100vmin * (1173 / 768) * -0.3312020460358056) calc(100vmin * (1173 / 768) * -0.5907928388746803);}
.icon-notice-study { width: calc(100vmin * (1173 / 768) * 0.04092071611253197); height: calc(100vmin * (1173 / 768) * 0.04092071611253197);
background-position: calc(100vmin * (1173 / 768) * -0.37851662404092073) calc(100vmin * (1173 / 768) * -0.5907928388746803);}
.icon-notice-success { width: calc(100vmin * (1173 / 768) * 0.013640238704177323); height: calc(100vmin * (1173 / 768) * 0.013640238704177323);
background-position: calc(100vmin * (1173 / 768) * -0.5754475703324808) calc(100vmin * (1173 / 768) * -0.6751918158567775);}
background-position: calc(100vmin * (1173 / 768) * -0.5954816709292413) calc(100vmin * (1173 / 768) * -0.6751918158567775);}
.icon-notice-system { width: calc(100vmin * (1173 / 768) * 0.04092071611253197); height: calc(100vmin * (1173 / 768) * 0.04092071611253197);
background-position: calc(100vmin * (1173 / 768) * -0.4258312020460358) calc(100vmin * (1173 / 768) * -0.5907928388746803);}
.icon-notice-violate { width: calc(100vmin * (1173 / 768) * 0.04092071611253197); height: calc(100vmin * (1173 / 768) * 0.04092071611253197);
......@@ -276,9 +278,9 @@
.icon-points { width: calc(100vmin * (1173 / 768) * 0.027280477408354646); height: calc(100vmin * (1173 / 768) * 0.027280477408354646);
background-position: calc(100vmin * (1173 / 768) * -0.4884910485933504) calc(100vmin * (1173 / 768) * -0.6381074168797954);}
.icon-preview { width: calc(100vmin * (1173 / 768) * 0.013640238704177323); height: calc(100vmin * (1173 / 768) * 0.013640238704177323);
background-position: calc(100vmin * (1173 / 768) * -0.5954816709292413) calc(100vmin * (1173 / 768) * -0.6751918158567775);}
.icon-previewDownLoad { width: calc(100vmin * (1173 / 768) * 0.013640238704177323); height: calc(100vmin * (1173 / 768) * 0.013640238704177323);
background-position: calc(100vmin * (1173 / 768) * -0.6155157715260017) calc(100vmin * (1173 / 768) * -0.6751918158567775);}
.icon-previewDownLoad { width: calc(100vmin * (1173 / 768) * 0.013640238704177323); height: calc(100vmin * (1173 / 768) * 0.013640238704177323);
background-position: calc(100vmin * (1173 / 768) * -0.6355498721227621) calc(100vmin * (1173 / 768) * -0.6751918158567775);}
.icon-promotion { width: calc(100vmin * (1173 / 768) * 0.020460358056265986); height: calc(100vmin * (1173 / 768) * 0.020460358056265986);
background-position: calc(100vmin * (1173 / 768) * -0.7020460358056266) calc(100vmin * (1173 / 768) * -0.252770673486786);}
.icon-prompt { width: calc(100vmin * (1173 / 768) * 0.10230179028132992); height: calc(100vmin * (1173 / 768) * 0.10230179028132992);
......@@ -302,9 +304,9 @@
.icon-rbkk-icon { width: calc(100vmin * (1173 / 768) * 0.017050298380221655); height: calc(100vmin * (1173 / 768) * 0.017050298380221655);
background-position: calc(100vmin * (1173 / 768) * -0.1875532821824382) calc(100vmin * (1173 / 768) * -0.6751918158567775);}
.icon-rear-gear { width: calc(100vmin * (1173 / 768) * 0.013640238704177323); height: calc(100vmin * (1173 / 768) * 0.013640238704177323);
background-position: calc(100vmin * (1173 / 768) * -0.6355498721227621) calc(100vmin * (1173 / 768) * -0.6751918158567775);}
.icon-rear-window { width: calc(100vmin * (1173 / 768) * 0.013640238704177323); height: calc(100vmin * (1173 / 768) * 0.013640238704177323);
background-position: calc(100vmin * (1173 / 768) * -0.6555839727195226) calc(100vmin * (1173 / 768) * -0.6751918158567775);}
.icon-rear-window { width: calc(100vmin * (1173 / 768) * 0.013640238704177323); height: calc(100vmin * (1173 / 768) * 0.013640238704177323);
background-position: calc(100vmin * (1173 / 768) * -0.675618073316283) calc(100vmin * (1173 / 768) * -0.6751918158567775);}
.icon-reception-1 { width: calc(100vmin * (1173 / 768) * 0.020460358056265986); height: calc(100vmin * (1173 / 768) * 0.020460358056265986);
background-position: calc(100vmin * (1173 / 768) * -0.7020460358056266) calc(100vmin * (1173 / 768) * -0.30647911338448425);}
.icon-reception-2 { width: calc(100vmin * (1173 / 768) * 0.020460358056265986); height: calc(100vmin * (1173 / 768) * 0.020460358056265986);
......@@ -324,17 +326,17 @@
.icon-revokeOrder { width: calc(100vmin * (1173 / 768) * 0.027280477408354646); height: calc(100vmin * (1173 / 768) * 0.027280477408354646);
background-position: calc(100vmin * (1173 / 768) * -0.5558397271952259) calc(100vmin * (1173 / 768) * -0.6381074168797954);}
.icon-right-arrow { width: calc(100vmin * (1173 / 768) * 0.013640238704177323); height: calc(100vmin * (1173 / 768) * 0.013640238704177323);
background-position: calc(100vmin * (1173 / 768) * -0.675618073316283) calc(100vmin * (1173 / 768) * -0.6751918158567775);}
background-position: calc(100vmin * (1173 / 768) * -0.6956521739130435) calc(100vmin * (1173 / 768) * -0.6751918158567775);}
.icon-role-1 { width: calc(100vmin * (1173 / 768) * 0.028985507246376812); height: calc(100vmin * (1173 / 768) * 0.028985507246376812);
background-position: calc(100vmin * (1173 / 768) * -0.1483375959079284) calc(100vmin * (1173 / 768) * -0.6381074168797954);}
.icon-role-2 { width: calc(100vmin * (1173 / 768) * 0.028985507246376812); height: calc(100vmin * (1173 / 768) * 0.028985507246376812);
background-position: calc(100vmin * (1173 / 768) * -0.1837169650468883) calc(100vmin * (1173 / 768) * -0.6381074168797954);}
.icon-rule { width: calc(100vmin * (1173 / 768) * 0.011935208866155157); height: calc(100vmin * (1173 / 768) * 0.011935208866155157);
background-position: calc(100vmin * (1173 / 768) * -0.3371696504688832) calc(100vmin * (1173 / 768) * -0.6986359761295823);}
background-position: calc(100vmin * (1173 / 768) * -0.35720375106564367) calc(100vmin * (1173 / 768) * -0.6986359761295823);}
.icon-scan { width: calc(100vmin * (1173 / 768) * 0.013640238704177323); height: calc(100vmin * (1173 / 768) * 0.013640238704177323);
background-position: calc(100vmin * (1173 / 768) * -0.6956521739130435) calc(100vmin * (1173 / 768) * -0.6751918158567775);}
.icon-scanIcon { width: calc(100vmin * (1173 / 768) * 0.013640238704177323); height: calc(100vmin * (1173 / 768) * 0.013640238704177323);
background-position: calc(100vmin * (1173 / 768) * 0) calc(100vmin * (1173 / 768) * -0.6986359761295823);}
.icon-scanIcon { width: calc(100vmin * (1173 / 768) * 0.013640238704177323); height: calc(100vmin * (1173 / 768) * 0.013640238704177323);
background-position: calc(100vmin * (1173 / 768) * -0.020034100596760442) calc(100vmin * (1173 / 768) * -0.6986359761295823);}
.icon-scanIconX { width: calc(100vmin * (1173 / 768) * 0.02557544757033248); height: calc(100vmin * (1173 / 768) * 0.017050298380221655);
background-position: calc(100vmin * (1173 / 768) * -0.7020460358056266) calc(100vmin * (1173 / 768) * -0.17561807331628304);}
.icon-scene-0 { width: calc(100vmin * (1173 / 768) * 0.04092071611253197); height: calc(100vmin * (1173 / 768) * 0.04092071611253197);
......@@ -346,7 +348,7 @@
.icon-scene-active { width: calc(100vmin * (1173 / 768) * 0.0443307757885763); height: calc(100vmin * (1173 / 768) * 0.0443307757885763);
background-position: calc(100vmin * (1173 / 768) * -0.10144927536231885) calc(100vmin * (1173 / 768) * -0.5400682011935208);}
.icon-scene-change { width: calc(100vmin * (1173 / 768) * 0.013640238704177323); height: calc(100vmin * (1173 / 768) * 0.013640238704177323);
background-position: calc(100vmin * (1173 / 768) * -0.020034100596760442) calc(100vmin * (1173 / 768) * -0.6986359761295823);}
background-position: calc(100vmin * (1173 / 768) * -0.040068201193520885) calc(100vmin * (1173 / 768) * -0.6986359761295823);}
.icon-scene { width: calc(100vmin * (1173 / 768) * 0.0443307757885763); height: calc(100vmin * (1173 / 768) * 0.0443307757885763);
background-position: calc(100vmin * (1173 / 768) * -0.15217391304347827) calc(100vmin * (1173 / 768) * -0.5400682011935208);}
.icon-search { width: calc(100vmin * (1173 / 768) * 0.017050298380221655); height: calc(100vmin * (1173 / 768) * 0.017050298380221655);
......@@ -358,7 +360,7 @@
.icon-second-right { width: calc(100vmin * (1173 / 768) * 0.05456095481670929); height: calc(100vmin * (1173 / 768) * 0.04092071611253197);
background-position: calc(100vmin * (1173 / 768) * -0.48934356351236147) calc(100vmin * (1173 / 768) * -0.30008525149190113);}
.icon-seeIcon { width: calc(100vmin * (1173 / 768) * 0.013640238704177323); height: calc(100vmin * (1173 / 768) * 0.013640238704177323);
background-position: calc(100vmin * (1173 / 768) * -0.040068201193520885) calc(100vmin * (1173 / 768) * -0.6986359761295823);}
background-position: calc(100vmin * (1173 / 768) * -0.06010230179028133) calc(100vmin * (1173 / 768) * -0.6986359761295823);}
.icon-setting { width: calc(100vmin * (1173 / 768) * 0.027280477408354646); height: calc(100vmin * (1173 / 768) * 0.027280477408354646);
background-position: calc(100vmin * (1173 / 768) * -0.5895140664961637) calc(100vmin * (1173 / 768) * -0.6381074168797954);}
.icon-short-first-nav { width: calc(100vmin * (1173 / 768) * 0.1773231031543052); height: calc(100vmin * (1173 / 768) * 0.0443307757885763);
......@@ -368,21 +370,21 @@
.icon-short-task-title { width: calc(100vmin * (1173 / 768) * 0.020460358056265986); height: calc(100vmin * (1173 / 768) * 0.020460358056265986);
background-position: calc(100vmin * (1173 / 768) * -0.7020460358056266) calc(100vmin * (1173 / 768) * -0.36018755328218244);}
.icon-sign_del { width: calc(100vmin * (1173 / 768) * 0.013640238704177323); height: calc(100vmin * (1173 / 768) * 0.013640238704177323);
background-position: calc(100vmin * (1173 / 768) * -0.06010230179028133) calc(100vmin * (1173 / 768) * -0.6986359761295823);}
background-position: calc(100vmin * (1173 / 768) * -0.08013640238704177) calc(100vmin * (1173 / 768) * -0.6986359761295823);}
.icon-start-text { width: calc(100vmin * (1173 / 768) * 0.0733162830349531); height: calc(100vmin * (1173 / 768) * 0.017050298380221655);
background-position: calc(100vmin * (1173 / 768) * -0.4761295822676897) calc(100vmin * (1173 / 768) * -0.2659846547314578);}
.icon-stick-top-blue { width: calc(100vmin * (1173 / 768) * 0.013640238704177323); height: calc(100vmin * (1173 / 768) * 0.013640238704177323);
background-position: calc(100vmin * (1173 / 768) * -0.08013640238704177) calc(100vmin * (1173 / 768) * -0.6986359761295823);}
.icon-stick-top { width: calc(100vmin * (1173 / 768) * 0.013640238704177323); height: calc(100vmin * (1173 / 768) * 0.013640238704177323);
background-position: calc(100vmin * (1173 / 768) * -0.10017050298380221) calc(100vmin * (1173 / 768) * -0.6986359761295823);}
.icon-store-icon { width: calc(100vmin * (1173 / 768) * 0.013640238704177323); height: calc(100vmin * (1173 / 768) * 0.013640238704177323);
.icon-stick-top { width: calc(100vmin * (1173 / 768) * 0.013640238704177323); height: calc(100vmin * (1173 / 768) * 0.013640238704177323);
background-position: calc(100vmin * (1173 / 768) * -0.12020460358056266) calc(100vmin * (1173 / 768) * -0.6986359761295823);}
.icon-store-icon { width: calc(100vmin * (1173 / 768) * 0.013640238704177323); height: calc(100vmin * (1173 / 768) * 0.013640238704177323);
background-position: calc(100vmin * (1173 / 768) * -0.1402387041773231) calc(100vmin * (1173 / 768) * -0.6986359761295823);}
.icon-store { width: calc(100vmin * (1173 / 768) * 0.04092071611253197); height: calc(100vmin * (1173 / 768) * 0.04092071611253197);
background-position: calc(100vmin * (1173 / 768) * -0.6547314578005116) calc(100vmin * (1173 / 768) * -0.18925831202046037);}
.icon-study-active { width: calc(100vmin * (1173 / 768) * 0.0443307757885763); height: calc(100vmin * (1173 / 768) * 0.0443307757885763);
background-position: calc(100vmin * (1173 / 768) * -0.2028985507246377) calc(100vmin * (1173 / 768) * -0.5400682011935208);}
.icon-study-tips { width: calc(100vmin * (1173 / 768) * 0.011935208866155157); height: calc(100vmin * (1173 / 768) * 0.011935208866155157);
background-position: calc(100vmin * (1173 / 768) * -0.3554987212276215) calc(100vmin * (1173 / 768) * -0.6986359761295823);}
background-position: calc(100vmin * (1173 / 768) * -0.3755328218243819) calc(100vmin * (1173 / 768) * -0.6986359761295823);}
.icon-study { width: calc(100vmin * (1173 / 768) * 0.0443307757885763); height: calc(100vmin * (1173 / 768) * 0.0443307757885763);
background-position: calc(100vmin * (1173 / 768) * -0.2536231884057971) calc(100vmin * (1173 / 768) * -0.5400682011935208);}
.icon-submit { width: calc(100vmin * (1173 / 768) * 0.017050298380221655); height: calc(100vmin * (1173 / 768) * 0.017050298380221655);
......@@ -392,21 +394,21 @@
.icon-suggestions-arrow { width: calc(100vmin * (1173 / 768) * 0.015345268542199489); height: calc(100vmin * (1173 / 768) * 0.015345268542199489);
background-position: calc(100vmin * (1173 / 768) * -0.47868712702472294) calc(100vmin * (1173 / 768) * -0.45865302642796246);}
.icon-suggestions-icon { width: calc(100vmin * (1173 / 768) * 0.013640238704177323); height: calc(100vmin * (1173 / 768) * 0.013640238704177323);
background-position: calc(100vmin * (1173 / 768) * -0.1402387041773231) calc(100vmin * (1173 / 768) * -0.6986359761295823);}
.icon-sun-roof { width: calc(100vmin * (1173 / 768) * 0.013640238704177323); height: calc(100vmin * (1173 / 768) * 0.013640238704177323);
background-position: calc(100vmin * (1173 / 768) * -0.16027280477408354) calc(100vmin * (1173 / 768) * -0.6986359761295823);}
.icon-sun-roof { width: calc(100vmin * (1173 / 768) * 0.013640238704177323); height: calc(100vmin * (1173 / 768) * 0.013640238704177323);
background-position: calc(100vmin * (1173 / 768) * -0.18030690537084398) calc(100vmin * (1173 / 768) * -0.6986359761295823);}
.icon-tag-checked { width: calc(100vmin * (1173 / 768) * 0.02557544757033248); height: calc(100vmin * (1173 / 768) * 0.013640238704177323);
background-position: calc(100vmin * (1173 / 768) * -0.7020460358056266) calc(100vmin * (1173 / 768) * -0.44075021312872975);}
.icon-task-pass { width: calc(100vmin * (1173 / 768) * 0.011935208866155157); height: calc(100vmin * (1173 / 768) * 0.011935208866155157);
background-position: calc(100vmin * (1173 / 768) * -0.37382779198635974) calc(100vmin * (1173 / 768) * -0.6986359761295823);}
background-position: calc(100vmin * (1173 / 768) * -0.3938618925831202) calc(100vmin * (1173 / 768) * -0.6986359761295823);}
.icon-tdcj-icon { width: calc(100vmin * (1173 / 768) * 0.017050298380221655); height: calc(100vmin * (1173 / 768) * 0.017050298380221655);
background-position: calc(100vmin * (1173 / 768) * -0.25788576300085253) calc(100vmin * (1173 / 768) * -0.6751918158567775);}
.icon-time-icon { width: calc(100vmin * (1173 / 768) * 0.013640238704177323); height: calc(100vmin * (1173 / 768) * 0.013640238704177323);
background-position: calc(100vmin * (1173 / 768) * -0.18030690537084398) calc(100vmin * (1173 / 768) * -0.6986359761295823);}
background-position: calc(100vmin * (1173 / 768) * -0.20034100596760443) calc(100vmin * (1173 / 768) * -0.6986359761295823);}
.icon-time { width: calc(100vmin * (1173 / 768) * 0.017050298380221655); height: calc(100vmin * (1173 / 768) * 0.017050298380221655);
background-position: calc(100vmin * (1173 / 768) * -0.2813299232736573) calc(100vmin * (1173 / 768) * -0.6751918158567775);}
.icon-tips-b { width: calc(100vmin * (1173 / 768) * 0.013640238704177323); height: calc(100vmin * (1173 / 768) * 0.013640238704177323);
background-position: calc(100vmin * (1173 / 768) * -0.20034100596760443) calc(100vmin * (1173 / 768) * -0.6986359761295823);}
background-position: calc(100vmin * (1173 / 768) * -0.22037510656436488) calc(100vmin * (1173 / 768) * -0.6986359761295823);}
.icon-tips-g { width: calc(100vmin * (1173 / 768) * 0.020460358056265986); height: calc(100vmin * (1173 / 768) * 0.020460358056265986);
background-position: calc(100vmin * (1173 / 768) * -0.7020460358056266) calc(100vmin * (1173 / 768) * -0.38704177323103156);}
.icon-tips { width: calc(100vmin * (1173 / 768) * 0.03410059676044331); height: calc(100vmin * (1173 / 768) * 0.03410059676044331);
......@@ -420,11 +422,11 @@
.icon-topTipsRightIcon { width: calc(100vmin * (1173 / 768) * 0.06990622335890878); height: calc(100vmin * (1173 / 768) * 0.05115089514066496);
background-position: calc(100vmin * (1173 / 768) * -0.2855924978687127) calc(100vmin * (1173 / 768) * -0.20758738277919864);}
.icon-total { width: calc(100vmin * (1173 / 768) * 0.013640238704177323); height: calc(100vmin * (1173 / 768) * 0.013640238704177323);
background-position: calc(100vmin * (1173 / 768) * -0.22037510656436488) calc(100vmin * (1173 / 768) * -0.6986359761295823);}
background-position: calc(100vmin * (1173 / 768) * -0.24040920716112532) calc(100vmin * (1173 / 768) * -0.6986359761295823);}
.icon-two-arrow { width: calc(100vmin * (1173 / 768) * 0.011935208866155157); height: calc(100vmin * (1173 / 768) * 0.010230179028132993);
background-position: calc(100vmin * (1173 / 768) * -0.4279624893435635) calc(100vmin * (1173 / 768) * -0.6986359761295823);}
background-position: calc(100vmin * (1173 / 768) * -0.44799658994032393) calc(100vmin * (1173 / 768) * -0.6986359761295823);}
.icon-up-arrow { width: calc(100vmin * (1173 / 768) * 0.011935208866155157); height: calc(100vmin * (1173 / 768) * 0.011935208866155157);
background-position: calc(100vmin * (1173 / 768) * -0.39215686274509803) calc(100vmin * (1173 / 768) * -0.6986359761295823);}
background-position: calc(100vmin * (1173 / 768) * -0.4121909633418585) calc(100vmin * (1173 / 768) * -0.6986359761295823);}
.icon-upload-play { width: calc(100vmin * (1173 / 768) * 0.017050298380221655); height: calc(100vmin * (1173 / 768) * 0.017050298380221655);
background-position: calc(100vmin * (1173 / 768) * -0.30477408354646207) calc(100vmin * (1173 / 768) * -0.6751918158567775);}
.icon-uploadAdd { width: calc(100vmin * (1173 / 768) * 0.020460358056265986); height: calc(100vmin * (1173 / 768) * 0.020460358056265986);
......@@ -432,12 +434,12 @@
.icon-visible { width: calc(100vmin * (1173 / 768) * 0.017050298380221655); height: calc(100vmin * (1173 / 768) * 0.017050298380221655);
background-position: calc(100vmin * (1173 / 768) * -0.32821824381926684) calc(100vmin * (1173 / 768) * -0.6751918158567775);}
.icon-warning-icon { width: calc(100vmin * (1173 / 768) * 0.013640238704177323); height: calc(100vmin * (1173 / 768) * 0.013640238704177323);
background-position: calc(100vmin * (1173 / 768) * -0.24040920716112532) calc(100vmin * (1173 / 768) * -0.6986359761295823);}
.icon-work-icon { width: calc(100vmin * (1173 / 768) * 0.013640238704177323); height: calc(100vmin * (1173 / 768) * 0.013640238704177323);
background-position: calc(100vmin * (1173 / 768) * -0.26044330775788577) calc(100vmin * (1173 / 768) * -0.6986359761295823);}
.icon-work-icon { width: calc(100vmin * (1173 / 768) * 0.013640238704177323); height: calc(100vmin * (1173 / 768) * 0.013640238704177323);
background-position: calc(100vmin * (1173 / 768) * -0.2804774083546462) calc(100vmin * (1173 / 768) * -0.6986359761295823);}
.icon-ybtc_icon { width: calc(100vmin * (1173 / 768) * 0.017050298380221655); height: calc(100vmin * (1173 / 768) * 0.017050298380221655);
background-position: calc(100vmin * (1173 / 768) * -0.3516624040920716) calc(100vmin * (1173 / 768) * -0.6751918158567775);}
.icon-yw-icon { width: calc(100vmin * (1173 / 768) * 0.015345268542199489); height: calc(100vmin * (1173 / 768) * 0.015345268542199489);
background-position: calc(100vmin * (1173 / 768) * -0.5004262574595055) calc(100vmin * (1173 / 768) * -0.45865302642796246);}
.icon-zj-icon { width: calc(100vmin * (1173 / 768) * 0.013640238704177323); height: calc(100vmin * (1173 / 768) * 0.013640238704177323);
background-position: calc(100vmin * (1173 / 768) * -0.2804774083546462) calc(100vmin * (1173 / 768) * -0.6986359761295823);}
\ No newline at end of file
background-position: calc(100vmin * (1173 / 768) * -0.30051150895140666) calc(100vmin * (1173 / 768) * -0.6986359761295823);}
\ No newline at end of file

2.94 MB | W: | H:

2.94 MB | W: | H:

assets/images/sprite.png
assets/images/sprite.png
assets/images/sprite.png
assets/images/sprite.png
  • 2-up
  • Swipe
  • Onion skin
const target = ['ip', 'dev', 'uat', 'prod', 'beta']
const index = 3
const index = 2
/**
*
0本地
......
......@@ -2,8 +2,8 @@
"name" : "展业助手",
"appid" : "__UNI__D3BD3DF",
"description" : "",
"versionName" : "2.19.0",
"versionCode" : 2190,
"versionName" : "2.20.0",
"versionCode" : 2200,
"transformPx" : false,
"sassImplementationName" : "node-sass",
/* 5+App特有相关 */
......@@ -68,8 +68,10 @@
"ad" : {},
"speech" : {},
"geolocation" : {
"system" : {
"__platform__" : [ "ios", "android" ]
"baidu" : {
"__platform__" : [ "android" ],
"appkey_ios" : "",
"appkey_android" : "rfN7u5gCi0KyCGIWWBYGXlmKrVQsKH8z"
}
}
},
......
......@@ -32,25 +32,13 @@
>
<view :class="['label',{required:i.required}]">{{ i.label }}</view>
<view :class="['value', { error: showError(i.key) && i.required },{disabled: pageParams.received}]">
<template v-if="i.type == 'input'">
<input
:type="i.inputType"
:maxlength="i.maxlength"
v-model="customerInfo[i.key]"
class="input"
:placeholder="i.placeholder"
:disabled="pageParams.received"
@input="inputCustomer"
placeholder-style="color:#c9c9c9;"
/>
</template>
<template v-else-if="i.type == 'select'">
<template v-if="i.addHtml">
<view
:class="['select', `${customerInfo[i.key]? '' : 'placeholder'}`]"
:class="['select', `${pageParams.carInfo[i.key]? '' : 'placeholder'}`]"
@click="showPopup(i.popKey)"
:key="selectKey"
>
{{ customerInfo[i.key] || i.placeholder }}
{{ pageParams.carInfo[i.key] || i.placeholder }}
<uni-icons
class="arrow"
type="down"
......@@ -59,7 +47,35 @@
</view>
</template>
<template v-else>
<view class="text">{{ customerInfo[i.key] }}</view>
<template v-if="i.type == 'input'">
<input
:type="i.inputType"
:maxlength="i.maxlength"
v-model="customerInfo[i.key]"
class="input"
:placeholder="i.placeholder"
:disabled="pageParams.received"
@input="inputCustomer"
placeholder-style="color:#c9c9c9;"
/>
</template>
<template v-else-if="i.type == 'select'">
<view
:class="['select', `${customerInfo[i.key]? '' : 'placeholder'}`]"
@click="showPopup(i.popKey)"
:key="selectKey"
>
{{ customerInfo[i.key] || i.placeholder }}
<uni-icons
class="arrow"
type="down"
:size="16"
></uni-icons>
</view>
</template>
<template v-else>
<view class="text">{{ customerInfo[i.key] }}</view>
</template>
</template>
</view>
</view>
......@@ -77,7 +93,14 @@
:key="idx"
>
<view class="label">{{ j.label }}</view>
<view class="value-text">{{ customerInfo[j.key] || '--'}}</view>
<view class="value-text">
<template v-if="j.addHtml">
{{ pageParams.carInfo[j.key] || '--'}}
</template>
<template v-else>
{{ customerInfo[j.key] || '--'}}
</template>
</view>
</view>
</view>
</view>
......@@ -147,6 +170,11 @@
>生成专属二维码</view>
</view>
</MessageBox>
<car-brands
:linkage="false"
ref="carBrandListVisible"
@select="handleSelect($event, 'carBrandListVisible')"
/>
<employee
ref="employeeBoxVisible"
@select="handleSelect($event,'employeeBoxVisible')"
......@@ -179,6 +207,8 @@
<script type="text/ecmascript-6">
import Employee from '@/components/Employee.vue'
import qrcode from '@/utils/qrcode.js'
import CarBrands from '@/components/CarBrands.vue'
const phoneRex = /^[1]([3-9])[0-9]{9}$/;
import dayjs from 'dayjs'
const formObject_boutique = [{
......@@ -201,10 +231,12 @@ const formObject_boutique = [{
},
{
label: "品牌车型",
key: "carModel",
type: "text",
type: "select",
popKey: "carBrandListVisible",
placeholder: '请选择车型'
placeholder: '请选择车型',
addHtml: 'carbrand',
key: 'name',
required: true
},
{
label: "交付专员",
......@@ -233,12 +265,22 @@ export default {
title: String,
tips: String
},
components: { Employee },
components: { Employee, CarBrands },
watch: {
watchCustomerInfo: {
immediate: true,
handler (newval) {
this.customerInfo = Object.assign(this.customerInfo, newval)
if (newval.carModel) {
this.pageParams.carInfo = {
carChildsBrandId: newval.carChildsBrandId,
carChildsBrandName: newval.carChildsBrandName,
carBrandId: newval.carBrandId,
carBrand: newval.carBrand,
id: newval.carSeriesId,
name: newval.carModel
}
}
try {
// 监听完成接待修改数据,同步修改生成优惠券按钮状态
const { customerName, phoneNumber, staffName } = this.customerInfo
......@@ -268,6 +310,21 @@ export default {
},
show () {
this.closeAllPopup()
},
carInfo: {
handler (newval) {
console.log(newval, '===')
this.pageParams.carInfo = {
carChildsBrandId: newval.carChildsBrandId,
carChildsBrandName: newval.carChildsBrandName,
carBrandId: newval.carBrandId,
carBrand: newval.carBrand,
id: newval.id,
name: newval.name
}
},
deep: true,
immediate: true
}
},
computed: {
......@@ -419,11 +476,18 @@ export default {
if (popkey == "employeeBoxVisible") {
this.customerInfo.salesUuid = item.uuid;
this.customerInfo.staffName = item.staffName;
this.$store.dispatch("setCustomerInfo", this.customerInfo);
} else {
this.$refs.carBrandListVisible.close();
this.customerInfo.carModel = item.name;
this.pageParams.carInfo = {
carChildsBrandId: item.carChildsBrandId,
carChildsBrandName: item.carChildsBrandName,
carBrandId: item.carBrandId,
carBrand: item.carBrand,
id: item.id,
name: item.name
}
}
this.$store.dispatch("setCustomerInfo", this.customerInfo);
this.selectKey = Date.now()
const { customerName, phoneNumber, staffName } = this.customerInfo
this.isCheck = customerName && phoneNumber && staffName
......@@ -455,7 +519,7 @@ export default {
if (this.pageParams.received) return
if (!this.isCheck) return // 按钮置灰的情况
try {
const { pageParams: { clickFlag, couponId }, carInfo, customerInfo } = this, {
const { pageParams: { clickFlag, couponId, carInfo }, customerInfo } = this, {
shopMerchantId } = uni.$storage.get("userInfo"),
validateStatus = await this.validate(),
checkCouponAmount = await this.checkCouponAmount(couponId, [shopMerchantId])
......@@ -512,7 +576,7 @@ export default {
try {
this.pageParams.received = false
this.pageParams.qrTimer = setInterval(async () => {
const { pageParams: { couponId }, customerInfo } = this,
const { pageParams: { couponId ,carInfo }, customerInfo } = this,
res = await uni.$api.boutiqueApi.findCustomerReceivedStatus({
merchantCouponId: couponId,
customerPhone: customerInfo.phoneNumber,
......@@ -524,7 +588,7 @@ export default {
this.$emit('reception', {
item: {
customerName: customerInfo.customerName,
carSeriesName: customerInfo.carModel,
carSeriesName: carInfo.name,
customerPhone: customerInfo.phoneNumber,
userId: customerInfo.salesUuid,
employeeName: customerInfo.staffName,
......
......@@ -84,7 +84,7 @@
ref="futureCalendar"
:insert="false"
:clearDate="false"
:startDate="endDate"
:startDate="startDate"
@confirm="confirmCalendar($event,'effectiveDate')"
:date="orderObj.effectiveDate"
showBottomBtn
......@@ -173,6 +173,7 @@ export default {
formList: utils.deepClone(EQUITY_FORM_LIST),
titleList: utils.deepClone(EQUITY_FORM_TITLE_LIST),
endDate: dayjs().format('YYYY-MM-DD'),
startDate: dayjs().add(1, 'day').format('YYYY-MM-DD'),
equityFormRule: utils.deepClone(EQUITY_FORM_RULE),
orderObj: {},
loadComplete: false,
......@@ -232,7 +233,6 @@ export default {
if (i.value == val.value) i.current = e.detail.value
})
})
this.viewKey = Date.now()
},
handleCell (val) {
if (['calendar', 'futureCalendar'].includes(val.key)) return this.$refs[val.key]?.open()
......@@ -246,16 +246,13 @@ export default {
Object.assign(this.orderObj, chooseContent)
this.$set(this.orderObj, 'carBrandText',
`${chooseContent.vehicleBrandName}/${chooseContent.vehicleSubBrandName}/${chooseContent.vehicleSeriesName}/${chooseContent.vehicleShapeName}`)
this.viewKey = Date.now()
return
} else if (_typeValue.options) {
this.$set(this.orderObj, _typeValue.targetIdKey, chooseContent[_typeValue.sourceIdKey || 'optionId'])
this.$set(this.orderObj, _typeValue.targetNameKey, chooseContent[_typeValue.sourceNameKey || 'optionLabel'])
this.viewKey = Date.now()
return
}
this.$set(this.orderObj, _typeValue.value, chooseContent)
this.viewKey = Date.now()
},
inputBlur (e, val) {
this.orderObj[val.value] = this.orderObj[val.value]
......@@ -367,7 +364,8 @@ export default {
})
}
let inclueType = data.addOnsFlag == 0 ? 2 : 1
Object.assign(this.orderObj, {
this.orderObj = utils.deepClone({
...this.orderObj,
...data,
vin: data.vin,
invoicePrice: NP.divide(Number(data.invoicePrice || 0), 100).toFixed(2),
......@@ -414,7 +412,6 @@ export default {
},
confirmCalendar (e, key) {
this.orderObj[key] = e.fulldate
this.viewKey = Date.now()
},
async submit (operationType) {
// VIN车架号-动态校验
......
<template>
<view class="order">
<view
:class="['order-box',{hide:showUpload}]"
:key="formKey"
>
<view class="common-title">车险信息</view>
<view class="box">
<scroll-view
class="scroll-view"
scroll-y="true"
>
<view class="box-content">
<GlCell
:formList="formList"
:formData="orderObj"
@radioChange="radioChange"
@inputBlur="inputBlur"
@handleCell="handleCell"
:titleList="titleList"
>
<template slot="customer">
<view class="customer-title flex">
客户信息
<view
class="customer-file flex"
@click="handleCell({
key:'customer'
})"
>
<view class="sprite-icon icon-customer-list"></view>
客户档案
</view>
</view>
</template>
<template slot="skuGoods">
<template v-if="orderObj.skuGoods.length">
<SkuGoods
:list="orderObj.skuGoods"
@changeTotalPrice="changeTotalPrice"
:positionTypeList="positionTypeList"
:baseConfigData="baseConfigData"
></SkuGoods>
</template>
<template v-if="orderObj.total > 0">
<view class="total">
<view class="total-left">总价</view>
<view class="total-right">¥{{ orderObj.total }}</view>
</view>
</template>
</template>
<template slot="otherPay">
<view
v-if="showPayTips"
class="pay-tips"
>其他收款:当客户已向嘀加付款但无法使用流水补录时,新建工单应选择收款方为「嘀加收款」且支付方为「其他收款」。</view>
</template>
</GlCell>
</view>
<view class="btns flex">
<view
class="btn save"
@click="handleEditSave"
>存草稿</view>
<view
@click="submit"
class="btn"
>{{confirmText}}</view>
</view>
</scroll-view>
</view>
</view>
<!-- 弹窗 -->
<order-popup
ref="orderPopup"
:data="orderObj"
:dataKey="valueKey"
@onConfirm="onConfirm"
:externalData="externalData"
:popupType="popupType"
:popupTitle="popupTitle"
/>
<template v-if="showUpload">
<view class="upload-box">
<upload-proof-of-payment
@back="clearPayMentDocList"
@confirm="uploadConfirm"
/>
</view>
</template>
<!-- 支付弹框 -->
<OrderPay
ref="OrderPay"
@closePopup="closePopup"
@jumpSuccess="jumpSuccess"
/>
</view>
</template>
<script>
import utils from '@/utils/utils'
import OrderPopup from '@/components/OrderPopup/index.vue'
import GlCell from '../../../../components/Form/GlCell.vue'
import Product from './Product.vue'
import Package from './Package.vue'
import SkuGoods from './SkuGoods.vue'
import { FORM_LIST, popupTypeEnum, payTypeList, titleList } from '../contant'
import { interceptionMixin } from '@/mixin/index'
import UploadProofOfPayment from './UploadProofOfPayment.vue'
import dayjs from 'dayjs'
import OrderPay from './OrderPay.vue'
import NP from 'number-precision'
import { validateVin, formatVinInput } from '@/utils/vinVaildate'
export default {
name: 'CreateOrder',
mixins: [interceptionMixin],
components: {
GlCell,
OrderPopup,
Product,
Package,
SkuGoods,
UploadProofOfPayment,
OrderPay
},
props: {
transmissionOfData: {
type: Object,
default: () => null
}
},
watch: {
'orderObj.payee': {
handler (val) {
this.formList[4].map(e => {
if (e.value == 'pay2Time') e.label = {
0: '嘀加收款时间',
1: '4S店收款时间'
}[val]
})
},
immediate: true,
deep: true
},
'orderObj.payType': {
handler (val) {
this.formList[4].map(e => {
if (e.value == 'notes') e.required = val == 7
if (e.value == 'pay2Time') e.hidden = ![2, 5, 6, 7].includes(+val)
})
},
immediate: true,
deep: true
},
transmissionOfData: {
handler (val) {
const paramsData = val?.paramsData || {}
if (paramsData && paramsData.id) this.paramsData = paramsData
},
deep: true,
immediate: true
}
},
data () {
return {
paramsData: {},
saveStatus: false,
showUpload: false,
titleList,
formList: utils.deepClone(FORM_LIST),
baseConfigData: {},
orderObj: {
mode: 1,
payee: 0, // 收款方式
payType: 1, // 支付方式
insurancePrice: '',
skuGoods: [], //商品列表
referrerId: '', //销售顾问id
referrer: '',//销售顾问名称
deliveryId: '',//交付专员id
deliveryName: '',//交付专员名称
total: '',//总价
notes: '',//备注
carSeriesId: '', //车系id
seat: '5',//座位数
ownerGender: '男',
salesType: '0',
carInfo: {},
price: ''
}, // 弹窗传入的数据},
popupType: 0,
popupTypeEnum,
externalData: [], //弹窗接口数据
djPayList: [], // 嘀加收款方对应支付方式
merchantPayList: [], // 门店收款方对应支付方式
configPayTypeList: [], // 园区店配置支持的支付方式
payTypeList,
goodsList: [],
subOrderList: [],
otherProduct: [],
positionTypeList: [],
valueKey: '',
popupTitle: '',
pointsMultiRole: 'Y',
formKey: Date.now(),
validateState: true
}
},
computed: {
showPayTips () {
return this.orderObj.payee == 0 && this.orderObj.payType == 7
},
confirmText () {
return [1, 3].includes(+this.orderObj.payType) ? '下一步·去支付' : '下一步·上传凭证'
},
userInfo () {
return uni.$storage.get('userInfo') || {}
}
},
mounted () {
this.baseConfigData = uni.$storage.get('mock_data') || {}
this.initData()
},
methods: {
async getQuotationInfoById (id) {
try {
let { goodsList: quotationGoodsList } = this, data = await uni.$api.equityApi.getQuotationInfoById({ id }),
{ orderObj } = this,
{ owner, insurancePrice, quotedPriceUpdate } = data
uni.hideLoading()
orderObj.price = this.divideByHundred(owner.price)
orderObj.insurancePrice = this.divideByHundred(insurancePrice)
orderObj.quotedPriceUpdate = this.divideByHundred(quotedPriceUpdate)
if(!data.vdQuotationGoodsList) data.vdQuotationGoodsList = []
orderObj.vdQuotationGoodsList = data.vdQuotationGoodsList.map(
item => {
item.price = this.divideByHundred(item.goodsPrice)
return item
}
)
if (!owner.ownerGender) owner.ownerGender = '男'
if (owner.carSeriesId) {
orderObj.carInfo = {
carBrand: owner.carBrand,
carBrandId: owner.carBrandId,
carChildsBrandId: owner.carChildsBrandId,
carChildsBrandName: owner.carChildsBrandName,
carSeriesId: owner.carSeriesId,
carSeriesName: owner.carSeriesName,
}
orderObj.carBrandText = `${owner.carBrand}-${owner.carChildsBrandName}-${owner.carSeriesName}`
}
if (owner.city) {
let [provinceText, cityText] = owner.city.split('-')
if (cityText) {
orderObj.provinceText = provinceText
orderObj.cityText = cityText
} else {
orderObj.provinceText = owner.city
orderObj.cityText = owner.city
}
}
this.formList[1].map(e => {
if (e.value == 'salesType') e.current = owner.salesType
if (e.value == 'ownerGender') e.current = owner.ownerGender
})
orderObj.skuGoods = data.vdQuotationGoodsList.reduce((pre, item) => {
// 是普通商品
if (!item.packageName && !item.specificationsValue) {
console.log(item)
let obj = {
...item,
goodsInfo: item,
upgradeGoodsId: item.goodsId,
merchantGoodsId: item.goodsId,
sellPrice: this.divideByHundred(item.goodsPrice),
minSellPrice: quotationGoodsList?.find(
val => val?.goods?.merchantGoodsId == item.goodsId
)?.goods?.minSellPrice, // 按商品数据对比补充详情商品最低价
validMinSellPrice: quotationGoodsList?.find(
val => val?.goods?.merchantGoodsId == item.goodsId
)?.goods?.validMinSellPrice // 按商品数据对比补充详情商品校验最低价字段
}
pre.push({
goodsFlag: 1,
goods: obj,
packageGoods: null
})
}
//套餐
if (item.packageName) {
let obj = {
...item,
merchantGoodsId: item.goodsId,
upgradeGoodsId: item.goodsId,
sellPrice: this.divideByHundred(item.goodsPrice),
number: 1,
minSellPrice: quotationGoodsList
?.find(
val =>
val.packageGoods?.goodsList?.length &&
val.packageGoods?.packageCode == item?.packageId
)
?.packageGoods?.goodsList?.find(
subV => subV.merchantGoodsId == item.goodsId
)?.minSellPrice, // 按商品数据对比补充详情商品最低价
validMinSellPrice: quotationGoodsList
?.find(
val =>
val.packageGoods?.goodsList?.length &&
val.packageGoods?.packageCode == item?.packageId
)
?.packageGoods?.goodsList?.find(
subV => subV.merchantGoodsId == item.goodsId
)?.validMinSellPrice // 按商品数据对比补充详情商品校验最低价字段
}
let index = pre.findIndex(ele => {
if (ele.packageGoods) {
return ele.packageGoods.packageId == item.packageId
}
})
if (index != -1) {
pre[index].packageGoods.goodsList.push(obj)
pre[index].price = NP.plus(pre[index].price, obj.price)
} else {
pre.push({
goods: null,
goodsFlag: 3,
price: item.price,
packageGoods: {
...item,
packageCode: item.packageId,
goodsList: [{
...obj
}]
}
})
}
}
//多规格商品
if (!item.packageName && item.specificationsValue) {
let specificdata = this.handleSpecificationsEcho(item)
pre = pre.concat(specificdata)
}
return pre
}, [])
let keyList = ['mode', 'payee', 'payType', 'referrerId', 'referrer',
'deliveryId', 'deliveryName', 'notes', 'id', 'orderId'
], customerKeyList = ['owner', 'phone', 'certificateNo', 'carVin', 'seat', ,
'ownerGender', 'ageRange', 'hobby', 'companion', 'carColor', 'salesType', 'city']
keyList.map(key => {
if (data[key] != null) orderObj[key] = data[key]
})
customerKeyList.map(key => {
if (owner[key] != null) orderObj[key] = owner[key]
})
if (owner.id) orderObj.ownerId = owner.id
let payeeCell = this.formList[4].find(item => item.value === 'payee')
if (payeeCell) payeeCell.current = orderObj.payee
this.orderObj = orderObj
this.getConfig()
setTimeout(() => {
this.changeTotalPrice()
}, 0)
} catch (error) {
console.log(error)
uni.hideLoading()
if (error) uni.showToast({
title: error,
icon: 'none',
})
}
},
initData () {
// 埋点
// uni.$track.add({ eventCode: 'app_create_order' })
const { paramsData } = this
this.getSelectOrderGoodsList()
if (!paramsData.id) this.getConfig()
this.getShopMerchantPointConfig()
this.orderSettingList()
},
async orderSettingList () {
const { shopMerchantId } = this.userInfo,
params = {
scene: 0,
isRequired: 1,
merchantId: shopMerchantId
},
data = await uni.$api.equityApi.orderSettingList(params)
if (data) {
let required = data.reduce((pre, item) => {
if (item.isRequired) {
pre.push(item.fieldKey)
}
return pre
}, [])
if (required.includes('carBrand')) this.formList[2].map(e => {
if (e.value == 'carBrandText') e.required = true
})
if (required.includes('carNo')) this.formList[2].map(e => {
if (e.value == 'carVin') e.required = true
})
if (required.includes('idNumber')) this.formList[1].map(e => {
if (e.value == 'certificateNo') e.required = true
})
}
},
async getShopMerchantPointConfig () {
const { shopMerchantId: merchantId } = this.userInfo,
{ pointsMultiRole } = await uni.$api.equityApi.getShopMerchantPointConfig({
merchantId
})
this.pointsMultiRole = pointsMultiRole
if (pointsMultiRole != 'Y') this.formList[0].map(e => {
if (e.value == 'deliveryName') e.hidden = true
if (e.value == 'referrer') e.label = '推荐人'
})
},
// 选择行事件
handleCell (val) {
let { payType } = this.orderObj,
{ pointsMultiRole } = this
this.popupTitle = ''
// 获取当前选中的popupType
this.popupType = Object.keys(this.popupTypeEnum).find(key => this.popupTypeEnum[key].key === val.key) * 1
// 获取对应的list字段
const popupConfig = this.popupTypeEnum[this.popupType]
if (popupConfig && popupConfig.list) {
this.externalData = this[popupConfig.list] || []
} else {
this.externalData = []
}
// 定义产品相关字段数组
const productFields = ['skuGoods']
if (productFields.includes(val.value)) {
this.valueKey = val.value
this.externalData = utils.deepClone(this.goodsList)
}
this.popupTitle = {
0: pointsMultiRole == 'Y' ? '销售顾问/录单员' : '推荐人',
4: '车型',
13: payType == 2 ? '4S店收款时间' : '嘀加收款时间'
}[this.popupType]
this.$refs.orderPopup.open()
},
// 单选框change事件
radioChange (e, val) {
this.$set(this.orderObj, val.value, e.detail.value)
if (val.value == 'payee') this.changePayee()
},
// 弹窗确认回调
onConfirm (val, flag) {
console.log(JSON.parse(JSON.stringify(val)), 'onConfirm')
this.externalData = []
// // const { chooseContent } = val
const chooseContent = utils.deepClone(val.chooseContent)
// 根据popupTypeEnum优化处理
const _typeValue = this.popupTypeEnum[this.popupType]
console.log(_typeValue)
// 定义产品相关字段数组
if (val.popupType == 19) return this.setCustomerInfo(chooseContent)
const productFields = ['skuGoods']
if (_typeValue.key == 'carBrand') {
// 车型
this.$set(this.orderObj, 'carBrandText', `${chooseContent.carBrand}-${chooseContent.carChildsBrandName}-${chooseContent.carSeriesName}`)
Object.assign(this.orderObj, {
carInfo: chooseContent
})
}
else if (productFields.includes(_typeValue.key)) {
if (_typeValue.key == 'skuGoods') {
if (!this.orderObj.skuGoods) {
// 其他精品第一次赋值
this.$set(this.orderObj, 'skuGoods', chooseContent)
} else {
// 过滤出已选的goodFlag为2的对象
const selectedGoods = this.orderObj[_typeValue.key].filter(item => item.goodsFlag === 2)
const singleGoods = flag ? this.orderObj[_typeValue.key].filter(item => item.goodsFlag != 2) : chooseContent.filter(item => item.goodsFlag != 2)
const moreGoods = chooseContent
.filter(item => item.goodsFlag === 2)
.filter(item => {
return !selectedGoods.some(selectedItem => selectedItem.multipleSpecificationsGoods.goods.goodsId === item.multipleSpecificationsGoods.goods.goodsId)
})
console.log(singleGoods, '===')
// 合并已选的goodFlag为2的对象
this.orderObj.skuGoods = [...singleGoods, ...moreGoods, ...selectedGoods]
}
}
setTimeout(() => {
this.changeTotalPrice()
}, 0)
}
else {
if (_typeValue.key == 'city') {
this.$set(this.orderObj, 'provinceText', chooseContent.province)
this.$set(this.orderObj, 'cityText', chooseContent.city)
this.$set(this.orderObj, 'city', chooseContent.city == chooseContent.province ? chooseContent.city : `${chooseContent.province}-${chooseContent.city}`)
} else if (_typeValue.key == 'todayShow') {
this.$set(this.orderObj, 'pay2Time', chooseContent)
} else if (_typeValue.list == 'employeeList') {
this.$set(this.orderObj, _typeValue.targetIdKey, chooseContent[_typeValue.sourceIdKey])
this.$set(this.orderObj, _typeValue.targetNameKey, chooseContent[_typeValue.sourceNameKey])
} else this.$set(this.orderObj, _typeValue.key, chooseContent)
console.log(this.orderObj, 'this.orderObj')
}
console.log(this.orderObj)
},
// 输入框失去焦点事件
inputBlur (e, val) {
console.log(e, val)
if (val.value == 'price') {
this.orderObj[val.value] = parseFloat(this.orderObj[val.value]) > 2000000 ? 2000000 : this.orderObj[val.value]
return
}
this.orderObj[val.value] = this.orderObj[val.value]
// VIN车架号动态校验:车架号字段,动态转换为大写
if (val.value === 'carVin') this.validateVin()
},
validateVin () {
let carVinVal = this.orderObj.carVin;
if (carVinVal) {
this.orderObj.carVin = formatVinInput(carVinVal)
validateVin(this.orderObj.carVin).then(result => {
console.log("validateVin", result);
let { valid } = result.data;
this.validateState = valid
// 校验成功,所有提示已在公共方法中处理
console.log('车架号校验成功:', result)
}).catch(err => {
console.log("validateVinErr", result);
})
}
},
// 校验必填等规则
checkRequired () {
try {
const phoneRex = /^[1]([3-9])[0-9]{9}$/,
requiredArr = [],
onlyLabelItem = [],
{ orderObj } = this
this.formList.forEach(group => {
group.forEach(item => {
if (item.required === true && item.hidden !== true) {
if (item.isArray) onlyLabelItem.push(item)
else requiredArr.push(item)
}
})
})
// VIN车架号-动态校验
const carVin = this.orderObj.carVin
console.log("validateState", this.validateState);
if (carVin) {
// 前置判断
if (carVin.length !== 17) {
uni.showToast({ title: '请输入 17 位有效字符(支持大写 A-H/J-N/P-Z、0-9)', icon: 'none' })
return false
}
// 根据接口校验结果判断
if (carVin.length === 17 && !this.validateState) {
uni.showToast({ title: '车架号校验不匹配,请核对后重新输入', icon: 'none' })
return false
}
}
// 遍历requiredArr,检查orderObj中是否有对应的值
for (let i = 0; i < requiredArr.length; i++) {
const item = requiredArr[i]
// 兼容嵌套customer对象的情况
let value = orderObj[item.value]
if (value === undefined || value === null || value === '') throw `${item.label}不能为空`
// 如果是customerPhone,添加phoneRex校验
if (item.value === 'phone' && !phoneRex.test(value)) throw `请输入正确的${item.label}`
}
// if (orderObj.carVin) {
// if (!utils.validateVIN(orderObj.carVin)) throw '车架号校验不匹配,请核对后重新输入'
// }
if (onlyLabelItem.length) {
const labelFields = ['skuGoods']
const hasValue = labelFields.some(field => {
const value = orderObj[field]
return value !== undefined && value !== null && (Array.isArray(value) ? value.length > 0 : value !== '')
})
if (!hasValue) throw '请选择增值车损险商品'
}
if (orderObj.certificateNo && orderObj.certificateNo.length != 18) throw '请输入正确的18位证件号'
return true
} catch (error) {
if (error) uni.showToast({
title: error,
icon: 'none'
})
return false
}
},
// 提交
async submit () {
if (!this.checkRequired() || await this.checkDailyReport()) return
this.handleSecondConfirmCheck(true)
},
async handleSecondConfirmCheck (check) {
try {
let orderInfo = this.getInsurance(),
{ payType } = orderInfo
if (check &&
([2, 5, 6, 7].includes(+payType)) &&
!(orderInfo.transactionNo && orderInfo.paymentDocList.length)
) return this.showUpload = true
if (orderInfo.pay2Time && ![1, 3].includes(+payType)) orderInfo.pay2Time = dayjs(orderInfo.pay2Time).format('YYYY-MM-DD HH:mm:ss')
else delete orderInfo.pay2Time
uni.showLoading({
title: `${check ? '报价' : '保存'}中...`,
mask: true
})
orderInfo.check = check
let apiName = orderInfo.id ? 'updateQuotation' : 'quotationAdd'
const data = await uni.$api.equityApi[apiName](orderInfo)
this.saveStatus = false
if (data) {
this.showUpload = false
wx.hideLoading()
if (check) {
if ([2, 5, 6, 7].includes(+payType)) return this.$emit('jump', 'OrderManagement')
let status = await this.createWithPay(data)
if (status) this.$refs.OrderPay.open(data)
else throw false
} else this.$emit('jump', 'OrderManagement')
} else throw false
} catch (error) {
console.log(error)
this.saveStatus = false
uni.hideLoading()
uni.showToast({
title: '提交失败',
icon: 'none'
})
}
},
createWithPay (id) {
return new Promise((resolve, reject) => {
let para = {
id,
customerNameUrl: '',
orderStatus: 2
}
uni.$api.equityApi.quotationUpgrade(para).then(res => {
resolve(res)
})
})
},
getInsurance () {
let {
orderObj,
userInfo
} = this,
orderInfo = utils.deepClone(orderObj),
{
default4SStoreInfo
} = userInfo,
params = {
owner: {
...orderInfo.carInfo
}
}
if (orderInfo.id) params.id = orderInfo.id
params.merchantId4s = default4SStoreInfo?.merchantId
params.merchantName4s = default4SStoreInfo?.merchantName
orderInfo.price = this.multipliedByHundred(orderInfo.price)
params.insurancePrice = this.multipliedByHundred(
orderInfo.insurancePrice
)
params.quotedPriceUpdate = this.multipliedByHundred(
orderInfo.quotedPriceUpdate
)
params.minEquityPrice = this.multipliedByHundred(
orderInfo.minEquityPrice
)
params.vdQuotationGoodsList = orderInfo.skuGoods.reduce(
(pre, item) => {
if (item.goods) {
item = item.goods
const obj = {
goodsId: item.merchantGoodsId,
goodsName: item.goodsName,
goodsNameAlias: item.goodsAlias || item.goodsNameAlias,
specificationsName: item.specificationNameSequence,
specificationsValue: item.specificationData ?
item.specificationData.replace(/;~;/g, '/') : '',
goodsPrice: this.multipliedByHundred(item.sellPrice)
}
pre.push(obj)
}
if (item.packageGoods) {
item = item.packageGoods
item.goodsList.map(ele => {
let obj = {
packageId: item.packageCode,
packageName: item.packageName,
packageNameAlias: item.packageAlias || item.packageNameAlias,
goodsId: ele.merchantGoodsId || ele.upgradeGoodsId,
goodsName: ele.upgradeGoodsName || ele.goodsName,
goodsNameAlias: ele.goodsAlias || ele.goodsNameAlias,
specificationsName: ele.specificationNameSequence,
specificationsValue: ele.specificationData ?
ele.specificationData.replace(/;~;/g, '/') : '',
// specificationsValue: item.specificationData ? item.specificationData.replace(reg, ' ') : '',
goodsPrice: this.multipliedByHundred(ele.sellPrice)
}
pre.push(obj)
})
}
if (item.multipleSpecificationsGoods) {
if (item.multipleSpecificationsGoods.goods) {
item = item.multipleSpecificationsGoods.goods
const obj = {
goodsId: item.merchantGoodsId,
goodsName: item.upgradeGoodsName || item.goodsName,
goodsNameAlias: item.goodsAlias || item.goodsNameAlias,
specificationsName: item.specificationNameSequence,
specificationsValue: item.specificationData ?
item.specificationData.replace(/;~;/g, '/') : '',
goodsPrice: this.multipliedByHundred(item.sellPrice)
}
pre.push(obj)
}
}
return pre
},
[]
)
let keyList = ['mode', 'payee', 'payType', 'referrerId', 'referrer',
'deliveryId', 'deliveryName', 'total', 'notes', 'tradeNo',
'transactionNo', 'paymentDocList', 'id', 'orderId', 'pay2Time'
],
customerKeyList = [
'owner', 'phone', 'certificateNo', 'carVin', 'seat', 'price',
'ownerGender', 'city', 'ageRange', 'hobby', 'companion', 'carColor', 'salesType'
]
keyList.map(key => {
if (orderInfo[key] != null) params[key] = orderInfo[key]
})
customerKeyList.map(key => {
if (orderInfo[key] != null) params.owner[key] = orderInfo[key]
})
if (orderInfo.ownerId) params.owner.id = orderInfo.ownerId
return params
},
// 乘以100保留两位小数点
multipliedByHundred (str) {
let floatVal = parseFloat(str)
if (isNaN(floatVal)) {
return 0
}
floatVal = Math.round(str * 10000) / 100
let strVal = floatVal.toString()
let searchVal = strVal.indexOf('.')
if (searchVal < 0) {
searchVal = strVal.length
strVal += '.'
}
while (strVal.length <= searchVal + 2) {
strVal += '0'
}
return parseFloat(strVal)
},
// 计算所有产品的总价
changeTotalPrice () {
let total = 0
// 遍历所有商品
const productFields = ['skuGoods']
productFields.forEach(slotName => {
const productList = this.orderObj[slotName]
if (Array.isArray(productList) && productList.length > 0) {
// 计算每个产品的价格 * 数量,并累加到总价
productList.forEach(item => {
if (item.goods && item.goods.sellPrice && item.goods.number) {
console.log(item.goods, '---单商品')
total = NP.plus(total, NP.times(item.goods.sellPrice, item.goods.number))
} else if (item.packageGoods && item.packageGoods.totalPrice) {
console.log(item.packageGoods, '套餐')
total = NP.plus(total, item.packageGoods.totalPrice)
} else if (item.multipleSpecificationsGoods && item.multipleSpecificationsGoods.goods && item.multipleSpecificationsGoods.goods.sellPrice) {
console.log(item.multipleSpecificationsGoods, '多规格')
total = NP.plus(total, NP.times(item.multipleSpecificationsGoods.goods.sellPrice, item.multipleSpecificationsGoods.number || 1))
}
})
}
})
console.log(total, 'total')
// 更新总价
this.orderObj.total = total.toFixed(2)
},
// 获取园区店支付方式
async getConfig () {
const { merchantId } = this.userInfo,
res = await uni.$api.boutiqueApi.getYqStoreConfig({
yqMerchantId: merchantId
})
console.log(123)
let m = res.supportPayTypes || []
let n = this.payTypeList
let list = n.filter(k => {
let idx = m.find(j => j == k.value)
return idx >= 0
})
this.djPayList = [
...list?.filter(v => ![2, 5].includes(Number(v.value))),
{
name: '对公转账',
value: '6'
},
{
name: '其它收款',
value: '7'
},
]
this.merchantPayList = [...list?.filter(v => v.value == 2)]
this.changePayee()
},
changePayee () {
const cell = this.formList[4].find(item => item.value === 'payType'),
{ payType } = this.orderObj
if (cell) {
cell.radioList = this.orderObj.payee == 1 ? this.merchantPayList : this.djPayList
let index = cell.radioList.findIndex(i => i.value == payType)
if (index == -1) index = 0
if (cell.radioList && cell.radioList.length > 0) {
cell.current = cell.radioList[index].value
// 使用 $set 确保响应式更新
this.$set(this.orderObj, 'payType', cell.radioList[index].value)
}
}
},
// 商品列表
async getSelectOrderGoodsList () {
const { userInfo, paramsData } = this
if (paramsData.id) uni.showLoading({
title: '加载中...',
mask: true
})
const res = await uni.$api.boutiqueApi.getSelectOrderGoodsList({
merchantId: userInfo.shopMerchantId,
sceneType: userInfo.sceneType
})
this.goodsList = res
this.changeTotalPrice()
if (paramsData.id) this.getQuotationInfoById(paramsData.id)
},
handleSpecificationsEcho (item) {
console.log('item', item)
let {
goodsList: quotationGoodsList
} = this, skuArr = [],
arr = item.specificationsValue.split('/'),
str = arr.join(';~;');
quotationGoodsList.forEach(data => {
if (data.goodsFlag == 2) {
let tempData = data.multipleSpecificationsGoods.specificationGoodsMap[str]
if (tempData) {
tempData.forEach(temp => {
if (temp.merchantGoodsId == item.goodsId) {
let obj = {
goodsFlag: 2,
goods: null,
}
obj.multipleSpecificationsGoods = {
goods: temp,
baseGoodsName: item.goodsName
}
temp.price = this.divideByHundred(item.goodsPrice)
temp.goodsId = item.goodsId
temp.specificationStr = item.specificationsValue
console.log('🚀', obj)
skuArr.push(obj)
}
})
}
}
})
return skuArr
},
uploadConfirm ({
payVoucherList,
outTradeNo
}) {
let paymentDocList = []
payVoucherList.map(e => {
paymentDocList.push({
paymentDocUrl: e,
type: 1
})
})
this.orderObj.transactionNo = outTradeNo
this.orderObj.tradeNo = outTradeNo
this.orderObj.paymentDocList = paymentDocList
this.submit()
},
setCustomerInfo (customerInfo) {
const { orderObj } = this,
ownerGender = customerInfo.customerSex != 2 ? '男' : '女',
salesType = customerInfo.salesType || '0',
city = customerInfo.customerCity
Object.assign(orderObj, {
customerId: customerInfo.id,
owner: customerInfo.customerName,
phone: customerInfo.customerPhone,
ownerGender,
seat: customerInfo.carSeat || 5,
ageRange: customerInfo.customerAgeRange,
hobby: customerInfo.customerHobby,
companion: customerInfo.customerCompanion,
certificateNo: customerInfo.customerCertificateNo || '',
salesType,
carVin: customerInfo.carVin || '',
carColor: customerInfo.carColor || '',
})
this.formList[1].map(e => {
if (e.value == 'salesType') e.current = salesType
if (e.value == 'ownerGender') e.current = ownerGender
})
if (city) {
let [provinceText, cityText] = city.split('-')
if (cityText) {
orderObj.provinceText = provinceText
orderObj.cityText = cityText
} else {
orderObj.provinceText = city
orderObj.cityText = city
}
orderObj.city = city
}
if (customerInfo.carPrice) orderObj.price = this.divideByHundred(customerInfo.carPrice)
if (customerInfo.salesUuid) {
orderObj.referrerId = customerInfo.salesUuid
orderObj.referrer = customerInfo.salesName
}
if (customerInfo.carSeriesName) {
orderObj.carInfo = {
carBrand: customerInfo.carBrand,
carBrandId: customerInfo.carBrandId,
carChildsBrandId: customerInfo.carChildsBrandId,
carChildsBrandName: customerInfo.carChildsBrandName,
carSeriesId: customerInfo.carSeriesId,
carSeriesName: customerInfo.carSeriesName,
}
orderObj.carBrandText = `${customerInfo.carBrand}-${customerInfo.carChildsBrandName}-${customerInfo.carSeriesName}`
}
this.orderObj = orderObj
this.formKey = Date.now()
this.validateVin()
console.log(this.orderObj)
},
jumpSuccess (params) {
this.$emit('jump', 'OrderDetail', params)
},
async handleEditSave () {
let {
saveStatus
} = this
if (saveStatus) return false
this.saveStatus = true
this.handleSecondConfirmCheck(false)
},
divideByHundred: str => {
let floatVal = parseFloat(str)
if (isNaN(floatVal)) {
return 0
}
floatVal = Math.round(str * 100) / 10000
let strVal = floatVal.toString()
let searchVal = strVal.indexOf('.')
if (searchVal < 0) {
searchVal = strVal.length
strVal += '.'
}
while (strVal.length <= searchVal + 2) {
strVal += '0'
}
return parseFloat(strVal)
},
closePopup () {
this.$emit('jump', 'OrderManagement')
},
clearPayMentDocList () {
this.showUpload = false
this.orderInfo.paymentDocList = []
this.orderInfo.transactionNo = ''
}
}
}
</script>
<style scoped lang="scss">
.order {
height: 100%;
position: relative;
&-box {
visibility: visible;
height: 100%;
}
.hide {
opacity: 0;
visibility: hidden;
}
.upload-box {
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 100%;
}
}
.box {
height: calc(100% - #{toRpx(120)});
padding-bottom: toRpx(24);
.scroll-view {
height: 100%;
}
}
.box-content {
padding: 0 toRpx(48);
}
.total {
display: flex;
justify-content: space-between;
align-items: center;
padding: toRpx(24) toRpx(32) toRpx(24) 0;
font-size: toRpx(28);
border-bottom: toRpx(2) solid #f7f7f6;
&-left {
color: #333;
font-weight: 500;
}
&-right {
color: #f24724;
font-weight: 500;
}
}
.pay-tips {
padding: toRpx(24) toRpx(24) toRpx(24) 0;
font-size: toRpx(24);
color: #999;
}
.btns {
padding: toRpx(24) toRpx(128);
gap: toRpx(32);
.save {
background: #3b73ff1a;
color: #4673ff;
font-size: toRpx(28);
font-weight: 500;
}
}
.btn {
display: flex;
align-items: center;
justify-content: center;
width: toRpx(1130);
height: toRpx(80);
color: #fff;
border-radius: toRpx(48);
background: linear-gradient(0deg, #2c66f7 0%, #48a6ff 100%);
}
.customer-title {
.customer-file {
margin-left: toRpx(20);
color: #347bff;
font-size: toRpx(24);
.sprite-icon {
margin-right: toRpx(4);
}
}
}
</style>
<template>
<view class="order">
<view
:class="['order-box',{hide:showUpload}]"
:key="formKey"
>
<view class="common-title">车险信息</view>
<view class="box">
<scroll-view
class="scroll-view"
scroll-y="true"
>
<view class="box-content">
<GlCell
:formList="formList"
:formData="orderObj"
@radioChange="radioChange"
@inputBlur="inputBlur"
@handleCell="handleCell"
:titleList="titleList"
>
<template slot="customer">
<view class="customer-title flex">
客户信息
<view
class="customer-file flex"
@click="handleCell({
key:'customer'
})"
>
<view class="sprite-icon icon-customer-list"></view>
客户档案
</view>
</view>
</template>
<template slot="skuGoods">
<template v-if="orderObj.skuGoods.length">
<SkuGoods
:list="orderObj.skuGoods"
@changeTotalPrice="changeTotalPrice"
:positionTypeList="positionTypeList"
:baseConfigData="baseConfigData"
></SkuGoods>
</template>
<template v-if="orderObj.total > 0">
<view class="total">
<view class="total-left">总价</view>
<view class="total-right">¥{{ orderObj.total }}</view>
</view>
</template>
</template>
<template slot="otherPay">
<view
v-if="showPayTips"
class="pay-tips"
>其他收款:当客户已向嘀加付款但无法使用流水补录时,新建工单应选择收款方为「嘀加收款」且支付方为「其他收款」。</view>
</template>
</GlCell>
</view>
<view class="btns flex">
<view
class="btn save"
@click="handleEditSave"
>存草稿</view>
<view
@click="submit"
class="btn"
>{{confirmText}}</view>
</view>
</scroll-view>
</view>
</view>
<!-- 弹窗 -->
<order-popup
ref="orderPopup"
:data="orderObj"
:dataKey="valueKey"
@onConfirm="onConfirm"
:externalData="externalData"
:popupType="popupType"
:popupTitle="popupTitle"
/>
<template v-if="showUpload">
<view class="upload-box">
<upload-proof-of-payment
@back="clearPayMentDocList"
@confirm="uploadConfirm"
/>
</view>
</template>
<!-- 支付弹框 -->
<OrderPay
ref="OrderPay"
@closePopup="closePopup"
@jumpSuccess="jumpSuccess"
/>
</view>
</template>
<script>
import utils from '@/utils/utils'
import OrderPopup from '@/components/OrderPopup/index.vue'
import GlCell from '../../../../components/Form/GlCell.vue'
import Product from './Product.vue'
import Package from './Package.vue'
import SkuGoods from './SkuGoods.vue'
import { FORM_LIST, popupTypeEnum, titleList } from '../contant'
import { interceptionMixin } from '@/mixin/index'
import UploadProofOfPayment from './UploadProofOfPayment.vue'
import dayjs from 'dayjs'
import OrderPay from './OrderPay.vue'
import NP from 'number-precision'
import { validateVin, formatVinInput } from '@/utils/vinVaildate'
export default {
name: 'CreateOrder',
mixins: [interceptionMixin],
components: {
GlCell,
OrderPopup,
Product,
Package,
SkuGoods,
UploadProofOfPayment,
OrderPay
},
props: {
transmissionOfData: {
type: Object,
default: () => null
}
},
watch: {
'orderObj.payee': {
handler (val) {
this.formList[4].map(e => {
if (e.value == 'pay2Time') e.label = {
0: '嘀加收款时间',
1: '4S店收款时间'
}[val]
})
},
immediate: true,
deep: true
},
'orderObj.payType': {
handler (val) {
this.formList[4].map(e => {
if (e.value == 'notes') e.required = val == 7
if (e.value == 'pay2Time') e.hidden = ![2, 5, 6, 7].includes(+val)
})
},
immediate: true,
deep: true
},
transmissionOfData: {
handler (val) {
const paramsData = val?.paramsData || {}
if (paramsData && paramsData.id) this.paramsData = paramsData
},
deep: true,
immediate: true
}
},
data () {
return {
paramsData: {},
saveStatus: false,
showUpload: false,
titleList,
formList: utils.deepClone(FORM_LIST),
baseConfigData: {},
orderObj: {
mode: 1,
payee: 0, // 收款方式
payType: 1, // 支付方式
insurancePrice: '',
skuGoods: [], //商品列表
referrerId: '', //销售顾问id
referrer: '',//销售顾问名称
deliveryId: '',//交付专员id
deliveryName: '',//交付专员名称
total: '',//总价
notes: '',//备注
carSeriesId: '', //车系id
seat: '5',//座位数
ownerGender: '男',
salesType: '0',
carInfo: {},
price: ''
}, // 弹窗传入的数据},
popupType: 0,
popupTypeEnum,
externalData: [], //弹窗接口数据
djPayList: [], // 嘀加收款方对应支付方式
merchantPayList: [], // 门店收款方对应支付方式
configPayTypeList: [], // 园区店配置支持的支付方式
goodsList: [],
subOrderList: [],
otherProduct: [],
positionTypeList: [],
valueKey: '',
popupTitle: '',
pointsMultiRole: 'Y',
formKey: Date.now(),
validateState: true
}
},
computed: {
showPayTips () {
return this.orderObj.payee == 0 && this.orderObj.payType == 7
},
confirmText () {
return [1, 3].includes(+this.orderObj.payType) ? '下一步·去支付' : '下一步·上传凭证'
},
userInfo () {
return uni.$storage.get('userInfo') || {}
}
},
mounted () {
this.baseConfigData = uni.$storage.get('mock_data') || {}
this.initData()
},
methods: {
async getQuotationInfoById (id) {
try {
let { goodsList: quotationGoodsList } = this, data = await uni.$api.equityApi.getQuotationInfoById({ id }),
{ orderObj } = this,
{ owner, insurancePrice, quotedPriceUpdate } = data
uni.hideLoading()
orderObj.price = this.divideByHundred(owner.price)
orderObj.insurancePrice = this.divideByHundred(insurancePrice)
orderObj.quotedPriceUpdate = this.divideByHundred(quotedPriceUpdate)
if (!data.vdQuotationGoodsList) data.vdQuotationGoodsList = []
orderObj.vdQuotationGoodsList = data.vdQuotationGoodsList.map(
item => {
item.price = this.divideByHundred(item.goodsPrice)
return item
}
)
if (!owner.ownerGender) owner.ownerGender = '男'
if (owner.carSeriesId) {
orderObj.carInfo = {
carBrand: owner.carBrand,
carBrandId: owner.carBrandId,
carChildsBrandId: owner.carChildsBrandId,
carChildsBrandName: owner.carChildsBrandName,
carSeriesId: owner.carSeriesId,
carSeriesName: owner.carSeriesName,
}
orderObj.carBrandText = `${owner.carBrand}-${owner.carChildsBrandName}-${owner.carSeriesName}`
}
if (owner.city) {
let [provinceText, cityText] = owner.city.split('-')
if (cityText) {
orderObj.provinceText = provinceText
orderObj.cityText = cityText
} else {
orderObj.provinceText = owner.city
orderObj.cityText = owner.city
}
}
this.formList[1].map(e => {
if (e.value == 'salesType') e.current = owner.salesType
if (e.value == 'ownerGender') e.current = owner.ownerGender
})
orderObj.skuGoods = data.vdQuotationGoodsList.reduce((pre, item) => {
// 是普通商品
if (!item.packageName && !item.specificationsValue) {
console.log(item)
let obj = {
...item,
goodsInfo: item,
upgradeGoodsId: item.goodsId,
merchantGoodsId: item.goodsId,
sellPrice: this.divideByHundred(item.goodsPrice),
minSellPrice: quotationGoodsList?.find(
val => val?.goods?.merchantGoodsId == item.goodsId
)?.goods?.minSellPrice, // 按商品数据对比补充详情商品最低价
validMinSellPrice: quotationGoodsList?.find(
val => val?.goods?.merchantGoodsId == item.goodsId
)?.goods?.validMinSellPrice // 按商品数据对比补充详情商品校验最低价字段
}
pre.push({
goodsFlag: 1,
goods: obj,
packageGoods: null
})
}
//套餐
if (item.packageName) {
let obj = {
...item,
merchantGoodsId: item.goodsId,
upgradeGoodsId: item.goodsId,
sellPrice: this.divideByHundred(item.goodsPrice),
number: 1,
minSellPrice: quotationGoodsList
?.find(
val =>
val.packageGoods?.goodsList?.length &&
val.packageGoods?.packageCode == item?.packageId
)
?.packageGoods?.goodsList?.find(
subV => subV.merchantGoodsId == item.goodsId
)?.minSellPrice, // 按商品数据对比补充详情商品最低价
validMinSellPrice: quotationGoodsList
?.find(
val =>
val.packageGoods?.goodsList?.length &&
val.packageGoods?.packageCode == item?.packageId
)
?.packageGoods?.goodsList?.find(
subV => subV.merchantGoodsId == item.goodsId
)?.validMinSellPrice // 按商品数据对比补充详情商品校验最低价字段
}
let index = pre.findIndex(ele => {
if (ele.packageGoods) {
return ele.packageGoods.packageId == item.packageId
}
})
if (index != -1) {
pre[index].packageGoods.goodsList.push(obj)
pre[index].price = NP.plus(pre[index].price, obj.price)
} else {
pre.push({
goods: null,
goodsFlag: 3,
price: item.price,
packageGoods: {
...item,
packageCode: item.packageId,
goodsList: [{
...obj
}]
}
})
}
}
//多规格商品
if (!item.packageName && item.specificationsValue) {
let specificdata = this.handleSpecificationsEcho(item)
pre = pre.concat(specificdata)
}
return pre
}, [])
let keyList = ['mode', 'payee', 'payType', 'referrerId', 'referrer',
'deliveryId', 'deliveryName', 'notes', 'id', 'orderId'
], customerKeyList = ['owner', 'phone', 'certificateNo', 'carVin', 'seat', ,
'ownerGender', 'ageRange', 'hobby', 'companion', 'carColor', 'salesType', 'city']
keyList.map(key => {
if (data[key] != null) orderObj[key] = data[key]
})
customerKeyList.map(key => {
if (owner[key] != null) orderObj[key] = owner[key]
})
if (owner.id) orderObj.ownerId = owner.id
let payeeCell = this.formList[4].find(item => item.value === 'payee')
if (payeeCell) payeeCell.current = orderObj.payee
this.orderObj = orderObj
this.getConfig()
setTimeout(() => {
this.changeTotalPrice()
}, 0)
} catch (error) {
console.log(error)
uni.hideLoading()
if (error) uni.showToast({
title: error,
icon: 'none',
})
}
},
initData () {
// 埋点
// uni.$track.add({ eventCode: 'app_create_order' })
const { paramsData } = this
this.getSelectOrderGoodsList()
if (!paramsData.id) this.getConfig()
this.getShopMerchantPointConfig()
this.orderSettingList()
},
async orderSettingList () {
const { shopMerchantId } = this.userInfo,
params = {
scene: 0,
isRequired: 1,
merchantId: shopMerchantId
},
data = await uni.$api.equityApi.orderSettingList(params)
if (data) {
let required = data.reduce((pre, item) => {
if (item.isRequired) {
pre.push(item.fieldKey)
}
return pre
}, [])
if (required.includes('carBrand')) this.formList[2].map(e => {
if (e.value == 'carBrandText') e.required = true
})
if (required.includes('carNo')) this.formList[2].map(e => {
if (e.value == 'carVin') e.required = true
})
if (required.includes('idNumber')) this.formList[1].map(e => {
if (e.value == 'certificateNo') e.required = true
})
}
},
async getShopMerchantPointConfig () {
const { shopMerchantId: merchantId } = this.userInfo,
{ pointsMultiRole } = await uni.$api.equityApi.getShopMerchantPointConfig({
merchantId
})
this.pointsMultiRole = pointsMultiRole
if (pointsMultiRole != 'Y') this.formList[0].map(e => {
if (e.value == 'deliveryName') e.hidden = true
if (e.value == 'referrer') e.label = '推荐人'
})
},
// 选择行事件
handleCell (val) {
let { payType } = this.orderObj,
{ pointsMultiRole } = this
this.popupTitle = ''
// 获取当前选中的popupType
this.popupType = Object.keys(this.popupTypeEnum).find(key => this.popupTypeEnum[key].key === val.key) * 1
// 获取对应的list字段
const popupConfig = this.popupTypeEnum[this.popupType]
if (popupConfig && popupConfig.list) {
this.externalData = this[popupConfig.list] || []
} else {
this.externalData = []
}
// 定义产品相关字段数组
const productFields = ['skuGoods']
if (productFields.includes(val.value)) {
this.valueKey = val.value
this.externalData = utils.deepClone(this.goodsList)
}
this.popupTitle = {
0: pointsMultiRole == 'Y' ? '销售顾问/录单员' : '推荐人',
4: '车型',
13: payType == 2 ? '4S店收款时间' : '嘀加收款时间'
}[this.popupType]
this.$refs.orderPopup.open()
},
// 单选框change事件
radioChange (e, val) {
this.$set(this.orderObj, val.value, e.detail.value)
if (val.value == 'payee') this.changePayee()
},
// 弹窗确认回调
onConfirm (val, flag) {
console.log(JSON.parse(JSON.stringify(val)), 'onConfirm')
this.externalData = []
// // const { chooseContent } = val
const chooseContent = utils.deepClone(val.chooseContent)
// 根据popupTypeEnum优化处理
const _typeValue = this.popupTypeEnum[this.popupType]
console.log(_typeValue)
// 定义产品相关字段数组
if (val.popupType == 19) return this.setCustomerInfo(chooseContent)
const productFields = ['skuGoods']
if (_typeValue.key == 'carBrand') {
// 车型
this.$set(this.orderObj, 'carBrandText', `${chooseContent.carBrand}-${chooseContent.carChildsBrandName}-${chooseContent.carSeriesName}`)
Object.assign(this.orderObj, {
carInfo: chooseContent
})
}
else if (productFields.includes(_typeValue.key)) {
if (_typeValue.key == 'skuGoods') {
if (!this.orderObj.skuGoods) {
// 其他精品第一次赋值
this.$set(this.orderObj, 'skuGoods', chooseContent)
} else {
// 过滤出已选的goodFlag为2的对象
const selectedGoods = this.orderObj[_typeValue.key].filter(item => item.goodsFlag === 2)
const singleGoods = flag ? this.orderObj[_typeValue.key].filter(item => item.goodsFlag != 2) : chooseContent.filter(item => item.goodsFlag != 2)
const moreGoods = chooseContent
.filter(item => item.goodsFlag === 2)
.filter(item => {
return !selectedGoods.some(selectedItem => selectedItem.multipleSpecificationsGoods.goods.goodsId === item.multipleSpecificationsGoods.goods.goodsId)
})
console.log(singleGoods, '===')
// 合并已选的goodFlag为2的对象
this.orderObj.skuGoods = [...singleGoods, ...moreGoods, ...selectedGoods]
}
}
setTimeout(() => {
this.changeTotalPrice()
}, 0)
}
else {
if (_typeValue.key == 'city') {
this.$set(this.orderObj, 'provinceText', chooseContent.province)
this.$set(this.orderObj, 'cityText', chooseContent.city)
this.$set(this.orderObj, 'city', chooseContent.city == chooseContent.province ? chooseContent.city : `${chooseContent.province}-${chooseContent.city}`)
} else if (_typeValue.key == 'todayShow') {
this.$set(this.orderObj, 'pay2Time', chooseContent)
} else if (_typeValue.list == 'employeeList') {
this.$set(this.orderObj, _typeValue.targetIdKey, chooseContent[_typeValue.sourceIdKey])
this.$set(this.orderObj, _typeValue.targetNameKey, chooseContent[_typeValue.sourceNameKey])
} else this.$set(this.orderObj, _typeValue.key, chooseContent)
console.log(this.orderObj, 'this.orderObj')
}
console.log(this.orderObj)
},
// 输入框失去焦点事件
inputBlur (e, val) {
console.log(e, val)
if (val.value == 'price') {
this.orderObj[val.value] = parseFloat(this.orderObj[val.value]) > 2000000 ? 2000000 : this.orderObj[val.value]
return
}
this.orderObj[val.value] = this.orderObj[val.value]
// VIN车架号动态校验:车架号字段,动态转换为大写
if (val.value === 'carVin') this.validateVin()
},
validateVin () {
let carVinVal = this.orderObj.carVin;
if (carVinVal) {
this.orderObj.carVin = formatVinInput(carVinVal)
validateVin(this.orderObj.carVin).then(result => {
console.log("validateVin", result);
let { valid } = result.data;
this.validateState = valid
// 校验成功,所有提示已在公共方法中处理
console.log('车架号校验成功:', result)
}).catch(err => {
console.log("validateVinErr", result);
})
}
},
// 校验必填等规则
checkRequired () {
try {
const phoneRex = /^[1]([3-9])[0-9]{9}$/,
requiredArr = [],
onlyLabelItem = [],
{ orderObj } = this
this.formList.forEach(group => {
group.forEach(item => {
if (item.required === true && item.hidden !== true) {
if (item.isArray) onlyLabelItem.push(item)
else requiredArr.push(item)
}
})
})
// VIN车架号-动态校验
const carVin = this.orderObj.carVin
console.log("validateState", this.validateState);
if (carVin) {
// 前置判断
if (carVin.length !== 17) {
uni.showToast({ title: '请输入 17 位有效字符(支持大写 A-H/J-N/P-Z、0-9)', icon: 'none' })
return false
}
// 根据接口校验结果判断
if (carVin.length === 17 && !this.validateState) {
uni.showToast({ title: '车架号校验不匹配,请核对后重新输入', icon: 'none' })
return false
}
}
// 遍历requiredArr,检查orderObj中是否有对应的值
for (let i = 0; i < requiredArr.length; i++) {
const item = requiredArr[i]
// 兼容嵌套customer对象的情况
let value = orderObj[item.value]
if (value === undefined || value === null || value === '') throw `${item.label}不能为空`
// 如果是customerPhone,添加phoneRex校验
if (item.value === 'phone' && !phoneRex.test(value)) throw `请输入正确的${item.label}`
}
// if (orderObj.carVin) {
// if (!utils.validateVIN(orderObj.carVin)) throw '车架号校验不匹配,请核对后重新输入'
// }
if (onlyLabelItem.length) {
const labelFields = ['skuGoods']
const hasValue = labelFields.some(field => {
const value = orderObj[field]
return value !== undefined && value !== null && (Array.isArray(value) ? value.length > 0 : value !== '')
})
if (!hasValue) throw '请选择增值车损险商品'
}
if (orderObj.certificateNo && orderObj.certificateNo.length != 18) throw '请输入正确的18位证件号'
return true
} catch (error) {
if (error) uni.showToast({
title: error,
icon: 'none'
})
return false
}
},
// 提交
async submit () {
if (!this.checkRequired() || await this.checkDailyReport()) return
this.handleSecondConfirmCheck(true)
},
async handleSecondConfirmCheck (check) {
try {
let orderInfo = this.getInsurance(),
{ payType } = orderInfo
if (check &&
([2, 5, 6, 7].includes(+payType)) &&
!(orderInfo.transactionNo && orderInfo.paymentDocList.length)
) return this.showUpload = true
if (orderInfo.pay2Time && ![1, 3].includes(+payType)) orderInfo.pay2Time = dayjs(orderInfo.pay2Time).format('YYYY-MM-DD HH:mm:ss')
else delete orderInfo.pay2Time
uni.showLoading({
title: `${check ? '报价' : '保存'}中...`,
mask: true
})
orderInfo.check = check
let apiName = orderInfo.id ? 'updateQuotation' : 'quotationAdd'
const data = await uni.$api.equityApi[apiName](orderInfo)
this.saveStatus = false
if (data) {
this.showUpload = false
wx.hideLoading()
if (check) {
if ([2, 5, 6, 7].includes(+payType)) return this.$emit('jump', 'OrderManagement')
let status = await this.createWithPay(data)
if (status) this.$refs.OrderPay.open(data)
else throw false
} else this.$emit('jump', 'OrderManagement')
} else throw false
} catch (error) {
console.log(error)
this.saveStatus = false
uni.hideLoading()
uni.showToast({
title: '提交失败',
icon: 'none'
})
}
},
createWithPay (id) {
return new Promise((resolve, reject) => {
let para = {
id,
customerNameUrl: '',
orderStatus: 2
}
uni.$api.equityApi.quotationUpgrade(para).then(res => {
resolve(res)
})
})
},
getInsurance () {
let {
orderObj,
userInfo
} = this,
orderInfo = utils.deepClone(orderObj),
{
default4SStoreInfo
} = userInfo,
params = {
owner: {
...orderInfo.carInfo
}
}
if (orderInfo.id) params.id = orderInfo.id
params.merchantId4s = default4SStoreInfo?.merchantId
params.merchantName4s = default4SStoreInfo?.merchantName
orderInfo.price = this.multipliedByHundred(orderInfo.price)
params.insurancePrice = this.multipliedByHundred(
orderInfo.insurancePrice
)
params.quotedPriceUpdate = this.multipliedByHundred(
orderInfo.quotedPriceUpdate
)
params.minEquityPrice = this.multipliedByHundred(
orderInfo.minEquityPrice
)
params.vdQuotationGoodsList = orderInfo.skuGoods.reduce(
(pre, item) => {
if (item.goods) {
item = item.goods
const obj = {
goodsId: item.merchantGoodsId,
goodsName: item.goodsName,
goodsNameAlias: item.goodsAlias || item.goodsNameAlias,
specificationsName: item.specificationNameSequence,
specificationsValue: item.specificationData ?
item.specificationData.replace(/;~;/g, '/') : '',
goodsPrice: this.multipliedByHundred(item.sellPrice)
}
pre.push(obj)
}
if (item.packageGoods) {
item = item.packageGoods
item.goodsList.map(ele => {
let obj = {
packageId: item.packageCode,
packageName: item.packageName,
packageNameAlias: item.packageAlias || item.packageNameAlias,
goodsId: ele.merchantGoodsId || ele.upgradeGoodsId,
goodsName: ele.upgradeGoodsName || ele.goodsName,
goodsNameAlias: ele.goodsAlias || ele.goodsNameAlias,
specificationsName: ele.specificationNameSequence,
specificationsValue: ele.specificationData ?
ele.specificationData.replace(/;~;/g, '/') : '',
// specificationsValue: item.specificationData ? item.specificationData.replace(reg, ' ') : '',
goodsPrice: this.multipliedByHundred(ele.sellPrice)
}
pre.push(obj)
})
}
if (item.multipleSpecificationsGoods) {
if (item.multipleSpecificationsGoods.goods) {
item = item.multipleSpecificationsGoods.goods
const obj = {
goodsId: item.merchantGoodsId,
goodsName: item.upgradeGoodsName || item.goodsName,
goodsNameAlias: item.goodsAlias || item.goodsNameAlias,
specificationsName: item.specificationNameSequence,
specificationsValue: item.specificationData ?
item.specificationData.replace(/;~;/g, '/') : '',
goodsPrice: this.multipliedByHundred(item.sellPrice)
}
pre.push(obj)
}
}
return pre
},
[]
)
let keyList = ['mode', 'payee', 'payType', 'referrerId', 'referrer',
'deliveryId', 'deliveryName', 'total', 'notes', 'tradeNo',
'transactionNo', 'paymentDocList', 'id', 'orderId', 'pay2Time'
],
customerKeyList = [
'owner', 'phone', 'certificateNo', 'carVin', 'seat', 'price',
'ownerGender', 'city', 'ageRange', 'hobby', 'companion', 'carColor', 'salesType'
]
keyList.map(key => {
if (orderInfo[key] != null) params[key] = orderInfo[key]
})
customerKeyList.map(key => {
if (orderInfo[key] != null) params.owner[key] = orderInfo[key]
})
if (orderInfo.ownerId) params.owner.id = orderInfo.ownerId
return params
},
// 乘以100保留两位小数点
multipliedByHundred (str) {
let floatVal = parseFloat(str)
if (isNaN(floatVal)) {
return 0
}
floatVal = Math.round(str * 10000) / 100
let strVal = floatVal.toString()
let searchVal = strVal.indexOf('.')
if (searchVal < 0) {
searchVal = strVal.length
strVal += '.'
}
while (strVal.length <= searchVal + 2) {
strVal += '0'
}
return parseFloat(strVal)
},
// 计算所有产品的总价
changeTotalPrice () {
let total = 0
// 遍历所有商品
const productFields = ['skuGoods']
productFields.forEach(slotName => {
const productList = this.orderObj[slotName]
if (Array.isArray(productList) && productList.length > 0) {
// 计算每个产品的价格 * 数量,并累加到总价
productList.forEach(item => {
if (item.goods && item.goods.sellPrice && item.goods.number) {
console.log(item.goods, '---单商品')
total = NP.plus(total, NP.times(item.goods.sellPrice, item.goods.number))
} else if (item.packageGoods && item.packageGoods.totalPrice) {
console.log(item.packageGoods, '套餐')
item.packageGoods.goodsList.map(i => {
total = NP.plus(total, i.sellPrice * i.number)
})
} else if (item.multipleSpecificationsGoods && item.multipleSpecificationsGoods.goods && item.multipleSpecificationsGoods.goods.sellPrice) {
console.log(item.multipleSpecificationsGoods, '多规格')
total = NP.plus(total, NP.times(item.multipleSpecificationsGoods.goods.sellPrice, item.multipleSpecificationsGoods.number || 1))
}
})
}
})
console.log(total, 'total')
// 更新总价
this.orderObj.total = total.toFixed(2)
},
// 获取园区店支付方式
async getConfig () {
this.djPayList = [
{
value: '1',
name: '微信支付'
},
{
name: '对公转账',
value: '6'
},
{
name: '其它收款',
value: '7'
},
]
this.merchantPayList = [{
value: '2',
name: '门店收款'
},]
this.changePayee()
},
changePayee () {
const cell = this.formList[4].find(item => item.value === 'payType'),
{ payType } = this.orderObj
if (cell) {
cell.radioList = this.orderObj.payee == 1 ? this.merchantPayList : this.djPayList
let index = cell.radioList.findIndex(i => i.value == payType)
if (index == -1) index = 0
if (cell.radioList && cell.radioList.length > 0) {
cell.current = cell.radioList[index].value
// 使用 $set 确保响应式更新
this.$set(this.orderObj, 'payType', cell.radioList[index].value)
}
}
},
// 商品列表
async getSelectOrderGoodsList () {
const { userInfo, paramsData } = this
if (paramsData.id) uni.showLoading({
title: '加载中...',
mask: true
})
const res = await uni.$api.boutiqueApi.getSelectOrderGoodsList({
merchantId: userInfo.shopMerchantId,
sceneType: userInfo.sceneType
})
this.goodsList = res
this.changeTotalPrice()
if (paramsData.id) this.getQuotationInfoById(paramsData.id)
},
handleSpecificationsEcho (item) {
console.log('item', item)
let {
goodsList: quotationGoodsList
} = this, skuArr = [],
arr = item.specificationsValue.split('/'),
str = arr.join(';~;');
quotationGoodsList.forEach(data => {
if (data.goodsFlag == 2) {
let tempData = data.multipleSpecificationsGoods.specificationGoodsMap[str]
if (tempData) {
tempData.forEach(temp => {
if (temp.merchantGoodsId == item.goodsId) {
let obj = {
goodsFlag: 2,
goods: null,
}
obj.multipleSpecificationsGoods = {
goods: temp,
baseGoodsName: item.goodsName
}
temp.price = this.divideByHundred(item.goodsPrice)
temp.goodsId = item.goodsId
temp.specificationStr = item.specificationsValue
console.log('🚀', obj)
skuArr.push(obj)
}
})
}
}
})
return skuArr
},
uploadConfirm ({
payVoucherList,
outTradeNo
}) {
let paymentDocList = []
payVoucherList.map(e => {
paymentDocList.push({
paymentDocUrl: e,
type: 1
})
})
this.orderObj.transactionNo = outTradeNo
this.orderObj.tradeNo = outTradeNo
this.orderObj.paymentDocList = paymentDocList
this.submit()
},
setCustomerInfo (customerInfo) {
const { orderObj } = this,
ownerGender = customerInfo.customerSex != 2 ? '男' : '女',
salesType = customerInfo.salesType || '0',
city = customerInfo.customerCity
Object.assign(orderObj, {
customerId: customerInfo.id,
owner: customerInfo.customerName,
phone: customerInfo.customerPhone,
ownerGender,
seat: customerInfo.carSeat || 5,
ageRange: customerInfo.customerAgeRange,
hobby: customerInfo.customerHobby,
companion: customerInfo.customerCompanion,
certificateNo: customerInfo.customerCertificateNo || '',
salesType,
carVin: customerInfo.carVin || '',
carColor: customerInfo.carColor || '',
})
this.formList[1].map(e => {
if (e.value == 'salesType') e.current = salesType
if (e.value == 'ownerGender') e.current = ownerGender
})
if (city) {
let [provinceText, cityText] = city.split('-')
if (cityText) {
orderObj.provinceText = provinceText
orderObj.cityText = cityText
} else {
orderObj.provinceText = city
orderObj.cityText = city
}
orderObj.city = city
}
if (customerInfo.carPrice) orderObj.price = this.divideByHundred(customerInfo.carPrice)
if (customerInfo.salesUuid) {
orderObj.referrerId = customerInfo.salesUuid
orderObj.referrer = customerInfo.salesName
}
if (customerInfo.carSeriesName) {
orderObj.carInfo = {
carBrand: customerInfo.carBrand,
carBrandId: customerInfo.carBrandId,
carChildsBrandId: customerInfo.carChildsBrandId,
carChildsBrandName: customerInfo.carChildsBrandName,
carSeriesId: customerInfo.carSeriesId,
carSeriesName: customerInfo.carSeriesName,
}
orderObj.carBrandText = `${customerInfo.carBrand}-${customerInfo.carChildsBrandName}-${customerInfo.carSeriesName}`
}
this.orderObj = orderObj
this.formKey = Date.now()
this.validateVin()
console.log(this.orderObj)
},
jumpSuccess (params) {
this.$emit('jump', 'OrderDetail', params)
},
async handleEditSave () {
let {
saveStatus
} = this
if (saveStatus) return false
this.saveStatus = true
this.handleSecondConfirmCheck(false)
},
divideByHundred: str => {
let floatVal = parseFloat(str)
if (isNaN(floatVal)) {
return 0
}
floatVal = Math.round(str * 100) / 10000
let strVal = floatVal.toString()
let searchVal = strVal.indexOf('.')
if (searchVal < 0) {
searchVal = strVal.length
strVal += '.'
}
while (strVal.length <= searchVal + 2) {
strVal += '0'
}
return parseFloat(strVal)
},
closePopup () {
this.$emit('jump', 'OrderManagement')
},
clearPayMentDocList () {
this.showUpload = false
this.orderObj.paymentDocList = []
this.orderObj.transactionNo = ''
}
}
}
</script>
<style scoped lang="scss">
.order {
height: 100%;
position: relative;
&-box {
visibility: visible;
height: 100%;
}
.hide {
opacity: 0;
visibility: hidden;
}
.upload-box {
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 100%;
}
}
.box {
height: calc(100% - #{toRpx(120)});
padding-bottom: toRpx(24);
.scroll-view {
height: 100%;
}
}
.box-content {
padding: 0 toRpx(48);
}
.total {
display: flex;
justify-content: space-between;
align-items: center;
padding: toRpx(24) toRpx(32) toRpx(24) 0;
font-size: toRpx(28);
border-bottom: toRpx(2) solid #f7f7f6;
&-left {
color: #333;
font-weight: 500;
}
&-right {
color: #f24724;
font-weight: 500;
}
}
.pay-tips {
padding: toRpx(24) toRpx(24) toRpx(24) 0;
font-size: toRpx(24);
color: #999;
}
.btns {
padding: toRpx(24) toRpx(128);
gap: toRpx(32);
.save {
background: #3b73ff1a;
color: #4673ff;
font-size: toRpx(28);
font-weight: 500;
}
}
.btn {
display: flex;
align-items: center;
justify-content: center;
width: toRpx(1130);
height: toRpx(80);
color: #fff;
border-radius: toRpx(48);
background: linear-gradient(0deg, #2c66f7 0%, #48a6ff 100%);
}
.customer-title {
.customer-file {
margin-left: toRpx(20);
color: #347bff;
font-size: toRpx(24);
.sprite-icon {
margin-right: toRpx(4);
}
}
}
</style>
<template>
<view>
<view class="shop-list">
<view
class="shop-item"
v-for="(item, index) in list"
:key="index"
>
<template v-if="item.goodsFlag == 3">
<view class="package-box">
<view class="shop-name flex">
<view
class="sprite-icon icon-blue-delete"
@click="deleteGoods(index)"
></view>
<view class="name">{{ goodsName(item) }}</view>
<view class="total-price">{{packageTotal(item)}}</view>
</view>
<view class="line"></view>
<view class="package-goods-list">
<template v-for="(i,ind) in item.packageGoods.goodsList">
<view
class="package-item flex"
:key="`package_${index}_${ind}`"
>
<view class="package-icon"></view>
<view class="package-label">{{packageName(i,item)}}</view>
<view class="package-value flex">
<template v-if="i.goodsPriceModify">
<view class="package-price">¥{{i.sellPrice}}</view>
</template>
<template v-else>
<view class="front-gear-input flex">
<view class="unit">¥</view>
<input
class="uni-input"
type="digit"
maxlength="9"
placeholder="请输入价格"
placeholder-style="font-size: 14px"
v-model="i.sellPrice"
@blur="validatePrice($event, item, index, ind)"
/>
</view>
</template>
<view class="number">x1</view>
</view>
</view>
</template>
</view>
</view>
</template>
<template v-else>
<view
class="sprite-icon icon-blue-delete"
@click="deleteGoods(index)"
></view>
<view :class="['right',{'one-line':item.goodsFlag == 1}]">
<view :class="['shop-name',{'name-top':item.goodsFlag == 2}]">{{ goodsName(item) }}</view>
<view
class="alias"
v-if="item.multipleSpecificationsGoods && item.multipleSpecificationsGoods.goods.goodsAlias"
>商品别名:{{
item.multipleSpecificationsGoods.goods.goodsAlias }}</view>
<view class="front-gear-box">
<view class="front-gear-input-box">
<template v-if="item.multipleSpecificationsGoods && item.multipleSpecificationsGoods.goods.specificationStr">
<view class="front-gear-label">
{{item.multipleSpecificationsGoods.goods.specificationStr}}
</view>
</template>
<view class="front-number-box flex">
<template v-if="item.goodsFlag == 1">
<template v-if="item.goods.goodsPriceModify">
¥{{item.goods.sellPrice}}
</template>
<template v-else>
<view class="front-gear-input">
<view class="unit">¥</view>
<input
class="uni-input"
type="digit"
maxlength="9"
placeholder="请输入价格"
placeholder-style="font-size: 14px"
v-model="item.goods.sellPrice"
@blur="validatePrice($event, item, index)"
/>
</view>
</template>
</template>
<template v-else>
<template v-if="item.multipleSpecificationsGoods.goods.goodsPriceModify">
¥{{item.multipleSpecificationsGoods.goods.sellPrice}}
</template>
<template v-else>
<view class="front-gear-input">
<view class="unit">¥</view>
<input
class="uni-input"
type="digit"
maxlength="9"
placeholder="请输入价格"
placeholder-style="font-size: 14px"
v-model="item.multipleSpecificationsGoods.goods.sellPrice"
@blur="validatePrice($event, item, index)"
/>
</view>
</template>
</template>
<view class="number">
x1
</view>
</view>
</view>
</view>
</view>
</template>
</view>
</view>
</view>
</template>
<script>
import NP from 'number-precision'
export default {
name: 'SkuGoods',
props: {
list: {
type: Array,
default: []
},
positionTypeList: {
type: Array,
default: []
},
baseConfigData: {
type: Object,
default: {}
}
},
created () {
// 初始化商品数量
this.initProductNumbers()
},
mounted () {
// 确保每次使用组件时都检查并设置number属性
this.initProductNumbers()
},
updated () {
// 当组件数据更新时也检查number属性
this.initProductNumbers()
},
computed: {
},
methods: {
goodsName (item) {
let { goodsFlag } = item,
str = ''
if (goodsFlag == 3) str = item.packageGoods.packageAlias || item.packageGoods.packageName
else str = item.multipleSpecificationsGoods ?
item.multipleSpecificationsGoods.baseGoodsName : item.goods.goodsAlias || item.goods.upgradeGoodsName ||
item.goods.goodsInfo.goodsName
return str
},
// 初始化商品数量方法
initProductNumbers () {
if (this.list && this.list.length > 0) {
this.list.forEach(item => {
if (!item.multipleSpecificationsGoods) {
// 如果没有多规格商品,直接设置goods的number
if (item.goodsFlag == 1 && !item.goods.number) {
this.$set(item.goods, 'number', '1')
}
} else if (item.multipleSpecificationsGoods) {
// 如果有多规格商品,给multipleSpecificationsGoods中的goods添加number
if (!item.multipleSpecificationsGoods.number) {
this.$set(item.multipleSpecificationsGoods, 'number', '1')
}
}
})
}
},
filterIncludes (item, arr) {
return arr.indexOf(item) > -1
},
// 格式化位置信息
formatPosition (item, positionTypeList) {
const filterData = positionTypeList.filter(v => v.positionValue == item)
return (filterData.length && filterData[0] && filterData[0].positionName) || ''
},
// 验证价格输入
validatePrice (event, item, index, cindex) {
let value = event.detail.value
// 如果为空则设置为0
if (!value || value.trim() === '') {
value = '0'
}
// 限制只能输入数字和小数点
value = value.replace(/[^\d.]/g, '')
// 限制只能有一个小数点
if (value.split('.').length > 2) {
value = value.slice(0, value.lastIndexOf('.')) + value.slice(value.lastIndexOf('.') + 1)
}
// 限制最多两位小数
if (value.includes('.')) {
const parts = value.split('.')
if (parts[1].length > 2) {
parts[1] = parts[1].substring(0, 2)
value = parts.join('.')
}
}
// 限制最 大值为100000
if (parseFloat(value) > 100000) {
value = '100000'
}
// 限制最小值为0
if (parseFloat(value) < 0 || parseFloat(value) == 0) {
value = '0'
}
// 检查最小价格
// if (!item.multipleSpecificationsGoods) {
// // 普通商品的最小价格检查
// if (item.goods.validMinSellPrice === 'Y' && item.goods.minSellPrice && parseFloat(value) < parseFloat(item.goods.minSellPrice)) {
// uni.showToast({
// title: '单价不可低于商品最低价',
// icon: 'none'
// })
// value = item.goods.minSellPrice.toString()
// }
// } else if (item.multipleSpecificationsGoods && item.multipleSpecificationsGoods.goods) {
// // 多规格商品的最小价格检查
// if (item.multipleSpecificationsGoods.goods.validMinSellPrice === 'Y' && item.multipleSpecificationsGoods.goods.minSellPrice && parseFloat(value) < parseFloat(item.multipleSpecificationsGoods.goods.minSellPrice)) {
// uni.showToast({
// title: '单价不可低于商品最低价',
// icon: 'none'
// })
// value = item.multipleSpecificationsGoods.goods.minSellPrice.toString()
// }
// }
if (!item.multipleSpecificationsGoods) {
if (item.goodsFlag == 1) {
//如果没有多规格商品,更新普通商品的价格
this.$set(this.list[index].goods, 'sellPrice', value)
} else {
this.$set(this.list[index].packageGoods.goodsList[cindex], 'sellPrice', value)
}
} else if (item.multipleSpecificationsGoods && item.multipleSpecificationsGoods.goods) {
// 如果有多规格商品,更新多规格商品的价格
this.$set(this.list[index].multipleSpecificationsGoods.goods, 'sellPrice', value)
}
this.$emit('changeTotalPrice')
},
// 验证数量输入
validateNumber (event, item) {
let value = event.detail.value
// 限制只能输入整数
value = value.replace(/[^\d]/g, '')
// 如果为空或0,设置为1
if (!value || value.trim() === '' || parseInt(value) === 0) {
value = '1'
}
// 更新值
if (!item.multipleSpecificationsGoods) {
this.$set(item.goods, 'number', value)
} else if (item.multipleSpecificationsGoods) {
// 强制更新多规格商品的数量
this.$set(item.multipleSpecificationsGoods, 'number', value)
}
this.$emit('changeTotalPrice')
},
// 增加数量
increaseNumber (item) {
if (!item.multipleSpecificationsGoods) {
// 处理普通商品
if (!item.goods.number) {
this.$set(item.goods, 'number', '1')
} else {
const currentValue = parseInt(item.goods.number)
// 限制最大数量为999
const newValue = currentValue >= 999 ? 999 : currentValue + 1
this.$set(item.goods, 'number', newValue.toString())
}
} else if (item.multipleSpecificationsGoods) {
// 处理多规格商品
if (!item.multipleSpecificationsGoods.number) {
this.$set(item.multipleSpecificationsGoods, 'number', '1')
} else {
const currentValue = parseInt(item.multipleSpecificationsGoods.number)
// 限制最大数量为999
const newValue = currentValue >= 999 ? 999 : currentValue + 1
this.$set(item.multipleSpecificationsGoods, 'number', newValue.toString())
}
}
this.$emit('changeTotalPrice')
},
// 减少数量
decreaseNumber (item) {
if (!item.multipleSpecificationsGoods) {
// 处理普通商品
// 如果商品数量不存在或小于等于1,设置为1
if (!item.goods.number || parseInt(item.goods.number) <= 1) {
this.$set(item.goods, 'number', '1')
return
}
const currentValue = parseInt(item.goods.number)
// 确保减少后的值不小于1
const newValue = Math.max(1, currentValue - 1)
this.$set(item.goods, 'number', newValue.toString())
} else if (item.multipleSpecificationsGoods) {
// 处理多规格商品
// 如果商品数量不存在或小于等于1,设置为1
if (!item.multipleSpecificationsGoods.number || parseInt(item.multipleSpecificationsGoods.number) <= 1) {
this.$set(item.multipleSpecificationsGoods, 'number', '1')
return
}
const currentValue = parseInt(item.multipleSpecificationsGoods.number)
// 确保减少后的值不小于1
const newValue = Math.max(1, currentValue - 1)
this.$set(item.multipleSpecificationsGoods, 'number', newValue.toString())
}
this.$emit('changeTotalPrice')
},
// 删除商品
deleteGoods (index) {
this.list.splice(index, 1)
this.$emit('changeTotalPrice')
},
replaceItemText (value) {
let reg = getRegExp(';~;', 'g')
return value ? value.replace(reg, '/') : ''
},
packageName (item, parent) {
return item.goodsAlias
|| item.goodsNameAlias
|| this.replaceItemText(item.upgradeGoodsName, (parent.specificationData ? '/' + item.specificationData : ''))
|| this.replaceItemText(item.goodsName, (parent.specificationData ? '/' + item.specificationData : ''))
},
packageTotal (item) {
let total = 0
item.packageGoods.goodsList.map(i => {
total = NP.plus(total, i.sellPrice * i.number)
})
item.packageGoods.totalPrice = total
return total
},
}
}
</script>
<style scoped lang="scss">
.shop-list {
padding-right: toRpx(32);
.shop-item {
display: flex;
align-items: center;
background-color: #f5f7fa;
border-radius: toRpx(16);
margin-top: toRpx(16);
padding: toRpx(24);
.right {
flex: 1;
font-size: toRpx(28);
margin-left: toRpx(24);
position: relative;
}
.one-line {
display: flex;
align-items: center;
min-height: toRpx(72);
.front-gear-box {
margin-left: auto;
}
}
.shop-name {
color: #ff781f;
max-width: 70%;
word-break: break-all;
}
.name-top {
margin-top: toRpx(4);
}
.alias {
margin-top: toRpx(12);
font-size: toRpx(24);
color: #666;
}
.package-box {
width: 100%;
.shop-name {
width: 100%;
max-width: 100%;
.name {
max-width: 70%;
}
.total-price {
margin-left: auto;
color: #292d33;
font-size: toRpx(28);
font-weight: 400;
}
}
.line {
width: calc(100% + #{toRpx(48)});
margin-left: toMinusRpx(24);
height: toRpx(2);
background-color: #dce1e6;
margin-top: toRpx(24);
}
.package-item {
margin-top: toRpx(16);
}
.sprite-icon {
margin-right: toRpx(24);
flex-shrink: 0;
}
.package-icon {
width: toRpx(12);
height: toRpx(12);
border-radius: 50%;
background: #4673ff;
margin-right: toRpx(16);
}
.package-label {
color: #292d33;
font-size: toRpx(28);
flex-shrink: 0;
max-width: 80%;
}
.package-value {
flex-shrink: 0;
margin-left: auto;
}
}
.number {
margin-left: toRpx(16);
}
.front-number-box{
position: absolute;
top: 50%;
right: toRpx(24);
transform: translateY(-50%);
}
}
}
.front-gear-input-box {
display: flex;
align-items: center;
width: 100%;
.front-gear-label {
font-size: toRpx(24);
margin-right: toRpx(24);
color: #999999;
}
}
.front-gear-input {
margin-left: auto;
position: relative;
display: flex;
border: toRpx(2) solid #eff0f2;
background-color: #fff;
font-size: toRpx(28);
height: toRpx(72);
width: toRpx(250);
line-height: toRpx(70);
text-align: right;
border-radius: toRpx(12);
.uni-input {
padding: 0 toRpx(32);
height: 100%;
font-size: toRpx(28);
}
.unit {
position: absolute;
top: 50%;
left: toRpx(24);
transform: translateY(-50%);
}
}
.front-gear-box {
display: flex;
justify-content: space-between;
.control {
display: flex;
align-items: center;
.control-input {
width: toRpx(94);
height: toRpx(74);
background-color: #fff;
border: toRpx(2) solid #eff0f2;
padding: 0 toRpx(10);
text-align: center;
}
.minus,
.add {
width: toRpx(80);
height: toRpx(74);
line-height: toRpx(70);
text-align: center;
background-color: #fff;
border-top: toRpx(2) solid #eff0f2;
border-bottom: toRpx(2) solid #eff0f2;
}
.minus {
border-radius: toRpx(12) 0 0 toRpx(12);
border-left: toRpx(2) solid #eff0f2;
}
.add {
border-radius: 0 toRpx(12) toRpx(12) 0;
border-right: toRpx(2) solid #eff0f2;
}
}
}
<template>
<view>
<view class="shop-list">
<view
class="shop-item"
v-for="(item, index) in list"
:key="index"
>
<template v-if="item.goodsFlag == 3">
<view class="package-box">
<view class="shop-name flex">
<view
class="sprite-icon icon-blue-delete"
@click="deleteGoods(index)"
></view>
<view class="name">{{ goodsName(item) }}</view>
<view class="total-price">{{packageTotal(item)}}</view>
</view>
<view class="line"></view>
<view class="package-goods-list">
<template v-for="(i,ind) in item.packageGoods.goodsList">
<view
class="package-item flex"
:key="`package_${index}_${ind}`"
>
<view class="package-icon"></view>
<view class="package-label">{{packageName(i,item)}}</view>
<view class="package-value flex">
<template v-if="i.goodsPriceModify">
<view class="package-price">¥{{i.sellPrice}}</view>
</template>
<template v-else>
<view class="front-gear-input flex">
<view class="unit">¥</view>
<input
class="uni-input"
type="digit"
maxlength="9"
placeholder="请输入价格"
placeholder-style="font-size: 14px"
v-model="i.sellPrice"
@blur="validatePrice($event, item, index, ind)"
/>
</view>
</template>
<view class="number">x1</view>
</view>
</view>
</template>
</view>
</view>
</template>
<template v-else>
<view
class="sprite-icon icon-blue-delete"
@click="deleteGoods(index)"
></view>
<view :class="['right',{'one-line':item.goodsFlag == 1}]">
<view :class="['shop-name',{'name-top':item.goodsFlag == 2}]">{{ goodsName(item) }}</view>
<view
class="alias"
v-if="item.multipleSpecificationsGoods && item.multipleSpecificationsGoods.goods.goodsAlias"
>商品别名:{{
item.multipleSpecificationsGoods.goods.goodsAlias }}</view>
<view class="front-gear-box">
<view class="front-gear-input-box">
<template v-if="item.multipleSpecificationsGoods && item.multipleSpecificationsGoods.goods.specificationStr">
<view class="front-gear-label">
{{item.multipleSpecificationsGoods.goods.specificationStr}}
</view>
</template>
<view class="front-number-box flex">
<template v-if="item.goodsFlag == 1">
<template v-if="item.goods.goodsPriceModify">
¥{{item.goods.sellPrice}}
</template>
<template v-else>
<view class="front-gear-input">
<view class="unit">¥</view>
<input
class="uni-input"
type="digit"
maxlength="9"
placeholder="请输入价格"
placeholder-style="font-size: 14px"
v-model="item.goods.sellPrice"
@blur="validatePrice($event, item, index)"
/>
</view>
</template>
</template>
<template v-else>
<template v-if="item.multipleSpecificationsGoods.goods.goodsPriceModify">
¥{{item.multipleSpecificationsGoods.goods.sellPrice}}
</template>
<template v-else>
<view class="front-gear-input">
<view class="unit">¥</view>
<input
class="uni-input"
type="digit"
maxlength="9"
placeholder="请输入价格"
placeholder-style="font-size: 14px"
v-model="item.multipleSpecificationsGoods.goods.sellPrice"
@blur="validatePrice($event, item, index)"
/>
</view>
</template>
</template>
<view class="number">
x1
</view>
</view>
</view>
</view>
</view>
</template>
</view>
</view>
</view>
</template>
<script>
import NP from 'number-precision'
export default {
name: 'SkuGoods',
props: {
list: {
type: Array,
default: []
},
positionTypeList: {
type: Array,
default: []
},
baseConfigData: {
type: Object,
default: {}
}
},
created () {
// 初始化商品数量
this.initProductNumbers()
},
mounted () {
// 确保每次使用组件时都检查并设置number属性
this.initProductNumbers()
},
updated () {
// 当组件数据更新时也检查number属性
this.initProductNumbers()
},
computed: {
},
methods: {
goodsName (item) {
let { goodsFlag } = item,
str = ''
if (goodsFlag == 3) str = item.packageGoods.packageAlias || item.packageGoods.packageName
else str = item.multipleSpecificationsGoods ?
item.multipleSpecificationsGoods.baseGoodsName : item.goods.goodsAlias || item.goods.upgradeGoodsName ||
item.goods.goodsInfo.goodsName
return str
},
// 初始化商品数量方法
initProductNumbers () {
if (this.list && this.list.length > 0) {
this.list.forEach(item => {
if (!item.multipleSpecificationsGoods) {
// 如果没有多规格商品,直接设置goods的number
if (item.goodsFlag == 1 && !item.goods.number) {
this.$set(item.goods, 'number', '1')
}
} else if (item.multipleSpecificationsGoods) {
// 如果有多规格商品,给multipleSpecificationsGoods中的goods添加number
if (!item.multipleSpecificationsGoods.number) {
this.$set(item.multipleSpecificationsGoods, 'number', '1')
}
}
})
}
},
filterIncludes (item, arr) {
return arr.indexOf(item) > -1
},
// 格式化位置信息
formatPosition (item, positionTypeList) {
const filterData = positionTypeList.filter(v => v.positionValue == item)
return (filterData.length && filterData[0] && filterData[0].positionName) || ''
},
// 验证价格输入
validatePrice (event, item, index, cindex) {
let value = event.detail.value
// 如果为空则设置为0
if (!value || value.trim() === '') {
value = '0'
}
// 限制只能输入数字和小数点
value = value.replace(/[^\d.]/g, '')
// 限制只能有一个小数点
if (value.split('.').length > 2) {
value = value.slice(0, value.lastIndexOf('.')) + value.slice(value.lastIndexOf('.') + 1)
}
// 限制最多两位小数
if (value.includes('.')) {
const parts = value.split('.')
if (parts[1].length > 2) {
parts[1] = parts[1].substring(0, 2)
value = parts.join('.')
}
}
// 限制最 大值为100000
if (parseFloat(value) > 100000) {
value = '100000'
}
// 限制最小值为0
if (parseFloat(value) < 0 || parseFloat(value) == 0) {
value = '0'
}
// 检查最小价格
if (!item.multipleSpecificationsGoods) {
if (item.packageGoods) {
item.packageGoods?.goodsList[cindex]
let packageItem = item.packageGoods?.goodsList[cindex]
if (packageItem && packageItem.validMinSellPrice === 'N' && packageItem.minSellPrice && parseFloat(value) < parseFloat(packageItem.minSellPrice)) {
uni.showToast({
title: '价格不可低于商品最低价',
icon: 'none'
})
value = packageItem.minSellPrice.toString()
}
} else {
// 普通商品的最小价格检查
if (item.goods.validMinSellPrice === 'Y' && item.goods.minSellPrice && parseFloat(value) < parseFloat(item.goods.minSellPrice)) {
uni.showToast({
title: '价格不可低于商品最低价',
icon: 'none'
})
value = item.goods.minSellPrice.toString()
}
}
} else if (item.multipleSpecificationsGoods && item.multipleSpecificationsGoods.goods) {
// 多规格商品的最小价格检查
if (item.multipleSpecificationsGoods.goods.validMinSellPrice === 'Y' && item.multipleSpecificationsGoods.goods.minSellPrice && parseFloat(value) < parseFloat(item.multipleSpecificationsGoods.goods.minSellPrice)) {
uni.showToast({
title: '价格不可低于商品最低价',
icon: 'none'
})
value = item.multipleSpecificationsGoods.goods.minSellPrice.toString()
}
}
if (!item.multipleSpecificationsGoods) {
if (item.goodsFlag == 1) {
//如果没有多规格商品,更新普通商品的价格
this.$set(this.list[index].goods, 'sellPrice', value)
} else {
this.$set(this.list[index].packageGoods.goodsList[cindex], 'sellPrice', value)
}
} else if (item.multipleSpecificationsGoods && item.multipleSpecificationsGoods.goods) {
// 如果有多规格商品,更新多规格商品的价格
this.$set(this.list[index].multipleSpecificationsGoods.goods, 'sellPrice', value)
}
this.$emit('changeTotalPrice')
},
// 验证数量输入
validateNumber (event, item) {
let value = event.detail.value
// 限制只能输入整数
value = value.replace(/[^\d]/g, '')
// 如果为空或0,设置为1
if (!value || value.trim() === '' || parseInt(value) === 0) {
value = '1'
}
// 更新值
if (!item.multipleSpecificationsGoods) {
this.$set(item.goods, 'number', value)
} else if (item.multipleSpecificationsGoods) {
// 强制更新多规格商品的数量
this.$set(item.multipleSpecificationsGoods, 'number', value)
}
this.$emit('changeTotalPrice')
},
// 增加数量
increaseNumber (item) {
if (!item.multipleSpecificationsGoods) {
// 处理普通商品
if (!item.goods.number) {
this.$set(item.goods, 'number', '1')
} else {
const currentValue = parseInt(item.goods.number)
// 限制最大数量为999
const newValue = currentValue >= 999 ? 999 : currentValue + 1
this.$set(item.goods, 'number', newValue.toString())
}
} else if (item.multipleSpecificationsGoods) {
// 处理多规格商品
if (!item.multipleSpecificationsGoods.number) {
this.$set(item.multipleSpecificationsGoods, 'number', '1')
} else {
const currentValue = parseInt(item.multipleSpecificationsGoods.number)
// 限制最大数量为999
const newValue = currentValue >= 999 ? 999 : currentValue + 1
this.$set(item.multipleSpecificationsGoods, 'number', newValue.toString())
}
}
this.$emit('changeTotalPrice')
},
// 减少数量
decreaseNumber (item) {
if (!item.multipleSpecificationsGoods) {
// 处理普通商品
// 如果商品数量不存在或小于等于1,设置为1
if (!item.goods.number || parseInt(item.goods.number) <= 1) {
this.$set(item.goods, 'number', '1')
return
}
const currentValue = parseInt(item.goods.number)
// 确保减少后的值不小于1
const newValue = Math.max(1, currentValue - 1)
this.$set(item.goods, 'number', newValue.toString())
} else if (item.multipleSpecificationsGoods) {
// 处理多规格商品
// 如果商品数量不存在或小于等于1,设置为1
if (!item.multipleSpecificationsGoods.number || parseInt(item.multipleSpecificationsGoods.number) <= 1) {
this.$set(item.multipleSpecificationsGoods, 'number', '1')
return
}
const currentValue = parseInt(item.multipleSpecificationsGoods.number)
// 确保减少后的值不小于1
const newValue = Math.max(1, currentValue - 1)
this.$set(item.multipleSpecificationsGoods, 'number', newValue.toString())
}
this.$emit('changeTotalPrice')
},
// 删除商品
deleteGoods (index) {
this.list.splice(index, 1)
this.$emit('changeTotalPrice')
},
replaceItemText (value) {
let reg = getRegExp(';~;', 'g')
return value ? value.replace(reg, '/') : ''
},
packageName (item, parent) {
return item.goodsAlias
|| item.goodsNameAlias
|| this.replaceItemText(item.upgradeGoodsName, (parent.specificationData ? '/' + item.specificationData : ''))
|| this.replaceItemText(item.goodsName, (parent.specificationData ? '/' + item.specificationData : ''))
},
packageTotal (item) {
let total = 0
item.packageGoods.goodsList.map(i => {
total = NP.plus(total, i.sellPrice * i.number)
})
item.packageGoods.totalPrice = total
return total
},
}
}
</script>
<style scoped lang="scss">
.shop-list {
padding-right: toRpx(32);
.shop-item {
display: flex;
align-items: center;
background-color: #f5f7fa;
border-radius: toRpx(16);
margin-top: toRpx(16);
padding: toRpx(24);
.right {
flex: 1;
font-size: toRpx(28);
margin-left: toRpx(24);
position: relative;
}
.one-line {
display: flex;
align-items: center;
min-height: toRpx(72);
.front-gear-box {
margin-left: auto;
}
}
.shop-name {
color: #ff781f;
max-width: 70%;
word-break: break-all;
}
.name-top {
margin-top: toRpx(4);
}
.alias {
margin-top: toRpx(12);
font-size: toRpx(24);
color: #666;
}
.package-box {
width: 100%;
.shop-name {
width: 100%;
max-width: 100%;
.name {
max-width: 70%;
}
.total-price {
margin-left: auto;
color: #292d33;
font-size: toRpx(28);
font-weight: 400;
}
}
.line {
width: calc(100% + #{toRpx(48)});
margin-left: toMinusRpx(24);
height: toRpx(2);
background-color: #dce1e6;
margin-top: toRpx(24);
}
.package-item {
margin-top: toRpx(16);
}
.sprite-icon {
margin-right: toRpx(24);
flex-shrink: 0;
}
.package-icon {
width: toRpx(12);
height: toRpx(12);
border-radius: 50%;
background: #4673ff;
margin-right: toRpx(16);
}
.package-label {
color: #292d33;
font-size: toRpx(28);
flex-shrink: 0;
max-width: 80%;
}
.package-value {
flex-shrink: 0;
margin-left: auto;
}
}
.number {
margin-left: toRpx(16);
}
.front-number-box {
position: absolute;
top: 50%;
right: toRpx(24);
transform: translateY(-50%);
}
}
}
.front-gear-input-box {
display: flex;
align-items: center;
width: 100%;
.front-gear-label {
font-size: toRpx(24);
margin-right: toRpx(24);
color: #999999;
}
}
.front-gear-input {
margin-left: auto;
position: relative;
display: flex;
border: toRpx(2) solid #eff0f2;
background-color: #fff;
font-size: toRpx(28);
height: toRpx(72);
width: toRpx(250);
line-height: toRpx(70);
text-align: right;
border-radius: toRpx(12);
.uni-input {
padding: 0 toRpx(32);
height: 100%;
font-size: toRpx(28);
}
.unit {
position: absolute;
top: 50%;
left: toRpx(24);
transform: translateY(-50%);
}
}
.front-gear-box {
display: flex;
justify-content: space-between;
.control {
display: flex;
align-items: center;
.control-input {
width: toRpx(94);
height: toRpx(74);
background-color: #fff;
border: toRpx(2) solid #eff0f2;
padding: 0 toRpx(10);
text-align: center;
}
.minus,
.add {
width: toRpx(80);
height: toRpx(74);
line-height: toRpx(70);
text-align: center;
background-color: #fff;
border-top: toRpx(2) solid #eff0f2;
border-bottom: toRpx(2) solid #eff0f2;
}
.minus {
border-radius: toRpx(12) 0 0 toRpx(12);
border-left: toRpx(2) solid #eff0f2;
}
.add {
border-radius: 0 toRpx(12) toRpx(12) 0;
border-right: toRpx(2) solid #eff0f2;
}
}
}
</style>
\ No newline at end of file
......@@ -156,6 +156,7 @@ import permision from '@/js_sdk/wa-permission/permission.js'
import { sign, md532, md516 } from 'utils/common'
import { signSecretKey } from '@/env.js'
import { validateVin, formatVinInput } from '@/utils/vinVaildate'
import { getPlateLocation } from '@/utils/licensePlateParser'
export default {
name: 'AddEvaluationFrom',
components: {
......@@ -556,7 +557,7 @@ export default {
uploadOtherFields: [{ key: 41, label: '其他图片', required: false, accept: 'image', maxCount: 30, fullwidth: true }],
currentField: null,
query: {},
validateState:true
validateState: true
}
},
onLoad(options) {
......@@ -886,7 +887,7 @@ export default {
// 车架号验证 - 长度17且只能包含数字和大写字母
// const vin = this.formData.carBaseReqDTO.vin
// const vinRegex = /^[A-Z0-9]+$/
// if (!vinRegex.test(vin)) {
// uni.showToast({
// title: '车架号只能包含数字和大写字母',
......@@ -901,22 +902,22 @@ export default {
// })
// return
// }
// VIN车架号-动态校验
const carVin = this.formData.carBaseReqDTO.vin
console.log("validateState",this.validateState);
if (carVin) {
// 前置判断
if (carVin.length !== 17) {
uni.showToast({title:'请输入 17 位有效字符(支持大写 A-H/J-N/P-Z、0-9)',icon:'none'})
return false
}
// 根据接口校验结果判断
if (carVin.length === 17 && !this.validateState) {
uni.showToast({title:'车架号校验不匹配,请核对后重新输入',icon:'none'})
return false
}
}
console.log('validateState', this.validateState)
if (carVin) {
// 前置判断
if (carVin.length !== 17) {
uni.showToast({ title: '请输入 17 位有效字符(支持大写 A-H/J-N/P-Z、0-9)', icon: 'none' })
return false
}
// 根据接口校验结果判断
if (carVin.length === 17 && !this.validateState) {
uni.showToast({ title: '车架号校验不匹配,请核对后重新输入', icon: 'none' })
return false
}
}
const engineNumber = this.formData.carBaseReqDTO.engineNumber
const engineNumberRegex = /^[A-Za-z0-9]+$/
if (!engineNumberRegex.test(engineNumber)) {
......@@ -1018,7 +1019,7 @@ export default {
},
handleCell(field) {
const that = this
console.log("handleCellAAAAA");
console.log('handleCellAAAAA')
if (field.isCar) {
this.openSelectCar()
} else if (field.isCity) {
......@@ -1138,17 +1139,19 @@ export default {
if (upperValue !== value) {
this.$set(this.formData.carBaseReqDTO, 'vin', upperValue)
}
// VIN车架号动态校验:车架号字段,动态转换为大写
validateVin(upperValue).then(result => {
console.log("validateVin",result);
let { valid } = result.data;
this.validateState = valid
// 校验成功,所有提示已在公共方法中处理
console.log('车架号校验成功:', result)
}).catch(err => {
console.log("validateVinErr",result);
})
// VIN车架号动态校验:车架号字段,动态转换为大写
validateVin(upperValue)
.then(result => {
console.log('validateVin', result)
let { valid } = result.data
this.validateState = valid
// 校验成功,所有提示已在公共方法中处理
console.log('车架号校验成功:', result)
})
.catch(err => {
console.log('validateVinErr', result)
})
}
if (field.key === 'mileage') {
let numValue = Number(value)
......@@ -1324,15 +1327,17 @@ export default {
if (res.data.code == 0) {
if (res.data.data.status == 1) {
this.formData.carBaseReqDTO.vin = res.data.data.vin
validateVin(this.formData.carBaseReqDTO.vin).then(result => {
console.log("validateVin",result);
let { valid } = result.data;
this.validateState = valid
// 校验成功,所有提示已在公共方法中处理
console.log('车架号校验成功:', result)
}).catch(err => {
console.log("validateVinErr",result);
})
validateVin(this.formData.carBaseReqDTO.vin)
.then(result => {
console.log('validateVin', result)
let { valid } = result.data
this.validateState = valid
// 校验成功,所有提示已在公共方法中处理
console.log('车架号校验成功:', result)
})
.catch(err => {
console.log('validateVinErr', result)
})
uni.showToast({ title: '车架号识别完成并已自动填写到表单中', icon: 'none' })
uni.hideLoading()
} else {
......@@ -1364,6 +1369,21 @@ export default {
uni.showToast({ title: '行驶证信息识别完成,已自动填写到表单中', icon: 'none' })
if (res.data.data.status == 1) {
this.formData.carBaseReqDTO.engineNumber = res.data.data.engineNumber
// 识别车牌号并解析省市回显到上牌城市
if (res.data.data.licensePlate) {
const plateLocation = getPlateLocation(res.data.data.licensePlate)
console.log('plateLocation', plateLocation)
if (plateLocation.success && plateLocation.province && plateLocation.city) {
// 清空上牌城市的ID,只保留名称
this.formData.carBaseReqDTO.registrationProvinceId = null
this.formData.carBaseReqDTO.registrationCityId = null
this.formData.carBaseReqDTO.registrationProvinceName = plateLocation.province
this.formData.carBaseReqDTO.registrationCityName = plateLocation.city
}
}
if (this.title == '新增评估单') {
this.formData.carBaseReqDTO.licensePlate = res.data.data.licensePlate
if (res.data.data.licensePlate) {
......@@ -1412,7 +1432,44 @@ export default {
this.formData.carBaseReqDTO.vin = res.data.data.vin
this.formData.carBaseReqDTO.registrationDate = res.data.data.registrationDate
this.formData.carLicenseReqDTO.previousOwnerAddress = res.data.data.previousOwnerAddress
// 处理 previousOwnerAddress,提取省市并回显到上牌城市
const previousOwnerAddress = res.data.data.previousOwnerAddress
this.formData.carLicenseReqDTO.previousOwnerAddress = previousOwnerAddress
if (previousOwnerAddress) {
// 解析地址,提取省和市(到市级)
let provinceName = ''
let cityName = ''
// 处理直辖市(北京市、上海市、天津市、重庆市)
const municipalities = ['北京市', '上海市', '天津市', '重庆市']
const municipalityMatch = municipalities.find(city => previousOwnerAddress.startsWith(city))
if (municipalityMatch) {
// 直辖市:省和市都是同一个名称
provinceName = municipalityMatch
cityName = municipalityMatch
} else {
// 普通省份:例如:"山东省济南市历下区" -> 省:"山东省",市:"济南市"
const provinceMatch = previousOwnerAddress.match(/^(.+?省)/)
const cityMatch = previousOwnerAddress.match(/省(.+?市)/)
if (provinceMatch && cityMatch) {
provinceName = provinceMatch[1]
cityName = cityMatch[1]
}
}
if (provinceName && cityName) {
// 清空上牌城市的ID,只保留名称
this.formData.carBaseReqDTO.registrationProvinceId = 0
this.formData.carBaseReqDTO.registrationCityId = 0
this.formData.carBaseReqDTO.registrationProvinceName = provinceName
this.formData.carBaseReqDTO.registrationCityName = cityName
}
}
this.formData.carLicenseReqDTO.previousOwnerName = res.data.data.previousOwnerName
this.formData.carLicenseReqDTO.carSeriesName = res.data.data.carSeriesName
this.formData.carLicenseReqDTO.carTypeName = res.data.data.carTypeName
......
......@@ -5,6 +5,7 @@
<view v-if="status == 20 && !subStatus" class="common-btn ml-24" @click.stop="handleClick('requote', 'app_evaluate_requote')">重新报价</view>
<view v-if="status == 20 && !subStatus" class="common-btn blue-btn ml-24" @click.stop="handleClick('sign', 'app_evaluate_sign')">客户签约</view>
<view v-if="subStatus == 1" class="common-btn gray-btn ml-24" @click.stop="handleClick('signing')">签约中</view>
<view v-if="subStatus == 1 && status == 20" class="common-btn ml-24" @click.stop="handleClick('withdrawal', 'app_evaluate_withdrawal')">撤回合同</view>
<view v-if="subStatus == 2 || subStatus == 3" class="common-btn gray-btn ml-24" @click.stop="handleClick('paying')">支付中</view>
<view v-if="status == 30 && !subStatus" class="common-btn ml-24" @click.stop="handleClick('cancelSign', 'app_evaluate_cancel_sign')">取消签约</view>
<view v-if="status == 31 && !subStatus" class="common-btn blue-btn ml-24" @click.stop="handleClick('signAgreement', 'app_evaluate_cancel_sign')">确认代保管</view>
......
......@@ -11,6 +11,9 @@
<view v-if="field.isScan" class="flex align-center scanBtn justify-center" @click.stop="scan('vinOcr')">
<view class="sprite-icon icon-scanIconX"></view>
</view>
<view v-if="field.isLocation" class="flex align-center scanBtn justify-center" @click.stop="location">
<view class="sprite-icon icon-location"></view>
</view>
<text v-if="field.isCell" class="ml-12 cellLabel" :class="{ disabled: field.disabled }">{{ field.cell }}</text>
</template>
<template v-if="field.type === 'select'">
......@@ -275,6 +278,9 @@ export default {
scan(type) {
this.$emit('scan', type)
},
location() {
this.$emit('location')
},
previewPdf(field) {
this.$emit('previewPdf', field)
},
......
......@@ -20,7 +20,7 @@
<view class="car-number mr-12">{{ carInfo.registrationDateStr }}</view>
<view class="car-number mr-12">{{ carInfo.mileageStr }}</view>
<view class="car-number mr-12">{{ carInfo.transferCountStr }}</view>
<view class="car-number">{{ vehicleCategoryMap[1] }}</view>
<view class="car-number">{{ vehicleCategoryMap[carInfo.vehicleCategory] }}</view>
</view>
<view class="info-row flex mb-30">
<view class="info-item flex align-center">
......
......@@ -136,6 +136,12 @@ export default {
sourceType: ['camera'],
success: async res => {
console.log('选择图片成功', res)
uni.saveImageToPhotosAlbum({
filePath: res.tempFilePaths[0],
success: function () {
console.log('图片保存成功')
}
})
try {
const MAX_IMAGE_SIZE = 10 * 1024 * 1024 // 10MB
for (const file of res.tempFiles) {
......@@ -218,6 +224,12 @@ export default {
compressed: false,
success: async res => {
console.log('拍摄视频成功', res)
uni.saveVideoToPhotosAlbum({
filePath: res.tempFilePath,
success: function () {
console.log('save success')
}
})
try {
const MAX_VIDEO_SIZE = 100 * 1024 * 1024 // 100MB
if (res.size > MAX_VIDEO_SIZE) {
......
......@@ -83,7 +83,7 @@
</view>
</view>
<view class="fromBox">
<FormCell :formFields="formFields" :formData="formData" @handleCell="handleCell" @previewPdf="previewPdf" @deletePdf="deletePdf" />
<FormCell :formFields="formFields" :formData="formData" @handleCell="handleCell" @previewPdf="previewPdf" @deletePdf="deletePdf" @location="location" />
</view>
</view>
<view class="button-module flex justify-center align-center">
......@@ -171,7 +171,8 @@ export default {
sourceKey: 'uuid',
targetKey: 'handoverAddress',
type: 'input',
maxlength: 43
maxlength: 43,
isLocation: true
},
{
key: 'buyerAgreementUrl',
......@@ -279,10 +280,28 @@ export default {
evalOrderNo: this.query.evalOrderNo
})
if (res.data.code == 0) {
// this.$set(this.formData, 'handoverAddress', res.data.data.evalCarBase.carProvinceName + '-' + res.data.data.evalCarBase.carCityName)
console.log('res.data.data', JSON.parse(res.data.data.custodyContract.electronicContractField))
// this.custodianName = JSON.parse(res.data.data.custodyContract.electronicContractField).custodianName || ''
const data = res.data.data
// 设置交车时间
this.formData.handoverTime = dayjs().format('YYYY-MM-DD HH:mm:00')
// 处理图片回显
if (data.imageListDTO && data.imageListDTO.length > 0) {
// 行驶证图片 (fileSubtype: 21)
const drivingLicenseImages = data.imageListDTO.filter(img => img.fileSubtype === 21).map(img => img.fileUrl)
if (drivingLicenseImages.length > 0) {
this.$set(this.uploadedImages, 'motorRegistrationCertificateUrl', drivingLicenseImages)
this.formData.motorRegistrationCertificateUrl = drivingLicenseImages.join(',')
}
// 登记证图片 (fileSubtype: 22)
const registrationImages = data.imageListDTO.filter(img => img.fileSubtype === 22).map(img => img.fileUrl)
if (registrationImages.length > 0) {
this.$set(this.uploadedImages, 'motorBookUrl', registrationImages)
this.formData.motorBookUrl = registrationImages.join(',')
}
}
// this.evalOrderSimpleDetail = res.data.data
} else {
uni.hideLoading()
......@@ -473,6 +492,12 @@ export default {
sizeType: ['original'],
sourceType: ['camera'],
success: async res => {
uni.saveImageToPhotosAlbum({
filePath: res.tempFilePaths[0],
success: function () {
console.log('图片保存成功')
}
})
try {
const MAX_IMAGE_SIZE = 10 * 1024 * 1024 // 10MB
for (const file of res.tempFiles) {
......@@ -542,6 +567,12 @@ export default {
compressed: false,
success: async res => {
console.log('拍摄视频成功', res)
uni.saveVideoToPhotosAlbum({
filePath: res.tempFilePath,
success: function () {
console.log('save success')
}
})
try {
const MAX_VIDEO_SIZE = 100 * 1024 * 1024 // 100MB
if (res.size > MAX_VIDEO_SIZE) {
......@@ -679,6 +710,22 @@ export default {
console.log(successDate)
this.$set(this.formData, 'handoverTime', successDate)
this.show = false
},
location() {
const that = this
uni.showLoading({ title: '定位中...' })
uni.getLocation({
type: 'gcj02',
geocode: true,
success: function (res) {
uni.hideLoading()
that.$set(that.formData, 'handoverAddress', res.address.province + res.address.city)
},
fail: function (err) {
uni.hideLoading()
uni.showToast({ title: '定位失败', icon: 'none' })
}
})
}
},
watch: {},
......
......@@ -104,7 +104,7 @@
<view class="upload-images-wrapper" v-if="getImageBySubtype(field.key)">
<view class="uploaded-media-container">
<view class="video-container">
<image :src="getImageBySubtype(field.key).fileUrl + videoProcess" mode="aspectFill" class="uploaded-media" @click.stop="previewMedia(getImageBySubtype(field.key).fileUrl, 2)"></image>
<image :src="getVideoThumbnail(getImageBySubtype(field.key).fileUrl)" mode="aspectFill" class="uploaded-media" @click.stop="previewMedia(getImageBySubtype(field.key).fileUrl, 2)"></image>
<!-- <video :src="getImageBySubtype(field.key).fileUrl" mode="aspectFill" controls class="uploaded-media"></video> -->
<view class="video-play-icon">
<view class="sprite-icon icon-upload-play"></view>
......@@ -173,10 +173,19 @@
<view class="tab-panel-title">二手车转让协议</view>
<view class="gridBoxNoPadding">
<template v-for="(item, index) in vehicleItems">
<view v-if="!detailsInfo.signingInfo.saleContract.depositPrice ? item.key !== 'signingInfo.saleContract.depositPrice' && item.key !== 'signingInfo.saleContract.finalPrice' : item.key !== 'signingInfo.saleContract.fullPrice'" :key="index" :class="['flex align-start', { 'full-width': item.fullWidth }, { 'align-center': item.type == 'link' }]">
<view v-if="(!detailsInfo.signingInfo.saleContract.depositPrice ? item.key !== 'signingInfo.saleContract.depositPrice' && item.key !== 'signingInfo.saleContract.finalPrice' : item.key !== 'signingInfo.saleContract.fullPrice') && (item.key !== 'signingInfo.saleContract.thirdPartyTransactionVoucher' || formatValue(item, detailsInfo))" :key="index" :class="['flex align-start', { 'full-width': item.fullWidth }, { 'align-center': item.type == 'link' }]">
<view class="title-label-see mr-16">{{ item.label }}</view>
<view v-if="item.type == 'image'">
<image :src="formatValue(item, detailsInfo)" @click.stop="previewMedia(formatValue(item, detailsInfo), 1)"></image>
<!-- 三方/委托交易凭证可能是视频 -->
<view v-if="item.key === 'signingInfo.saleContract.thirdPartyTransactionVoucher' && isVideoUrl(formatValue(item, detailsInfo))" class="uploaded-media-container">
<view class="video-container">
<image :src="getVideoThumbnail(formatValue(item, detailsInfo))" mode="aspectFill" class="uploaded-media" @click.stop="previewMedia(formatValue(item, detailsInfo), 2)"></image>
<view class="video-play-icon">
<view class="sprite-icon icon-upload-play"></view>
</view>
</view>
</view>
<image v-else :src="formatValue(item, detailsInfo)" @click.stop="previewMedia(formatValue(item, detailsInfo), 1)"></image>
</view>
<view v-else-if="item.type == 'link'" class="flex-1" @click.stop="pdfPreview(detailsInfo.signingInfo.saleContract.contractNo)">
<view class="pdf-box flex align-center justify-between">
......@@ -311,7 +320,15 @@
<image @click.stop="previewMedia(url, 1)" v-for="(url, idx) in splitMediaUrls(formatValue(item, detailsInfo))" :key="idx" :src="url" mode="aspectFill" style="margin-right: 10px"></image>
</template>
<template v-else>
<image v-if="formatValue(item, detailsInfo).includes('mp4')" :src="formatValue(item, detailsInfo) + videoProcess" @click.stop="previewMedia(formatValue(item, detailsInfo), 2)"></image>
<!-- 过户授权委托书可能是视频 -->
<view v-if="item.key === 'carHandoverInfo.transferPhotoUrl' && isVideoUrl(formatValue(item, detailsInfo))" class="uploaded-media-container">
<view class="video-container">
<image :src="getVideoThumbnail(formatValue(item, detailsInfo))" mode="aspectFill" class="uploaded-media" @click.stop="previewMedia(formatValue(item, detailsInfo), 2)"></image>
<view class="video-play-icon">
<view class="sprite-icon icon-upload-play"></view>
</view>
</view>
</view>
<image v-else :src="formatValue(item, detailsInfo)" @click.stop="previewMedia(formatValue(item, detailsInfo), 1)"></image>
</template>
</view>
......@@ -393,7 +410,7 @@
</template>
</view>
<view v-else-if="item.fieldType == 'video'">
<image @click.stop="previewMedia(url, 2)" v-for="(url, idx) in splitMediaUrls(item.fieldBeforeValue)" :key="idx" :src="url + videoProcess" mode="aspectFill" style="margin-right: 10px; width: 80px; height: 80px"></image>
<image @click.stop="previewMedia(url, 2)" v-for="(url, idx) in splitMediaUrls(item.fieldBeforeValue)" :key="idx" :src="getVideoThumbnail(url)" mode="aspectFill" style="margin-right: 10px; width: 80px; height: 80px"></image>
</view>
</template>
</view>
......@@ -409,7 +426,7 @@
</template>
</view>
<view v-else-if="item.fieldType == 'video'">
<image @click.stop="previewMedia(url, 2)" v-for="(url, idx) in splitMediaUrls(item.fieldAfterValue)" :key="idx" :src="url + videoProcess" mode="aspectFill" style="margin-right: 10px; width: 80px; height: 80px"></image>
<image @click.stop="previewMedia(url, 2)" v-for="(url, idx) in splitMediaUrls(item.fieldAfterValue)" :key="idx" :src="getVideoThumbnail(url)" mode="aspectFill" style="margin-right: 10px; width: 80px; height: 80px"></image>
</view>
</template>
</view>
......@@ -553,6 +570,7 @@ export default {
{ label: '交车地点', key: 'signingInfo.saleContract.handoverAddress' },
{ label: '身份证国徽面', key: 'signingInfo.saleContract.idCardFrontUrl', type: 'image' },
{ label: '身份证人像面', key: 'signingInfo.saleContract.idCardBackUrl', type: 'image' },
{ label: '三方/委托交易凭证', key: 'signingInfo.saleContract.thirdPartyTransactionVoucher', type: 'image' },
{ label: '查阅合同', key: 'signingInfo.saleContract.contractUrl', type: 'link' }
],
payeeItems: [
......@@ -708,6 +726,45 @@ export default {
.map(url => url.trim())
.filter(url => url)
},
// 判断URL是否是视频
isVideoUrl(url) {
if (!url) return false
// 1. 检查是否包含阿里云视频处理参数
if (url.includes(this.videoProcess)) {
return true
}
// 2. 检查文件扩展名(视频格式)
const videoExtensions = ['.mp4', '.mov', '.avi', '.wmv', '.flv', '.m4v', '.3gp', '.mkv', '.webm']
const urlLower = url.toLowerCase()
const hasVideoExtension = videoExtensions.some(ext => {
// 检查扩展名,需要排除查询参数
const urlWithoutQuery = urlLower.split('?')[0].split('#')[0]
return urlWithoutQuery.endsWith(ext)
})
return hasVideoExtension
},
// 获取视频缩略图URL
getVideoThumbnail(url) {
if (!url) return ''
// 如果已经是阿里云链接且包含videoProcess,直接返回
if (url.includes(this.videoProcess)) {
return url
}
// 如果是阿里云OSS链接,添加videoProcess参数
if (url.includes('aliyuncs.com') || url.includes('oss-')) {
// 如果URL已经有查询参数,用&连接;否则用?连接
const separator = url.includes('?') ? '&' : '?'
return url + separator + this.videoProcess.replace('?', '')
}
// 如果不是阿里云链接(如小程序上传),返回默认视频图片
return 'https://img02.glsx.com.cn/weapp/resource/dj-car-boutique-work-wechat/usedCar/video_default.png'
},
statusClass(status) {
return status > 0 ? `status-${status}` : 'status-0'
},
......
......@@ -153,6 +153,7 @@
</view>
</template>
</GeneralPopup>
<NoticePopup ref="notice" title="重要提示" text="确定要撤回合同吗?" type="warning"></NoticePopup>
<OrderPopup ref="orderPopup" :data="custodyAgreementObj" :isDefeatOrder="true" :externalData="[]" @onConfirm="onConfirm" :popupType="14" idKey="id" />
</view>
</template>
......@@ -165,7 +166,7 @@ import EvaluationCard from './components/evaluationCard.vue'
import ZPMixin from '@/uni_modules/z-paging/components/z-paging/js/z-paging-mixin'
import GeneralPopup from './components/GeneralPopup.vue'
import OrderPopup from '@/components/OrderPopup/index.vue'
import { set } from 'lodash'
import NoticePopup from '@/components/NoticePopup.vue'
export default {
name: 'EvaluationFormList',
mixins: [ZPMixin],
......@@ -175,7 +176,8 @@ export default {
TypeTabComponent,
EvaluationCard,
GeneralPopup,
OrderPopup
OrderPopup,
NoticePopup
},
data() {
return {
......@@ -391,8 +393,55 @@ export default {
this.reSubmit(e)
} else if (e.type === 'signAgreement') {
this.signAgreement(e)
} else if (e.type === 'withdrawal') {
this.withdrawal(e)
}
},
async withdrawal(e) {
this.$refs.notice.buttonsList = [
{
text: '取消',
type: 'default',
callback: () => {
this.$refs.notice.close()
}
},
{
text: '确定',
type: 'primary',
callback: async () => {
uni.showLoading()
const res = await uni.$api.evaluationApi.revokeSaleContract({
saleContractNo: e.saleContractNo
})
console.log('res:', res)
if (res.data.code == 0) {
this.$refs.notice.close()
uni.hideLoading()
uni.showToast({
title: '撤回合同成功',
icon: 'none'
})
setTimeout(() => {
this.currentPage = 1
this.search()
}, 1000)
} else {
this.$refs.notice.close()
uni.hideLoading()
uni.showToast({
title: res.data.msg || '请求失败',
icon: 'none'
})
}
}
}
]
// 打开弹窗
this.$refs.notice.open()
},
async reSubmit(e) {
uni.showLoading()
const res = await uni.$api.evaluationApi.evalOrderConfirmVehicleDelivery({
......@@ -734,11 +783,13 @@ export default {
border-radius: toRpx(42);
background: rgb(255, 255, 255) !important;
.tipsPopupBg {
border-radius: toRpx(42) toRpx(42) 0 0;
width: 100%;
height: toRpx(244);
}
.title {
color: #333333;
font-size: toRpx(40);
......@@ -746,6 +797,7 @@ export default {
text-align: center;
margin-top: toRpx(48);
}
.tipsConent {
color: #666666;
font-size: toRpx(32);
......@@ -753,14 +805,17 @@ export default {
padding: toRpx(16) toRpx(64);
line-height: toRpx(48);
text-align: center;
text {
color: #347bff;
}
}
.footer-box {
height: toRpx(154);
}
}
.evaluation-form-list {
position: relative;
width: 100vw;
......@@ -775,6 +830,7 @@ export default {
height: 100%;
box-sizing: border-box;
overflow: hidden;
.box-class {
height: calc(100% - #{toRpx(110)});
background: #ffffff59;
......@@ -782,24 +838,29 @@ export default {
box-shadow: inset 0 0 toRpx(16) 0 #ffffff;
border-radius: toRpx(48);
overflow: hidden;
.paging-class {
background-color: #fff;
height: calc(100% - #{toRpx(96)});
box-sizing: border-box;
border-radius: toRpx(32);
}
.no-br {
border-radius: 0 toRpx(32) toRpx(32) toRpx(32);
}
.no-br1 {
border-radius: toRpx(32) 0 toRpx(32) toRpx(32);
}
.mask-box {
height: calc(100% - #{toRpx(96)});
width: 100%;
background: #fff;
border-radius: toRpx(48);
color: #808291;
.noDataImg {
width: toRpx(480);
height: toRpx(240);
......@@ -807,9 +868,11 @@ export default {
}
}
}
.signAgreement-content {
width: 100%;
height: 100%;
.signAgreement-label {
color: #999999;
font-size: toRpx(28);
......@@ -817,12 +880,14 @@ export default {
display: flex;
align-items: flex-start;
}
.requiredLabel {
color: #f24724;
font-size: toRpx(28);
font-weight: 400;
margin-left: toRpx(8);
}
.from-value {
display: flex;
justify-content: space-between;
......@@ -832,16 +897,19 @@ export default {
background: #f4f5f7;
padding: toRpx(28) toRpx(24);
flex: 1;
.sprite-icon {
margin-bottom: toRpx(2);
}
}
.btn {
color: #3b73ff;
font-size: toRpx(28);
font-weight: 400;
margin-left: toRpx(24);
}
.placeholder {
color: #999;
font-size: toRpx(28);
......@@ -861,6 +929,7 @@ export default {
.requote-content {
width: 100%;
height: 100%;
.requote-label {
color: #333333;
font-size: toRpx(32);
......@@ -868,12 +937,14 @@ export default {
display: flex;
align-items: flex-start;
}
.requiredLabel {
color: #f24724;
font-size: toRpx(28);
font-weight: 400;
margin-left: toRpx(8);
}
::v-deep .intention-input {
height: toRpx(96);
border-radius: toRpx(16);
......@@ -882,11 +953,13 @@ export default {
background: #f4f5f7;
padding: toRpx(24);
box-sizing: border-box;
.uni-input-placeholder {
margin-left: toRpx(24);
}
}
}
.intention-input-cell {
height: toRpx(96);
border-radius: toRpx(16);
......@@ -894,6 +967,7 @@ export default {
padding: toRpx(24);
box-sizing: border-box;
}
::v-deep .feedback-textarea {
height: toRpx(288);
border-radius: toRpx(16);
......@@ -901,6 +975,7 @@ export default {
width: 100%;
padding: toRpx(24);
box-sizing: border-box;
.uni-input-wrapper {
background: #f4f5f7;
}
......@@ -915,6 +990,7 @@ export default {
background: #f1f7fe;
padding-left: toRpx(32);
box-sizing: border-box;
.amount-title {
color: #333333;
font-size: toRpx(32);
......@@ -922,12 +998,14 @@ export default {
margin-right: toRpx(16);
width: toRpx(168);
}
.amount-value {
color: #3b73ff;
font-size: toRpx(36);
font-weight: 700;
}
}
.popup-cell-title {
color: #999;
font-size: toRpx(28);
......@@ -935,14 +1013,17 @@ export default {
margin-right: toRpx(16);
width: toRpx(168);
}
.popup-cell-value {
color: #222;
font-size: toRpx(28);
font-weight: 400;
}
.light-title {
color: #333333;
}
.light-value {
color: #4673ff;
}
......
......@@ -76,6 +76,38 @@
</template>
</view>
</view>
<view class="upload-container mb-24">
<view class="form-item flex align-start justify-between">
<view class="from-label">
三方/委托交易凭证
<!-- <text class="requiredLabel">*</text> -->
</view>
<template>
<!-- 判断是否已上传 -->
<view v-if="formData.thirdPartyTransactionVoucher" class="uploaded-item">
<!-- 视频显示 -->
<view v-if="formData.thirdPartyTransactionVoucher.includes(videoProcess)" class="video-container">
<image :src="formData.thirdPartyTransactionVoucher" mode="aspectFit" @click.stop="previewMedia(formData.thirdPartyTransactionVoucher, 2)"></image>
<view class="video-play-icon">
<view class="sprite-icon icon-upload-play"></view>
</view>
</view>
<!-- 图片显示 -->
<image v-else :src="formData.thirdPartyTransactionVoucher" mode="aspectFit" @click.stop="previewMedia(formData.thirdPartyTransactionVoucher, 1)"></image>
<view class="delete-icon" @click.stop="removeMedia('thirdPartyTransactionVoucher')">
<view class="sprite-icon icon-icon-circle-error"></view>
</view>
</view>
<view v-else class="upload-item" @click.stop="handleMediaUpload('thirdPartyTransactionVoucher')">
<view class="upload-placeholder">
<view class="sprite-icon icon-uploadAdd"></view>
<text class="upload-text">上传图片/视频</text>
</view>
</view>
</template>
</view>
</view>
<FormCell :formFields="formFields2" :formData="formData" @handleCell="handleCell" />
<view class="upload-container">
<view class="form-item flex align-start justify-between">
......@@ -145,14 +177,14 @@
<checkbox class="sign-checkbox" style="transform: scale(0.7)" activeBackgroundColor="#4673FF" iconColor="#fff" :value="item.value" :checked="item.checked" :disabled="item.disabled" />
</view>
<view class="checkbox-name">{{ item.name }}</view>
<input class="checkbox-input" v-if="item.isShowInput && item.key != 'other'" v-model="formData[item.inputValue]" placeholder="请输入" type="number" maxlength="1" />
<input class="checkbox-input" @click.stop="" v-if="item.isShowInput && item.key == 'other'" v-model="formData[item.inputValue]" placeholder="请输入" maxlength="28" @blur="e => handleBlur(e, item)" />
<input class="checkbox-input" @click.stop="" v-if="item.isShowInput && item.key != 'other'" v-model="formData[item.inputValue]" placeholder="请输入" type="number" maxlength="1" :disabled="!item.checked" />
<input class="checkbox-input" @click.stop="" v-if="item.isShowInput && item.key == 'other'" v-model="formData[item.inputValue]" placeholder="请输入" maxlength="28" @blur="e => handleBlur(e, item)" :disabled="!item.checked" />
</label>
</checkbox-group>
</template>
</view>
</view>
<FormCell :formFields="formFields1" :formData="formData" @handleCell="handleCell" class="mb-24" />
<FormCell :formFields="formFields1" :formData="formData" @handleCell="handleCell" @location="location" class="mb-24" />
<FormCell :formFields="formFields3" :formData="formData" @handleCell="handleCell" />
</view>
<view v-else class="flex flex-col align-center justify-center no-data">
......@@ -213,6 +245,18 @@
<view class="title-label-see mr-16">身份证人像面</view>
<image :src="formData.idCardBackUrl" @click.stop="previewMedia(formData.idCardBackUrl, 1)"></image>
</view>
<view class="flex align-start" v-if="formData.thirdPartyTransactionVoucher">
<view class="title-label-see mr-16">三方/委托交易 凭证</view>
<!-- 视频显示 -->
<view v-if="formData.thirdPartyTransactionVoucher.includes(videoProcess)" class="video-preview" @click.stop="previewMedia(formData.thirdPartyTransactionVoucher, 2)">
<image :src="formData.thirdPartyTransactionVoucher"></image>
<view class="video-play-icon">
<view class="sprite-icon icon-upload-play"></view>
</view>
</view>
<!-- 图片显示 -->
<image v-else :src="formData.thirdPartyTransactionVoucher" @click.stop="previewMedia(formData.thirdPartyTransactionVoucher, 1)"></image>
</view>
</view>
<view class="flex align-center gridBox mb-32">
<view class="flex align-center">
......@@ -297,6 +341,7 @@ export default {
},
data() {
return {
videoProcess: '?x-oss-process=video/snapshot,t_7000,f_jpg,w_800,h_600,m_fast',
comfirmPage: false,
signInfo: {},
title: '签约信息',
......@@ -321,36 +366,31 @@ export default {
key: 'motorBook',
value: 'motorBook',
name: '机动车登记本',
checked: true,
disabled: true
checked: false
},
{
value: 'motorRegistrationCertificate',
name: '机动车行驶证',
key: 'motorRegistrationCertificate',
checked: true,
disabled: true
checked: false
},
{
value: 'trafficScreenshot',
name: '交管12123截图',
key: 'trafficScreenshot',
checked: true,
disabled: true
checked: false
},
{
value: 'trafficInsurance',
name: '交强险',
key: 'trafficInsurance',
checked: true,
disabled: true
checked: false
},
{
value: 'carKey',
name: '车钥匙',
key: 'carKey',
checked: true,
disabled: true,
checked: false,
isShowInput: true,
inputValue: 'carKeyCount'
},
......@@ -376,8 +416,7 @@ export default {
value: 'transferPhoto',
name: '过户授权委托书照片',
key: 'transferPhoto',
checked: true,
disabled: true
checked: false
},
{
value: 'other',
......@@ -451,7 +490,8 @@ export default {
sourceKey: 'uuid',
targetKey: 'handoverAddress',
type: 'input',
maxlength: 43
maxlength: 43,
isLocation: true
}
],
formFields2: [
......@@ -854,13 +894,12 @@ export default {
const isSelected = e.detail.value.some(value => value === item.value)
resultObject[itemKey] = isSelected ? '1' : '0'
item.checked = isSelected
})
const otherItem = this.checkboxList.find(item => item.name === '其他')
const otherIndex = this.checkboxList.indexOf(otherItem)
if (otherItem && !otherItem.checked) {
this.formData[this.checkboxList[otherIndex].inputValue] = ''
}
// 如果取消勾选且该项有输入框,清空输入值
if (!isSelected && item.isShowInput && item.inputValue) {
this.formData[item.inputValue] = ''
}
})
// 更新formData
this.formData = { ...this.formData, ...resultObject }
......@@ -877,6 +916,47 @@ export default {
.map(item => item.name)
.join(', ')
},
// 处理图片/视频上传(用于三方/委托交易凭证)
async handleMediaUpload(field) {
// #ifdef APP-PLUS
const photoLibrary = await permision.requestAndroidPermission('android.permission.READ_EXTERNAL_STORAGE')
const camera = await permision.requestAndroidPermission('android.permission.CAMERA')
const isOnline = await uni.$isNetWork()
if (photoLibrary != 1) {
uni.showToast({ title: '您的设备不支持相册功能或未授权访问,请前往设置中开启相册权限', icon: 'none' })
return
}
if (camera != 1) {
uni.showToast({ title: '您的设备不支持摄像头功能或未授权访问,请前往设置中开启摄像头权限', icon: 'none' })
return
}
if (!isOnline) {
uni.showToast({ title: '当前无网络连接,请连接网络后重试', icon: 'none' })
return
}
// #endif
uni.showActionSheet({
itemList: ['拍照', '从相册选择图片', '拍摄视频', '从相册选择视频'],
success: res => {
if (res.tapIndex === 0) {
// 拍照
this.takePhoto(field)
} else if (res.tapIndex === 1) {
// 从相册选择图片
this.chooseImageFromAlbum(field)
} else if (res.tapIndex === 2) {
// 拍摄视频
this.takeVideo(field)
} else if (res.tapIndex === 3) {
// 从相册选择视频
this.chooseVideoFromAlbum(field)
}
},
fail: err => {
console.log('选择操作失败', err)
}
})
},
async handleImageUpload(field) {
// #ifdef APP-PLUS
const photoLibrary = await permision.requestAndroidPermission('android.permission.READ_EXTERNAL_STORAGE')
......@@ -919,6 +999,13 @@ export default {
sourceType: ['camera'],
success: async res => {
try {
uni.saveImageToPhotosAlbum({
filePath: res.tempFilePaths[0],
success: function () {
console.log('图片保存成功')
}
})
const MAX_IMAGE_SIZE = 10 * 1024 * 1024 // 10MB
for (const file of res.tempFiles) {
if (file.size > MAX_IMAGE_SIZE) {
......@@ -926,11 +1013,12 @@ export default {
return
}
}
uni.showLoading({ title: '上传中...', mask: true })
// 上传所有选择的图片
for (const tempFilePath of res.tempFilePaths) {
console.log('上传图片开始', tempFilePath)
const url = await uploadFile(tempFilePath)
for (let i = 0; i < res.tempFilePaths.length; i++) {
const url = await uploadFile(res.tempFiles[i], res.tempFilePaths[i])
console.log('上传图片成功', url)
uni.hideLoading()
this.addMedia(field, { url, fileFormat: 'png', type: 'image', name: field.label })
}
} catch (error) {
......@@ -981,6 +1069,95 @@ export default {
}
})
},
// 拍摄视频
takeVideo(field) {
uni.chooseVideo({
sourceType: ['camera'],
maxDuration: 60,
camera: 'back',
compressed: false,
success: async res => {
console.log('拍摄视频成功', res)
uni.saveVideoToPhotosAlbum({
filePath: res.tempFilePath,
success: function () {
console.log('save success')
}
})
try {
const MAX_VIDEO_SIZE = 100 * 1024 * 1024 // 100MB
if (res.size > MAX_VIDEO_SIZE) {
uni.showToast({ title: '视频上传最大100MB', icon: 'none' })
return
}
uni.showLoading({ title: '上传中...' })
// let url = await uploadFile(null, res.tempFilePath)
// #ifdef H5
let url = await uploadFile(res.tempFile, res.tempFilePath)
// #endif
// #ifdef APP-PLUS
let url = await uploadFile(null, res.tempFilePath)
// #endif
url = url + this.videoProcess
console.log('上传视频成功', url)
this.$set(this.formData, field, url)
uni.hideLoading()
uni.showToast({ title: '上传成功', icon: 'success' })
} catch (error) {
console.log('上传视频失败', error)
uni.hideLoading()
uni.showToast({ title: '视频上传失败,请重试', icon: 'none' })
}
},
fail: err => {
console.log('拍摄视频失败', err)
if (err.errMsg.indexOf('cancel') === -1) {
uni.showToast({ title: '拍摄视频失败', icon: 'none' })
}
}
})
},
// 从相册选择视频
chooseVideoFromAlbum(field) {
uni.chooseVideo({
sourceType: ['album'],
compressed: false,
maxDuration: 60,
success: async res => {
console.log('选择视频成功', res)
try {
const MAX_VIDEO_SIZE = 100 * 1024 * 1024 // 100MB
if (res.size > MAX_VIDEO_SIZE) {
uni.showToast({ title: '视频上传最大100MB', icon: 'none' })
return
}
uni.showLoading({ title: '上传中...' })
// #ifdef H5
let url = await uploadFile(res.tempFile, res.tempFilePath)
// #endif
// #ifdef APP-PLUS
let url = await uploadFile(null, res.tempFilePath)
// #endif
url = url + this.videoProcess
console.log('上传视频成功', url)
this.$set(this.formData, field, url)
uni.hideLoading()
uni.showToast({ title: '上传成功', icon: 'success' })
} catch (error) {
console.log('上传视频失败', error)
uni.hideLoading()
uni.showToast({ title: '视频上传失败,请重试', icon: 'none' })
}
},
fail: err => {
console.log('选择视频失败', err)
if (err.errMsg.indexOf('cancel') === -1) {
uni.showToast({ title: '选择视频失败', icon: 'none' })
}
}
})
},
addMedia(field, media) {
this.$set(this.formData, field, media.url)
},
......@@ -988,7 +1165,7 @@ export default {
// 显示确认对话框
uni.showModal({
title: '确认删除',
content: '确定要删除此图片吗?',
content: '确定要删除此图片/视频吗?',
success: res => {
if (res.confirm) {
// 用户确认删除
......@@ -1096,21 +1273,39 @@ export default {
})
return
}
if (!this.formData.carKeyCount) {
// 验证随车材料:至少选择一项
const checkedItems = this.checkboxList.filter(item => item.checked)
if (checkedItems.length === 0) {
uni.showToast({
title: '请至少选择一项随车材料',
icon: 'none'
})
return
}
// 验证车钥匙:如果勾选了车钥匙,必须输入数量
const carKeyItem = this.checkboxList.find(item => item.key === 'carKey')
if (carKeyItem && carKeyItem.checked && !this.formData.carKeyCount) {
uni.showToast({
title: '请输入车钥匙数量',
icon: 'none'
})
return
}
if (this.selectedItemsText.indexOf('其他') !== -1) {
if (!this.formData.otherText) {
uni.showToast({
title: '请完善随车材料',
icon: 'none'
})
return
}
// 验证其他:如果勾选了其他,必须输入内容
const otherItem = this.checkboxList.find(item => item.key === 'other')
if (otherItem && otherItem.checked && !this.formData.otherText) {
uni.showToast({
title: '请输入其他随车材料内容',
icon: 'none'
})
return
}
// 更新 selectedItemsText
if (this.selectedItemsText.indexOf('其他') !== -1 && this.formData.otherText) {
this.selectedItemsText = this.selectedItemsText.replace('其他', '')
this.selectedItemsText += this.formData.otherText
}
......@@ -1124,8 +1319,24 @@ export default {
delete this.formData.depositPrice
delete this.formData.finalPrice
}
// 处理视频 URL,去掉 videoProcess 后缀
const submitData = { ...this.formData }
if (submitData.thirdPartyTransactionVoucher && submitData.thirdPartyTransactionVoucher.includes(this.videoProcess)) {
submitData.thirdPartyTransactionVoucher = submitData.thirdPartyTransactionVoucher.replace(this.videoProcess, '')
}
// 只提交勾选的随车材料,未勾选的设为 '0'
this.checkboxList.forEach(item => {
if (item.key) {
if (!item.checked) {
submitData[item.key] = '0'
}
}
})
uni.showLoading()
uni.$api.evaluationApi.evalOrderSignContract({ ...this.formData, evalOrderNo: this.query.evalOrderNo }).then(res => {
uni.$api.evaluationApi.evalOrderSignContract({ ...submitData, evalOrderNo: this.query.evalOrderNo }).then(res => {
console.log('res:', res)
if (res.data.code == 0) {
uni.hideLoading()
......@@ -1177,6 +1388,22 @@ export default {
uni.navigateTo({
url: `${url}`
})
},
location() {
const that = this
uni.showLoading({ title: '定位中...' })
uni.getLocation({
type: 'gcj02',
geocode: true,
success: function (res) {
uni.hideLoading()
that.$set(that.formData, 'handoverAddress', res.address.province + res.address.city)
},
fail: function (err) {
uni.hideLoading()
uni.showToast({ title: '定位失败', icon: 'none' })
}
})
}
}
}
......@@ -1400,6 +1627,26 @@ export default {
height: 100%;
object-fit: contain;
}
.video-container {
position: relative;
width: 100%;
height: 100%;
display: flex;
align-items: center;
justify-content: center;
}
.video-play-icon {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: toRpx(64);
height: toRpx(64);
display: flex;
align-items: center;
justify-content: center;
pointer-events: none;
}
.delete-icon {
position: absolute;
top: toRpx(8);
......@@ -1501,6 +1748,35 @@ export default {
border-radius: toRpx(12);
background: #f4f5f7;
}
.video-preview {
position: relative;
width: toRpx(240);
height: toRpx(240);
border-radius: toRpx(12);
background: #f4f5f7;
display: flex;
align-items: center;
justify-content: center;
image {
width: 100%;
height: 100%;
object-fit: contain;
}
.video-play-icon {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: toRpx(64);
height: toRpx(64);
display: flex;
align-items: center;
justify-content: center;
pointer-events: none;
}
}
.full-width {
grid-column: 1 / -1;
}
......
<template>
<view class="uni-calendar">
<view
v-if="!insert&&show"
class="uni-calendar__mask"
:class="[{'uni-calendar--mask-show':aniMaskShow},{'uni-calendar--mask-bg-hide':hideMask}]"
@click="clean"
></view>
<view
v-if="insert || show"
class="uni-calendar__content"
:class="{'uni-calendar--fixed':!insert,'uni-calendar--ani-show':aniMaskShow}"
:style="[{backgroundColor:backgroundColor}]"
>
<view
v-if="!insert"
class="uni-calendar__header uni-calendar--fixed-top"
>
<template v-if="!showBottomBtn">
<view
class="uni-calendar__header-btn-box"
@click="close"
>
<text class="uni-calendar__header-text uni-calendar--fixed-width">{{cancelText}}</text>
</view>
</template>
<viw :class="['uni-calendar__header-title',{'header-title-center':showBottomBtn}]">{{title}}</viw>
<template v-if="!showBottomBtn">
<view
class="uni-calendar__header-btn-box"
@click="confirm"
>
<text class="uni-calendar__header-text uni-calendar--fixed-width">{{okText}}</text>
</view>
</template>
<template v-if="showBottomBtn">
<view
class="popup-close"
@click="close"
>
<uni-icons
type="closeempty"
size="18"
></uni-icons>
</view>
</template>
</view>
<view class="uni-calendar__header">
<view
class="uni-calendar__header-btn-box"
@click.stop="pre"
>
<view class="uni-calendar__header-btn uni-calendar--left"></view>
</view>
<picker
mode="date"
:value="date"
:end="endDate"
fields="month"
@change="bindDateChange"
>
<text class="uni-calendar__header-text">{{ (nowDate.year||'') +' / '+( nowDate.month||'')}}</text>
</picker>
<view
:class="['uni-calendar__header-btn-box next-btn',{'show-next-btn':showNextBtn}]"
@click.stop="next"
>
<view class="uni-calendar__header-btn uni-calendar--right"></view>
</view>
<text
class="uni-calendar__backtoday"
@click="backToday"
v-if="!hideTodayBtn"
>{{todayText}}</text>
</view>
<view class="uni-calendar__box">
<view
v-if="showMonth"
class="uni-calendar__box-bg"
>
<text class="uni-calendar__box-bg-text">{{nowDate.month}}</text>
</view>
<view class="uni-calendar__weeks">
<view class="uni-calendar__weeks-day">
<text class="uni-calendar__weeks-day-text">{{SUNText}}</text>
</view>
<view class="uni-calendar__weeks-day">
<text class="uni-calendar__weeks-day-text">{{monText}}</text>
</view>
<view class="uni-calendar__weeks-day">
<text class="uni-calendar__weeks-day-text">{{TUEText}}</text>
</view>
<view class="uni-calendar__weeks-day">
<text class="uni-calendar__weeks-day-text">{{WEDText}}</text>
</view>
<view class="uni-calendar__weeks-day">
<text class="uni-calendar__weeks-day-text">{{THUText}}</text>
</view>
<view class="uni-calendar__weeks-day">
<text class="uni-calendar__weeks-day-text">{{FRIText}}</text>
</view>
<view class="uni-calendar__weeks-day">
<text class="uni-calendar__weeks-day-text">{{SATText}}</text>
</view>
</view>
<view
class="uni-calendar__weeks"
v-for="(item,weekIndex) in weeks"
:key="weekIndex"
>
<view
class="uni-calendar__weeks-item"
v-for="(weeks,weeksIndex) in item"
:key="weeksIndex"
>
<calendar-item
class="uni-calendar-item--hook"
:weeks="weeks"
:calendar="calendar"
:selected="selected"
:lunar="lunar"
@change="choiceDate"
></calendar-item>
</view>
</view>
</view>
<template v-if="showBottomBtn">
<view class="uni-calendar__footer_btns">
<view
class="uni-calendar__footer_btn"
@click="close"
>取消</view>
<view
class="uni-calendar__footer_btn uni-calendar__footer_btn-primary"
@click="confirm"
>确定</view>
</view>
</template>
</view>
</view>
</template>
<script>
import Calendar from './util.js';
import CalendarItem from './uni-calendar-item.vue'
import { initVueI18n } from '@dcloudio/uni-i18n'
import i18nMessages from './i18n/index.js'
const { t } = initVueI18n(i18nMessages)
/**
* Calendar 日历
* @description 日历组件可以查看日期,选择任意范围内的日期,打点操作。常用场景如:酒店日期预订、火车机票选择购买日期、上下班打卡等
* @tutorial https://ext.dcloud.net.cn/plugin?id=56
* @property {String} date 自定义当前时间,默认为今天
* @property {Boolean} lunar 显示农历
* @property {String} startDate 日期选择范围-开始日期
* @property {String} endDate 日期选择范围-结束日期
* @property {Boolean} range 范围选择
* @property {Boolean} insert = [true|false] 插入模式,默认为false
* @value true 弹窗模式
* @value false 插入模式
* @property {Boolean} clearDate = [true|false] 弹窗模式是否清空上次选择内容
* @property {Array} selected 打点,期待格式[{date: '2019-06-27', info: '签到', data: { custom: '自定义信息', name: '自定义消息头',xxx:xxx... }}]
* @property {Boolean} showMonth 是否选择月份为背景
* @event {Function} change 日期改变,`insert :ture` 时生效
* @event {Function} confirm 确认选择`insert :false` 时生效
* @event {Function} monthSwitch 切换月份时触发
* @example <uni-calendar :insert="true":lunar="true" :start-date="'2019-3-2'":end-date="'2019-5-20'"@change="change" />
*/
export default {
components: {
CalendarItem
},
emits: ['close', 'confirm', 'change', 'monthSwitch'],
props: {
date: {
type: String,
default: ''
},
selected: {
type: Array,
default () {
return []
}
},
lunar: {
type: Boolean,
default: false
},
startDate: {
type: String,
default: ''
},
endDate: {
type: String,
default: ''
},
range: {
type: Boolean,
default: false
},
insert: {
type: Boolean,
default: true
},
showMonth: {
type: Boolean,
default: true
},
clearDate: {
type: Boolean,
default: true
},
rangeValue: {
type: Object,
default: () => {
return {}
}
},
backgroundColor: {
type: String,
default: '#fff'
},
title: {
type: String,
default: '选择日期'
},
hideTodayBtn: {
type: Boolean,
default: true
},
openBeforeChange: {
type: Boolean,
default: false
},
showBottomBtn: {
type: Boolean,
default: false
},
hideMask: {
type: Boolean,
default: false
}
},
data () {
return {
show: false,
weeks: [],
calendar: {},
nowDate: '',
aniMaskShow: false
}
},
computed: {
/**
* for i18n
*/
okText () {
return t("uni-calender.ok")
},
cancelText () {
return t("uni-calender.cancel")
},
todayText () {
return t("uni-calender.today")
},
monText () {
return t("uni-calender.MON")
},
TUEText () {
return t("uni-calender.TUE")
},
WEDText () {
return t("uni-calender.WED")
},
THUText () {
return t("uni-calender.THU")
},
FRIText () {
return t("uni-calender.FRI")
},
SATText () {
return t("uni-calender.SAT")
},
SUNText () {
return t("uni-calender.SUN")
},
showNextBtn () {
let { cale, endDate, nowDate } = this,
maxDate = cale.getDate(endDate, -1, 'month')
return cale.dateCompare(`${nowDate.year}/${nowDate.month}`, `${maxDate.year}/${maxDate.month}`)
}
},
watch: {
date (newVal) {
this.init(newVal)
},
startDate (val) {
this.cale.resetSatrtDate(val)
this.cale.setDate(this.nowDate.fullDate)
this.weeks = this.cale.weeks
},
endDate (val) {
this.cale.resetEndDate(val)
this.cale.setDate(this.nowDate.fullDate)
this.weeks = this.cale.weeks
},
selected (newVal) {
this.cale.setSelectInfo(this.nowDate.fullDate, newVal)
this.weeks = this.cale.weeks
},
nowDate: {
handler (val) {
if (val) {
let { cale, endDate } = this,
maxDate = cale.getDate(endDate, -1, 'month')
cale.dateCompare(`${val.year}/${val.month}`, `${maxDate.year}/${maxDate.month}`)
}
},
deep: true,
immediate: true
}
},
created () {
this.cale = new Calendar({
selected: this.selected,
startDate: this.startDate,
endDate: this.endDate,
range: this.range,
})
this.init(this.date)
},
methods: {
// 取消穿透
clean () { },
bindDateChange (e) {
const value = e.detail.value + '-1'
this.setDate(value)
const { year, month } = this.cale.getDate(value)
this.$emit('monthSwitch', {
year,
month
})
},
/**
* 初始化日期显示
* @param {Object} date
*/
init (date) {
this.cale.setDate(date)
this.weeks = this.cale.weeks
this.nowDate = this.calendar = this.cale.getInfo(date)
},
/**
* 手动清空数据
*/
cleanDate () {
this.cale.cleanMultipleStatus()
this.init(this.date)
},
/**
* 打开日历弹窗
*/
open () {
// 弹窗模式并且清理数据
if (this.clearDate && !this.insert) {
this.cale.cleanMultipleStatus()
// this.cale.setDate(this.date)
this.init(this.date)
}
let { rangeValue } = this
if (Object.keys(rangeValue).length) {
uni.showLoading({
mask: true
})
let before = {
fullDate: rangeValue.before
},
after = {
fullDate: rangeValue.after
}
this.choiceDate(before)
setTimeout(() => {
uni.hideLoading()
this.choiceDate(after)
}, 100)
}
this.show = true
this.$nextTick(() => {
setTimeout(() => {
this.aniMaskShow = true
}, 50)
})
},
/**
* 关闭日历弹窗
*/
close () {
this.aniMaskShow = false
this.$nextTick(() => {
setTimeout(() => {
this.show = false
this.$emit('close')
}, 300)
})
},
/**
* 确认按钮
*/
confirm () {
this.setEmit('confirm')
this.close()
},
/**
* 变化触发
*/
change () {
if (!this.insert) return
this.setEmit('change')
},
/**
* 选择月份触发
*/
monthSwitch () {
let {
year,
month
} = this.nowDate
this.$emit('monthSwitch', {
year,
month: Number(month)
})
},
/**
* 派发事件
* @param {Object} name
*/
setEmit (name) {
let {
year,
month,
date,
fullDate,
lunar,
extraInfo
} = this.calendar
this.$emit(name, {
range: this.cale.multipleStatus,
year,
month,
date,
fulldate: fullDate,
lunar,
extraInfo: extraInfo || {}
})
},
/**
* 选择天触发
* @param {Object} weeks
*/
choiceDate (weeks) {
if (weeks.disable) return
if (this.openBeforeChange) {
// return this.setEmit('beforeChange', weeks)
return this.$emit('beforeChange', weeks)
}
this.calendar = weeks
// 设置多选
this.cale.setMultiple(this.calendar.fullDate)
this.weeks = this.cale.weeks
this.change()
},
/**手动触发选择天 */
manualChangeDate (weeks) {
this.calendar = weeks
this.cale.setMultiple(this.calendar.fullDate)
this.weeks = this.cale.weeks
this.change()
},
/**
* 回到今天
*/
backToday () {
const nowYearMonth = `${this.nowDate.year}-${this.nowDate.month}`
const date = this.cale.getDate(new Date())
const todayYearMonth = `${date.year}-${date.month}`
this.init(date.fullDate)
if (nowYearMonth !== todayYearMonth) {
this.monthSwitch()
}
this.change()
},
/**
* 上个月
*/
pre () {
const preDate = this.cale.getDate(this.nowDate.fullDate, -1, 'month').fullDate
this.setDate(preDate)
this.monthSwitch()
},
/**
* 下个月
*/
next () {
let { showNextBtn } = this
if (!showNextBtn) return
const nextDate = this.cale.getDate(this.nowDate.fullDate, +1, 'month').fullDate
this.setDate(nextDate)
this.monthSwitch()
},
/**
* 设置日期
* @param {Object} date
*/
setDate (date) {
this.cale.setDate(date)
this.weeks = this.cale.weeks
this.nowDate = this.cale.getInfo(date)
}
}
}
</script>
<style lang="scss" scoped>
$uni-bg-color-mask: rgba(
$color: #000000,
$alpha: 0.4
);
$uni-border-color: #ededed;
$uni-text-color: #333;
$uni-bg-color-hover: #f1f1f1;
$uni-font-size-base: 14px;
$uni-text-color-placeholder: #808080;
$uni-color-subtitle: #555555;
$uni-text-color-grey: #999;
.uni-calendar {
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
flex-direction: column;
}
.uni-calendar__mask {
position: fixed;
bottom: 0;
top: 0;
left: 0;
right: 0;
background-color: $uni-bg-color-mask;
transition-property: opacity;
transition-duration: 0.3s;
opacity: 0;
/* #ifndef APP-NVUE */
z-index: 99;
/* #endif */
}
.uni-calendar--mask-show {
opacity: 1;
}
.uni-calendar--mask-bg-hide {
opacity: 0;
}
.uni-calendar--fixed {
position: fixed;
/* #ifdef APP-NVUE */
bottom: 0;
/* #endif */
left: 0;
right: 0;
transition-property: transform;
transition-duration: 0.3s;
transform: translateY(460px);
/* #ifndef APP-NVUE */
bottom: calc(var(--window-bottom));
z-index: 99;
/* #endif */
border-radius: toRpx(32) toRpx(32) 0 0;
}
.uni-calendar--ani-show {
transform: translateY(0);
}
.uni-calendar__content {
background-color: #fff;
}
.uni-calendar__header {
position: relative;
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
flex-direction: row;
justify-content: center;
align-items: center;
height: 50px;
// border-bottom-color: $uni-border-color;
// border-bottom-style: solid;
// border-bottom-width: 1px;
}
.uni-calendar--fixed-top {
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
flex-direction: row;
justify-content: space-between;
// border-top-color: $uni-border-color;
// border-top-style: solid;
// border-top-width: 1px;
}
.uni-calendar--fixed-width {
width: 50px;
}
.uni-calendar__backtoday {
position: absolute;
right: 0;
top: toRpx(25);
padding: 0 5px;
padding-left: 10px;
height: 25px;
line-height: 25px;
font-size: 12px;
border-top-left-radius: 25px;
border-bottom-left-radius: 25px;
color: $uni-text-color;
background-color: $uni-bg-color-hover;
}
.uni-calendar__header-text {
text-align: center;
width: 100px;
font-size: $uni-font-size-base;
color: $uni-text-color;
}
.uni-calendar__header-btn-box {
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
flex-direction: row;
align-items: center;
justify-content: center;
width: 50px;
height: 50px;
}
.next-btn {
opacity: 0;
}
.show-next-btn {
opacity: 1;
}
.uni-calendar__header-btn {
width: 10px;
height: 10px;
border-left-color: $uni-text-color-placeholder;
border-left-style: solid;
border-left-width: 2px;
border-top-color: $uni-color-subtitle;
border-top-style: solid;
border-top-width: 2px;
}
.uni-calendar--left {
transform: rotate(-45deg);
}
.uni-calendar--right {
transform: rotate(135deg);
}
.uni-calendar__weeks {
position: relative;
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
flex-direction: row;
}
.uni-calendar__weeks-item {
flex: 1;
}
.uni-calendar__weeks-day {
flex: 1;
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
flex-direction: column;
justify-content: center;
align-items: center;
height: 45px;
border-bottom-color: #f5f5f5;
border-bottom-style: solid;
border-bottom-width: 1px;
}
.uni-calendar__weeks-day-text {
font-size: 14px;
}
.uni-calendar__box {
position: relative;
}
.uni-calendar__box-bg {
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
justify-content: center;
align-items: center;
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
}
.uni-calendar__box-bg-text {
font-size: 200px;
font-weight: bold;
color: $uni-text-color-grey;
opacity: 0.1;
text-align: center;
/* #ifndef APP-NVUE */
line-height: 1;
/* #endif */
}
.header-title-center {
margin: 0 auto;
}
.uni-calendar__footer_btns {
height: toRpx(176);
display: flex;
justify-content: center;
align-items: center;
gap: toRpx(32);
.uni-calendar__footer_btn {
width: toRpx(720);
height: toRpx(80);
border-radius: toRpx(64);
background: #f0f1f5;
display: flex;
align-items: center;
justify-content: center;
color: #333333;
font-size: toRpx(32);
font-weight: 500;
}
.uni-calendar__footer_btn-primary {
color: #fff;
background: linear-gradient(0deg, #2c66f7 0%, #48a6ff 100%);
}
}
.popup-close {
padding: 0 toRpx(48);
position: absolute;
right: 0;
top: 0;
height: 100%;
display: flex;
align-items: center;
}
</style>
<template>
<view class="uni-calendar">
<view
v-if="!insert&&show"
class="uni-calendar__mask"
:class="[{'uni-calendar--mask-show':aniMaskShow},{'uni-calendar--mask-bg-hide':hideMask}]"
@click="clean"
></view>
<view
v-if="insert || show"
class="uni-calendar__content"
:class="{'uni-calendar--fixed':!insert,'uni-calendar--ani-show':aniMaskShow}"
:style="[{backgroundColor:backgroundColor}]"
>
<view
v-if="!insert"
class="uni-calendar__header uni-calendar--fixed-top"
>
<template v-if="!showBottomBtn">
<view
class="uni-calendar__header-btn-box"
@click="close"
>
<text class="uni-calendar__header-text uni-calendar--fixed-width">{{cancelText}}</text>
</view>
</template>
<viw :class="['uni-calendar__header-title',{'header-title-center':showBottomBtn}]">{{title}}</viw>
<template v-if="!showBottomBtn">
<view
class="uni-calendar__header-btn-box"
@click="confirm"
>
<text class="uni-calendar__header-text uni-calendar--fixed-width">{{okText}}</text>
</view>
</template>
<template v-if="showBottomBtn">
<view
class="popup-close"
@click="close"
>
<uni-icons
type="closeempty"
size="18"
></uni-icons>
</view>
</template>
</view>
<view class="uni-calendar__header">
<view
:class="['uni-calendar__header-btn-box prev-btn',{'show-prev-btn':showPreBtn}]"
@click.stop="pre"
>
<view class="uni-calendar__header-btn uni-calendar--left"></view>
</view>
<picker
mode="date"
:value="date"
:end="endDate"
fields="month"
@change="bindDateChange"
>
<text class="uni-calendar__header-text">{{ (nowDate.year||'') +' / '+( nowDate.month||'')}}</text>
</picker>
<view
:class="['uni-calendar__header-btn-box next-btn',{'show-next-btn':showNextBtn}]"
@click.stop="next"
>
<view class="uni-calendar__header-btn uni-calendar--right"></view>
</view>
<text
class="uni-calendar__backtoday"
@click="backToday"
v-if="!hideTodayBtn"
>{{todayText}}</text>
</view>
<view class="uni-calendar__box">
<view
v-if="showMonth"
class="uni-calendar__box-bg"
>
<text class="uni-calendar__box-bg-text">{{nowDate.month}}</text>
</view>
<view class="uni-calendar__weeks">
<view class="uni-calendar__weeks-day">
<text class="uni-calendar__weeks-day-text">{{SUNText}}</text>
</view>
<view class="uni-calendar__weeks-day">
<text class="uni-calendar__weeks-day-text">{{monText}}</text>
</view>
<view class="uni-calendar__weeks-day">
<text class="uni-calendar__weeks-day-text">{{TUEText}}</text>
</view>
<view class="uni-calendar__weeks-day">
<text class="uni-calendar__weeks-day-text">{{WEDText}}</text>
</view>
<view class="uni-calendar__weeks-day">
<text class="uni-calendar__weeks-day-text">{{THUText}}</text>
</view>
<view class="uni-calendar__weeks-day">
<text class="uni-calendar__weeks-day-text">{{FRIText}}</text>
</view>
<view class="uni-calendar__weeks-day">
<text class="uni-calendar__weeks-day-text">{{SATText}}</text>
</view>
</view>
<view
class="uni-calendar__weeks"
v-for="(item,weekIndex) in weeks"
:key="weekIndex"
>
<view
class="uni-calendar__weeks-item"
v-for="(weeks,weeksIndex) in item"
:key="weeksIndex"
>
<calendar-item
class="uni-calendar-item--hook"
:weeks="weeks"
:calendar="calendar"
:selected="selected"
:lunar="lunar"
@change="choiceDate"
></calendar-item>
</view>
</view>
</view>
<template v-if="showBottomBtn">
<view class="uni-calendar__footer_btns">
<view
class="uni-calendar__footer_btn"
@click="close"
>取消</view>
<view
class="uni-calendar__footer_btn uni-calendar__footer_btn-primary"
@click="confirm"
>确定</view>
</view>
</template>
</view>
</view>
</template>
<script>
import Calendar from './util.js';
import CalendarItem from './uni-calendar-item.vue'
import { initVueI18n } from '@dcloudio/uni-i18n'
import i18nMessages from './i18n/index.js'
const { t } = initVueI18n(i18nMessages)
/**
* Calendar 日历
* @description 日历组件可以查看日期,选择任意范围内的日期,打点操作。常用场景如:酒店日期预订、火车机票选择购买日期、上下班打卡等
* @tutorial https://ext.dcloud.net.cn/plugin?id=56
* @property {String} date 自定义当前时间,默认为今天
* @property {Boolean} lunar 显示农历
* @property {String} startDate 日期选择范围-开始日期
* @property {String} endDate 日期选择范围-结束日期
* @property {Boolean} range 范围选择
* @property {Boolean} insert = [true|false] 插入模式,默认为false
* @value true 弹窗模式
* @value false 插入模式
* @property {Boolean} clearDate = [true|false] 弹窗模式是否清空上次选择内容
* @property {Array} selected 打点,期待格式[{date: '2019-06-27', info: '签到', data: { custom: '自定义信息', name: '自定义消息头',xxx:xxx... }}]
* @property {Boolean} showMonth 是否选择月份为背景
* @event {Function} change 日期改变,`insert :ture` 时生效
* @event {Function} confirm 确认选择`insert :false` 时生效
* @event {Function} monthSwitch 切换月份时触发
* @example <uni-calendar :insert="true":lunar="true" :start-date="'2019-3-2'":end-date="'2019-5-20'"@change="change" />
*/
export default {
components: {
CalendarItem
},
emits: ['close', 'confirm', 'change', 'monthSwitch'],
props: {
date: {
type: String,
default: ''
},
selected: {
type: Array,
default () {
return []
}
},
lunar: {
type: Boolean,
default: false
},
startDate: {
type: String,
default: ''
},
endDate: {
type: String,
default: ''
},
range: {
type: Boolean,
default: false
},
insert: {
type: Boolean,
default: true
},
showMonth: {
type: Boolean,
default: true
},
clearDate: {
type: Boolean,
default: true
},
rangeValue: {
type: Object,
default: () => {
return {}
}
},
backgroundColor: {
type: String,
default: '#fff'
},
title: {
type: String,
default: '选择日期'
},
hideTodayBtn: {
type: Boolean,
default: true
},
openBeforeChange: {
type: Boolean,
default: false
},
showBottomBtn: {
type: Boolean,
default: false
},
hideMask: {
type: Boolean,
default: false
}
},
data () {
return {
show: false,
weeks: [],
calendar: {},
nowDate: '',
aniMaskShow: false
}
},
computed: {
/**
* for i18n
*/
okText () {
return t("uni-calender.ok")
},
cancelText () {
return t("uni-calender.cancel")
},
todayText () {
return t("uni-calender.today")
},
monText () {
return t("uni-calender.MON")
},
TUEText () {
return t("uni-calender.TUE")
},
WEDText () {
return t("uni-calender.WED")
},
THUText () {
return t("uni-calender.THU")
},
FRIText () {
return t("uni-calender.FRI")
},
SATText () {
return t("uni-calender.SAT")
},
SUNText () {
return t("uni-calender.SUN")
},
showNextBtn () {
let { cale, endDate, nowDate } = this,
maxDate = cale.getDate(endDate, -1, 'month')
return !endDate ? true :cale.dateCompare(`${nowDate.year}/${nowDate.month}`, `${maxDate.year}/${maxDate.month}`)
},
showPreBtn () {
let { cale, startDate, nowDate } = this,
minDate = cale.getDate(startDate, -1, 'month')
return !startDate ? true : cale.dateCompare(`${nowDate.year}/${nowDate.month}`, `${minDate.year}/${minDate.month}`)
}
},
watch: {
date (newVal) {
this.init(newVal)
},
startDate (val) {
this.cale.resetSatrtDate(val)
this.cale.setDate(this.nowDate.fullDate)
this.weeks = this.cale.weeks
},
endDate (val) {
this.cale.resetEndDate(val)
this.cale.setDate(this.nowDate.fullDate)
this.weeks = this.cale.weeks
},
selected (newVal) {
this.cale.setSelectInfo(this.nowDate.fullDate, newVal)
this.weeks = this.cale.weeks
},
nowDate: {
handler (val) {
if (val) {
let { cale, endDate } = this,
maxDate = cale.getDate(endDate, -1, 'month')
cale.dateCompare(`${val.year}/${val.month}`, `${maxDate.year}/${maxDate.month}`)
}
},
deep: true,
immediate: true
}
},
created () {
this.cale = new Calendar({
selected: this.selected,
startDate: this.startDate,
endDate: this.endDate,
range: this.range,
})
this.init(this.date)
},
methods: {
// 取消穿透
clean () { },
bindDateChange (e) {
const value = e.detail.value + '-1'
this.setDate(value)
const { year, month } = this.cale.getDate(value)
this.$emit('monthSwitch', {
year,
month
})
},
/**
* 初始化日期显示
* @param {Object} date
*/
init (date) {
this.cale.setDate(date)
this.weeks = this.cale.weeks
this.nowDate = this.calendar = this.cale.getInfo(date)
},
/**
* 手动清空数据
*/
cleanDate () {
this.cale.cleanMultipleStatus()
this.init(this.date)
},
/**
* 打开日历弹窗
*/
open () {
// 弹窗模式并且清理数据
if (this.clearDate && !this.insert) {
this.cale.cleanMultipleStatus()
// this.cale.setDate(this.date)
this.init(this.date)
}
let { rangeValue } = this
if (Object.keys(rangeValue).length) {
uni.showLoading({
mask: true
})
let before = {
fullDate: rangeValue.before
},
after = {
fullDate: rangeValue.after
}
this.choiceDate(before)
setTimeout(() => {
uni.hideLoading()
this.choiceDate(after)
}, 100)
}
this.show = true
this.$nextTick(() => {
setTimeout(() => {
this.aniMaskShow = true
}, 50)
})
},
/**
* 关闭日历弹窗
*/
close () {
this.aniMaskShow = false
this.$nextTick(() => {
setTimeout(() => {
this.show = false
this.$emit('close')
}, 300)
})
},
/**
* 确认按钮
*/
confirm () {
this.setEmit('confirm')
this.close()
},
/**
* 变化触发
*/
change () {
if (!this.insert) return
this.setEmit('change')
},
/**
* 选择月份触发
*/
monthSwitch () {
let {
year,
month
} = this.nowDate
this.$emit('monthSwitch', {
year,
month: Number(month)
})
},
/**
* 派发事件
* @param {Object} name
*/
setEmit (name) {
let {
year,
month,
date,
fullDate,
lunar,
extraInfo
} = this.calendar
this.$emit(name, {
range: this.cale.multipleStatus,
year,
month,
date,
fulldate: fullDate,
lunar,
extraInfo: extraInfo || {}
})
},
/**
* 选择天触发
* @param {Object} weeks
*/
choiceDate (weeks) {
if (weeks.disable) return
if (this.openBeforeChange) {
// return this.setEmit('beforeChange', weeks)
return this.$emit('beforeChange', weeks)
}
this.calendar = weeks
// 设置多选
this.cale.setMultiple(this.calendar.fullDate)
this.weeks = this.cale.weeks
this.change()
},
/**手动触发选择天 */
manualChangeDate (weeks) {
this.calendar = weeks
this.cale.setMultiple(this.calendar.fullDate)
this.weeks = this.cale.weeks
this.change()
},
/**
* 回到今天
*/
backToday () {
const nowYearMonth = `${this.nowDate.year}-${this.nowDate.month}`
const date = this.cale.getDate(new Date())
const todayYearMonth = `${date.year}-${date.month}`
this.init(date.fullDate)
if (nowYearMonth !== todayYearMonth) {
this.monthSwitch()
}
this.change()
},
/**
* 上个月
*/
pre () {
const preDate = this.cale.getDate(this.nowDate.fullDate, -1, 'month').fullDate
this.setDate(preDate)
this.monthSwitch()
},
/**
* 下个月
*/
next () {
let { showNextBtn } = this
if (!showNextBtn) return
const nextDate = this.cale.getDate(this.nowDate.fullDate, +1, 'month').fullDate
this.setDate(nextDate)
this.monthSwitch()
},
/**
* 设置日期
* @param {Object} date
*/
setDate (date) {
this.cale.setDate(date)
this.weeks = this.cale.weeks
this.nowDate = this.cale.getInfo(date)
}
}
}
</script>
<style lang="scss" scoped>
$uni-bg-color-mask: rgba(
$color: #000000,
$alpha: 0.4
);
$uni-border-color: #ededed;
$uni-text-color: #333;
$uni-bg-color-hover: #f1f1f1;
$uni-font-size-base: 14px;
$uni-text-color-placeholder: #808080;
$uni-color-subtitle: #555555;
$uni-text-color-grey: #999;
.uni-calendar {
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
flex-direction: column;
}
.uni-calendar__mask {
position: fixed;
bottom: 0;
top: 0;
left: 0;
right: 0;
background-color: $uni-bg-color-mask;
transition-property: opacity;
transition-duration: 0.3s;
opacity: 0;
/* #ifndef APP-NVUE */
z-index: 99;
/* #endif */
}
.uni-calendar--mask-show {
opacity: 1;
}
.uni-calendar--mask-bg-hide {
opacity: 0;
}
.uni-calendar--fixed {
position: fixed;
/* #ifdef APP-NVUE */
bottom: 0;
/* #endif */
left: 0;
right: 0;
transition-property: transform;
transition-duration: 0.3s;
transform: translateY(460px);
/* #ifndef APP-NVUE */
bottom: calc(var(--window-bottom));
z-index: 99;
/* #endif */
border-radius: toRpx(32) toRpx(32) 0 0;
}
.uni-calendar--ani-show {
transform: translateY(0);
}
.uni-calendar__content {
background-color: #fff;
}
.uni-calendar__header {
position: relative;
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
flex-direction: row;
justify-content: center;
align-items: center;
height: 50px;
// border-bottom-color: $uni-border-color;
// border-bottom-style: solid;
// border-bottom-width: 1px;
}
.uni-calendar--fixed-top {
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
flex-direction: row;
justify-content: space-between;
// border-top-color: $uni-border-color;
// border-top-style: solid;
// border-top-width: 1px;
}
.uni-calendar--fixed-width {
width: 50px;
}
.uni-calendar__backtoday {
position: absolute;
right: 0;
top: toRpx(25);
padding: 0 5px;
padding-left: 10px;
height: 25px;
line-height: 25px;
font-size: 12px;
border-top-left-radius: 25px;
border-bottom-left-radius: 25px;
color: $uni-text-color;
background-color: $uni-bg-color-hover;
}
.uni-calendar__header-text {
text-align: center;
width: 100px;
font-size: $uni-font-size-base;
color: $uni-text-color;
}
.uni-calendar__header-btn-box {
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
flex-direction: row;
align-items: center;
justify-content: center;
width: 50px;
height: 50px;
}
.next-btn ,.prev-btn{
opacity: 0;
}
.show-next-btn ,.show-prev-btn{
opacity: 1;
}
.uni-calendar__header-btn {
width: 10px;
height: 10px;
border-left-color: $uni-text-color-placeholder;
border-left-style: solid;
border-left-width: 2px;
border-top-color: $uni-color-subtitle;
border-top-style: solid;
border-top-width: 2px;
}
.uni-calendar--left {
transform: rotate(-45deg);
}
.uni-calendar--right {
transform: rotate(135deg);
}
.uni-calendar__weeks {
position: relative;
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
flex-direction: row;
}
.uni-calendar__weeks-item {
flex: 1;
}
.uni-calendar__weeks-day {
flex: 1;
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
flex-direction: column;
justify-content: center;
align-items: center;
height: 45px;
border-bottom-color: #f5f5f5;
border-bottom-style: solid;
border-bottom-width: 1px;
}
.uni-calendar__weeks-day-text {
font-size: 14px;
}
.uni-calendar__box {
position: relative;
}
.uni-calendar__box-bg {
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
justify-content: center;
align-items: center;
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
}
.uni-calendar__box-bg-text {
font-size: 200px;
font-weight: bold;
color: $uni-text-color-grey;
opacity: 0.1;
text-align: center;
/* #ifndef APP-NVUE */
line-height: 1;
/* #endif */
}
.header-title-center {
margin: 0 auto;
}
.uni-calendar__footer_btns {
height: toRpx(176);
display: flex;
justify-content: center;
align-items: center;
gap: toRpx(32);
.uni-calendar__footer_btn {
width: toRpx(720);
height: toRpx(80);
border-radius: toRpx(64);
background: #f0f1f5;
display: flex;
align-items: center;
justify-content: center;
color: #333333;
font-size: toRpx(32);
font-weight: 500;
}
.uni-calendar__footer_btn-primary {
color: #fff;
background: linear-gradient(0deg, #2c66f7 0%, #48a6ff 100%);
}
}
.popup-close {
padding: 0 toRpx(48);
position: absolute;
right: 0;
top: 0;
height: 100%;
display: flex;
align-items: center;
}
</style>
// 车牌号省市代码映射表
const licenseData = {
京: { name: '北京', cities: { A: '城区', B: '出租车', C: '城区', E: '城区', F: '城区', G: '远郊区', H: '远郊区', J: '远郊区', K: '城区', L: '城区', M: '城区', N: '城区', P: '城区', Q: '城区' } },
津: { name: '天津', cities: { A: '公交/公安', B: '城区', C: '城区', D: '城区', E: '出租车', F: '城区', G: '城区', H: '城区' } },
沪: { name: '上海', cities: { A: '市区', B: '市区', C: '郊区', D: '市区', E: '市区', F: '市区', G: '市区', H: '市区', J: '市区', K: '市区', L: '市区', M: '市区', N: '市区', R: '崇明/长兴/横沙' } },
渝: { name: '重庆', cities: { A: '市区', B: '万州', C: '永川', D: '市区', F: '涪陵', G: '黔江', H: '武隆' } },
冀: { name: '河北', cities: { A: '石家庄', B: '唐山', C: '秦皇岛', D: '邯郸', E: '邢台', F: '保定', G: '张家口', H: '承德', J: '沧州', R: '廊坊', T: '衡水' } },
豫: { name: '河南', cities: { A: '郑州', B: '开封', C: '洛阳', D: '平顶山', E: '安阳', F: '鹤壁', G: '新乡', H: '焦作', J: '濮阳', K: '许昌', L: '漯河', M: '三门峡', N: '商丘', P: '周口', Q: '驻马店', R: '南阳', S: '信阳', U: '济源' } },
云: { name: '云南', cities: { A: '昆明', C: '昭通', D: '曲靖', E: '楚雄', F: '玉溪', G: '红河', H: '文山', J: '普洱', K: '西双版纳', L: '大理', M: '保山', N: '德宏', P: '丽江', Q: '怒江', R: '迪庆', S: '临沧' } },
辽: { name: '辽宁', cities: { A: '沈阳', B: '大连', C: '鞍山', D: '抚顺', E: '本溪', F: '丹东', G: '锦州', H: '营口', J: '阜新', K: '辽阳', L: '盘锦', M: '铁岭', N: '朝阳', P: '葫芦岛' } },
黑: { name: '黑龙江', cities: { A: '哈尔滨', B: '齐齐哈尔', C: '牡丹江', D: '佳木斯', E: '大庆', F: '伊春', G: '鸡西', H: '鹤岗', J: '双鸭山', K: '七台河', L: '松原', M: '绥化', N: '黑河', P: '大兴安岭' } },
湘: { name: '湖南', cities: { A: '长沙', B: '株洲', C: '湘潭', D: '衡阳', E: '邵阳', F: '岳阳', G: '张家界', H: '益阳', J: '常德', K: '娄底', L: '郴州', M: '永州', N: '怀化', U: '湘西' } },
皖: { name: '安徽', cities: { A: '合肥', B: '芜湖', C: '蚌埠', D: '淮南', E: '马鞍山', F: '淮北', G: '铜陵', H: '安庆', J: '黄山', K: '阜阳', L: '宿州', M: '滁州', N: '六安', P: '宣城', Q: '池州', R: '亳州' } },
鲁: { name: '山东', cities: { A: '济南', B: '青岛', C: '淄博', D: '枣庄', E: '东营', F: '烟台', G: '潍坊', H: '济宁', J: '泰安', K: '威海', L: '日照', M: '滨州', N: '德州', P: '聊城', Q: '临沂', R: '菏泽', S: '莱芜', U: '青岛增补', V: '潍坊增补' } },
新: { name: '新疆', cities: { A: '乌鲁木齐', B: '昌吉', C: '石河子', D: '奎屯', E: '博尔塔拉', F: '伊犁', G: '塔城', H: '阿勒泰', J: '克拉玛依', K: '吐鲁番', L: '哈密', M: '巴音郭楞', N: '阿克苏', P: '克孜勒苏', Q: '喀什', R: '和田' } },
苏: { name: '江苏', cities: { A: '南京', B: '无锡', C: '徐州', D: '常州', E: '苏州', F: '南通', G: '连云港', H: '淮安', J: '盐城', K: '扬州', L: '镇江', M: '泰州', N: '宿迁', U: '苏州增补' } },
浙: { name: '浙江', cities: { A: '杭州', B: '宁波', C: '温州', D: '绍兴', E: '湖州', F: '嘉兴', G: '金华', H: '衢州', J: '台州', K: '丽水', L: '舟山' } },
赣: { name: '江西', cities: { A: '南昌', B: '赣州', C: '宜春', D: '吉安', E: '上饶', F: '抚州', G: '九江', H: '景德镇', J: '萍乡', K: '新余', L: '鹰潭' } },
鄂: { name: '湖北', cities: { A: '武汉', B: '黄石', C: '十堰', D: '荆州', E: '宜昌', F: '襄阳', G: '鄂州', H: '荆门', J: '黄冈', K: '孝感', L: '咸宁', M: '仙桃', N: '潜江', P: '神农架', Q: '天门', R: '恩施' } },
桂: { name: '广西', cities: { A: '南宁', B: '柳州', C: '桂林', D: '梧州', E: '北海', F: '崇左', G: '来宾', H: '桂林', J: '贺州', K: '玉林', L: '百色', M: '河池', N: '钦州', P: '防城港', R: '贵港' } },
甘: { name: '甘肃', cities: { A: '兰州', B: '嘉峪关', C: '金昌', D: '白银', E: '天水', F: '酒泉', G: '张掖', H: '平凉', J: '庆阳', K: '定西', L: '陇南', M: '临夏', N: '甘南' } },
晋: { name: '山西', cities: { A: '太原', B: '大同', C: '阳泉', D: '长治', E: '晋城', F: '朔州', H: '忻州', J: '吕梁', K: '晋中', L: '临汾', M: '运城' } },
蒙: { name: '内蒙古', cities: { A: '呼和浩特', B: '包头', C: '乌海', D: '赤峰', E: '呼伦贝尔', F: '兴安盟', G: '通辽', H: '锡林郭勒', J: '乌兰察布', K: '鄂尔多斯', L: '巴彦淖尔', M: '阿拉善' } },
陕: { name: '陕西', cities: { A: '西安', B: '铜川', C: '宝鸡', D: '咸阳', E: '渭南', F: '汉中', G: '安康', H: '商洛', J: '延安', K: '榆林', V: '杨凌' } },
吉: { name: '吉林', cities: { A: '长春', B: '吉林', C: '四平', D: '辽源', E: '通化', F: '白山', G: '白城', H: '延边', J: '松原' } },
闽: { name: '福建', cities: { A: '福州', B: '厦门', C: '宁德', D: '莆田', E: '泉州', F: '漳州', G: '龙岩', H: '三明', J: '南平' } },
贵: { name: '贵州', cities: { A: '贵阳', B: '六盘水', C: '遵义', D: '安顺', E: '铜仁', F: '毕节', G: '黔西南', H: '黔东南', J: '黔南' } },
粤: { name: '广东', cities: { A: '广州', B: '深圳', C: '珠海', D: '汕头', E: '佛山', F: '韶关', G: '湛江', H: '肇庆', J: '江门', K: '茂名', L: '惠州', M: '梅州', N: '汕尾', P: '河源', Q: '阳江', R: '清远', S: '东莞', T: '中山', U: '潮州', V: '揭阳', W: '云浮', X: '顺德', Y: '南海', Z: '港澳' } },
青: { name: '青海', cities: { A: '西宁', B: '海东', C: '海北', D: '黄南', E: '海南州', F: '果洛', G: '玉树', H: '海西' } },
藏: { name: '西藏', cities: { A: '拉萨', B: '昌都', C: '山南', D: '日喀则', E: '那曲', F: '阿里', G: '林芝' } },
川: { name: '四川', cities: { A: '成都', B: '绵阳', C: '自贡', D: '攀枝花', E: '泸州', F: '德阳', G: '成都增补', H: '广元', J: '遂宁', K: '内江', L: '乐山', M: '资阳', Q: '宜宾', R: '南充', S: '达州', T: '雅安', U: '阿坝', V: '甘孜', W: '凉山', X: '广安', Y: '巴中', Z: '眉山' } },
宁: { name: '宁夏', cities: { A: '银川', B: '石嘴山', C: '吴忠', D: '固原', E: '中卫' } },
琼: { name: '海南', cities: { A: '海口', B: '三亚', C: '三沙', D: '五指山', E: '洋浦', F: '儋州' } }
}
/**
* 解析车牌省市
* @param {string} plateStr - 车牌号 (如: "粤B12345")
* @returns {object} { province, city, success }
*/
export function getPlateLocation(plateStr) {
// 基础校验
if (!plateStr || typeof plateStr !== 'string' || plateStr.length < 2) {
return { province: '', city: '', success: false }
}
const pChar = plateStr.charAt(0) // 提取省份简称:粤
const cChar = plateStr.charAt(1).toUpperCase() // 提取地市代码:B
const provinceInfo = licenseData[pChar]
if (provinceInfo) {
const cityName = provinceInfo.cities[cChar]
if (cityName) {
// 处理省份名称,添加"省"或"市"后缀
let province = provinceInfo.name
// 直辖市不需要加"省",只需要加"市"
const municipalities = ['北京', '上海', '天津', '重庆']
if (municipalities.includes(province)) {
province = province + '市'
} else if (province === '内蒙古') {
province = province + '自治区'
} else if (province === '新疆' || province === '西藏' || province === '广西' || province === '宁夏') {
// 其他自治区,根据习惯可能需要加"自治区"或"省",这里统一加"省"
province = province + '省'
} else {
province = province + '省'
}
// 处理城市名称,添加"市"后缀(如果还没有)
let city = cityName
// 特殊情况:不需要加"市"的情况
// 1. 已经以"市"结尾
// 2. 包含特殊关键词:城区、市区、郊区、出租车、公交、增补
// 3. 包含斜杠(如:崇明/长兴/横沙)
const specialKeywords = ['城区', '市区', '郊区', '出租车', '公交', '增补']
const isSpecialCase = specialKeywords.some(keyword => city.includes(keyword)) || city.includes('/')
// 普通城市名称添加"市"后缀
if (!city.endsWith('市') && !isSpecialCase) {
city = city + '市'
}
return {
province: province,
city: city,
success: true
}
}
}
return { province: '', city: '', success: false }
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!