|
@@ -93,6 +93,7 @@ Page({
|
|
|
showService: false,
|
|
|
isFromPreviewImage: false,
|
|
|
showBuyer: false, // 收益人
|
|
|
+ cacheArea: [] as { cityCode: string, shiftCityCode: string }[], // 临时存储的对应关系
|
|
|
|
|
|
phone: '',
|
|
|
name: '',
|
|
@@ -127,6 +128,7 @@ Page({
|
|
|
schoolInfo: ''
|
|
|
},
|
|
|
showArea: false,
|
|
|
+ showAreaAfterLeave: false,
|
|
|
areaList: [] as any,
|
|
|
showSchool: false,
|
|
|
showSchoolAfterLeave: false, // 离开后
|
|
@@ -591,8 +593,19 @@ Page({
|
|
|
province_list[item.code] = item.name;
|
|
|
});
|
|
|
area.forEach((item: any) => {
|
|
|
- item.areas && item.areas.forEach((city: any) => {
|
|
|
- city_list[city.code] = city.name;
|
|
|
+ item.areas && item.areas.forEach((city: any, index: number) => {
|
|
|
+ let code = city.code + ""
|
|
|
+ // 某些数据不标准 这里需要转换一下
|
|
|
+ if (code[4] !== "0" || code[5] !== "0") {
|
|
|
+ // 现在把区域的数据改为市的
|
|
|
+ const newCode = code.substring(0, 2) + (index < 10 ? `a${index}` : index < 20 ? `b${index - 10}` : index < 30 ? `c${index - 20}` : `d${index - 30}`) + "00";
|
|
|
+ this.data.cacheArea.push({
|
|
|
+ cityCode: code,
|
|
|
+ shiftCityCode: newCode
|
|
|
+ })
|
|
|
+ code = newCode
|
|
|
+ }
|
|
|
+ city_list[code] = city.name;
|
|
|
});
|
|
|
});
|
|
|
area.forEach((item: any) => {
|
|
@@ -608,6 +621,16 @@ Page({
|
|
|
county_list
|
|
|
};
|
|
|
},
|
|
|
+ // 转换
|
|
|
+ formateCityCode(reverse?: boolean) {
|
|
|
+ if (!this.data.regionCode && this.data.cityCode) {
|
|
|
+ const cityCodeObj = this.data.cacheArea.find((item: any) => {
|
|
|
+ return item[reverse ? "cityCode" : "shiftCityCode"] == this.data.cityCode
|
|
|
+ })
|
|
|
+ return cityCodeObj ? cityCodeObj[reverse ? "shiftCityCode" : "cityCode"] : ""
|
|
|
+ }
|
|
|
+ return this.data.cityCode
|
|
|
+ },
|
|
|
/** 获取学校列表 */
|
|
|
async getSchools(name?: string) {
|
|
|
this.setData({
|
|
@@ -615,14 +638,15 @@ Page({
|
|
|
})
|
|
|
try {
|
|
|
// 判断是否有地区信息
|
|
|
- if (!this.data.provinceCode || !this.data.cityCode || !this.data.regionCode) {
|
|
|
+ if (!this.data.provinceCode || !this.data.cityCode) {
|
|
|
return
|
|
|
}
|
|
|
+ const citycode = this.formateCityCode()
|
|
|
const { data } = await api_schoolAreaList({
|
|
|
name,
|
|
|
testFlag: true,
|
|
|
provinceCode: this.data.provinceCode,
|
|
|
- cityCode: this.data.cityCode,
|
|
|
+ cityCode: citycode,
|
|
|
regionCode: this.data.regionCode
|
|
|
})
|
|
|
const result = data.data || []
|
|
@@ -764,6 +788,7 @@ Page({
|
|
|
const classIndex = this.data.classIndex
|
|
|
console.log(tempGradeGradeList, tempClassList)
|
|
|
if ((tempGradeGradeList.length || 0) - 1 < gradeIndex) {
|
|
|
+
|
|
|
this.setData({
|
|
|
gradeGradeList: tempGradeGradeList,
|
|
|
classList: tempClassList,
|
|
@@ -811,16 +836,28 @@ Page({
|
|
|
showArea: false
|
|
|
})
|
|
|
},
|
|
|
+ /** 选择地区关闭后 */
|
|
|
+ onAreaAfterLeave() {
|
|
|
+ this.setData({
|
|
|
+ showAreaAfterLeave: true
|
|
|
+ })
|
|
|
+ },
|
|
|
+ /** 选择地区打开前 */
|
|
|
+ onAreaBeforeEnter() {
|
|
|
+ this.setData({
|
|
|
+ showAreaAfterLeave: false
|
|
|
+ })
|
|
|
+ },
|
|
|
/** 确定选择地区 */
|
|
|
submitArea(e: any) {
|
|
|
const selectedOptions: any = e.detail.values
|
|
|
this.setData({
|
|
|
provinceCode: selectedOptions[0].code,
|
|
|
cityCode: selectedOptions[1].code,
|
|
|
- regionCode: selectedOptions[2].code,
|
|
|
- provinceName: selectedOptions[0].name,
|
|
|
- cityName: selectedOptions[1].name,
|
|
|
- regionName: selectedOptions[2].name,
|
|
|
+ regionCode: selectedOptions[2]?.code,
|
|
|
+ provinceName: selectedOptions[0].name || '',
|
|
|
+ cityName: selectedOptions[1].name || '',
|
|
|
+ regionName: selectedOptions[2]?.name || '',
|
|
|
showArea: false,
|
|
|
|
|
|
searchName: '',
|
|
@@ -1043,7 +1080,7 @@ Page({
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- if (!params.provinceCode || !params.cityCode || !params.regionCode) {
|
|
|
+ if (!params.provinceCode || !params.cityCode) {
|
|
|
wx.showToast({
|
|
|
title: '请选择学校地区',
|
|
|
icon: "none"
|