| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122 |
- let dialog = {};
- dialog.config = {
- cancelColor: '#888',
- confirmColor: '#3CC51F',
- title: '系统提示'
- }
- dialog.toast = (title, callfun = null, duration = 1000, mask = true, image = '', icon = 'none') => {
- uni.showToast({
- title: title,
- icon: icon,
- image: image,
- mask: mask,
- duration: duration
- });
- if (typeof(callfun) == 'function') {
- setTimeout(() => {
- callfun()
- }, duration)
- }
- };
- dialog.success = (title, callfun = null, duration = 1000) => {
- dialog.toast(title, callfun, duration, true, '/static/dialog/dialog_success.png')
- };
- dialog.error = (title, callfun = null, duration = 1000) => {
- dialog.toast(title, callfun, duration, true, '/static/dialog/dialog_fail.png')
- };
- dialog.warn = (title, callfun = null, duration = 1000) => {
- dialog.toast(title, callfun, duration, true, '/static/dialog/dialog_warn.png')
- };
- dialog.showLoading = (title = '加载中..', mask = true) => {
- uni.showLoading({
- title: title,
- mask: mask
- });
- };
- dialog.hideLoading = () => {
- uni.hideLoading();
- };
- ///弹出框
- dialog.alert = (opt) => {
- let def = {
- title: dialog.config.title,
- content: '',
- showCancel: false,
- cancelText: '取消',
- cancelColor: dialog.config.cancelColor,
- confirmText: '我知道了',
- confirmColor: dialog.config.confirmColor,
- }
- uni.showModal(Object.assign(def, opt));
- };
- ///确认对话框
- dialog.confirm = (opt) => {
- let def = {
- title: dialog.config.title,
- content: '',
- showCancel: true,
- cancelText: '取消',
- cancelColor: dialog.config.cancelColor,
- confirmText: '确定',
- confirmColor: dialog.config.confirmColor,
- }
- uni.showModal(Object.assign(def, opt));
- };
- //显示操作菜单
- dialog.actionSheet = (opt) => {
- let def = {
- itemColor: "#000000"
- }
- uni.showActionSheet(Object.assign(def, opt));
- };
- /**
- * 封装模态框
- */
- dialog.showModal = (content, showCancel = true, confirmColor) => {
- return new Promise((resolve, reject) => {
- uni.showModal({
- title: '提示',
- content,
- showCancel,
- confirmColor: confirmColor ? confirmColor : '#2979ff',
- success: (res) => {
- if (res.confirm) {
- resolve(res)
- }
- }
- });
- })
- }
- dialog.showModalAndBack = (content, confirmColor) => {
- uni.showModal({
- title: "提示",
- content: content,
- showCancel: false,
- confirmColor: confirmColor ? confirmColor : '#2979ff',
- success: (res) => {
- if (res.confirm) {
- uni.navigateBack({
- delta: 1
- })
- }
- }
- });
- }
- export default dialog;
|