mirror of
https://github.com/youzan/vant.git
synced 2025-10-20 02:31:21 +00:00
[breaking change] AddressEdit: use camelcase data (#1644)
This commit is contained in:
@@ -26,11 +26,11 @@
|
||||
/>
|
||||
<address-edit-detail
|
||||
:focused="detailFocused"
|
||||
:value="data.address_detail"
|
||||
:error="errorInfo.address_detail"
|
||||
:value="data.addressDetail"
|
||||
:error="errorInfo.addressDetail"
|
||||
:search-result="searchResult"
|
||||
:show-search-result="showSearchResult"
|
||||
@focus="onFocus('address_detail')"
|
||||
@focus="onFocus('addressDetail')"
|
||||
@blur="detailFocused = false"
|
||||
@input="onChangeDetail"
|
||||
@select-search="$emit('select-search', $event)"
|
||||
@@ -38,20 +38,20 @@
|
||||
<field
|
||||
v-if="showPostal"
|
||||
v-show="!hideBottomFields"
|
||||
v-model="data.postal_code"
|
||||
v-model="data.postalCode"
|
||||
type="tel"
|
||||
maxlength="6"
|
||||
class="van-hairline--top"
|
||||
:label="$t('postal')"
|
||||
:placeholder="$t('postal')"
|
||||
:error="errorInfo.postal_code"
|
||||
@focus="onFocus('postal_code')"
|
||||
:error="errorInfo.postalCode"
|
||||
@focus="onFocus('postalCode')"
|
||||
/>
|
||||
<slot />
|
||||
<switch-cell
|
||||
v-if="showSetDefault"
|
||||
v-show="!hideBottomFields"
|
||||
v-model="data.is_default"
|
||||
v-model="data.isDefault"
|
||||
:title="$t('defaultAddress')"
|
||||
/>
|
||||
</cell-group>
|
||||
@@ -69,7 +69,7 @@
|
||||
<van-area
|
||||
ref="area"
|
||||
:loading="!areaListLoaded"
|
||||
:value="data.area_code"
|
||||
:value="data.areaCode"
|
||||
:area-list="areaList"
|
||||
@confirm="onAreaConfirm"
|
||||
@cancel="showArea = false"
|
||||
@@ -98,10 +98,10 @@ const defaultData = {
|
||||
province: '',
|
||||
city: '',
|
||||
county: '',
|
||||
area_code: '',
|
||||
postal_code: '',
|
||||
address_detail: '',
|
||||
is_default: false
|
||||
areaCode: '',
|
||||
postalCode: '',
|
||||
addressDetail: '',
|
||||
isDefault: false
|
||||
};
|
||||
|
||||
export default create({
|
||||
@@ -148,8 +148,8 @@ export default create({
|
||||
errorInfo: {
|
||||
tel: false,
|
||||
name: false,
|
||||
postal_code: false,
|
||||
address_detail: false
|
||||
postalCode: false,
|
||||
addressDetail: false
|
||||
}
|
||||
};
|
||||
},
|
||||
@@ -169,8 +169,8 @@ export default create({
|
||||
},
|
||||
|
||||
areaText() {
|
||||
const { province, city, county, area_code } = this.data;
|
||||
return province && city && county && area_code
|
||||
const { province, city, county, areaCode } = this.data;
|
||||
return province && city && county && areaCode
|
||||
? `${province} ${city} ${county}`
|
||||
: '';
|
||||
}
|
||||
@@ -184,32 +184,32 @@ export default create({
|
||||
...val
|
||||
};
|
||||
|
||||
this.setAreaCode(val.area_code);
|
||||
this.setAreaCode(val.areaCode);
|
||||
},
|
||||
deep: true,
|
||||
immediate: true
|
||||
},
|
||||
|
||||
areaList() {
|
||||
this.setAreaCode(this.data.area_code);
|
||||
this.setAreaCode(this.data.areaCode);
|
||||
}
|
||||
},
|
||||
|
||||
methods: {
|
||||
onFocus(key) {
|
||||
this.errorInfo[key] = false;
|
||||
this.detailFocused = key === 'address_detail';
|
||||
this.detailFocused = key === 'addressDetail';
|
||||
this.$emit('focus', key);
|
||||
},
|
||||
|
||||
onChangeDetail(val) {
|
||||
this.data.address_detail = val;
|
||||
this.data.addressDetail = val;
|
||||
this.$emit('change-detail', val);
|
||||
},
|
||||
|
||||
onAreaConfirm(values) {
|
||||
this.showArea = false;
|
||||
this.data.area_code = values[2].code;
|
||||
this.data.areaCode = values[2].code;
|
||||
this.assignAreaValues(values);
|
||||
this.$emit('change-area', values);
|
||||
},
|
||||
@@ -223,10 +223,10 @@ export default create({
|
||||
},
|
||||
|
||||
onSave() {
|
||||
const items = ['name', 'tel', 'area_code', 'address_detail'];
|
||||
const items = ['name', 'tel', 'areaCode', 'addressDetail'];
|
||||
|
||||
if (this.showPostal) {
|
||||
items.push('postal_code');
|
||||
items.push('postalCode');
|
||||
}
|
||||
|
||||
const isValid = items.every(item => {
|
||||
@@ -252,11 +252,11 @@ export default create({
|
||||
return value ? '' : $t('nameEmpty');
|
||||
case 'tel':
|
||||
return this.telValidator(value) ? '' : $t('telInvalid');
|
||||
case 'area_code':
|
||||
case 'areaCode':
|
||||
return value ? '' : $t('areaEmpty');
|
||||
case 'address_detail':
|
||||
case 'addressDetail':
|
||||
return value ? '' : $t('addressEmpty');
|
||||
case 'postal_code':
|
||||
case 'postalCode':
|
||||
return value && !/^\d{6}$/.test(value) ? $t('postalEmpty') : '';
|
||||
}
|
||||
},
|
||||
@@ -280,7 +280,7 @@ export default create({
|
||||
|
||||
// set area code to area component
|
||||
setAreaCode(code) {
|
||||
this.data.area_code = code || '';
|
||||
this.data.areaCode = code || '';
|
||||
this.$nextTick(() => {
|
||||
const { area } = this.$refs;
|
||||
if (area) {
|
||||
|
Reference in New Issue
Block a user