From fd5867fa7c26a268e522dd5ec3e0d8f3368a7e55 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=BE=90=E9=A3=9E=E6=B4=8B?=
<15778543+xufeiyang6017@user.noreply.gitee.com>
Date: Tue, 9 Dec 2025 10:29:38 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=BC=96=E8=BE=91=E8=B4=A7?=
=?UTF-8?q?=E6=BA=90=E4=B8=AD=E7=9A=84=E5=9C=B0=E5=8C=BA=E6=B2=A1=E6=9C=89?=
=?UTF-8?q?=E8=AE=B0=E5=BF=86=E5=8A=9F=E8=83=BD=E9=97=AE=E9=A2=98?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
pages/seller/index.js | 65 +++++++++++++++++++++++++++++++++++++----
pages/seller/index.wxml | 33 +++++++++++----------
2 files changed, 76 insertions(+), 22 deletions(-)
diff --git a/pages/seller/index.js b/pages/seller/index.js
index 3076937..e5275fd 100644
--- a/pages/seller/index.js
+++ b/pages/seller/index.js
@@ -4863,6 +4863,49 @@ Page({
});
},
+ // 根据地区字符串查找对应的省市区索引
+ findRegionIndex(region) {
+ if (!region) return { provinceIndex: 0, cityIndex: 0, districtIndex: 0 };
+
+ const regionArray = region.split(' ').filter(item => item.trim() !== '');
+ if (regionArray.length < 3) return { provinceIndex: 0, cityIndex: 0, districtIndex: 0 };
+
+ const provinceName = regionArray[0];
+ const cityName = regionArray[1];
+ const districtName = regionArray[2];
+
+ // 查找省份索引
+ let provinceIndex = 0;
+ for (let i = 0; i < this.data.regionOptions.length; i++) {
+ if (this.data.regionOptions[i].name === provinceName) {
+ provinceIndex = i;
+ break;
+ }
+ }
+
+ // 查找城市索引
+ const province = this.data.regionOptions[provinceIndex];
+ let cityIndex = 0;
+ for (let i = 0; i < province.cities.length; i++) {
+ if (province.cities[i].name === cityName) {
+ cityIndex = i;
+ break;
+ }
+ }
+
+ // 查找区县索引
+ const city = province.cities[cityIndex];
+ let districtIndex = 0;
+ for (let i = 0; i < city.districts.length; i++) {
+ if (city.districts[i] === districtName) {
+ districtIndex = i;
+ break;
+ }
+ }
+
+ return { provinceIndex, cityIndex, districtIndex };
+ },
+
// 打开编辑货源的地区选择弹窗
openEditRegionModal() {
// 通过全局数据控制自定义tab-bar的显示状态
@@ -4871,18 +4914,28 @@ Page({
app.globalData.showTabBar = false;
}
- // 重置三级联动选择和搜索
+ // 获取当前编辑货源的地区
+ const currentRegion = this.data.editSupply.region;
+
+ // 查找地区对应的省市区索引
+ const { provinceIndex, cityIndex, districtIndex } = this.findRegionIndex(currentRegion);
+
+ // 获取对应的省市区数据
+ const province = this.data.regionOptions[provinceIndex];
+ const city = province.cities[cityIndex];
+
+ // 设置地区选择器状态
this.setData({
currentRegionMode: 'edit',
regionSearchKeyword: '',
editRegionSearchKeyword: '',
filteredRegionOptions: [],
showSearchResults: false,
- selectedProvinceIndex: 0,
- selectedCityIndex: 0,
- selectedDistrictIndex: 0,
- currentCities: this.data.regionOptions[0].cities,
- currentDistricts: this.data.regionOptions[0].cities[0].districts,
+ selectedProvinceIndex: provinceIndex,
+ selectedCityIndex: cityIndex,
+ selectedDistrictIndex: districtIndex,
+ currentCities: province.cities,
+ currentDistricts: city.districts,
showRegionSelectModal: true,
showTabBar: false // 隐藏底部tab-bar
});
diff --git a/pages/seller/index.wxml b/pages/seller/index.wxml
index ad48632..c1309f2 100644
--- a/pages/seller/index.wxml
+++ b/pages/seller/index.wxml
@@ -508,6 +508,14 @@
+
+ 地区
+
+
+ {{newSupply.region || '请选择省市区'}}
+ ▼
+
+
价格
@@ -518,13 +526,6 @@
- 地区
-
-
- {{newSupply.region || '请选择省市区'}}
- ▼
-
-
@@ -591,7 +592,14 @@
-
+ 地区
+
+ {{editSupply.region || '请选择省市区'}}
+
价格
@@ -603,14 +611,7 @@
- 地区
-
- {{editSupply.region || '请选择省市区'}}
-
+