Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
saas_plus
/
dj-car-boutique-work-wechat
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
1
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit cdec3bb4
authored
Jun 30, 2026
by
岑成威
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
fix: 验证签约
1 parent
489c03a9
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
186 additions
and
93 deletions
packageUsedCar/pages/evaluationForm/signInfo/services/contractAmount.js
packageUsedCar/pages/evaluationForm/signInfo/signInfo.js
packageUsedCar/pages/evaluationForm/signInfo/tests/contractAmount.test.mjs
project.config.json
packageUsedCar/pages/evaluationForm/signInfo/services/contractAmount.js
0 → 100644
View file @
cdec3bb
/**
* @file 签约金额提交计算服务。
* 仅负责根据页面付款类型计算接口所需 fullPrice,不处理页面 setData 或接口调用。
*/
/**
* 计算签约提交参数中的合同总金额(fullPrice)。
* @param {Object} formData 页面表单数据
* @param {string|number} formData.paymentType 付款类型:1 定金+尾款,2 全款
* @param {string|number} [formData.depositPrice] 定金金额
* @param {string|number} [formData.finalPrice] 尾款金额
* @param {string|number} [formData.fullPrice] 全款金额
* @param {string|number} [formData.evalPrice] 评估价
* @param {Object} [query] 页面路由参数
* @param {string|number} [query.evalPrice] 路由透传评估价
* @returns {number|string} 提交给后端的 fullPrice;无法计算时返回空字符串
*/
function
computeSubmitContractAmount
(
formData
=
{},
query
=
{})
{
const
evalPrice
=
Number
(
formData
.
evalPrice
||
query
?.
evalPrice
||
0
)
if
(
formData
.
paymentType
==
1
)
{
const
depositPrice
=
Number
(
formData
.
depositPrice
||
0
)
const
finalPrice
=
Number
(
formData
.
finalPrice
||
0
)
const
splitAmount
=
depositPrice
+
finalPrice
// 定金场景优先用分金额合计,避免全款字段串场;分金额缺失时兜底评估价
return
splitAmount
>
0
?
splitAmount
:
(
evalPrice
||
''
)
}
return
formData
.
fullPrice
||
evalPrice
||
''
}
module
.
exports
=
{
computeSubmitContractAmount
}
packageUsedCar/pages/evaluationForm/signInfo/signInfo.js
View file @
cdec3bb
...
...
@@ -5,12 +5,14 @@ import api from '~/api/api.js'
import
{
uploadFile
,
getImageDisplayUrl
}
from
'~/packageUsedCar/utils/oss/ossUpload.js'
import
newApi
from
'~/packageUsedCar/api'
import
mapApi
from
"~/packageUsedCar/utils/mapapi/mapapi"
;
import
contractAmountService
from
'./services/contractAmount.js'
/** 合同模板查询类型:广联 / 小鹏等 */
const
CONTRACT_TEMPLATE_TYPES
=
[
'1'
,
'5'
]
/** 默认优先选中的合同模板名称 */
const
DEFAULT_TEMPLATE_NAME
=
'广联二手车转让协议'
const
{
computeSubmitContractAmount
}
=
contractAmountService
Page
({
...
...
@@ -577,15 +579,20 @@ Page({
)
const
pickedTemplate
=
template
||
this
.
getDefaultTemplate
(
this
.
data
.
contractTemplateList
)
const
evalPrice
=
formData
.
evalPrice
||
query
?.
evalPrice
||
''
this
.
setData
({
formFields
:
newFormFields
,
'formData.paymentType'
:
value
,
'formData.finalPrice'
:
''
,
'formData.depositPrice'
:
''
,
'formData.fullPrice'
:
value
==
2
?
evalPrice
:
''
,
'formData.fullPrice'
:
''
,
'formData.docTemplateId'
:
pickedTemplate
?.
docTemplateId
||
''
,
'formData.docTemplateName'
:
pickedTemplate
?.
docTemplateName
||
''
},
()
=>
{
setTimeout
(()
=>
{
if
(
query
?.
evalPrice
&&
value
==
2
)
{
this
.
setData
({
'formData.fullPrice'
:
query
.
evalPrice
})
}
},
150
)
})
},
...
...
@@ -1272,8 +1279,10 @@ Page({
wx.$util.showToast('请选择合同类型')
return
}
const contractAmount = computeSubmitContractAmount(formData, query)
const submitData = {
...formData,
fullPrice: contractAmount,
evalOrderNo: query.evalOrderNo,
docTemplateId: formData.docTemplateId
}
...
...
packageUsedCar/pages/evaluationForm/signInfo/tests/contractAmount.test.mjs
0 → 100644
View file @
cdec3bb
import { describe, it } from 'node:test'
import assert from 'node:assert/strict'
import { createRequire } from 'node:module'
const require = createRequire(import.meta.url)
const {
computeSubmitContractAmount
} = require('../services/contractAmount.js')
describe('signInfo contract amount compute', () => {
it('returns deposit + final for paymentType=1', () => {
const amount = computeSubmitContractAmount({
paymentType: 1,
depositPrice: '1200',
finalPrice: '800',
evalPrice: '3000'
}, {})
assert.equal(amount, 2000)
})
it('falls back to evalPrice for paymentType=1 when split missing', () => {
const amount = computeSubmitContractAmount({
paymentType: 1,
depositPrice: '',
finalPrice: '',
evalPrice: '25600'
}, {})
assert.equal(amount, 25600)
})
it('uses fullPrice for paymentType=2', () => {
const amount = computeSubmitContractAmount({
paymentType: 2,
fullPrice: '18800',
evalPrice: '20000'
}, {})
assert.equal(amount, '18800')
})
it('falls back to query evalPrice for paymentType=2 when fullPrice empty', () => {
const amount = computeSubmitContractAmount({
paymentType: 2,
fullPrice: '',
evalPrice: ''
}, {
evalPrice: '19999'
})
assert.equal(amount, 19999)
})
})
project.config.json
View file @
cdec3bb
{
"projectname"
:
"%E7%B2%BE%E5%93%81%E5%8D%87%E7%BA%A7"
,
"compileType"
:
"miniprogram"
,
"libVersion"
:
"3.13.1"
,
"packOptions"
:
{
"ignore"
:
[
{
"value"
:
".vscode"
,
"type"
:
"folder"
},
{
"value"
:
"docs"
,
"type"
:
"folder"
},
{
"value"
:
"packageDynamicForm/tests"
,
"type"
:
"folder"
},
{
"value"
:
"packageDynamicForm/test"
,
"type"
:
"folder"
},
{
"value"
:
"packageDynamicForm/scripts"
,
"type"
:
"folder"
},
{
"value"
:
"packageDynamicForm/docs"
,
"type"
:
"folder"
},
{
"value"
:
"packageDynamicForm/README.md"
,
"type"
:
"file"
},
{
"value"
:
"packageDynamicForm/fixtures/schema-staff-daily-full.json"
,
"type"
:
"file"
},
{
"value"
:
"packageDynamicForm/fixtures/mock-store-detail-jsonContent.json"
,
"type"
:
"file"
}
],
"include"
:
[]
},
"setting"
:
{
"urlCheck"
:
false
,
"coverView"
:
true
,
"es6"
:
true
,
"postcss"
:
true
,
"minified"
:
true
,
"enhance"
:
true
,
"showShadowRootInWxmlPanel"
:
true
,
"packNpmRelationList"
:
[
{
"packageJsonPath"
:
"./package.json"
,
"miniprogramNpmDistDir"
:
"./"
},
{
"packageJsonPath"
:
"./packageUsedCar/package.json"
,
"miniprogramNpmDistDir"
:
"./packageUsedCar/"
}
],
"ignoreUploadUnusedFiles"
:
true
,
"babelSetting"
:
{
"ignore"
:
[],
"disablePlugins"
:
[],
"outputPath"
:
""
},
"useCompilerPlugins"
:
[
"sass"
],
"ignoreDevUnusedFiles"
:
false
,
"minifyWXML"
:
true
,
"compileWorklet"
:
false
,
"uglifyFileName"
:
false
,
"uploadWithSourceMap"
:
false
,
"packNpmManually"
:
true
,
"minifyWXSS"
:
true
,
"localPlugins"
:
false
,
"disableUseStrict"
:
false
,
"condition"
:
false
,
"swc"
:
false
,
"disableSWC"
:
true
},
"editorSetting"
:
{
"tabIndent"
:
"insertSpaces"
,
"tabSize"
:
2
},
"appid"
:
"wx4e697bcf4954ceef"
,
"simulatorPluginLibVersion"
:
{}
{
"projectname"
:
"%E7%B2%BE%E5%93%81%E5%8D%87%E7%BA%A7"
,
"compileType"
:
"miniprogram"
,
"libVersion"
:
"3.13.1"
,
"packOptions"
:
{
"ignore"
:
[
{
"value"
:
".vscode"
,
"type"
:
"folder"
},
{
"value"
:
"docs"
,
"type"
:
"folder"
},
{
"value"
:
"packageDynamicForm/tests"
,
"type"
:
"folder"
},
{
"value"
:
"packageDynamicForm/test"
,
"type"
:
"folder"
},
{
"value"
:
"packageDynamicForm/scripts"
,
"type"
:
"folder"
},
{
"value"
:
"packageDynamicForm/docs"
,
"type"
:
"folder"
},
{
"value"
:
"packageDynamicForm/README.md"
,
"type"
:
"file"
},
{
"value"
:
"packageDynamicForm/fixtures/schema-staff-daily-full.json"
,
"type"
:
"file"
},
{
"value"
:
"packageDynamicForm/fixtures/mock-store-detail-jsonContent.json"
,
"type"
:
"file"
}
],
"include"
:
[]
},
"setting"
:
{
"urlCheck"
:
false
,
"coverView"
:
true
,
"es6"
:
true
,
"postcss"
:
true
,
"minified"
:
true
,
"enhance"
:
true
,
"showShadowRootInWxmlPanel"
:
true
,
"packNpmRelationList"
:
[
{
"packageJsonPath"
:
"./package.json"
,
"miniprogramNpmDistDir"
:
"./"
},
{
"packageJsonPath"
:
"./packageUsedCar/package.json"
,
"miniprogramNpmDistDir"
:
"./packageUsedCar/"
}
],
"ignoreUploadUnusedFiles"
:
true
,
"babelSetting"
:
{
"ignore"
:
[],
"disablePlugins"
:
[],
"outputPath"
:
""
},
"useCompilerPlugins"
:
[
"sass"
],
"ignoreDevUnusedFiles"
:
false
,
"minifyWXML"
:
true
,
"compileWorklet"
:
false
,
"uglifyFileName"
:
false
,
"uploadWithSourceMap"
:
false
,
"packNpmManually"
:
true
,
"minifyWXSS"
:
true
,
"localPlugins"
:
false
,
"disableUseStrict"
:
false
,
"condition"
:
false
,
"swc"
:
false
,
"disableSWC"
:
true
},
"editorSetting"
:
{
"tabIndent"
:
"insertSpaces"
,
"tabSize"
:
2
},
"appid"
:
"wx4e697bcf4954ceef"
,
"simulatorPluginLibVersion"
:
{}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment