2023-09-08 15:17:21 +08:00
|
|
|
|
import $store from '@/store'
|
2025-03-25 10:17:30 +08:00
|
|
|
|
let baseUrl = "https://tc.pcxbc.com"
|
2023-09-08 15:17:21 +08:00
|
|
|
|
export default {
|
|
|
|
|
|
msg,
|
|
|
|
|
|
ab2hex,
|
|
|
|
|
|
getTime,
|
|
|
|
|
|
getDate,
|
|
|
|
|
|
getMonth,
|
|
|
|
|
|
GetDateStr,
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function ab2hex(buffer, split) {
|
|
|
|
|
|
var hexArr = Array.prototype.map.call(
|
|
|
|
|
|
new Uint8Array(buffer),
|
|
|
|
|
|
function(bit) {
|
|
|
|
|
|
return ('00' + bit.toString(16)).slice(-2)
|
|
|
|
|
|
}
|
|
|
|
|
|
)
|
|
|
|
|
|
return hexArr.join(split);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function msg(str) {
|
|
|
|
|
|
uni.showToast({
|
|
|
|
|
|
title: str,
|
|
|
|
|
|
icon: 'none'
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//获取AddDayCount天后的日期
|
|
|
|
|
|
function GetDateStr(AddDayCount) {
|
|
|
|
|
|
var dd = new Date();
|
|
|
|
|
|
dd.setDate(dd.getDate() + AddDayCount);
|
|
|
|
|
|
var y = dd.getFullYear();
|
|
|
|
|
|
var m = (dd.getMonth() + 1) < 10 ? "0" + (dd.getMonth() + 1) : (dd.getMonth() + 1); //获取当前月份的日期,不足10补0
|
|
|
|
|
|
var d = dd.getDate() < 10 ? "0" + dd.getDate() : dd.getDate(); //获取当前几号,不足10补0
|
|
|
|
|
|
return m + "月" + d + '日';
|
|
|
|
|
|
}
|
|
|
|
|
|
// 获取当前年、月、日、时、分、秒
|
|
|
|
|
|
function getTime() {
|
|
|
|
|
|
var date = new Date()
|
|
|
|
|
|
var y = date.getFullYear();
|
|
|
|
|
|
var m = (date.getMonth() + 1) < 10 ? "0" + (date.getMonth() + 1) : (date.getMonth() + 1); //获取当前月份的日期,不足10补0
|
|
|
|
|
|
var d = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
|
|
|
|
|
|
let H = date.getHours() > 9 ? date.getHours() : '0' + date.getHours()
|
|
|
|
|
|
let Min = date.getMinutes() > 9 ? date.getMinutes() : '0' + date.getMinutes()
|
|
|
|
|
|
return y + '/' + m + '/' + d + " " + H + ':' + Min
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function getDate(type) {
|
|
|
|
|
|
const date = new Date();
|
|
|
|
|
|
let year = date.getFullYear();
|
|
|
|
|
|
let month = date.getMonth() + 1;
|
|
|
|
|
|
let day = date.getDate();
|
|
|
|
|
|
month = month > 9 ? month : '0' + month;;
|
|
|
|
|
|
day = day > 9 ? day : '0' + day;
|
|
|
|
|
|
if (type === 'start') {
|
|
|
|
|
|
year = year;
|
|
|
|
|
|
return `${year}-${month}-${day}`;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (type === 'month') {
|
|
|
|
|
|
return month + '月' + day + '日'
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
// 月初到月底
|
|
|
|
|
|
function getMonth(dates, months) {
|
|
|
|
|
|
var d = new Date(dates.substring(0, 10));
|
|
|
|
|
|
let year = d.getFullYear();
|
|
|
|
|
|
var month = d.getMonth() + 1;
|
|
|
|
|
|
if (Math.abs(months) > 12) {
|
|
|
|
|
|
months = months % 12;
|
|
|
|
|
|
};
|
|
|
|
|
|
if (months != 0) {
|
|
|
|
|
|
if (month + months > 12) {
|
|
|
|
|
|
year++;
|
|
|
|
|
|
month = (month + months) % 12;
|
|
|
|
|
|
} else if (month + months < 1) {
|
|
|
|
|
|
year--;
|
|
|
|
|
|
month = 12 + month + months;
|
|
|
|
|
|
} else {
|
|
|
|
|
|
month = month + months;
|
|
|
|
|
|
};
|
|
|
|
|
|
};
|
|
|
|
|
|
month = month < 10 ? "0" + month : month;
|
|
|
|
|
|
var date = d.getDate();
|
|
|
|
|
|
if (month == "01" || month == "03" || month == "05" || month == "07" || month == "08" || month == "10" ||
|
|
|
|
|
|
month == "12") {
|
2025-03-25 10:17:30 +08:00
|
|
|
|
return year + "-" + month + "-01" + "~" + year + "-" + month + "-31";
|
2023-09-08 15:17:21 +08:00
|
|
|
|
} else if (month == "02") {
|
|
|
|
|
|
if ((year % 4 == 0 && year % 100 != 0) || (year % 100 == 0 && year % 400 == 0)) {
|
2025-03-25 10:17:30 +08:00
|
|
|
|
return year + "-" + month + "-01" + "~" + year + "-" + month + "-29";
|
2023-09-08 15:17:21 +08:00
|
|
|
|
} else {
|
2025-03-25 10:17:30 +08:00
|
|
|
|
return year + "-" + month + "-01" + "~" + year + "-" + month + "-28";
|
2023-09-08 15:17:21 +08:00
|
|
|
|
};
|
|
|
|
|
|
} else {
|
2025-03-25 10:17:30 +08:00
|
|
|
|
return year + "-" + month + "-01" + "~" + year + "-" + month + "-30";
|
2023-09-08 15:17:21 +08:00
|
|
|
|
};
|
2025-03-25 10:17:30 +08:00
|
|
|
|
// if (month == "01" || month == "03" || month == "05" || month == "07" || month == "08" || month == "10" ||
|
|
|
|
|
|
// month == "12") {
|
|
|
|
|
|
// return year + "/" + month + "/01" + "~" + year + "/" + month + "/31";
|
|
|
|
|
|
// } else if (month == "02") {
|
|
|
|
|
|
// if ((year % 4 == 0 && year % 100 != 0) || (year % 100 == 0 && year % 400 == 0)) {
|
|
|
|
|
|
// return year + '/' + month + "/01" + "~" + year + "/" + year + "/" + month + "/29";
|
|
|
|
|
|
// } else {
|
|
|
|
|
|
// return year + '/' + month + "/01" + "~" + year + "/" + month + "/28";
|
|
|
|
|
|
// };
|
|
|
|
|
|
// } else {
|
|
|
|
|
|
// return year + '/' + month + "/01" + "~" + year + "/" + month + "/30";
|
|
|
|
|
|
// };
|
|
|
|
|
|
};
|