80 lines
1.2 KiB
JavaScript
80 lines
1.2 KiB
JavaScript
|
export default {
|
||
|
// 消息提示
|
||
|
msg(text) {
|
||
|
uni.showToast({
|
||
|
title: text,
|
||
|
icon: 'none',
|
||
|
duration: 3000
|
||
|
})
|
||
|
},
|
||
|
// 错误消息
|
||
|
msgError(text) {
|
||
|
uni.showToast({
|
||
|
title: text,
|
||
|
icon: 'none',
|
||
|
duration: 3000
|
||
|
})
|
||
|
},
|
||
|
// 成功消息
|
||
|
msgSuccess(text) {
|
||
|
uni.showToast({
|
||
|
title: text,
|
||
|
icon: 'none',
|
||
|
duration: 3000
|
||
|
})
|
||
|
},
|
||
|
// 隐藏消息
|
||
|
hideMsg(text) {
|
||
|
uni.hideToast()
|
||
|
},
|
||
|
// 弹出提示
|
||
|
alert(text) {
|
||
|
uni.showModal({
|
||
|
title: '提示',
|
||
|
content: text,
|
||
|
showCancel: false
|
||
|
})
|
||
|
},
|
||
|
// 确认窗体
|
||
|
confirm(text) {
|
||
|
return new Promise((resolve, reject) => {
|
||
|
uni.showModal({
|
||
|
title: '系统提示',
|
||
|
content: text,
|
||
|
cancelText: '取消',
|
||
|
confirmText: '确定',
|
||
|
success: function(res) {
|
||
|
if (res.confirm) {
|
||
|
resolve(res.confirm)
|
||
|
}
|
||
|
if(res.cancel){
|
||
|
reject(res.cancel);
|
||
|
}
|
||
|
}
|
||
|
})
|
||
|
})
|
||
|
},
|
||
|
// 提示信息
|
||
|
showToast(option) {
|
||
|
if (typeof option === "object") {
|
||
|
uni.showToast(option)
|
||
|
} else {
|
||
|
uni.showToast({
|
||
|
title: option,
|
||
|
icon: "none",
|
||
|
duration: 2500
|
||
|
})
|
||
|
}
|
||
|
},
|
||
|
// 打开遮罩层
|
||
|
loading(text) {
|
||
|
uni.showLoading({
|
||
|
title: text,
|
||
|
icon: 'none'
|
||
|
})
|
||
|
},
|
||
|
// 关闭遮罩层
|
||
|
closeLoading() {
|
||
|
uni.hideLoading()
|
||
|
}
|
||
|
}
|