31 lines
648 B
TypeScript

import { BizError } from "./request";
type ToastIcon = 'success' | 'error' | 'none';
export function toast(message: string | any, icon: ToastIcon = 'none', callback: (() => void) | null = null) {
if (message instanceof BizError) {
message = message.message
}
if (callback) {
setTimeout(callback, 2000);
}
return wx.showToast({
title: message,
duration: 2000,
icon
})
}
export function showLoading({ message = '加载中...', mask = true }) {
return wx.showLoading({
title: message,
mask
})
}
export function hideLoading() {
wx.hideLoading()
}
export default {
toast,
showLoading,
hideLoading,
}