[new feature] Dialog: 支持openType相关参数

support #1093
This commit is contained in:
rex 2019-02-18 13:34:03 +08:00 committed by GitHub
parent 2e28702b8c
commit 84f73456fc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 51 additions and 12 deletions

View File

@ -124,8 +124,8 @@ Page({
通过函数调用 Dialog 时,支持传入以下选项: 通过函数调用 Dialog 时,支持传入以下选项:
| 参数 | 说明 | 类型 | 默认值 | | 参数 | 说明 | 类型 | 默认值 | 生效时机 |
|-----------|-----------|-----------|-------------| |-----------|-----------|-----------|-------------|-------------|
| title | 标题 | `String` | - | | title | 标题 | `String` | - |
| message | 内容 | `String` | - | | message | 内容 | `String` | - |
| messageAlign | 内容对齐方式,可选值为`left` `right` | `String` | `center` | | messageAlign | 内容对齐方式,可选值为`left` `right` | `String` | `center` |
@ -141,13 +141,21 @@ Page({
| asyncClose | 是否异步关闭弹窗,开启后需要手动控制弹窗的关闭 | `Boolean` | `false` | | asyncClose | 是否异步关闭弹窗,开启后需要手动控制弹窗的关闭 | `Boolean` | `false` |
| context | 选择器的选择范围,可以传入自定义组件的 this 作为上下文 | `Object` | 当前页面 | | context | 选择器的选择范围,可以传入自定义组件的 this 作为上下文 | `Object` | 当前页面 |
| transition | 动画名称,可选值为`fade` | `String` | `scale` | | transition | 动画名称,可选值为`fade` | `String` | `scale` |
| app-parameter | 打开 APP 时,向 APP 传递的参数 | `String` | - | `confirmButtonOpenType="launchApp"` |
| lang | 指定返回用户信息的语言zh_CN 简体中文,<br>zh_TW 繁体中文en 英文 | `String` | `en` | `confirmButtonOpenType="getUserInfo"` |
| session-from | 会话来源 | `String` | - | `confirmButtonOpenType="contact"` |
| business-id | 客服消息子商户 id | `Number` | - |
| send-message-title | 会话内消息卡片标题 | `String` | 当前标题 | `confirmButtonOpenType="contact"` |
| send-message-path | 会话内消息卡片点击跳转小程序路径 | `String` | 当前分享路径 | `confirmButtonOpenType="contact"` |
| send-message-img | sendMessageImg | `String` | 截图 | `confirmButtonOpenType="contact"` |
| show-message-card | 显示会话内消息卡片 | `String` | `false` | `confirmButtonOpenType="contact"` |
### API ### API
通过组件调用 Dialog 时,支持以下 API 通过组件调用 Dialog 时,支持以下 API
| 参数 | 说明 | 类型 | 默认值 | | 参数 | 说明 | 类型 | 默认值 | 生效时机 |
|-----------|-----------|-----------|-------------| |-----------|-----------|-----------|-------------|-------------|
| show | 是否显示弹窗 | `Boolean` | - | | show | 是否显示弹窗 | `Boolean` | - |
| title | 标题 | `String` | - | | title | 标题 | `String` | - |
| message | 内容 | `String` | - | | message | 内容 | `String` | - |
@ -163,6 +171,14 @@ Page({
| use-slot | 是否使用自定义内容的插槽 | `Boolean` | `false` | | use-slot | 是否使用自定义内容的插槽 | `Boolean` | `false` |
| async-close | 是否异步关闭弹窗,开启后需要手动控制弹窗的关闭 | `Boolean` | `false` | | async-close | 是否异步关闭弹窗,开启后需要手动控制弹窗的关闭 | `Boolean` | `false` |
| transition | 动画名称,可选值为`fade` | `String` | `scale` | | transition | 动画名称,可选值为`fade` | `String` | `scale` |
| app-parameter | 打开 APP 时,向 APP 传递的参数 | `String` | - | `confirm-button-open-type="launchApp"` |
| lang | 指定返回用户信息的语言zh_CN 简体中文,<br>zh_TW 繁体中文en 英文 | `String` | `en` | `confirm-button-open-type="getUserInfo"` |
| session-from | 会话来源 | `String` | - | `confirm-button-open-type="contact"` |
| business-id | 客服消息子商户 id | `Number` | - |
| send-message-title | 会话内消息卡片标题 | `String` | 当前标题 | `confirm-button-open-type="contact"` |
| send-message-path | 会话内消息卡片点击跳转小程序路径 | `String` | 当前分享路径 | `confirm-button-open-type="contact"` |
| send-message-img | sendMessageImg | `String` | 截图 | `confirm-button-open-type="contact"` |
| show-message-card | 显示会话内消息卡片 | `String` | `false` | `confirm-button-open-type="contact"` |
### Event ### Event

View File

@ -2,6 +2,7 @@ let queue = [];
type DialogAction = 'confirm' | 'cancel'; type DialogAction = 'confirm' | 'cancel';
type DialogOptions = { type DialogOptions = {
lang?: string;
show?: boolean; show?: boolean;
title?: string; title?: string;
zIndex?: number; zIndex?: number;
@ -9,9 +10,17 @@ type DialogOptions = {
message?: string; message?: string;
overlay?: boolean; overlay?: boolean;
selector?: string; selector?: string;
ariaLabel?: string;
transition?: string; transition?: string;
asyncClose?: boolean; asyncClose?: boolean;
businessId?: number;
sessionFrom?: string;
appParameter?: string;
messageAlign?: string; messageAlign?: string;
sendMessageImg?: string;
showMessageCard?: boolean;
sendMessagePath?: string;
sendMessageTitle?: string;
confirmButtonText?: string; confirmButtonText?: string;
cancelButtonText?: string; cancelButtonText?: string;
showConfirmButton?: boolean; showConfirmButton?: boolean;

View File

@ -1,8 +1,11 @@
import { VantComponent } from '../common/component'; import { VantComponent } from '../common/component';
import { button } from '../mixins/button';
import { openType } from '../mixins/open-type'; import { openType } from '../mixins/open-type';
type Action = 'confirm' | 'cancel' | 'overlay';
VantComponent({ VantComponent({
mixins: [openType], mixins: [button, openType],
props: { props: {
show: Boolean, show: Boolean,
@ -48,7 +51,7 @@ VantComponent({
}, },
watch: { watch: {
show(show) { show(show: boolean) {
!show && this.stopLoading(); !show && this.stopLoading();
} }
}, },
@ -66,7 +69,7 @@ VantComponent({
this.onClose('overlay'); this.onClose('overlay');
}, },
handleAction(action) { handleAction(action: Action) {
if (this.data.asyncClose) { if (this.data.asyncClose) {
this.set({ this.set({
[`loading.${action}`]: true [`loading.${action}`]: true
@ -91,7 +94,7 @@ VantComponent({
}); });
}, },
onClose(action) { onClose(action: Action) {
if (!this.data.asyncClose) { if (!this.data.asyncClose) {
this.close(); this.close();
} }

View File

@ -39,13 +39,24 @@
class="van-dialog__button" class="van-dialog__button"
loading="{{ loading.confirm }}" loading="{{ loading.confirm }}"
custom-class="van-dialog__confirm" custom-class="van-dialog__confirm"
open-type="{{ confirmButtonOpenType }}" open-type="{{ confirmButtonOpenType }}"
lang="{{ lang }}"
business-id="{{ businessId }}"
session-from="{{ sessionFrom }}"
send-message-title="{{ sendMessageTitle }}"
send-message-path="{{ sendMessagePath }}"
send-message-img="{{ sendMessageImg }}"
show-message-card="{{ showMessageCard }}"
app-parameter="{{ appParameter }}"
bind:click="onConfirm" bind:click="onConfirm"
binderror="bindError"
bindcontact="bindContact"
bindopensetting="bindOpenSetting"
bindgetuserinfo="bindGetUserInfo" bindgetuserinfo="bindGetUserInfo"
bindcontact="bindContact"
bindgetphonenumber="bindGetPhoneNumber" bindgetphonenumber="bindGetPhoneNumber"
binderror="bindError"
bindlaunchapp="bindLaunchApp"
bindopensetting="bindOpenSetting"
> >
{{ confirmButtonText }} {{ confirmButtonText }}
</van-button> </van-button>

View File

@ -12,7 +12,7 @@ export const button = Behavior({
sendMessageTitle: String, sendMessageTitle: String,
sendMessagePath: String, sendMessagePath: String,
sendMessageImg: String, sendMessageImg: String,
showMessageCard: String, showMessageCard: Boolean,
appParameter: String, appParameter: String,
ariaLabel: String ariaLabel: String
} }