//常用对话框
export const success = (title : string, duration = 1500, mask = false) => {
	return toast(title, duration, mask, 'success');
}

export const toast = function (title : string, duration : number, mask : boolean, icon : any) {
	return new Promise((resolve, reject) => {
		uni.showToast({
			title, duration, mask, icon,
			success: res => {
				setTimeout(function () {
					resolve(res);
				}, duration);
			},
			fail: err => {
				reject(err)
			}
		});

	});
}



//获取 错误提示
export const error = (title : string, duration = 1500, mask = false) => {
	return toast(title, duration, mask, 'error');
}



//顶部信息
export const tip = (title : string) => {
	uni.showToast({
		title,
		position: 'top',
		duration: 1500,
		mask: false,
		icon: 'none'
	});
}

export default {
	success, toast, error, tip,
}