-
Notifications
You must be signed in to change notification settings - Fork 1
/
modal.vue
93 lines (90 loc) · 3.31 KB
/
modal.vue
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
<template>
<div class="wrapper">
<mpwx-btn class="btn" label="toast" id="0" @onBtnClicked="onClicked"></mpwx-btn>
<mpwx-btn class="btn" label="alert" id="1" @onBtnClicked="onClicked"></mpwx-btn>
<mpwx-btn class="btn" label="confirm" id="2" @onBtnClicked="onClicked"></mpwx-btn>
<mpwx-btn class="btn" label="prompt" id="3" @onBtnClicked="onClicked"></mpwx-btn>
<mpwx-btn class="btn" label="progress" id="4" @onBtnClicked="onClicked"></mpwx-btn>
</div>
</template>
<script>
import MpwxBtn from "../mpwx-btn"
var modal = weex.requireModule('modal');
export default {
components: {MpwxBtn},
methods: {
onClicked(event) {
const {id} = event;
switch (id) {
case "0":
modal.toast({
message: "toast test",
gravity: "center",
duration: 1
});
break;
case "1":
modal.alert({
// title: "title",
message: 'This is a alert',
okTitle: 'ok label'
}, function (value) {
modal.toast({
message: `${value} clicked`
});
});
break;
case "2":
modal.confirm({
title: "title",
message: 'Do you confirm?',
okTitle: 'ok label',
cancelTitle: 'cancel label'
}, function (value) {
modal.toast({
message: `${value} clicked`
});
});
break;
case "3":
modal.prompt({
title: "title",
message: 'This is a prompt',
// default: 'default text',
hint: 'hint text',
okTitle: 'ok label',
cancelTitle: 'cancel label'
}, function (res) {
modal.toast({
message: `${res.result} : ${res.data}`
});
});
break;
case "4":
modal.progress({
// cancelable: false,
message: '正在加载...'
}, function (value) {
modal.toast({
message: `${value}`
});
});
setTimeout(function () {
modal.dismiss();
}, 2000);
break;
}
}
}
}
</script>
<style scoped>
.wrapper {
flex: 1;
padding: 40px;
}
.btn {
margin-bottom: 12px;
margin-top: 12px;
}
</style>