2023-08-12 15:44:27 +00:00
|
|
|
|
export default {
|
2023-08-28 14:43:06 +00:00
|
|
|
|
/**
|
|
|
|
|
|
* 消息提示
|
|
|
|
|
|
* @param content 消息内容
|
|
|
|
|
|
*/
|
|
|
|
|
|
msg(content: string): void {
|
2023-08-12 15:44:27 +00:00
|
|
|
|
uni.showToast({
|
|
|
|
|
|
title: content,
|
|
|
|
|
|
icon: 'none'
|
|
|
|
|
|
})
|
|
|
|
|
|
},
|
2023-08-28 14:43:06 +00:00
|
|
|
|
/**
|
|
|
|
|
|
* 错误消息
|
|
|
|
|
|
* @param content 消息内容
|
|
|
|
|
|
*/
|
|
|
|
|
|
msgError(content: string): void {
|
2023-08-12 15:44:27 +00:00
|
|
|
|
uni.showToast({
|
|
|
|
|
|
title: content,
|
|
|
|
|
|
icon: 'error'
|
|
|
|
|
|
})
|
|
|
|
|
|
},
|
2023-08-28 14:43:06 +00:00
|
|
|
|
/**
|
|
|
|
|
|
* 成功消息
|
|
|
|
|
|
* @param content 消息内容
|
|
|
|
|
|
*/
|
|
|
|
|
|
msgSuccess(content: string): void {
|
2023-08-12 15:44:27 +00:00
|
|
|
|
uni.showToast({
|
|
|
|
|
|
title: content,
|
|
|
|
|
|
icon: 'success'
|
|
|
|
|
|
})
|
|
|
|
|
|
},
|
2023-08-28 14:43:06 +00:00
|
|
|
|
/**
|
|
|
|
|
|
* 隐藏消息
|
|
|
|
|
|
*/
|
|
|
|
|
|
hideMsg(): void {
|
2023-08-12 15:44:27 +00:00
|
|
|
|
uni.hideToast()
|
|
|
|
|
|
},
|
2023-08-28 14:43:06 +00:00
|
|
|
|
/**
|
|
|
|
|
|
* 弹出提示
|
|
|
|
|
|
* @param content 提示内容
|
|
|
|
|
|
*/
|
|
|
|
|
|
alert(content: string): void {
|
2023-08-12 15:44:27 +00:00
|
|
|
|
uni.showModal({
|
|
|
|
|
|
title: '提示',
|
|
|
|
|
|
content: content,
|
|
|
|
|
|
showCancel: false
|
|
|
|
|
|
})
|
|
|
|
|
|
},
|
2023-08-28 14:43:06 +00:00
|
|
|
|
/**
|
|
|
|
|
|
* 确认窗体
|
|
|
|
|
|
* @param content 提示内容
|
|
|
|
|
|
* @returns
|
|
|
|
|
|
*/
|
|
|
|
|
|
confirm(content: string): Promise<unknown> {
|
|
|
|
|
|
return new Promise((resolve: Function, reject: Function) => {
|
2023-08-12 15:44:27 +00:00
|
|
|
|
uni.showModal({
|
|
|
|
|
|
title: '系统提示',
|
|
|
|
|
|
content: content,
|
|
|
|
|
|
cancelText: '取消',
|
|
|
|
|
|
confirmText: '确定',
|
2023-08-28 14:43:06 +00:00
|
|
|
|
success: function (res) {
|
2023-08-12 15:44:27 +00:00
|
|
|
|
if (res.confirm) {
|
|
|
|
|
|
resolve(res.confirm)
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
})
|
|
|
|
|
|
},
|
2023-08-28 14:43:06 +00:00
|
|
|
|
/**
|
|
|
|
|
|
* 提示信息
|
|
|
|
|
|
* @param option 提示内容或者提示框配置
|
|
|
|
|
|
*/
|
|
|
|
|
|
showToast(option: string | object): void {
|
2023-08-12 15:44:27 +00:00
|
|
|
|
if (typeof option === "object") {
|
|
|
|
|
|
uni.showToast(option)
|
|
|
|
|
|
} else {
|
|
|
|
|
|
uni.showToast({
|
|
|
|
|
|
title: option,
|
|
|
|
|
|
icon: "none",
|
|
|
|
|
|
duration: 2500
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
2023-08-28 14:43:06 +00:00
|
|
|
|
/**
|
|
|
|
|
|
* 打开遮罩层,需要手动关闭遮罩层
|
|
|
|
|
|
* @param content 遮罩层内容
|
|
|
|
|
|
*/
|
|
|
|
|
|
loading(content: string): void {
|
2023-08-12 15:44:27 +00:00
|
|
|
|
uni.showLoading({
|
2023-08-27 10:16:10 +00:00
|
|
|
|
title: content
|
2023-08-12 15:44:27 +00:00
|
|
|
|
})
|
|
|
|
|
|
},
|
2023-08-28 14:43:06 +00:00
|
|
|
|
/**
|
|
|
|
|
|
* 关闭遮罩层
|
|
|
|
|
|
*/
|
|
|
|
|
|
closeLoading(): void {
|
2023-08-12 15:44:27 +00:00
|
|
|
|
uni.hideLoading()
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|