diff --git a/components.js b/components.js index e061b9047..b2ebf7b8d 100644 --- a/components.js +++ b/components.js @@ -80,4 +80,5 @@ module.exports = [ 'goods-action', 'goods-action-icon', 'goods-action-button', + 'address-edit', ]; diff --git a/src/address-edit/Detail.js b/src/address-edit/Detail.js index e89c0ed3a..364f5b4e4 100644 --- a/src/address-edit/Detail.js +++ b/src/address-edit/Detail.js @@ -20,6 +20,8 @@ export default createComponent({ showSearchResult: Boolean, }, + emits: ['blur', 'focus', 'input', 'select-search'], + computed: { shouldShowSearchResult() { return this.focused && this.searchResult && this.showSearchResult; @@ -39,6 +41,14 @@ export default createComponent({ this.$refs.field.blur(); }, + onFocus(event) { + this.$emit('focus', event); + }, + + onBlur(event) { + this.$emit('blur', event); + }, + genFinish() { const show = this.value && this.focused && android; if (show) { @@ -55,16 +65,7 @@ export default createComponent({ if (shouldShowSearchResult) { return searchResult.map((express) => ( { - this.onSelect(express); - }} - scopedSlots={{ + v-slots={{ title: () => { if (express.name) { const text = express.name.replace( @@ -76,6 +77,15 @@ export default createComponent({ } }, }} + key={express.name + express.address} + clickable + border={false} + icon="location-o" + label={express.address} + class={bem('search-item')} + onClick={() => { + this.onSelect(express); + }} /> )); } @@ -86,19 +96,25 @@ export default createComponent({ return ( { + this.$emit('input', val); + }, + }} /> {this.genSearchResult()} diff --git a/src/address-edit/index.js b/src/address-edit/index.js index e208cc87c..881d8302f 100644 --- a/src/address-edit/index.js +++ b/src/address-edit/index.js @@ -282,11 +282,11 @@ export default createComponent({ return ( ); } @@ -328,7 +328,7 @@ export default createComponent({ placeholder={this.areaPlaceholder || t('areaPlaceholder')} errorMessage={errorInfo.areaCode} rightIcon={!disableArea ? 'arrow' : null} - value={this.areaText} + modelValue={this.areaText} onFocus={onFocus('areaCode')} onClick={() => { this.$emit('click-area'); @@ -337,15 +337,15 @@ export default createComponent({ /> { this.$emit('select-search', event); @@ -363,7 +363,7 @@ export default createComponent({ onFocus={onFocus('postalCode')} /> )} - {this.slots()} + {this.$slots.default?.()} {this.genSetDefaultCell(h)}
@@ -386,11 +386,16 @@ export default createComponent({ )}
{ + this.showAreaPopup = value; + }, + }} >