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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
| // component/sidebar/sidebar.js
| Component({
| options: {
| multipleSlots: true,
| // 在组件定义时的选项中启用多slot支持
| addGlobalClass: true
| },
| properties: {
| maskClass: {
| // 遮罩层class
| type: String,
| value: ''
| },
| extClass: {
| // 弹出窗 class
| type: String,
| value: ''
| },
| maskClosable: {
| // 点击遮罩 关闭 actionsheet
| type: Boolean,
| value: true
| },
| mask: {
| // 是否需要 遮罩层
| type: Boolean,
| value: true
| },
| show: {
| // 是否开启 actionsheet
| type: Boolean,
| value: false
| },
| menus: {
| // 一级菜单 列表
| type: Array,
| value: [],
| },
| items: {
| // 二级菜单 列表
| type: Array,
| value: [],
| }
| },
| data: {
| selectedIndex: [0, 0],
| tempSelectedIndex: [0, 0]
| },
| methods: {
| _groupChange(e) {
| // 支持 一维数组 写法
| if (e.length > 0 && typeof e[0] !== 'string' && !(e[0] instanceof Array)) {
| this.setData({
| actions: [this.data.actions]
| });
| }
| },
|
| buttonTap(e) {
| const {
| value,
| groupindex,
| index
| } = e.currentTarget.dataset;
| this.triggerEvent('actiontap', {
| value,
| groupindex,
| index
| });
| },
|
| closeActionSheet(e) {
| this.setData({
| tempSelectedIndex: this.data.selectedIndex
| })
| const {
| type
| } = e.currentTarget.dataset;
|
| if (this.data.maskClosable || type) {
| // 点击 action 里面的 取消
| this.setData({
| show: false
| }); // 关闭回调事件
|
| this.triggerEvent('close');
| }
| },
|
| chooseMenu(e) {
| const {
| index
| } = e.currentTarget.dataset;
| this.setData({
| tempSelectedIndex: [index, 0]
| })
| },
|
| chooseItem(e) {
| const {
| index
| } = e.currentTarget.dataset;
| this.setData({
| 'tempSelectedIndex[1]': index
| })
| },
|
| submit() {
| this.setData({
| selectedIndex: this.data.tempSelectedIndex
| })
| this.triggerEvent('submit', this.data.selectedIndex);
| this.setData({
| show: false
| });
| }
| }
| })
|
|