28 lines
551 B
TypeScript
28 lines
551 B
TypeScript
import { BizError } from "./request";
|
|
|
|
type ToastIcon = 'success' | 'error' | 'none';
|
|
export function toast(message: string|any, icon: ToastIcon = 'none') {
|
|
if(message instanceof BizError){
|
|
message = message.message
|
|
}
|
|
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,
|
|
} |