Yao b8930d972a
[refactor] Dialog: 升级为自定义组件 (#184)
* 封装 doc-page, 方便写文档

* add pop manager

* popup upgrade

* 更新 README

* add empty line

* delete empty css

* dialog init

* dialog

* dialog upgrade

* 修复 helper 里的样式问题

* dialog 文档

* 修复 button 奇怪的边框问题

* 缩进处理
2018-04-07 22:28:23 +08:00

50 lines
984 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

const defaultData = require('./data');
const _f = function() {};
Component({
properties: {},
data: {
...defaultData,
key: '',
show: false,
showCustomBtns: false,
promiseFunc: {}
},
methods: {
handleButtonClick(e) {
const { currentTarget = {} } = e;
const { dataset = {} } = currentTarget;
// 获取当次弹出框的信息
const { resolve = _f, reject = _f } = this.data.promiseFunc || {};
// 重置展示
this.setData({
show: false
});
// 自定义按钮,全部 resolve 形式返回,根据 type 区分点击按钮
if (this.data.showCustomBtns) {
resolve({
type: dataset.type
});
return;
}
// 默认按钮,确认为 resolve取消为 reject
if (dataset.type === 'confirm') {
resolve({
type: 'confirm'
});
} else {
reject({
type: 'cancel'
});
}
}
}
});