import dialog from "./dialog"

const jxMOdal = {
	/**
	 * 弹出提示
	 */
	alert(options: any) {
		let platform = uni.getSystemInfoSync().platform
		if (platform == 'android') {
			dialog.alert({
				content: options.content,
				title: options.title,
				confirmText: options.confirmText || '确定',
				isReturn: options.isReturn || 0
			}, options.success)
		} else {
			uni.showModal({
				title: options.title,
				content: options.content,
				confirmText: options.confirmText || '确定',
				showCancel: false,
				confirmColor: "#51b535",
				success: options.success
			})
		}
	},

	/**
	 * 确认提示框
	 */
	confirm(options: any) {
		let platform = uni.getSystemInfoSync().platform
		if (platform == 'android') {
			dialog.confirm({
				content: options.content,
				title: options.title,
				confirmText: options.confirmText || '确定',
				cancelText: options.cancelText || '取消',
				isReturn: options.isReturn || 0,
			}, options.success, options.fail)
		} else {
			uni.showModal({
				content: options.content,
				title: options.title,
				confirmText: options.confirmText || '确定',
				cancelText: options.cancelText || '取消',
				confirmColor: "#51b535",
				success: (e) => {
					if (e.confirm) {
						options.success && options.success()
					} else if (e.cancel) {
						options.fail && options.fail()
					}
				},
				fail: (e) => {
					console.log(e, '自定义弹窗发生错误')
				}
			})
		}

	}
}

export default jxMOdal