diff --git a/packages/goods-action-button/index.less b/packages/goods-action-button/index.less index 5f81e6c6..574a806e 100644 --- a/packages/goods-action-button/index.less +++ b/packages/goods-action-button/index.less @@ -1,3 +1,41 @@ +@import '../common/style/var.less'; + :host { flex: 1; } + +.van-goods-action-button { + height: 36px !important; + font-weight: 500 !important; + font-size: @font-size-md !important; + line-height: 34px !important; + border: none !important; + + &--first { + display: block !important; + width: auto !important; + margin-left: 5px; + border-top-left-radius: 18px !important; + border-bottom-left-radius: 18px !important; + } + + &--last { + display: block !important; + width: auto !important; + margin-right: 5px; + border-top-right-radius: 18px !important; + border-bottom-right-radius: 18px !important; + } + + &--warning { + background: linear-gradient(to right, #ffd01e, #ff8917); + } + + &--danger { + background: linear-gradient(to right, #ff6034, #ee0a24); + } + + @media (max-width: 321px) { + font-size: 13px; + } +} diff --git a/packages/goods-action-button/index.ts b/packages/goods-action-button/index.ts index 9112c122..b59ed951 100644 --- a/packages/goods-action-button/index.ts +++ b/packages/goods-action-button/index.ts @@ -6,7 +6,13 @@ import { Weapp } from 'definitions/weapp'; VantComponent({ mixins: [link, button, openType], - + relation: { + type: 'ancestor', + name: 'goods-action', + linked(parent) { + this.parent = parent; + } + }, props: { text: String, color: String, @@ -18,10 +24,31 @@ VantComponent({ } }, + mounted: function() { + this.updateStyle(); + }, + methods: { onClick(event: Weapp.Event) { this.$emit('click', event.detail); this.jumpLink(); + }, + updateStyle() { + const parent = this.parent; + const { children = [] } = parent; + const index = children.indexOf(this); + const length = children.length; + let isFirst = false, isLast = false; + if ( index === 0 ) { + isFirst = true; + } + if (index === length - 1) { + isLast = true; + } + this.setData({ + isFirst, + isLast + }); } } }); diff --git a/packages/goods-action-button/index.wxml b/packages/goods-action-button/index.wxml index 052b9210..366b8cd7 100644 --- a/packages/goods-action-button/index.wxml +++ b/packages/goods-action-button/index.wxml @@ -1,3 +1,4 @@ + - + item !== child); + } + }, + beforeCreate() { + this.children = []; + }, props: { safeAreaInsetBottom: { type: Boolean,