/**
 * title：显示内容；mask：是否显示遮罩层
 */

/**
 * 成功
 */
function success (title, mask = false) {
	return new Promise((resolve, reject) => {
		uni.showToast({
			icon: 'success',
			title,
			mask,
			success: (e) => {
				resolve(e)
			},
			fail: (err) => {
				reject(err)
			}
		})
	})
}

function error (title, mask = false) {
	return new Promise((resolve, reject) => {
		uni.showToast({
			icon: 'error',
			title,
			mask,
			success: (e) => {
				resolve(e)
			},
			fail: (err) => {
				reject(err)
			}
		})
	})
}

function fail (title, mask = false) {
	return new Promise((resolve, reject) => {
		uni.showToast({
			icon: 'fail',
			title,
			mask,
			success: (e) => {
				resolve(e)
			},
			fail: (err) => {
				reject(err)
			}
		})
	})
}

function exception (title, mask = false) {
	return new Promise((resolve, reject) => {
		uni.showToast({
			icon: 'exception',
			title,
			mask,
			success: (e) => {
				resolve(e)
			},
			fail: (err) => {
				reject(err)
			}
		})
	})
}

function loading (title, mask = false) {
	return new Promise((resolve, reject) => {
		uni.showToast({
			icon: 'loading',
			title,
			mask,
			success: (e) => {
				resolve(e)
			},
			fail: (err) => {
				reject(err)
			}
		})
	})
}

function none (title, mask = false) {
	return new Promise((resolve, reject) => {
		uni.showToast({
			icon: 'none',
			title,
			mask,
			success: (e) => {
				resolve(e)
			},
			fail: (err) => {
				reject(err)
			}
		})
	})
}

export default {
	success,
	fail,
	exception,
	loading,
	none
}
