2024-02-22 19:28:16 +08:00
|
|
|
/**
|
|
|
|
* 结算 埋点方法
|
|
|
|
* @param {string} key
|
|
|
|
* @param {number} settlementType
|
|
|
|
*/
|
|
|
|
const settlementFun = (token, settlementType) => {
|
2024-02-25 17:58:32 +08:00
|
|
|
let obj_yz_data = JSON.parse(sessionStorage.getItem("bm_auth"));
|
2024-02-28 14:13:05 +08:00
|
|
|
if (obj_yz_data && obj_yz_data.settlement_data.is_settlement) {
|
2024-02-25 17:58:32 +08:00
|
|
|
return;
|
|
|
|
}
|
2024-02-22 19:28:16 +08:00
|
|
|
let params = {
|
|
|
|
token,
|
|
|
|
type: settlementType
|
|
|
|
};
|
|
|
|
req.axiosPost("/key/settlement/create", params).then((res) => {
|
|
|
|
if (res.code === 200) {
|
|
|
|
// 接口请求成功后,就不能再请求接口了
|
|
|
|
let obj_sy = JSON.parse(sessionStorage.getItem("bm_auth"));
|
|
|
|
obj_sy.settlement_data.is_settlement = true;
|
|
|
|
sessionStorage.setItem("bm_auth", JSON.stringify(obj_sy));
|
|
|
|
}
|
|
|
|
});
|
|
|
|
};
|
2024-02-27 17:46:13 +08:00
|
|
|
|
|
|
|
// 兼容IOS 返回
|
|
|
|
const locationReplace = (url) => {
|
2024-05-06 17:38:59 +08:00
|
|
|
if (history && history.replaceState) {
|
2024-02-27 17:46:13 +08:00
|
|
|
history.replaceState(null, document.title, url);
|
|
|
|
history.go(0);
|
|
|
|
} else {
|
|
|
|
location.replace(url);
|
|
|
|
}
|
|
|
|
};
|
2024-03-14 09:57:00 +08:00
|
|
|
|
|
|
|
// 获取url参数
|
|
|
|
const getQueryString = (name) => {
|
|
|
|
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
|
|
|
|
var r = window.location.search.substr(1).match(reg);
|
|
|
|
if (r != null) return unescape(r[2]);
|
|
|
|
return null;
|
|
|
|
};
|
2024-03-25 18:54:04 +08:00
|
|
|
|
|
|
|
/** 倒计时函数
|
|
|
|
* @param {*} timestamp
|
|
|
|
* @returns
|
|
|
|
*/
|
|
|
|
const pageOutTime = (timestamp) => {
|
2024-03-25 19:57:57 +08:00
|
|
|
if (timestamp || timestamp === "0") {
|
2024-03-25 18:54:04 +08:00
|
|
|
const now = new Date().getTime(); // 获取当前时间的时间戳
|
|
|
|
let diff = Number(timestamp) - now; // 计算差异(以毫秒为单位)
|
|
|
|
|
|
|
|
// 判断还剩多久
|
|
|
|
if (diff <= 0) {
|
2024-03-25 19:39:10 +08:00
|
|
|
window.location.replace("/outtime.html");
|
2024-03-25 18:54:04 +08:00
|
|
|
return false;
|
|
|
|
} else {
|
|
|
|
// 将差异转换为小时、分钟、秒
|
|
|
|
const hours = Math.floor(diff / (1000 * 60 * 60));
|
|
|
|
diff -= hours * (1000 * 60 * 60);
|
|
|
|
const minutes = Math.floor(diff / (1000 * 60));
|
|
|
|
diff -= minutes * (1000 * 60);
|
|
|
|
const seconds = Math.floor(diff / 1000);
|
|
|
|
|
2024-03-25 20:36:17 +08:00
|
|
|
const hoursPadded = String(hours).padStart(2, "0");
|
|
|
|
const minutesPadded = String(minutes).padStart(2, "0");
|
|
|
|
const secondsPadded = String(seconds).padStart(2, "0");
|
2024-03-25 21:49:15 +08:00
|
|
|
|
2024-03-25 18:54:04 +08:00
|
|
|
// 返回结果数组
|
2024-03-25 20:36:17 +08:00
|
|
|
return [hoursPadded, minutesPadded, secondsPadded];
|
2024-03-25 18:54:04 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
2024-04-16 09:23:26 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 判断是否是微信环境
|
|
|
|
* @returns
|
|
|
|
*/
|
|
|
|
const globalIsWx = () => {
|
|
|
|
let wx = navigator.userAgent.toLowerCase();
|
|
|
|
if (wx.match(/MicroMessenger/i) === "micromessenger") {
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
};
|
2024-05-07 09:31:46 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 获取参数
|
|
|
|
* https://22233.cn/xxx/xxxx
|
|
|
|
*/
|
|
|
|
const globalGetQueryString = (url) => {
|
|
|
|
// 创建 URL 对象
|
|
|
|
const urlObj = new URL(url);
|
|
|
|
// 获取路径
|
|
|
|
const path = urlObj.pathname;
|
|
|
|
// 分割路径
|
2024-05-07 09:53:20 +08:00
|
|
|
const partsArr = path.split("/").filter((item) => item !== "");
|
2024-05-07 09:31:46 +08:00
|
|
|
return partsArr;
|
|
|
|
};
|