Permalink
Browse files

[improvement] Dialog: 优化弹窗组件对 open 信息的处理 (#366)

* dialog 支持 open-type 的按钮,并增加获取 open 数据的方式

* 增加 dialog 调用 open数据的文档说明

* 增加 dialog close 方法

* 增加文档
  • Loading branch information...
pangxie1991 committed Jul 15, 2018
1 parent cf9cfdb commit 87bf9c9ea71f163a562e840eaf2336281e908618
View
@@ -55,6 +55,7 @@ module.exports = {
label: '表单',
include: {
checkbox: require('./packages/checkbox/README.md'),
datetime_picker: require('./packages/datetime-picker/README.md'),
field: require('./packages/field/README.md'),
radio: require('./packages/radio/README.md'),
search: require('./packages/search/README.md'),
@@ -79,7 +80,6 @@ module.exports = {
label: '交互',
include: {
actionsheet: require('./packages/actionsheet/README.md'),
datetime_picker: require('./packages/datetime-picker/README.md'),
dialog: require('./packages/dialog/README.md'),
popup: require('./packages/popup/README.md'),
tab: require('./packages/tab/README.md'),
@@ -38,21 +38,9 @@ export default {
}, {
name: 'Popup 弹出层',
path: '/pages/popup/index'
}, {
name: 'Select 选择',
path: '/pages/select/index'
}, {
name: 'Stepper 计数器',
path: '/pages/stepper/index'
}, {
name: 'Steps 步骤条',
path: '/pages/steps/index'
}, {
name: 'Switch 开关',
path: '/pages/switch/index'
}, {
name: 'Search 搜索',
path: '/pages/search/index'
}, {
name: 'Tab 标签',
path: '/pages/tab/index'
@@ -71,19 +59,28 @@ export default {
{
name: 'Checkbox 复选框',
path: '/pages/checkbox/index'
},
{
}, {
name: 'Datetime 时间选择器',
path: '/pages/datetime/index'
},
{
}, {
name: 'Field 输入框',
path: '/pages/field/index'
},
{
}, {
name: 'Radio 单选框',
path: '/pages/radio/index'
},
}, {
name: 'Search 搜索',
path: '/pages/search/index'
}, {
name: 'Select 选择',
path: '/pages/select/index'
}, {
name: 'Stepper 计数器',
path: '/pages/stepper/index'
}, {
name: 'Switch 开关',
path: '/pages/switch/index'
}
]
},
action: {
@@ -101,9 +98,6 @@ export default {
}, {
name: 'TopTips 顶部提示',
path: '/pages/toptips/index'
}, {
name: 'Datetime 时间选择器',
path: '/pages/datetime/index'
}
]
}
@@ -1,4 +1,5 @@
const Dialog = require('../../dist/dialog/dialog');
const Toast = require('../../dist/toast/toast');
Page({
toggleBaseDialog() {
@@ -76,6 +77,60 @@ Page({
});
},
toggleOpenDialog() {
Dialog({
title: '弹窗',
message: '获取用户数据',
selector: '#zan-open-dialog',
buttons: [{
text: '用户信息',
type: 'userInfo',
openType: 'getUserInfo'
}, {
text: '获取手机号',
type: 'tel',
openType: 'getPhoneNumber'
}, {
text: '打开授权页',
type: 'setting',
openType: 'openSetting'
}]
}).then(({ type, hasOpenDataPromise, openDataPromise }) => {
console.log(type);
// 如果没有 open 数据返回,就不处理
if (!hasOpenDataPromise) {
return;
}
openDataPromise.then((data) => {
console.log('成功获取信息', data);
}).catch((data) => {
console.log('获取信息失败', data);
});
});
},
toggleCloseDialog() {
Dialog({
title: '弹窗',
message: '这是一个自由控制关闭的弹窗',
selector: '#zan-close-dialog',
autoClose: false
}).then(() => {
console.log('=== dialog resolve ===', 'type: confirm');
Toast.loading({
selector: '#zan-toast'
});
// 2s 后自动关闭弹窗
setTimeout(() => {
Dialog.close({ selector: '#zan-close-dialog' });
Toast.clear();
}, 2000);
});
},
onShareAppMessage() {
return {
title: 'ZanUI-WeApp',
@@ -4,6 +4,7 @@
"doc-page": "../../components/doc-page/index",
"zan-dialog": "../../dist/dialog/index",
"zan-button": "../../dist/btn/index",
"zan-button-group": "../../dist/btn-group/index"
"zan-button-group": "../../dist/btn-group/index",
"zan-toast": "../../dist/toast/index"
}
}
@@ -4,10 +4,16 @@
<zan-button bindtap="toggleWithoutTitleDialog">Dialog - 无标题</zan-button>
<zan-button bindtap="toggleButtonDialog">Dialog - 自定义显示按钮</zan-button>
<zan-button bindtap="toggleVerticalDialog">Dialog - 按钮纵向排布</zan-button>
<zan-button bindtap="toggleOpenDialog">Dialog - 获取 Open 数据的弹窗</zan-button>
<zan-button bindtap="toggleCloseDialog">Dialog - 控制弹窗关闭</zan-button>
</zan-button-group>
<zan-dialog id="zan-base-dialog"></zan-dialog>
<zan-dialog id="zan-no-title-dialog"></zan-dialog>
<zan-dialog id="zan-button-dialog"></zan-dialog>
<zan-dialog id="zan-vertical-dialog"></zan-dialog>
<zan-dialog id="zan-open-dialog"></zan-dialog>
<zan-dialog id="zan-close-dialog"></zan-dialog>
<zan-toast id="zan-toast"></zan-toast>
</doc-page>
Oops, something went wrong.

0 comments on commit 87bf9c9

Please sign in to comment.