import {
	ElMessage,
	ElMessageBox,
	ElNotification,
	ElLoading
} from 'element-plus'
import {
	Toast,
	Dialog,
} from 'vant'
import Store from '@/store'
let loadingInstance;

export default {
	// 消息提示
	msg(content) {
		if (Store.state.app.device == 'mobile') {
			Toast(content)
		} else
			ElMessage.info(content)
	},
	// 错误消息
	msgError(content) {
		if (Store.state.app.device == 'mobile') {
			Toast.fail(content)
		} else
			ElMessage.error(content)
	},
	error(content) {
		if (Store.state.app.device == 'mobile') {
			Toast.fail(content)
		} else
			ElMessage.error(content)
	},
	// 成功消息
	msgSuccess(content) {
		if (Store.state.app.device == 'mobile') {
			Toast.success(content)
		} else
			ElMessage.success(content)
	},
	success(content) {
		if (Store.state.app.device == 'mobile') {
			Toast.success(content)
		} else
			ElMessage.success(content)
	},
	// 警告消息
	msgWarning(content) {
		if (Store.state.app.device == 'mobile') {
			Toast.fail(content)
		} else
			ElMessage.warning(content)
	},
	warning(content) {
		if (Store.state.app.device == 'mobile') {
			Toast.fail(content)
		} else
			ElMessage.warning(content)
	},
	// 弹出提示
	alert(content) {
		if (Store.state.app.device == 'mobile') {
			Toast(content)
		} else
			ElMessageBox.alert(content, "系统提示")
	},
	// 错误提示
	alertError(content) {
		if (Store.state.app.device == 'mobile') {
			Toast(content)
		} else
			ElMessageBox.alert(content, "系统提示", {
				type: 'error'
			})
	},
	// 成功提示
	alertSuccess(content) {
		if (Store.state.app.device == 'mobile') {
			Toast(content)
		} else
			ElMessageBox.alert(content, "系统提示", {
				type: 'success'
			})
	},
	// 警告提示
	alertWarning(content) {
		if (Store.state.app.device == 'mobile') {
			Toast(content)
		} else
			ElMessageBox.alert(content, "系统提示", {
				type: 'warning'
			})
	},
	// 通知提示
	notify(content, title = "通知", position = "top-right") {
		if (Store.state.app.device == 'mobile') {
			Toast(content)
		} else
			ElNotification({
				title: title,
				message: content,
				position: position,
			})
		// ElNotification.info(content)
	},
	// 错误通知
	notifyError(content) {
		if (Store.state.app.device == 'mobile') {
			Toast(content)
		} else
			ElNotification.error(content);
	},
	// 成功通知
	notifySuccess(content) {
		if (Store.state.app.device == 'mobile') {
			Toast(content)
		} else
			ElNotification.success(content)
	},
	// 警告通知
	notifyWarning(content) {
		if (Store.state.app.device == 'mobile') {
			Toast(content)
		} else
			ElNotification.warning(content)
	},
	// 确认窗体
	confirm(content) {
		if (Store.state.app.device == 'mobile') {
			return Dialog.confirm({
				title: '系统提示',
				message: content,
				confirmButtonColor: Store.state.settings.theme,
			})
		} else
			return ElMessageBox.confirm(content, "系统提示", {
				confirmButtonText: '确定',
				cancelButtonText: '取消',
				type: "warning",
			})
	},
	// 提交内容
	prompt(content) {
		if (Store.state.app.device == 'mobile') {
			return Dialog.confirm({
				title: '系统提示',
				confirmButtonColor: Store.state.settings.theme,
			})
		} else
			return ElMessageBox.prompt(content, "系统提示", {
				confirmButtonText: '确定',
				cancelButtonText: '取消',
				type: "warning",
			})
	},
	// 打开遮罩层
	loading(content) {
		loadingInstance = ElLoading.service({
			lock: true,
			text: content,
			background: "rgba(0, 0, 0, 0.7)",
		})
	},
	// 关闭遮罩层
	closeLoading() {
		loadingInstance.close();
	}
}
