1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
| import fmtUnit from '../_util/fmtUnit';
| Component({
| data: {
| _buttonsLayout: '',
| adviceClose: fmtUnit(26),
| normalClose: fmtUnit(18)
| },
| props: {
| className: '',
| topImageSize: 'md',
| showClose: false,
| closeType: '0',
| mask: true,
| buttonsLayout: 'horizontal',
| disableScroll: true,
| maskClick: false
| },
| didMount: function didMount() {
| var _this$props = this.props,
| buttons = _this$props.buttons,
| buttonsLayout = _this$props.buttonsLayout; // button数目大于 2 个,则强制使用竖排结构
|
| if (buttons && buttons.length > 2) {
| this.setData({
| _buttonsLayout: 'vertical'
| });
| } else {
| this.setData({
| _buttonsLayout: buttonsLayout
| });
| }
| },
| methods: {
| // footer点击
| _onModalClick: function _onModalClick() {
| var onModalClick = this.props.onModalClick;
|
| if (onModalClick) {
| onModalClick();
| }
| },
| // buttons点击
| _onButtonClick: function _onButtonClick(e) {
| var onButtonClick = this.props.onButtonClick;
|
| if (onButtonClick) {
| onButtonClick(e);
| }
| },
| // 关闭按钮点击
| _onModalClose: function _onModalClose() {
| var onModalClose = this.props.onModalClose;
|
| if (onModalClose) {
| onModalClose();
| }
| },
| // mask 遮罩层点击
| _onMaskTap: function _onMaskTap() {
| var onMaskClick = this.props.onMaskClick;
|
| if (typeof onMaskClick === 'function') {
| onMaskClick();
| } else {
| return false;
| }
| }
| }
| });
|
|