2025-07-22 11:21:01 +08:00
|
|
|
/**
|
|
|
|
|
* 弹出 toast
|
|
|
|
|
*
|
|
|
|
|
* @param msg
|
|
|
|
|
* @param icon
|
|
|
|
|
* @param mask
|
|
|
|
|
* @returns
|
|
|
|
|
*/
|
|
|
|
|
export const showToast = (msg, icon = 'none', mask = false) => {
|
|
|
|
|
return uni.showToast({
|
|
|
|
|
title: msg,
|
|
|
|
|
icon: icon,
|
|
|
|
|
mask
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 弹出 alert
|
|
|
|
|
* @param content
|
|
|
|
|
* @param title
|
|
|
|
|
* @returns
|
|
|
|
|
*/
|
2025-08-12 13:43:21 +08:00
|
|
|
export const showAlert = (content, title = '提示',showCancel=false,succFun) => {
|
2025-07-22 11:21:01 +08:00
|
|
|
return uni.showModal({
|
|
|
|
|
title: title,
|
|
|
|
|
content: content,
|
|
|
|
|
showCancel,
|
|
|
|
|
success: function (res) {
|
|
|
|
|
if (res.confirm) {
|
|
|
|
|
// console.log('用户点击确定');
|
|
|
|
|
succFun();
|
|
|
|
|
} else if (res.cancel) {
|
|
|
|
|
// console.log('用户点击取消');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 弹出加载动画
|
|
|
|
|
*
|
|
|
|
|
* @param text
|
|
|
|
|
* @param mask
|
|
|
|
|
* @returns
|
|
|
|
|
*/
|
|
|
|
|
export const showLoading = (text = null, mask = true) => {
|
|
|
|
|
return uni.showLoading({
|
|
|
|
|
title: text,
|
|
|
|
|
mask: mask
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 隐藏加载动画
|
|
|
|
|
*/
|
|
|
|
|
export const hideLoading = () => uni.hideLoading()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 组合式API
|
|
|
|
|
*/
|
|
|
|
|
export const useMessage = () => {
|
|
|
|
|
return {
|
|
|
|
|
toast: showToast,
|
|
|
|
|
success: (msg, mask = true) => showToast(msg, 'success', mask),
|
|
|
|
|
error: (msg, mask = true) => showToast(msg, 'error', mask),
|
|
|
|
|
alert: showAlert,
|
|
|
|
|
showLoading,
|
|
|
|
|
hideLoading
|
|
|
|
|
}
|
|
|
|
|
}
|