移除省市区
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,5 @@
|
|||||||
import Toast from 'tdesign-miniprogram/toast/index';
|
import Toast from 'tdesign-miniprogram/toast/index';
|
||||||
import { fetchDeliveryAddress } from '../../../../services/address/fetchAddress';
|
import { fetchDeliveryAddress } from '../../../../services/address/fetchAddress';
|
||||||
import { areaData } from '../../../../config/index';
|
|
||||||
import { resolveAddress, rejectAddress } from './util';
|
import { resolveAddress, rejectAddress } from './util';
|
||||||
|
|
||||||
const innerPhoneReg = '^1(?:3\\d|4[4-9]|5[0-35-9]|6[67]|7[0-8]|8\\d|9\\d)\\d{8}$';
|
const innerPhoneReg = '^1(?:3\\d|4[4-9]|5[0-35-9]|6[67]|7[0-8]|8\\d|9\\d)\\d{8}$';
|
||||||
@@ -36,9 +35,7 @@ Page({
|
|||||||
isOrderDetail: false,
|
isOrderDetail: false,
|
||||||
isOrderSure: false,
|
isOrderSure: false,
|
||||||
},
|
},
|
||||||
areaData: areaData,
|
|
||||||
labels: labelsOptions,
|
labels: labelsOptions,
|
||||||
areaPickerVisible: false,
|
|
||||||
submitActive: false,
|
submitActive: false,
|
||||||
visible: false,
|
visible: false,
|
||||||
labelValue: '',
|
labelValue: '',
|
||||||
@@ -78,27 +75,6 @@ Page({
|
|||||||
},
|
},
|
||||||
onInputValue(e) {
|
onInputValue(e) {
|
||||||
const { item } = e.currentTarget.dataset;
|
const { item } = e.currentTarget.dataset;
|
||||||
if (item === 'address') {
|
|
||||||
const { selectedOptions = [] } = e.detail;
|
|
||||||
this.setData(
|
|
||||||
{
|
|
||||||
'locationState.provinceCode': selectedOptions[0].value,
|
|
||||||
'locationState.provinceName': selectedOptions[0].label,
|
|
||||||
'locationState.cityName': selectedOptions[1].label,
|
|
||||||
'locationState.cityCode': selectedOptions[1].value,
|
|
||||||
'locationState.districtCode': selectedOptions[2].value,
|
|
||||||
'locationState.districtName': selectedOptions[2].label,
|
|
||||||
areaPickerVisible: false,
|
|
||||||
},
|
|
||||||
() => {
|
|
||||||
const { isLegal, tips } = this.onVerifyInputLegal();
|
|
||||||
this.setData({
|
|
||||||
submitActive: isLegal,
|
|
||||||
});
|
|
||||||
this.privateData.verifyTips = tips;
|
|
||||||
},
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
const { value = '' } = e.detail;
|
const { value = '' } = e.detail;
|
||||||
this.setData(
|
this.setData(
|
||||||
{
|
{
|
||||||
@@ -112,10 +88,6 @@ Page({
|
|||||||
this.privateData.verifyTips = tips;
|
this.privateData.verifyTips = tips;
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
|
||||||
},
|
|
||||||
onPickArea() {
|
|
||||||
this.setData({ areaPickerVisible: true });
|
|
||||||
},
|
},
|
||||||
onPickLabels(e) {
|
onPickLabels(e) {
|
||||||
const { item } = e.currentTarget.dataset;
|
const { item } = e.currentTarget.dataset;
|
||||||
|
|||||||
@@ -10,7 +10,6 @@
|
|||||||
"t-toast": "tdesign-miniprogram/toast/toast",
|
"t-toast": "tdesign-miniprogram/toast/toast",
|
||||||
"t-dialog": "tdesign-miniprogram/dialog/dialog",
|
"t-dialog": "tdesign-miniprogram/dialog/dialog",
|
||||||
"t-switch": "tdesign-miniprogram/switch/switch",
|
"t-switch": "tdesign-miniprogram/switch/switch",
|
||||||
"t-location": "/pages/usercenter/components/t-location/index",
|
"t-location": "/pages/usercenter/components/t-location/index"
|
||||||
"t-cascader": "tdesign-miniprogram/cascader/cascader"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -49,7 +49,6 @@
|
|||||||
placeholder="省/市/区"
|
placeholder="省/市/区"
|
||||||
data-item="address"
|
data-item="address"
|
||||||
value="{{locationState.provinceName ? locationState.provinceName+'/':'' }}{{locationState.cityName ? locationState.cityName+'/':''}}{{locationState.districtName}}"
|
value="{{locationState.provinceName ? locationState.provinceName+'/':'' }}{{locationState.cityName ? locationState.cityName+'/':''}}{{locationState.districtName}}"
|
||||||
catch:tap="onPickArea"
|
|
||||||
disabled
|
disabled
|
||||||
/>
|
/>
|
||||||
<t-icon slot="right-icon" t-class="map" prefix="wr" name="location" catch:tap="onSearchAddress" />
|
<t-icon slot="right-icon" t-class="map" prefix="wr" name="location" catch:tap="onSearchAddress" />
|
||||||
@@ -108,16 +107,6 @@
|
|||||||
</view>
|
</view>
|
||||||
</form>
|
</form>
|
||||||
</view>
|
</view>
|
||||||
<t-cascader
|
|
||||||
data-item="address"
|
|
||||||
data-type="1"
|
|
||||||
visible="{{areaPickerVisible}}"
|
|
||||||
theme="tab"
|
|
||||||
options="{{areaData}}"
|
|
||||||
value="{{locationState.districtCode}}"
|
|
||||||
title="选择地区"
|
|
||||||
bind:change="onInputValue"
|
|
||||||
></t-cascader>
|
|
||||||
</view>
|
</view>
|
||||||
<t-dialog
|
<t-dialog
|
||||||
visible="{{visible}}"
|
visible="{{visible}}"
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import { getPermission } from '../../../../utils/getPermission';
|
import { getPermission } from '../../../../utils/getPermission';
|
||||||
import { phoneRegCheck } from '../../../../utils/util';
|
import { phoneRegCheck } from '../../../../utils/util';
|
||||||
import Toast from 'tdesign-miniprogram/toast/index';
|
import Toast from 'tdesign-miniprogram/toast/index';
|
||||||
import { addressParse } from '../../../../utils/addressParse';
|
|
||||||
import { resolveAddress, rejectAddress } from '../../address/list/util';
|
import { resolveAddress, rejectAddress } from '../../address/list/util';
|
||||||
|
|
||||||
Component({
|
Component({
|
||||||
|
|||||||
@@ -1,25 +0,0 @@
|
|||||||
import { areaData } from '../config/index';
|
|
||||||
|
|
||||||
const addressParse = (provinceName, cityName, countryName) => {
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
try {
|
|
||||||
const province = areaData.find((v) => v.label === provinceName);
|
|
||||||
const { value: provinceCode } = province;
|
|
||||||
const city = province.children.find((v) => v.label === cityName);
|
|
||||||
const { value: cityCode } = city;
|
|
||||||
const country = city.children.find((v) => v.label === countryName);
|
|
||||||
const { value: districtCode } = country;
|
|
||||||
resolve({
|
|
||||||
provinceCode,
|
|
||||||
cityCode,
|
|
||||||
districtCode,
|
|
||||||
});
|
|
||||||
} catch (error) {
|
|
||||||
reject('地址解析失败');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
addressParse,
|
|
||||||
};
|
|
||||||
Reference in New Issue
Block a user