From 466d1e4d2e38cfbe90159d5ee269164f2ccb2ed8 Mon Sep 17 00:00:00 2001 From: BAKEYi <16298417+bakeyi@user.noreply.gitee.com> Date: Thu, 18 Jun 2026 14:05:59 +0800 Subject: [PATCH] =?UTF-8?q?=E9=97=A8=E5=BA=97=E4=BF=A1=E6=81=AF=E5=9C=B0?= =?UTF-8?q?=E5=9D=80=E5=9B=9E=E6=98=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/shop/sj-info-change.vue | 83 +++++++++++++++++++++-------------- 1 file changed, 51 insertions(+), 32 deletions(-) diff --git a/pages/shop/sj-info-change.vue b/pages/shop/sj-info-change.vue index ec44595..0bb9192 100644 --- a/pages/shop/sj-info-change.vue +++ b/pages/shop/sj-info-change.vue @@ -331,8 +331,48 @@ } catch (e) {} }, - // 获取用户信息(原有,未变) - getUserInfo() { + // 兼容接口里门店地址字段的不同命名 + pickFirst(data, fields) { + for (const field of fields) { + const value = data && data[field]; + if (value !== undefined && value !== null && String(value).trim() !== '') { + return value; + } + } + return ''; + }, + + normalizeStoreInfo(data = {}) { + return { + head_photo: this.pickFirst(data, ['head_photo', 'shop_head_photo']), + name: this.pickFirst(data, ['name', 'shop_name']), + dependency: this.pickFirst(data, ['dependency', 'shop_dependency', 'uscc_dependency']), + address: this.pickFirst(data, ['address', 'shop_address', 'uscc_address']), + dependency_code: this.pickFirst(data, ['dependency_code', 'shop_dependency_code', 'uscc_area']), + dependency_province: this.pickFirst(data, ['dependency_province', 'shop_dependency_province', 'uscc_province']), + dependency_city: this.pickFirst(data, ['dependency_city', 'shop_dependency_city', 'uscc_city']), + longitude: this.pickFirst(data, ['longitude', 'shop_longitude']), + latitude: this.pickFirst(data, ['latitude', 'shop_latitude']) + }; + }, + + mergeStoreInfoWithOriginal(data = {}) { + const storeInfo = this.normalizeStoreInfo(data); + return { + head_photo: storeInfo.head_photo || this.originalData.head_photo, + name: storeInfo.name || this.originalData.name, + dependency: storeInfo.dependency || this.originalData.dependency, + address: storeInfo.address || this.originalData.address, + dependency_code: storeInfo.dependency_code || this.originalData.dependency_code, + dependency_province: storeInfo.dependency_province || this.originalData.dependency_province, + dependency_city: storeInfo.dependency_city || this.originalData.dependency_city, + longitude: storeInfo.longitude || this.originalData.longitude, + latitude: storeInfo.latitude || this.originalData.latitude + }; + }, + + // 获取用户信息 + getUserInfo() { console.log('开始获取用户信息...'); const type = 3; @@ -347,23 +387,13 @@ this.userId = userData.id; - this.originalData = { - head_photo: userData.head_photo || '', - name: userData.name || '', - dependency: userData.dependency || '', - address: userData.address || '', - dependency_code: userData.dependency_code || '', - dependency_province: userData.dependency_province || '', - dependency_city: userData.dependency_city || '', - longitude: userData.longitude || '', - latitude: userData.latitude || '' - }; - - this.dependency_code = userData.dependency_code || ''; - this.dependency_province = userData.dependency_province || ''; - this.dependency_city = userData.dependency_city || ''; - this.longitude = userData.longitude || ''; - this.latitude = userData.latitude || ''; + this.originalData = this.normalizeStoreInfo(userData); + + this.dependency_code = this.originalData.dependency_code || ''; + this.dependency_province = this.originalData.dependency_province || ''; + this.dependency_city = this.originalData.dependency_city || ''; + this.longitude = this.originalData.longitude || ''; + this.latitude = this.originalData.latitude || ''; this.pendingData = { ...this.originalData @@ -444,18 +474,7 @@ } if (this.auditStatus === 1 || this.auditStatus === 3) { - this.pendingData = { - head_photo: detail.head_photo || this.originalData.head_photo, - name: detail.name || this.originalData.name, - dependency: detail.dependency || this.originalData.dependency, - address: detail.address || this.originalData.address, - dependency_code: detail.dependency_code || this.originalData.dependency_code, - dependency_province: detail.dependency_province || this.originalData - .dependency_province, - dependency_city: detail.dependency_city || this.originalData.dependency_city, - longitude: detail.longitude || this.originalData.longitude, - latitude: detail.latitude || this.originalData.latitude - }; + this.pendingData = this.mergeStoreInfoWithOriginal(detail); } if (this.auditStatus === 2) { @@ -1679,4 +1698,4 @@ opacity: 1; visibility: visible; } - \ No newline at end of file +