2025-04-14 10:57:27 +08:00

65 lines
1.7 KiB
JavaScript

"use strict";
const common_vendor = require("../common/vendor.js");
const showModelMessage = (content, title, showCancel, confirmText = "确定") => {
if (title == null || title == "")
title = "提示";
if (showCancel == null)
showCancel = false;
return new Promise((resolve, reject) => {
common_vendor.index.showModal({
title,
content,
showCancel,
confirmText,
success: function(res) {
resolve(res);
}
});
});
};
function dataFormat(date, fmt) {
var o = {
"M+": date.getMonth() + 1,
//月份
"d+": date.getDate(),
//日
"H+": date.getHours(),
//小时
"m+": date.getMinutes(),
//分
"s+": date.getSeconds(),
//秒
"q+": Math.floor((date.getMonth() + 3) / 3),
//季度
"S": date.getMilliseconds()
//毫秒
};
if (/(y+)/.test(fmt))
fmt = fmt.replace(RegExp.$1, (date.getFullYear() + "").substr(4 - RegExp.$1.length));
for (var k in o) {
if (new RegExp("(" + k + ")").test(fmt))
fmt = fmt.replace(RegExp.$1, RegExp.$1.length === 1 ? o[k] : ("00" + o[k]).substr(("" + o[k]).length));
}
return fmt;
}
function getUrlParams(url) {
const paramsRegex = /[?&]+([^=&]+)=([^&]*)/gi;
const params = {};
let match;
while (match = paramsRegex.exec(url)) {
params[match[1]] = match[2];
}
return params;
}
function isNullOrEmpty(value) {
if (typeof value == "undefined" || value == null || value == "")
return true;
else
return false;
}
exports.dataFormat = dataFormat;
exports.getUrlParams = getUrlParams;
exports.isNullOrEmpty = isNullOrEmpty;
exports.showModelMessage = showModelMessage;
//# sourceMappingURL=../../.sourcemap/mp-weixin/utils/tools.js.map