吉祥物缓存,替换安卓弹窗
This commit is contained in:
+34
-15
@@ -1,3 +1,4 @@
|
||||
import showDialog from '@/common/dialogMessage'
|
||||
|
||||
function msg(title, duration = 1000) {
|
||||
uni.showToast({
|
||||
@@ -9,21 +10,39 @@ function msg(title, duration = 1000) {
|
||||
}
|
||||
|
||||
function show(title, msg, showCancel = true, cancelText = '取消', confirmText = '确定') {
|
||||
return new Promise((resolve, reject) => {
|
||||
uni.showModal({
|
||||
title: title,
|
||||
content: msg,
|
||||
showCancel: showCancel,
|
||||
cancelText: cancelText,
|
||||
confirmText: confirmText,
|
||||
success: function(res) {
|
||||
resolve(res.confirm)
|
||||
},
|
||||
fail: function(res) {
|
||||
reject(res)
|
||||
},
|
||||
});
|
||||
})
|
||||
return new Promise((resolve, reject) => {
|
||||
// 创建通用参数对象
|
||||
const dialogOptions = {
|
||||
title,
|
||||
content: msg,
|
||||
showCancel,
|
||||
cancelText,
|
||||
confirmText,
|
||||
success: (res) => {
|
||||
// 统一处理成功回调,解析为布尔值
|
||||
resolve(!!res.confirm);
|
||||
}
|
||||
};
|
||||
|
||||
if (getPhoneEnvBool('AND')) {
|
||||
// 安卓环境使用showDialog,补充cancel回调
|
||||
showDialog({
|
||||
...dialogOptions,
|
||||
cancel: () => {
|
||||
console.log('用户点击取消');
|
||||
resolve(false); // 取消时也返回Promise结果
|
||||
}
|
||||
});
|
||||
} else {
|
||||
// 其他环境使用uni.showModal,补充fail回调
|
||||
uni.showModal({
|
||||
...dialogOptions,
|
||||
fail: (res) => {
|
||||
reject(res);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
const loading = (title = '加载中', mask = true) => uni.showLoading({
|
||||
|
||||
Reference in New Issue
Block a user