diff --git a/src/address-edit/Detail.js b/src/address-edit/Detail.js index 8d8485682..f2c10d4ba 100644 --- a/src/address-edit/Detail.js +++ b/src/address-edit/Detail.js @@ -17,6 +17,12 @@ export default createComponent({ showSearchResult: Boolean }, + computed: { + shouldShowSearchResult() { + return this.focused && this.searchResult && this.showSearchResult; + } + }, + methods: { onSelect(express) { this.$emit('select-search', express); @@ -42,19 +48,30 @@ export default createComponent({ }, genSearchResult() { - const { searchResult } = this; - const show = this.focused && searchResult && this.showSearchResult; - if (show) { + const { value, shouldShowSearchResult, searchResult } = this; + if (shouldShowSearchResult) { return searchResult.map(express => ( { this.onSelect(express); }} + scopedSlots={{ + title: () => + express.name && ( +
${value}` + )} + /> + ) + }} /> )); } @@ -72,6 +89,7 @@ export default createComponent({ type="textarea" value={this.value} error={this.error} + border={!this.shouldShowSearchResult} label={t('label')} maxlength={this.detailMaxlength} placeholder={t('placeholder')} diff --git a/src/address-edit/index.js b/src/address-edit/index.js index 55d35a196..2d85422fc 100644 --- a/src/address-edit/index.js +++ b/src/address-edit/index.js @@ -251,64 +251,68 @@ export default createComponent({ return (
- - - { - this.showAreaPopup = true; - }} - /> - { - this.$emit('select-search', event); - }} - /> - {this.showPostal && ( +
- )} - {this.slots()} + + { + this.showAreaPopup = true; + }} + /> + { + this.$emit('select-search', event); + }} + /> + {this.showPostal && ( + + )} + {this.slots()} +
{this.showSetDefault && (
+
diff --git a/src/address-edit/test/__snapshots__/index.spec.js.snap b/src/address-edit/test/__snapshots__/index.spec.js.snap index 4d3906873..462c99692 100644 --- a/src/address-edit/test/__snapshots__/index.spec.js.snap +++ b/src/address-edit/test/__snapshots__/index.spec.js.snap @@ -2,75 +2,85 @@ exports[`create a AddressEdit 1`] = `
-
-
姓名
-
-
+
+
+
姓名
+
+
+
-
-
-
电话
-
-
+
+
电话
+
+
+
-
-
-
地区
-
-
+
+
地区
+
+
+
+
+
+
-
-
-
-
-
详细地址
-
-
+
+
+
+
详细地址
+
+
+
-
+
`; exports[`create a AddressEdit with props 1`] = `
-
-
姓名
-
-
+
+
+
姓名
+
+
+
-
-
-
电话
-
-
+
+
电话
+
+
+
-
-
-
地区
-
-
-
-
-
-
-
-
详细地址
-
-
+
+
地区
+
+
+
+
-
-
-
邮政编码
-
-
+
+
+
+
详细地址
+
+
+
+
+
+
+
+
邮政编码
+
+
+
-
+
设为默认收货地址
@@ -78,47 +88,52 @@ exports[`create a AddressEdit with props 1`] = `
-
+
`; exports[`set-default 1`] = `
-
-
姓名
-
-
+
+
+
姓名
+
+
+
-
-
-
电话
-
-
+
+
电话
+
+
+
-
-
-
地区
-
-
-
-
-
-
-
-
详细地址
-
-
+
+
地区
+
+
+
+
-
-
-
邮政编码
-
-
+
+
+
+
详细地址
+
+
+
+
+
+
+
+
邮政编码
+
+
+
-
+
设为默认收货地址
@@ -126,47 +141,52 @@ exports[`set-default 1`] = `
-
+
`; exports[`show area component 1`] = `
-
-
姓名
-
-
+
+
+
姓名
+
+
+
-
-
-
电话
-
-
+
+
电话
+
+
+
-
-
-
地区
-
-
-
-
-
-
-
-
详细地址
-
-
+
+
地区
+
+
+
+
-
-
-
邮政编码
-
-
+
+
+
+
详细地址
+
+
+
+
+
+
+
+
邮政编码
+
+
+
-
+
设为默认收货地址
@@ -174,47 +194,52 @@ exports[`show area component 1`] = `
-
+
`; exports[`show area component 2`] = `
-
-
姓名
-
-
+
+
+
姓名
+
+
+
-
-
-
电话
-
-
+
+
电话
+
+
+
-
-
-
地区
-
-
-
-
-
-
-
-
详细地址
-
-
+
+
地区
+
+
+
+
-
-
-
邮政编码
-
-
+
+
+
+
详细地址
+
+
+
+
+
+
+
+
邮政编码
+
+
+
-
+
设为默认收货地址
@@ -222,40 +247,45 @@ exports[`show area component 2`] = `
-
+
`; exports[`valid area placeholder confirm 1`] = `
-
-
姓名
-
-
+
+
+
姓名
+
+
+
-
-
-
电话
-
-
+
+
电话
+
+
+
-
-
-
地区
-
-
+
+
地区
+
+
+
+
+
+
-
-
-
-
-
详细地址
-
-
+
+
+
+
详细地址
+
+
+
-
+
`; diff --git a/src/style/var.less b/src/style/var.less index b339968d1..94d63ba5f 100644 --- a/src/style/var.less +++ b/src/style/var.less @@ -75,7 +75,8 @@ @action-sheet-cancel-padding-color: @background-color; // AddressEdit -@address-edit-buttons-padding: @padding-xl @padding-md; +@address-edit-padding: @padding-sm; +@address-edit-buttons-padding: @padding-xl @padding-base; @address-edit-button-margin-bottom: @padding-sm; @address-edit-detail-finish-color: @blue; @address-edit-detail-finish-font-size: @font-size-sm;