|
|
@ -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() { |
|
|
openEditRegionModal() { |
|
|
// 通过全局数据控制自定义tab-bar的显示状态
|
|
|
// 通过全局数据控制自定义tab-bar的显示状态
|
|
|
@ -4871,18 +4914,28 @@ Page({ |
|
|
app.globalData.showTabBar = false; |
|
|
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({ |
|
|
this.setData({ |
|
|
currentRegionMode: 'edit', |
|
|
currentRegionMode: 'edit', |
|
|
regionSearchKeyword: '', |
|
|
regionSearchKeyword: '', |
|
|
editRegionSearchKeyword: '', |
|
|
editRegionSearchKeyword: '', |
|
|
filteredRegionOptions: [], |
|
|
filteredRegionOptions: [], |
|
|
showSearchResults: false, |
|
|
showSearchResults: false, |
|
|
selectedProvinceIndex: 0, |
|
|
selectedProvinceIndex: provinceIndex, |
|
|
selectedCityIndex: 0, |
|
|
selectedCityIndex: cityIndex, |
|
|
selectedDistrictIndex: 0, |
|
|
selectedDistrictIndex: districtIndex, |
|
|
currentCities: this.data.regionOptions[0].cities, |
|
|
currentCities: province.cities, |
|
|
currentDistricts: this.data.regionOptions[0].cities[0].districts, |
|
|
currentDistricts: city.districts, |
|
|
showRegionSelectModal: true, |
|
|
showRegionSelectModal: true, |
|
|
showTabBar: false // 隐藏底部tab-bar
|
|
|
showTabBar: false // 隐藏底部tab-bar
|
|
|
}); |
|
|
}); |
|
|
|