You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
49 lines
1.3 KiB
49 lines
1.3 KiB
export default {
|
|
confirm: function (content, confirm, cancel, cancelText = '取消', title = '提示') {
|
|
uni.showModal({
|
|
title: '提示',
|
|
content: content || '这是一个模态弹窗',
|
|
success: function (res) {
|
|
if (res.confirm) {
|
|
confirm()
|
|
|
|
} else if (res.cancel) {
|
|
cancel && cancel()
|
|
}
|
|
}
|
|
});
|
|
},
|
|
/**
|
|
* 不带图标的 toast
|
|
* @param title
|
|
* @param position {'center' | 'bottom'}
|
|
* @param duration 默认 1.5 秒
|
|
*/
|
|
toast(title, position = 'center', duration = 1500) {
|
|
uni.showToast({
|
|
title,
|
|
icon: 'none',
|
|
position,
|
|
duration
|
|
});
|
|
},
|
|
error(text) {
|
|
this.toast(text || '发生了一些问题');
|
|
},
|
|
// 模态框 提示,只有确定 没有取消
|
|
alert(text) {
|
|
uni.showModal({
|
|
title: '提示',
|
|
content: text,
|
|
cancelText: '重新选择',
|
|
showCancel: false,
|
|
success: function (res) {
|
|
if (res.confirm) {
|
|
|
|
} else if (res.cancel) {
|
|
console.log('用户点击取消');
|
|
}
|
|
}
|
|
});
|
|
}
|
|
}
|
|
|