feat(order): 新增身份证号手动填写及格式校验
- 在订单确认页新增身份证号输入框,支持识别失败时手动填写 - 身份证号字段改为可选项,仅有值时进行格式校验,格式校验规则为18位数字或含X/x结尾的号码 - 提交订单时仅当身份证号非空才将该字段传给后端,避免覆盖后端OCR识别结果 - 移除前端OCR相关密钥配置及调用,改为后端统一识别处理 - 优化上传逻辑及界面交互,确保身份证号信息正确传递及提示
This commit is contained in:
+38
-19
@@ -62,6 +62,7 @@
|
||||
<u-input type="number" v-model="emergentUser" placeholder="请输入紧急联系人电话" />
|
||||
<u-input type="text" v-model="officeAddress" placeholder="请输入单位地址" />
|
||||
<u-input type="text" v-model="homeAddress" placeholder="请输入家庭地址" />
|
||||
<u-input type="idcard" v-model="idCode" placeholder="身份证号(一般自动识别,识别失败可手动填写)" />
|
||||
</view>
|
||||
</u-form>
|
||||
<view class="btn">
|
||||
@@ -127,12 +128,21 @@
|
||||
message: '请输入单位地址',
|
||||
trigger: ['blur', 'change']
|
||||
}],
|
||||
homeAddress: [{
|
||||
required: true,
|
||||
message: '请输入家庭地址',
|
||||
trigger: ['blur', 'change']
|
||||
}],
|
||||
}
|
||||
homeAddress: [{
|
||||
required: true,
|
||||
message: '请输入家庭地址',
|
||||
trigger: ['blur', 'change']
|
||||
}],
|
||||
idCode: [{
|
||||
validator: (rule, value, callback) => {
|
||||
// 允许为空(身份证号由后端 OCR 自动识别);有值时才校验格式
|
||||
if (!value) return true
|
||||
return /^\d{17}[\dXx]$/.test(value || '')
|
||||
},
|
||||
message: '身份证号格式不正确',
|
||||
trigger: ['blur', 'change']
|
||||
}],
|
||||
}
|
||||
|
||||
// 图片槽位说明(与 orderSourceData 下标一一对应)
|
||||
const imageSlotLabels = ['身份证正面', '身份证反面', '人车合照', '车子照片', '安装照片']
|
||||
@@ -157,6 +167,8 @@
|
||||
emergentUser: '',
|
||||
officeAddress: '',
|
||||
homeAddress: '',
|
||||
// 身份证号(上传正面后由 OCR 自动识别回填,也可手动修改)
|
||||
idCode: '',
|
||||
// 按钮禁用
|
||||
// disabled: false,
|
||||
submitText: '证件已上传并确认收货',
|
||||
@@ -269,7 +281,7 @@
|
||||
handleSubmit() {
|
||||
const that = this
|
||||
const app = this
|
||||
const { orderId, orderSourceData, captcha, receiptPhone, emergentUser, officeAddress, homeAddress } = app
|
||||
const { orderId, orderSourceData, captcha, receiptPhone, emergentUser, officeAddress, homeAddress, idCode } = app
|
||||
|
||||
// 1) 校验 5 张图是否都已上传
|
||||
const missingIndex = []
|
||||
@@ -285,15 +297,21 @@
|
||||
return
|
||||
}
|
||||
|
||||
receiptOrder({
|
||||
orderId: orderId,
|
||||
orderSourceData: JSON.stringify(orderSourceData),
|
||||
captcha: captcha,
|
||||
receiptPhone: receiptPhone,
|
||||
emergentUser: emergentUser,
|
||||
officeAddress: officeAddress,
|
||||
homeAddress: homeAddress
|
||||
}).then(result => {
|
||||
// 2) 身份证号优先由后端 OCR 自动识别并写库;前端仅在用户手动填写时才随请求带上(避免空串覆盖后端结果)
|
||||
const params = {
|
||||
orderId: orderId,
|
||||
orderSourceData: JSON.stringify(orderSourceData),
|
||||
captcha: captcha,
|
||||
receiptPhone: receiptPhone,
|
||||
emergentUser: emergentUser,
|
||||
officeAddress: officeAddress,
|
||||
homeAddress: homeAddress
|
||||
}
|
||||
if (idCode) {
|
||||
params.idCode = idCode
|
||||
}
|
||||
|
||||
receiptOrder(params).then(result => {
|
||||
if(result.code == 0) {
|
||||
that.$success("确认收货成功!")
|
||||
// uni.navigateBack()
|
||||
@@ -335,9 +353,9 @@
|
||||
} else {
|
||||
app.orderSourceData.push(res.data.url)
|
||||
}
|
||||
console.log('app.orderSourceData', app.orderSourceData)
|
||||
app.$success(`${slotLabel}上传成功`)
|
||||
}).catch(err => {
|
||||
console.log('app.orderSourceData', app.orderSourceData)
|
||||
app.$success(`${slotLabel}上传成功`)
|
||||
}).catch(err => {
|
||||
app.$toast(formatErrorMsg((err && (err.errMsg || err.message)) || `${slotLabel}上传失败,请重试`), 2500)
|
||||
}).finally(() => {
|
||||
uni.hideLoading()
|
||||
@@ -347,6 +365,7 @@
|
||||
});
|
||||
},
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user