fix(shopOperation): 完善法人身份证照片的取值与初始化

- 安全访问法人身份证照片,并统一初始化为数组
- 新增规范化方法,兼容字符串格式的法人身份证照片
- 店铺表单初始化时正确格式化法人身份证照片数据

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
pikachu1995@126.com
2026-08-18 07:36:38 +08:00
parent f959ab4b92
commit 1c8fccae66

View File

@@ -213,14 +213,14 @@
shape="square"
:size="100"
@click="handleCLickImg('legalPhoto', 0)"
:src="shopForm.legalPhoto[0]"
:src="(shopForm.legalPhoto && shopForm.legalPhoto[0]) || ''"
/>
<el-avatar
class="legal-photo"
shape="square"
:size="100"
@click="handleCLickImg('legalPhoto', 1)"
:src="shopForm.legalPhoto[1]"
:src="(shopForm.legalPhoto && shopForm.legalPhoto[1]) || ''"
/>
</div>
<div class="form-tip">点击图片上传身份证正反面要求身份证清晰四角无缺漏</div>
@@ -626,12 +626,24 @@ export default {
callbackSelected(val) {
this.picModelFlag = false;
if (this.picIndex === 0 || this.picIndex === 1) {
if (!Array.isArray(this.shopForm[this.selectedFormBtnName])) {
this.shopForm[this.selectedFormBtnName] = this.normalizeLegalPhoto(
this.shopForm[this.selectedFormBtnName]
);
}
this.shopForm[this.selectedFormBtnName][this.picIndex] = val.url;
} else {
this.shopForm[this.selectedFormBtnName] = val.url;
}
this.picIndex = "";
},
normalizeLegalPhoto(value) {
const photos = String(value || "")
.split(",")
.map((item) => item.trim())
.filter(Boolean);
return [photos[0] || "", photos[1] || ""];
},
// 初始化数据
init() {
this.getCategories();
@@ -654,16 +666,20 @@ export default {
shopDetail(this.shopId).then((res) => {
if (res.success) {
this.infoResult = res.result;
this.shopForm = res.result;
this.shopForm = {
...res.result,
legalPhoto: this.normalizeLegalPhoto(res.result.legalPhoto),
};
this.shopForm.selfOperated
? (this.shopForm.selfOperated = "true")
: (this.shopForm.selfOperated = "false");
this.checkAllGroup = this.shopForm.goodsManagementCategory.split(",");
this.checkAllGroup = this.shopForm.goodsManagementCategory
? this.shopForm.goodsManagementCategory.split(",")
: [];
if (this.shopForm.settlementCycle) {
this.settlementCycle = this.shopForm.settlementCycle.split(",");
}
this.shopForm.legalPhoto = this.shopForm.legalPhoto.split(",");
this.address = this.shopForm.companyAddressIdPath;
this.returnAddress = this.shopForm.salesConsigneeAddressId;