2025-03-20 08:46:07 +08:00
|
|
|
"use strict";
|
|
|
|
|
const common_vendor = require("../common/vendor.js");
|
2025-05-07 09:54:33 +08:00
|
|
|
function formatDate(date) {
|
|
|
|
|
if (!date) {
|
|
|
|
|
return "";
|
|
|
|
|
}
|
|
|
|
|
return common_vendor.dayjs(date).format("YYYY-MM-DD HH:mm:ss");
|
|
|
|
|
}
|
|
|
|
|
function formatDate1(date) {
|
|
|
|
|
if (!date) {
|
|
|
|
|
return "";
|
|
|
|
|
}
|
|
|
|
|
common_vendor.dayjs(date).format("HH:mm:ss");
|
|
|
|
|
return common_vendor.dayjs(date).format("HH:mm:ss");
|
|
|
|
|
}
|
2025-03-20 08:46:07 +08:00
|
|
|
function copyData(val) {
|
|
|
|
|
common_vendor.index.setClipboardData({
|
|
|
|
|
data: val
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
function assembleAddress(addressObj) {
|
|
|
|
|
const resutlObj = {};
|
|
|
|
|
if (!addressObj || Object.keys(addressObj).length === 0) {
|
|
|
|
|
return resutlObj;
|
|
|
|
|
}
|
|
|
|
|
const ids = [];
|
|
|
|
|
if (addressObj.countryId) {
|
|
|
|
|
ids.push(addressObj.countryId);
|
|
|
|
|
}
|
|
|
|
|
if (addressObj.provinceId) {
|
|
|
|
|
ids.push(addressObj.provinceId);
|
|
|
|
|
}
|
|
|
|
|
if (addressObj.cityId) {
|
|
|
|
|
ids.push(addressObj.cityId);
|
|
|
|
|
}
|
|
|
|
|
if (addressObj.areaId) {
|
|
|
|
|
ids.push(addressObj.areaId);
|
|
|
|
|
}
|
|
|
|
|
const names = [];
|
|
|
|
|
if (addressObj.countryName) {
|
|
|
|
|
names.push(addressObj.countryName);
|
|
|
|
|
}
|
|
|
|
|
if (addressObj.provinceName) {
|
|
|
|
|
names.push(addressObj.provinceName);
|
|
|
|
|
}
|
|
|
|
|
if (addressObj.cityName) {
|
|
|
|
|
names.push(addressObj.cityName);
|
|
|
|
|
}
|
|
|
|
|
if (addressObj.areaName) {
|
|
|
|
|
names.push(addressObj.areaName);
|
|
|
|
|
}
|
|
|
|
|
resutlObj.ids = ids.join(",");
|
|
|
|
|
resutlObj.names = names.join(" ");
|
|
|
|
|
return resutlObj;
|
|
|
|
|
}
|
2025-05-07 09:54:33 +08:00
|
|
|
function handleAmount(amount) {
|
|
|
|
|
let currentAmount = parseFloat(amount) || 0;
|
|
|
|
|
if (amount && amount > 0) {
|
|
|
|
|
currentAmount = "+" + currentAmount;
|
|
|
|
|
}
|
|
|
|
|
return currentAmount;
|
|
|
|
|
}
|
|
|
|
|
function getBankNumber(number) {
|
|
|
|
|
let currentAmount = number || "";
|
|
|
|
|
if (number && number.length > 4) {
|
|
|
|
|
currentAmount = currentAmount.slice(-4);
|
|
|
|
|
}
|
|
|
|
|
return currentAmount;
|
|
|
|
|
}
|
|
|
|
|
function encipherBankNumber(cardNumber) {
|
|
|
|
|
if (cardNumber.length <= 8) {
|
|
|
|
|
return cardNumber;
|
|
|
|
|
}
|
|
|
|
|
const firstFour = cardNumber.slice(0, 4);
|
|
|
|
|
const lastFour = cardNumber.slice(-4);
|
|
|
|
|
const mask = "****";
|
|
|
|
|
const maskedCard = firstFour + " " + mask + " " + lastFour;
|
|
|
|
|
return maskedCard;
|
|
|
|
|
}
|
|
|
|
|
function comparisonVersionHandler(reqV, curV) {
|
|
|
|
|
if (curV && reqV) {
|
|
|
|
|
curV = String(curV);
|
|
|
|
|
reqV = String(reqV);
|
|
|
|
|
let arr1 = curV.split("."), arr2 = reqV.split(".");
|
|
|
|
|
let minLength = Math.min(arr1.length, arr2.length), position = 0, diff = 0;
|
|
|
|
|
while (position < minLength && (diff = parseInt(arr1[position]) - parseInt(arr2[position])) == 0) {
|
|
|
|
|
position++;
|
|
|
|
|
}
|
|
|
|
|
diff = diff != 0 ? diff : arr1.length - arr2.length;
|
|
|
|
|
return diff > 0;
|
|
|
|
|
} else {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-03-20 08:46:07 +08:00
|
|
|
exports.assembleAddress = assembleAddress;
|
2025-05-07 09:54:33 +08:00
|
|
|
exports.comparisonVersionHandler = comparisonVersionHandler;
|
2025-03-20 08:46:07 +08:00
|
|
|
exports.copyData = copyData;
|
2025-05-07 09:54:33 +08:00
|
|
|
exports.encipherBankNumber = encipherBankNumber;
|
|
|
|
|
exports.formatDate = formatDate;
|
|
|
|
|
exports.formatDate1 = formatDate1;
|
|
|
|
|
exports.getBankNumber = getBankNumber;
|
|
|
|
|
exports.handleAmount = handleAmount;
|
2025-03-20 08:46:07 +08:00
|
|
|
//# sourceMappingURL=../../.sourcemap/mp-weixin/utils/index.js.map
|