modal.js
1.93 KB
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
export default {
// 消息提示
msg(content) {
uni.showToast({
title: content,
icon: 'none'
})
},
// 错误消息
msgError(content) {
uni.showToast({
title: content,
icon: 'error'
})
},
// 成功消息
msgSuccess(content) {
uni.showToast({
title: content,
icon: 'success'
})
},
// 隐藏消息
hideMsg(content) {
uni.hideToast()
},
// 弹出提示
alert(content, title) {
uni.showModal({
title: title || '系统提示',
content: content,
showCancel: false
})
},
// 确认窗体
confirm(content, title, option = {
confirmText: "确认",
cancelText: "取消",
delCancel: false
}) {
return new Promise((resolve, reject) => {
// #ifdef APP
Vue.prototype.$showModal({
title: title || '系统提示',
concent: content,
cancelVal: option.cancelText,
confirmVal: option.confirmText,
delCancel: option.delCancel,
}).then(res => {
console.log(res);
// uni.hideLoading()
//确认
resolve(res)
}).catch(res => {
//取消
reject()
console.log(res);
})
// #endif
// #ifndef APP
uni.showModal({
title: title || '系统提示',
content: content,
cancelText: option.cancelText,
confirmText: option.confirmText,
showCancel: option.showCancel,
confirmColor: "#EA5504",
success: function(res) {
if (res.confirm) {
resolve(res.confirm)
}
if (res.cancel) {
reject()
}
}
})
// #endif
})
},
// 提示信息
showToast(option) {
if (typeof option === "object") {
uni.showToast(option)
} else {
uni.showToast({
title: option,
icon: "none",
duration: 2500
})
}
},
// 打开遮罩层
loading(content) {
uni.showLoading({
title: content,
icon: 'none'
})
},
showLoading(content) {
uni.showLoading({
title: content,
icon: 'loading'
})
},
// 关闭遮罩层
closeLoading() {
uni.hideLoading()
}
}