Skip to content

Commit

Permalink
feat(button): add button-id prop & agreePrivacyAuthorization event su…
Browse files Browse the repository at this point in the history
…pport (#5533)
  • Loading branch information
johnsonwong666 authored Aug 30, 2023
1 parent b9dea4f commit fd41bd8
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 6 deletions.
1 change: 1 addition & 0 deletions packages/button/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@
| 参数 | 说明 | 类型 | 默认值 |
| --- | --- | --- | --- |
| id | 标识符 | _string_ | - |
| button-id `v1.10.25`| 标识符,作为原生button组件的id值 | _string_ | - |
| type | 按钮类型,可选值为 `primary` `info` `warning` `danger` | _string_ | `default` |
| size | 按钮尺寸,可选值为 `normal` `large` `small` `mini` | _string_ | `normal` |
| color `v1.0.0` | 按钮颜色,支持传入`linear-gradient`渐变色 | _string_ | - |
Expand Down
2 changes: 1 addition & 1 deletion packages/button/index.wxml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<wxs src="./index.wxs" module="computed" />

<button
id="{{ id }}"
id="{{ id || buttonId }}"
data-detail="{{ dataset }}"
class="custom-class {{ utils.bem('button', [type, size, { block, round, plain, square, loading, disabled, hairline, unclickable: disabled || loading }]) }} {{ hairline ? 'van-hairline--surround' : '' }}"
hover-class="{{ disabled || loading ? '' : 'van-button--active hover-class'}}"
Expand Down
3 changes: 2 additions & 1 deletion packages/dialog/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ Page({
| 参数 | 说明 | 类型 | 默认值 |
| --- | --- | --- | --- |
| show | 是否显示弹窗 | _boolean_ | - |
| confirm-button-id `v1.10.25`| 确认按钮的标识符,作为底层原生button组件的id值 | _string_ | - |
| title | 标题 | _string_ | - |
| width | 弹窗宽度,默认单位为`px` | _string \| number_ | `320px` |
| message | 文本内容,支持通过`\n`换行 | _string_ | - |
Expand Down Expand Up @@ -292,7 +293,7 @@ Page({
| bind:contact | 客服消息回调 | - |
| bind:getphonenumber | 获取用户手机号回调 | - |
| bind:getrealtimephonenumber `v1.10.21` | 获取手机号实时验证回调,open-type=getRealtimePhoneNumber 时有效 | - |
| bind:agreeprivacyauthorization `v1.10.24` | 同意隐私协议回调,openType="agreePrivacyAuthorization"时有效 | - |
| bind:agreeprivacyauthorization `v1.10.25` | 同意隐私协议回调,openType="agreePrivacyAuthorization"时有效 | - |
| bind:error | 当使用开放能力时,发生错误的回调 | - |
| bind:opensetting | 在打开授权设置页后回调 | - |

Expand Down
1 change: 1 addition & 0 deletions packages/dialog/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ VantComponent({
type: String,
value: 'default',
},
confirmButtonId: String,
className: String,
customStyle: String,
asyncClose: Boolean,
Expand Down
8 changes: 4 additions & 4 deletions packages/dialog/index.wxml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
loading="{{ loading.confirm }}"
custom-class="van-dialog__confirm confirm-button-class"
custom-style="color: {{ confirmButtonColor }}"

button-id="{{ confirmButtonId }}"
open-type="{{ confirmButtonOpenType }}"
lang="{{ lang }}"
business-id="{{ businessId }}"
Expand All @@ -56,7 +56,7 @@
send-message-img="{{ sendMessageImg }}"
show-message-card="{{ showMessageCard }}"
app-parameter="{{ appParameter }}"

bindagreeprivacyauthorization="onAgreePrivacyAuthorization"
bind:click="onConfirm"
bindgetuserinfo="onGetUserInfo"
bindcontact="onContact"
Expand Down Expand Up @@ -96,7 +96,7 @@
loading="{{ loading.confirm }}"
custom-class="van-dialog__confirm confirm-button-class"
custom-style="color: {{ confirmButtonColor }}"

button-id="{{ confirmButtonId }}"
open-type="{{ confirmButtonOpenType }}"
lang="{{ lang }}"
business-id="{{ businessId }}"
Expand All @@ -106,7 +106,7 @@
send-message-img="{{ sendMessageImg }}"
show-message-card="{{ showMessageCard }}"
app-parameter="{{ appParameter }}"

bindagreeprivacyauthorization="onAgreePrivacyAuthorization"
bind:click="onConfirm"
bindgetuserinfo="onGetUserInfo"
bindcontact="onContact"
Expand Down
2 changes: 2 additions & 0 deletions packages/goods-action-button/index.wxml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<wxs src="../wxs/utils.wxs" module="utils" />
<van-button
id="{{ id }}"
button-id="{{ buttonId }}"
lang="{{ lang }}"
type="{{ type }}"
size="{{ size }}"
Expand All @@ -23,6 +24,7 @@
bindcontact="onContact"
bindopensetting="onOpenSetting"
bindgetuserinfo="onGetUserInfo"
bindagreeprivacyauthorization="onAgreePrivacyAuthorization"
bindgetphonenumber="onGetPhoneNumber"
bindlaunchapp="onLaunchApp"
>
Expand Down
1 change: 1 addition & 0 deletions packages/goods-action/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ Page({
| url | 点击后跳转的链接地址 | _string_ | - |
| link-type | 链接跳转类型,可选值为 `redirectTo` `switchTab` `reLaunch` | _string_ | `navigateTo` |
| id | 标识符 | _string_ | - |
| button-id `v1.10.25`| 标识符,作为原生button组件的id值 | _string_ | - |
| type | 按钮类型,可选值为 `primary` `warning` `danger` | _string_ | `danger` |
| plain | 是否为朴素按钮 | _boolean_ | `false` |
| size | 按钮尺寸,可选值为 `normal` `large` `small` `mini` | _string_ | `normal` |
Expand Down
8 changes: 8 additions & 0 deletions packages/goods-action/test/__snapshots__/demo.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ exports[`should render demo and match snapshot 1`] = `
<van-button
class="van-goods-action-button van-goods-action-button--warning van-goods-action-button--first"
customClass="van-goods-action-button__inner custom-class"
bind:agreeprivacyauthorization="onAgreePrivacyAuthorization"
bind:click="onClick"
bind:contact="onContact"
bind:error="onError"
Expand Down Expand Up @@ -209,6 +210,7 @@ exports[`should render demo and match snapshot 1`] = `
<van-button
class="van-goods-action-button van-goods-action-button--danger van-goods-action-button--last"
customClass="van-goods-action-button__inner custom-class"
bind:agreeprivacyauthorization="onAgreePrivacyAuthorization"
bind:click="onClick"
bind:contact="onContact"
bind:error="onError"
Expand Down Expand Up @@ -490,6 +492,7 @@ exports[`should render demo and match snapshot 1`] = `
<van-button
class="van-goods-action-button van-goods-action-button--warning van-goods-action-button--first"
customClass="van-goods-action-button__inner custom-class"
bind:agreeprivacyauthorization="onAgreePrivacyAuthorization"
bind:click="onClick"
bind:contact="onContact"
bind:error="onError"
Expand Down Expand Up @@ -540,6 +543,7 @@ exports[`should render demo and match snapshot 1`] = `
<van-button
class="van-goods-action-button van-goods-action-button--danger van-goods-action-button--last"
customClass="van-goods-action-button__inner custom-class"
bind:agreeprivacyauthorization="onAgreePrivacyAuthorization"
bind:click="onClick"
bind:contact="onContact"
bind:error="onError"
Expand Down Expand Up @@ -741,6 +745,7 @@ exports[`should render demo and match snapshot 1`] = `
<van-button
class="van-goods-action-button van-goods-action-button--warning van-goods-action-button--first"
customClass="van-goods-action-button__inner custom-class"
bind:agreeprivacyauthorization="onAgreePrivacyAuthorization"
bind:click="onClick"
bind:contact="onContact"
bind:error="onError"
Expand Down Expand Up @@ -791,6 +796,7 @@ exports[`should render demo and match snapshot 1`] = `
<van-button
class="van-goods-action-button van-goods-action-button--danger van-goods-action-button--last"
customClass="van-goods-action-button__inner custom-class"
bind:agreeprivacyauthorization="onAgreePrivacyAuthorization"
bind:click="onClick"
bind:contact="onContact"
bind:error="onError"
Expand Down Expand Up @@ -992,6 +998,7 @@ exports[`should render demo and match snapshot 1`] = `
<van-button
class="van-goods-action-button van-goods-action-button--warning van-goods-action-button--first"
customClass="van-goods-action-button__inner custom-class"
bind:agreeprivacyauthorization="onAgreePrivacyAuthorization"
bind:click="onClick"
bind:contact="onContact"
bind:error="onError"
Expand Down Expand Up @@ -1042,6 +1049,7 @@ exports[`should render demo and match snapshot 1`] = `
<van-button
class="van-goods-action-button van-goods-action-button--danger van-goods-action-button--last van-goods-action-button--plain"
customClass="van-goods-action-button__inner custom-class"
bind:agreeprivacyauthorization="onAgreePrivacyAuthorization"
bind:click="onClick"
bind:contact="onContact"
bind:error="onError"
Expand Down
1 change: 1 addition & 0 deletions packages/mixins/button.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export const button = Behavior({

properties: {
id: String,
buttonId: String,
lang: String,
businessId: Number,
sessionFrom: String,
Expand Down

0 comments on commit fd41bd8

Please sign in to comment.