|
@@ -45,12 +45,14 @@ Page({
|
|
addressShow: false, // 添加/修改收货地址
|
|
addressShow: false, // 添加/修改收货地址
|
|
addressListShow: false, // 收货地址列表
|
|
addressListShow: false, // 收货地址列表
|
|
addressList: [] as any, // 收货地址列表
|
|
addressList: [] as any, // 收货地址列表
|
|
|
|
+ showAreaAfterLeave: false, // 所在地区
|
|
|
|
+ cacheArea: [] as { cityCode: string, shiftCityCode: string }[], // 临时存储的对应关系
|
|
// 添加地址表单信息
|
|
// 添加地址表单信息
|
|
id: "",
|
|
id: "",
|
|
name: '',
|
|
name: '',
|
|
phoneNumber: '',
|
|
phoneNumber: '',
|
|
detailAddress: '',
|
|
detailAddress: '',
|
|
- cityCode: 0,
|
|
|
|
|
|
+ cityCode: null,
|
|
cityName: "",
|
|
cityName: "",
|
|
provinceCode: 0,
|
|
provinceCode: 0,
|
|
provinceName: "",
|
|
provinceName: "",
|
|
@@ -169,6 +171,7 @@ Page({
|
|
phoneNumber: beneficiary.phone,
|
|
phoneNumber: beneficiary.phone,
|
|
schoolInfo: tempSchoolAddress.join('')
|
|
schoolInfo: tempSchoolAddress.join('')
|
|
},
|
|
},
|
|
|
|
+ 'goodsInfo.createTime': result.createTime
|
|
})
|
|
})
|
|
} catch {
|
|
} catch {
|
|
//
|
|
//
|
|
@@ -240,8 +243,19 @@ Page({
|
|
province_list[item.code] = item.name;
|
|
province_list[item.code] = item.name;
|
|
});
|
|
});
|
|
area.forEach((item: any) => {
|
|
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) => {
|
|
area.forEach((item: any) => {
|
|
@@ -257,6 +271,17 @@ Page({
|
|
county_list
|
|
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
|
|
|
|
+ })
|
|
|
|
+ console.log(this.data.cacheArea, 'this.data.cacheArea', reverse ? "shiftCityCode" : "cityCode", cityCodeObj)
|
|
|
|
+ return cityCodeObj ? cityCodeObj[reverse ? "shiftCityCode" : "cityCode"] : ""
|
|
|
|
+ }
|
|
|
|
+ return this.data.cityCode
|
|
|
|
+ },
|
|
// 获取后台配置的支付方式
|
|
// 获取后台配置的支付方式
|
|
async queryPayType() {
|
|
async queryPayType() {
|
|
try {
|
|
try {
|
|
@@ -507,19 +532,40 @@ Page({
|
|
showArea: false
|
|
showArea: false
|
|
})
|
|
})
|
|
},
|
|
},
|
|
|
|
+ onAreaBeforeEnter() {
|
|
|
|
+ this.setData({
|
|
|
|
+ showAreaAfterLeave: false
|
|
|
|
+ })
|
|
|
|
+ },
|
|
|
|
+ onAreaAfterLeave() {
|
|
|
|
+ this.setData({
|
|
|
|
+ showAreaAfterLeave: true
|
|
|
|
+ })
|
|
|
|
+ },
|
|
/** 确定选择地区 */
|
|
/** 确定选择地区 */
|
|
submitArea() {
|
|
submitArea() {
|
|
const selectedOptions = this.data.currentValues
|
|
const selectedOptions = this.data.currentValues
|
|
this.setData({
|
|
this.setData({
|
|
provinceCode: selectedOptions[0].code,
|
|
provinceCode: selectedOptions[0].code,
|
|
cityCode: selectedOptions[1].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
|
|
showArea: false
|
|
})
|
|
})
|
|
},
|
|
},
|
|
|
|
+ onCopy(e: { currentTarget: any }) {
|
|
|
|
+ wx.setClipboardData({
|
|
|
|
+ data: e.currentTarget.dataset.orderno,
|
|
|
|
+ success: () => {
|
|
|
|
+ wx.showToast({ title: '复制成功', icon: 'none' })
|
|
|
|
+ },
|
|
|
|
+ fail: () => {
|
|
|
|
+ wx.showToast({ title: '复制失败,请稍后再试', icon: 'none' })
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ },
|
|
// cancelArea() {
|
|
// cancelArea() {
|
|
// this.setData({ showArea: false })
|
|
// this.setData({ showArea: false })
|
|
// },
|
|
// },
|
|
@@ -547,7 +593,6 @@ Page({
|
|
// // }}
|
|
// // }}
|
|
// },
|
|
// },
|
|
changeArea(e: any) {
|
|
changeArea(e: any) {
|
|
- console.log(e.detail.values, 'e.detail.values')
|
|
|
|
this.setData({
|
|
this.setData({
|
|
currentValues: e.detail.values
|
|
currentValues: e.detail.values
|
|
})
|
|
})
|
|
@@ -570,7 +615,7 @@ Page({
|
|
})
|
|
})
|
|
return
|
|
return
|
|
}
|
|
}
|
|
- if (!addressForm.provinceCode || !addressForm.cityCode || !addressForm.regionCode) {
|
|
|
|
|
|
+ if (!addressForm.provinceCode || !addressForm.cityCode) {
|
|
wx.showToast({
|
|
wx.showToast({
|
|
title: '请选择地区',
|
|
title: '请选择地区',
|
|
icon: "none"
|
|
icon: "none"
|
|
@@ -585,25 +630,27 @@ Page({
|
|
return
|
|
return
|
|
}
|
|
}
|
|
if (addressForm.id) {
|
|
if (addressForm.id) {
|
|
|
|
+ const citycode = this.formateCityCode()
|
|
await api_userReceiveAddressUpdate({
|
|
await api_userReceiveAddressUpdate({
|
|
id: addressForm.id,
|
|
id: addressForm.id,
|
|
name: addressForm.name,
|
|
name: addressForm.name,
|
|
phoneNumber: addressForm.phoneNumber,
|
|
phoneNumber: addressForm.phoneNumber,
|
|
province: addressForm.provinceCode,
|
|
province: addressForm.provinceCode,
|
|
- city: addressForm.cityCode,
|
|
|
|
- region: addressForm.regionCode,
|
|
|
|
|
|
+ city: citycode,
|
|
|
|
+ region: addressForm.regionCode || '',
|
|
detailAddress: addressForm.detailAddress
|
|
detailAddress: addressForm.detailAddress
|
|
})
|
|
})
|
|
|
|
|
|
this.getAddresss()
|
|
this.getAddresss()
|
|
this.onCloseAddress()
|
|
this.onCloseAddress()
|
|
} else {
|
|
} else {
|
|
|
|
+ const citycode = this.formateCityCode()
|
|
const { data } = await api_userReceiveAddressSave({
|
|
const { data } = await api_userReceiveAddressSave({
|
|
name: addressForm.name,
|
|
name: addressForm.name,
|
|
phoneNumber: addressForm.phoneNumber,
|
|
phoneNumber: addressForm.phoneNumber,
|
|
province: addressForm.provinceCode,
|
|
province: addressForm.provinceCode,
|
|
- city: addressForm.cityCode,
|
|
|
|
- region: addressForm.regionCode,
|
|
|
|
|
|
+ city: citycode,
|
|
|
|
+ region: addressForm.regionCode || '',
|
|
detailAddress: addressForm.detailAddress
|
|
detailAddress: addressForm.detailAddress
|
|
})
|
|
})
|
|
|
|
|