57 lines
1.3 KiB
JavaScript
57 lines
1.3 KiB
JavaScript
const showModal=function(content, successCallback = function() {}, title = '提示', showCancel = false, comfirmText = '知道了', confirmColor = '#03a9f4', hasCancel = false, cancelText = '取消', cancelColor = '#000') {
|
|
var params = {
|
|
title: title,
|
|
content: content,
|
|
showCancel: showCancel,
|
|
confirmText: comfirmText,
|
|
confirmColor: confirmColor,
|
|
success: function(res) {
|
|
if (res.confirm) {
|
|
successCallback();
|
|
}
|
|
}
|
|
}
|
|
if (hasCancel == true) {
|
|
params.cancelText = cancelText;
|
|
params.cancelColor = cancelColor;
|
|
}
|
|
wx.showModal(params);
|
|
}
|
|
|
|
/**
|
|
* 封装toast
|
|
*/
|
|
function showToast (type, text, obj) {
|
|
let param = { duration: (obj && obj.duration) || 1500, mask: (obj && obj.isMask) || false }
|
|
switch(type) {
|
|
case 'text': {
|
|
param['title'] = text || ''
|
|
param['icon'] = 'none'
|
|
break
|
|
}
|
|
case 'loading': {
|
|
param['title'] = text || ''
|
|
param['icon'] = 'loading'
|
|
break
|
|
}
|
|
case 'success': {
|
|
param['title'] = text || ''
|
|
param['icon'] = 'success'
|
|
break
|
|
}
|
|
case 'error': {
|
|
param['title'] = text || ''
|
|
param['image'] = '/images/emoji.png'
|
|
break
|
|
}
|
|
default: {
|
|
break
|
|
}
|
|
}
|
|
wx.showToast(param)
|
|
}
|
|
|
|
module.exports={
|
|
showModal,
|
|
showToast
|
|
} |