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
+10 -6
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) {
+19 -6
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);
}
},
+4 -1
View File
@@ -15,11 +15,12 @@
<textarea
v-if="type === 'textarea'"
v-bind="$attrs"
v-on="$listeners"
ref="textarea"
class="van-field__control"
:value="value"
@input="onInput"
@focus="$emit('focus')"
@blur="$emit('blur')"
/>
<input
v-else
@@ -29,6 +30,8 @@
:type="type"
:value="value"
@input="onInput"
@focus="$emit('focus')"
@blur="$emit('blur')"
/>
<div
v-if="hasIcon"
+7 -2
View File
@@ -23,9 +23,14 @@
margin-bottom: 10px;
}
.van-icon-clear {
color: $gray-dark;
}
&-detail {
&__finish-edit {
color: $blue;
font-size: 12px;
}
&__suggest-list {
@@ -39,7 +44,7 @@
&__location {
float: left;
font-size: 18px;
color: #666;
color: $gray-darker;
}
&__item-info {
@@ -54,7 +59,7 @@
&__subtitle {
font-size: 12px;
color: #666;
color: $gray-darker;
}
}
}