# 弹窗(Modal)
用于弹窗出现时,让用户聚焦弹窗内容;所有弹窗高度,均不可超过544像素。弹窗按钮高均为48。
# 示例
<template>
<div class="wrapper">
<dof-minibar title="7.3弹窗"></dof-minibar>
<scroller class="btn-box">
<dof-button @dofButtonClicked="modal1 = true" text="一个按钮弹窗"></dof-button>
<dof-button class="m-t-16" @dofButtonClicked="modal2 = true" text="一个按钮弹窗带描述"></dof-button>
<dof-button class="m-t-16" @dofButtonClicked="modal3 = true" text="两个按钮弹窗"></dof-button>
<dof-button class="m-t-16" @dofButtonClicked="modal4 = true" text="两个按钮弹窗自定义文案"></dof-button>
<dof-button class="m-t-16" @dofButtonClicked="modal5 = true" text="多个按钮弹窗"></dof-button>
<dof-button class="m-t-16" @dofButtonClicked="modal6 = true" text="带输出框弹窗"></dof-button>
<dof-button class="m-t-16" @dofButtonClicked="modal7 = true" text="打开图片弹窗1"></dof-button>
<dof-button class="m-t-16" @dofButtonClicked="modal8 = true" text="打开图片弹窗2"></dof-button>
<dof-button class="m-t-16" @dofButtonClicked="modal9 = true" text="打开图标弹窗1"></dof-button>
<dof-button class="m-t-16" @dofButtonClicked="modal10 = true" text="打开图标弹窗2"></dof-button>
</scroller>
<dof-modal
title="样式1"
:show="modal1"
@close="modal1 = false"
@dofModalConfirmBtnClicked="modal1 = false"
:single="true"
>
</dof-modal>
<dof-modal
title="标题"
content="平台变得更大了,我们增加了大约100个新的产品应用。"
:show="modal2"
@close="modal2 = false"
@dofModalConfirmBtnClicked="modal2 = false"
:single="true"
>
</dof-modal>
<dof-modal title="样式2" :show="modal3" @close="modal3 = false" @dofModalConfirmBtnClicked="modal3 = false">
</dof-modal>
<dof-modal
title="检测到新版本"
content="是否更新到最新版本v5.1(155M)?"
:show="modal4"
@close="modal4 = false"
@dofModalCancelBtnClicked="modal4 = false"
@dofModalConfirmBtnClicked="modal4 = false"
:cancel-text="'操作1'"
:confirm-text="'操作2'"
>
</dof-modal>
<dof-modal
title="标题"
content="平台变得更大了,我们增加了大约100个新的产品应用。"
:show="modal5"
@close="modal5 = false"
@dofModalConfirmBtnClicked="modal5 = false"
:btnGroup="[{ text: '确定', color: '#B35336' }, '更多', '取消']"
>
</dof-modal>
<dof-modal
title="家的名称"
content="描述"
hasInput="true"
:inputContent="inputContent"
placeholder="输入文字"
:show="modal6"
@dofModalCancelBtnClicked="modal6 = false"
@close="modal6 = false"
@dofModalConfirmBtnClicked="modal6 = false"
>
</dof-modal>
<dof-modal
title="检测到新版本"
:show="modal7"
@dofModalCancelBtnClicked="modal7 = false"
@dofModalConfirmBtnClicked="modal7 = false"
:image="'./assets/image/modal/img.png'"
:img-style="imgStyle"
:modal-content-style="{ paddingLeft: '0px', paddingRight: '0px' }"
>
<div class="contentTextBox" slot="content">
<text class="contentText">{{ content }}</text>
</div>
</dof-modal>
<dof-modal
:show="modal8"
@dofModalCancelBtnClicked="modal8 = false"
@dofModalConfirmBtnClicked="modal8 = false"
:image="'./assets/image/modal/img.png'"
:img-style="imgStyle2"
:modal-content-style="{ paddingTop: '0px', paddingLeft: '0px', paddingRight: '0px' }"
>
<div class="contentTextBox" slot="content">
<text class="contentText t-a-l">{{ content2 }}</text>
</div>
</dof-modal>
<dof-modal
title="检测到新版本"
:show="modal9"
@close="modal9 = false"
@dofModalConfirmBtnClicked="modal9 = false"
@closeIconClicked="modal9 = false"
:btn-group="null"
:image="'./assets/image/modal/img.png'"
:img-style="imgStyle"
:modal-content-style="{ paddingLeft: '0px', paddingRight: '0px', paddingBottom: '0px' }"
:isShowCloseIcon="true"
>
<div slot="content">
<text class="contentTitle">狗粮小盆</text>
<text class="contentTip">识别准确率 98%</text>
<div class="contentTextBox">
<text class="contentText">{{ content }}</text>
</div>
<div class="selectBox">
<div>
<div :class="['selectItem']" ref="selectItem1" @click="handleSelect(1)">
<dof-iconfont
:code="'\u4827'"
:size="88"
:color="'rgba(255,255,255,0.80)'"
@dofIconFontClicked="handleSelect(1)"
></dof-iconfont>
</div>
<text class="selectText">好评</text>
</div>
<div>
<div :class="['selectItem']" ref="selectItem2" @click="handleSelect(2)">
<dof-iconfont
:code="'\u4828'"
:size="88"
:color="'rgba(255,255,255,0.80)'"
@dofIconFontClicked="handleSelect(2)"
></dof-iconfont>
</div>
<text class="selectText">差评</text>
</div>
<div class="dotBox">
<div
:class="['dot', i === 0 ? 'firstDot' : i === 2 ? 'lastDot' : '']"
v-for="(item, i) in 3"
:key="i"
></div>
</div>
</div>
</div>
</dof-modal>
<dof-modal
title="检测到新版本"
:show="modal10"
@close="modal10 = false"
@dofModalConfirmBtnClicked="modal10 = false"
@closeIconClicked="modal10 = false"
:btn-group="null"
:modal-content-style="{ paddingLeft: '0px', paddingRight: '0px', paddingBottom: '0px' }"
:isShowCloseIcon="true"
>
<div slot="content">
<div class="contentTextBox" style="margin-top: 20px;">
<text class="contentText">{{ content }}</text>
</div>
<div class="selectBox" style="padding-bottom: 40px;">
<div>
<div :class="['selectItem']" ref="selectItem1" @click="handleSelect(1)">
<dof-iconfont
:code="'\u4827'"
:size="88"
:color="'rgba(255,255,255,0.80)'"
@dofIconFontClicked="handleSelect(1)"
></dof-iconfont>
</div>
<text class="selectText">好评</text>
</div>
<div>
<div :class="['selectItem']" ref="selectItem2" @click="handleSelect(2)">
<dof-iconfont
:code="'\u4828'"
:size="88"
:color="'rgba(255,255,255,0.80)'"
@dofIconFontClicked="handleSelect(2)"
></dof-iconfont>
</div>
<text class="selectText">差评</text>
</div>
</div>
</div>
</dof-modal>
</div>
</template>
<style scoped>
.wrapper {
background-color: #f9f9f9;
}
.m-t-16 {
margin-top: 16px;
}
.btn-box {
flex-direction: column;
align-items: center;
justify-content: center;
margin-top: 120px;
}
.contentTextBox {
display: flex;
flex-direction: row;
justify-content: center;
margin-bottom: 20px;
}
.contentText {
width: 480px;
font-family: PingFangSC-Regular;
font-size: 28px;
color: rgba(255, 255, 255, 0.6);
text-align: center;
}
.t-a-l {
text-align: left;
}
.selectText {
margin-top: 14px;
font-family: PingFangSC-Regular;
font-size: 24px;
color: #ffffff;
text-align: center;
font-weight: 400;
}
.contentTitle {
font-family: PingFangSC-Regular;
font-size: 32px;
color: rgba(255, 255, 255, 0.8);
text-align: center;
font-weight: 400;
}
.contentTip {
font-family: PingFangSC-Light;
font-size: 28px;
color: #b35336;
text-align: center;
font-weight: 200;
margin-top: 16px;
margin-bottom: 15px;
}
.selectBox {
display: flex;
flex-direction: row;
justify-content: space-between;
padding-left: 86px;
padding-right: 86px;
margin-top: 44px;
padding-bottom: 66px;
position: relative;
}
.selectItem {
width: 96px;
height: 96px;
background-color: #27272a;
display: flex;
flex-direction: row;
align-items: center;
justify-content: center;
border-radius: 48px;
}
.selectImg {
width: 60px;
height: 60px;
}
.active {
background-color: #b35336;
}
.selectText {
margin-top: 14px;
font-family: PingFangSC-Regular;
font-size: 24px;
color: #ffffff;
text-align: center;
font-weight: 400;
}
.dotBox {
position: absolute;
left: 0;
right: 0;
bottom: 24px;
display: flex;
flex-direction: row;
justify-content: center;
}
.dot {
width: 8px;
height: 8px;
border-radius: 4px;
background-color: rgba(255, 255, 255, 0.4);
margin-right: 8px;
}
.firstDot {
background-color: #b35336;
}
.lastDot {
margin-right: 0;
}
@media screen and (weex-theme: colmo) {
.wrapper {
background-color: #151617;
}
}
</style>
<script>
import { DofMinibar, DofButton, DofModal, DofIconfont } from 'dolphin-weex-ui'
const animation = weex.requireModule('animation')
export default {
components: { DofMinibar, DofButton, DofModal, DofIconfont },
data: () => ({
modal1: false,
modal2: false,
modal3: false,
modal4: false,
modal5: false,
modal6: false,
modal7: false,
modal8: false,
modal9: false,
modal10: false,
inputContent: '',
content: '小美提醒:定期收纳整理,保持地面整齐,清洁体验更佳。',
content2:
'小美提醒:定期收纳整理,保持地面整齐,清洁体验更佳。小美提醒:定期收纳整理,保持地面整齐,清洁体验更佳。小美提醒:定期收纳整理,保持地面整齐,清洁体验更佳。',
imgStyle: { marginTop: '40px', marginBottom: '40px', width: '540px', height: '332px' },
imgStyle2: { marginBottom: '40px', width: '540px', height: '332px' },
selectVal: 1
}),
watch: {
modal9(val) {
val &&
setTimeout(() => {
this.handleSelect(1)
}, 20)
},
modal10(val) {
val &&
setTimeout(() => {
this.handleSelect(1)
}, 20)
}
},
computed: {},
created() {},
mounted() {},
methods: {
handleSelect(i) {
animation.transition(this.$refs['selectItem' + i], {
styles: {
backgroundColor: '#b35336'
},
duration: 300, //ms
timingFunction: 'ease',
needLayout: true,
delay: 0 //ms
})
animation.transition(this.$refs['selectItem' + (i === 2 ? 1 : 2)], {
styles: {
backgroundColor: '#27272a'
},
duration: 300, //ms
timingFunction: 'ease',
needLayout: true,
delay: 0 //ms
})
}
}
}
</script>
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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
# Attributes
Prop | Type | Required | Default | Description |
---|---|---|---|---|
show | Boolean | N | false | 是否显示 |
single | Boolean | N | false | modal是否为一个按钮 |
title | String | N | - | 标题 |
content | String | N | - | modal的文本内容 |
cancel-text | String | N | 取消 | modal的左边按钮默认label |
confirm-text | String | N | 确定 | modal的右边按钮默认label,ps:single为true时默认显示的是右边的'确认按钮' |
has-input | Boolean | N | - | 是否有输入框 |
placeholder | String | N | - | 输入框的placeholder |
input-content | String | N | - | 输入框的绑定内容 |
btn-group | Array | N | [] | 竖向多按钮组 例:['确定','更多','取消'] |
main-btn-color | String | N | #267AFF | 单个按钮字体颜色或者右边按钮的字体颜色 |
second-btn-color | String | N | #267AFF | 两个按钮左边按钮的字体颜色或者btnGroup按钮组字体颜色 |
modal-style | Object | N | {} | modal样式自定义 |
modal-content-style | Object | N | {} | modal-content样式自定义,适用于修改内部padding等需求 |
modal-footer-border-color | String | N | #c8c7cc | 底部按钮边框颜色 |
image | String | N | - | 图片地址 |
imgStyle | Object | N | {} | 图片样式 |
isShowCloseIcon | Boolean | N | false | 是否展示右上角关闭图标 |
closeIcon | String | N | - | 右上角关闭按钮地址 |
# Events
事件名 | 说明 | 回调参数 |
---|---|---|
dofModalCancelBtnClicked | 点击左边取消按钮 | e, e.type, e.content 见注1 |
dofModalConfirmBtnClicked | 点击右边确定按钮 | e, e.type, e.content 见注1 |
btnItemClicked | 多按钮组点击事件 | e, 参数e返回列表项信息为{index, text} |
close | 模态窗关闭 | {} |
点我扫二维码 查看demo