AddressEdit: add test cases

This commit is contained in:
陈嘉涵
2017-09-26 20:37:27 +08:00
parent 037d6979b2
commit fa06465d87
6 changed files with 433 additions and 25 deletions

View File

@@ -14,9 +14,9 @@
@focus="handleFocus"
@blur="handleBlur"
>
<template v-if="value && isFocused" slot="icon">
<span v-if="isAndroid" class="van-address-edit-detail__finish-edit van-font--12">完成</span>
<van-icon v-else name="clear" />
<template slot="icon">
<span v-if="showIcon && isAndroid" class="van-address-edit-detail__finish-edit">完成</span>
<van-icon v-else-if="showIcon" name="clear" />
</template>
</van-field>
@@ -70,6 +70,10 @@ export default {
computed: {
showSearchList() {
return this.showSearchResult && this.isFocused && this.searchResult.length > 0;
},
showIcon() {
return this.value && this.isFocused;
}
},
@@ -89,11 +93,11 @@ export default {
},
onIconClick() {
// 安卓直接完成,不触发清除
if (this.isAndroid) {
return;
this.$refs.root.querySelector('.van-field__control').blur();
} else {
this.$emit('input', '');
}
this.$emit('input', '');
},
onSuggestSelect(express) {

View File

@@ -105,7 +105,17 @@ export default {
},
addressInfo: {
type: Object,
default: () => ({})
default: () => ({
user_name: '',
tel: '',
province: '',
city: '',
county: '',
area_code: '',
postal_code: '',
address_detail: '',
is_default: false
})
},
searchResult: {
type: Array,
@@ -129,9 +139,12 @@ export default {
},
watch: {
addressInfo(val) {
this.currentInfo = val;
this.isEdit = !!val.id;
addressInfo: {
handler(val) {
this.currentInfo = val;
this.isEdit = !!val.id;
},
deep: true
}
},
@@ -191,8 +204,8 @@ export default {
return !msg;
});
if (isValid) {
this.$emit('save', this.currentInfo, this.isEdit);
if (isValid && !this.isSaving) {
this.$emit('save', this.currentInfo);
}
},