来源仓库:jxc/ai-fresh-delivery 来源提交:f0b1a180e2deb7e4673b9d1c8542619f7bc0f73d 快照树: 09f679334ff38f0ff25e907961c94a8223bcaedd(与来源 HEAD 工作树逐字节一致,3801 个文件) 按约定本仓库不带任何历史提交:来源仓库的历史中含真实凭据 (生产 SSH 私钥 deploy/id_rsa_tencent、server/.env、.env.tencent/.env.production/.env.gitea、 deploy/小程序AppSecret.txt,其中 MP_APPSECRET / S3 AccessKey 经哈希比对与线上同值), 整包推送会把这些凭据永久带入本仓库,故只取「当前版本」的单提交快照。 供应商系统后续开发自本提交开始。
93 lines
2.8 KiB
JavaScript
93 lines
2.8 KiB
JavaScript
"use strict";
|
|
var __assign = (this && this.__assign) || function () {
|
|
__assign = Object.assign || function(t) {
|
|
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
s = arguments[i];
|
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
t[p] = s[p];
|
|
}
|
|
return t;
|
|
};
|
|
return __assign.apply(this, arguments);
|
|
};
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
var queue = [];
|
|
var defaultOptions = {
|
|
show: false,
|
|
title: '',
|
|
width: null,
|
|
theme: 'default',
|
|
message: '',
|
|
zIndex: 100,
|
|
overlay: true,
|
|
selector: '#van-dialog',
|
|
className: '',
|
|
asyncClose: false,
|
|
beforeClose: null,
|
|
transition: 'scale',
|
|
customStyle: '',
|
|
messageAlign: '',
|
|
overlayStyle: '',
|
|
confirmButtonText: '确认',
|
|
cancelButtonText: '取消',
|
|
showConfirmButton: true,
|
|
showCancelButton: false,
|
|
closeOnClickOverlay: false,
|
|
confirmButtonOpenType: '',
|
|
};
|
|
var currentOptions = __assign({}, defaultOptions);
|
|
function getContext() {
|
|
var pages = getCurrentPages();
|
|
return pages[pages.length - 1];
|
|
}
|
|
var Dialog = function (options) {
|
|
options = __assign(__assign({}, currentOptions), options);
|
|
return new Promise(function (resolve, reject) {
|
|
var context = (typeof options.context === 'function'
|
|
? options.context()
|
|
: options.context) || getContext();
|
|
var dialog = context.selectComponent(options.selector);
|
|
delete options.context;
|
|
delete options.selector;
|
|
if (dialog) {
|
|
dialog.setData(__assign({ callback: function (action, instance) {
|
|
action === 'confirm' ? resolve(instance) : reject(instance);
|
|
} }, options));
|
|
wx.nextTick(function () {
|
|
dialog.setData({ show: true });
|
|
});
|
|
queue.push(dialog);
|
|
}
|
|
else {
|
|
console.warn('未找到 van-dialog 节点,请确认 selector 及 context 是否正确');
|
|
}
|
|
});
|
|
};
|
|
Dialog.alert = function (options) { return Dialog(options); };
|
|
Dialog.confirm = function (options) {
|
|
return Dialog(__assign({ showCancelButton: true }, options));
|
|
};
|
|
Dialog.close = function () {
|
|
queue.forEach(function (dialog) {
|
|
dialog.close();
|
|
});
|
|
queue = [];
|
|
};
|
|
Dialog.stopLoading = function () {
|
|
queue.forEach(function (dialog) {
|
|
dialog.stopLoading();
|
|
});
|
|
};
|
|
Dialog.currentOptions = currentOptions;
|
|
Dialog.defaultOptions = defaultOptions;
|
|
Dialog.setDefaultOptions = function (options) {
|
|
currentOptions = __assign(__assign({}, currentOptions), options);
|
|
Dialog.currentOptions = currentOptions;
|
|
};
|
|
Dialog.resetDefaultOptions = function () {
|
|
currentOptions = __assign({}, defaultOptions);
|
|
Dialog.currentOptions = currentOptions;
|
|
};
|
|
Dialog.resetDefaultOptions();
|
|
exports.default = Dialog;
|