forked from youzan/vant-weapp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
45 lines (38 loc) · 921 Bytes
/
index.js
File metadata and controls
45 lines (38 loc) · 921 Bytes
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
import Page from '../../common/page';
import Toast from '../../dist/toast/toast';
Page({
showToast() {
Toast('提示内容');
},
showLongToast() {
Toast('这是一条长文字提示,超过一定字数就会换行');
},
showLoadingToast() {
Toast.loading({ mask: true, message: '加载中...' });
},
showSuccessToast() {
Toast.success('成功文案');
},
showFailToast() {
Toast.fail('失败提示');
},
showCustomizedToast(duration) {
const text = second => `倒计时 ${second} 秒`;
const toast = Toast.loading({
duration: 0,
forbidClick: true,
loadingType: 'spinner',
message: text(3)
});
let second = 3;
const timer = setInterval(() => {
second--;
if (second) {
toast.setData({ message: text(second) });
} else {
clearInterval(timer);
Toast.clear();
}
}, 1000);
}
});