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 || '请选择省市区'}}
-
+