diff --git a/src/address-edit/README.md b/src/address-edit/README.md index fafcf28e2..8bd371d86 100644 --- a/src/address-edit/README.md +++ b/src/address-edit/README.md @@ -73,6 +73,9 @@ export default { | show-delete | Whether to show delete button | *boolean* | `false` | | show-set-default | Whether to show default address switch | *boolean* | `false` | | show-search-result | Whether to show address search result | *boolean* | `false` | +| show-area | Whether to show area cell | *boolean* | `true` | +| show-detail | Whether to show detail field | *boolean* | `true` | +| disable-area | Whether to disable area select | *boolean* | `false` | | save-button-text | Save button text | *string* | `Save` | | delete-button-text | Delete button text | *string* | `Delete` | | detail-rows | Detail input rows | *number \| string* | `1` | diff --git a/src/address-edit/README.zh-CN.md b/src/address-edit/README.zh-CN.md index ac93c6d30..80efbddb8 100644 --- a/src/address-edit/README.zh-CN.md +++ b/src/address-edit/README.zh-CN.md @@ -73,6 +73,9 @@ export default { | show-delete | 是否显示删除按钮 | *boolean* | `false` | | show-set-default | 是否显示默认地址栏 | *boolean* | `false` | | show-search-result | 是否显示搜索结果 | *boolean* | `false` | +| show-area | 是否显示地区 | *boolean* | `true` | +| show-detail | 是否显示详细地址 | *boolean* | `true` | +| disable-area | 是否禁用地区选择 | *boolean* | `false` | | save-button-text | 保存按钮文字 | *string* | `保存` | | delete-button-text | 删除按钮文字 | *string* | `删除` | | detail-rows | 详细地址输入框行数 | *number \| string* | `1` | diff --git a/src/address-edit/index.js b/src/address-edit/index.js index e24164db3..3e9d42179 100644 --- a/src/address-edit/index.js +++ b/src/address-edit/index.js @@ -52,6 +52,7 @@ export default createComponent({ type: Boolean, default: true, }, + disableArea: Boolean, detailRows: { type: [Number, String], default: 1, @@ -250,7 +251,7 @@ export default createComponent({ }, render() { - const { data, errorInfo, searchResult } = this; + const { data, errorInfo, searchResult, disableArea } = this; const onFocus = name => () => this.onFocus(name); // hide bottom field when use search && detail get focused @@ -280,15 +281,15 @@ export default createComponent({ { - this.showAreaPopup = true; + this.showAreaPopup = !disableArea; }} /> ) { const { disabled, switchable } = props; @@ -95,18 +99,18 @@ function AddressItem( } return ( - +
+ + {slots.bottom?.({ ...props.data, disabled })} +
); } diff --git a/src/address-list/README.md b/src/address-list/README.md index 415984d15..3b3575309 100644 --- a/src/address-list/README.md +++ b/src/address-list/README.md @@ -104,7 +104,8 @@ export default { ### Slots -| Name | Description | -|------|------| -| default | Custom content after list | -| top | Custom content before list | +| Name | Description | SlotProps | +|------|------|------| +| default | Custom content after list | - | +| top | Custom content before list | - | +| item-bottom | Custom content after list item | item | diff --git a/src/address-list/README.zh-CN.md b/src/address-list/README.zh-CN.md index 60505d0d6..0d6387976 100644 --- a/src/address-list/README.zh-CN.md +++ b/src/address-list/README.zh-CN.md @@ -104,7 +104,8 @@ export default { ### Slots -| 名称 | 说明 | -|------|------| -| default | 在列表下方插入内容 | -| top | 在顶部插入内容 | +| 名称 | 说明 | SlotProps | +|------|------|------| +| default | 在列表下方插入内容 | - | +| top | 在顶部插入内容 | - | +| item-bottom | 在列表项底部插入内容 | 列表项的值 | diff --git a/src/address-list/index.less b/src/address-list/index.less index 45d47da63..d49805799 100644 --- a/src/address-list/index.less +++ b/src/address-list/index.less @@ -31,6 +31,7 @@ .van-address-item { padding: @address-list-item-padding; + background-color: @white; border-radius: @border-radius-lg; &:not(:last-child) { @@ -79,6 +80,10 @@ transform: translate(0, -50%); } + .van-cell { + padding: 0; + } + .van-radio__label { margin-left: @padding-sm; } diff --git a/src/address-list/index.tsx b/src/address-list/index.tsx index 06bb14b1f..1726e0508 100644 --- a/src/address-list/index.tsx +++ b/src/address-list/index.tsx @@ -23,6 +23,7 @@ export type AddressListProps = { export type AddressListSlots = DefaultSlots & { top?: ScopedSlot; + 'item-bottom'?: ScopedSlot; }; const [createComponent, bem, t] = createNamespace('address-list'); @@ -45,6 +46,9 @@ function AddressList( disabled={disabled} switchable={props.switchable} defaultTagText={props.defaultTagText} + scopedSlots={{ + bottom: slots['item-bottom'], + }} onSelect={() => { emit(ctx, disabled ? 'select-disabled' : 'select', item, index); diff --git a/src/address-list/test/__snapshots__/demo.spec.js.snap b/src/address-list/test/__snapshots__/demo.spec.js.snap index f7de8ec31..46d2927fc 100644 --- a/src/address-list/test/__snapshots__/demo.spec.js.snap +++ b/src/address-list/test/__snapshots__/demo.spec.js.snap @@ -5,34 +5,40 @@ exports[`renders demo correctly 1`] = `
-
-
- -
-
- -
- +
+
+
+ +
+ +
以下地址超出配送范围
-
-
-
王五 1320000000
-
浙江省杭州市滨江区江南大道 15 号
-
- +
+
+
+
王五 1320000000
+
浙江省杭州市滨江区江南大道 15 号
+
+ +
diff --git a/src/address-list/test/__snapshots__/index.spec.js.snap b/src/address-list/test/__snapshots__/index.spec.js.snap index 867138aca..d9ffb7d07 100644 --- a/src/address-list/test/__snapshots__/index.spec.js.snap +++ b/src/address-list/test/__snapshots__/index.spec.js.snap @@ -3,19 +3,23 @@ exports[`unswitchable 1`] = `
-
-
-
张三 13000000000
-
浙江省杭州市西湖区文三路 138 号东方通信大厦 7 楼 501 室
-
- +
+
+
+
张三 13000000000
+
浙江省杭州市西湖区文三路 138 号东方通信大厦 7 楼 501 室
+
+ +
-
-
-
李四 1310000000
-
浙江省杭州市拱墅区莫干山路 50 号
-
- +
+
+
+
李四 1310000000
+
浙江省杭州市拱墅区莫干山路 50 号
+
+ +