This commit is contained in:
2025-04-05 23:47:00 +08:00
commit 8001f8eaeb
215 changed files with 14655 additions and 0 deletions

86
utils/common.js Normal file
View File

@@ -0,0 +1,86 @@
function e(e) {
return [ e.getFullYear(), e.getMonth() + 1, e.getDate() ].map(function(e) {
return e > 9 ? e : "0" + e;
}).join("-");
}
function t(e) {
return e > 9 ? e : "0" + e;
}
module.exports = {
changeTimeyear: function(e) {
return [ e.getFullYear(), "年", e.getMonth() + 1, "月", e.getDate() ].map(function(e, t) {
return e > 9 || t % 2 == 1 ? e : "0" + e;
}).join("");
},
changeTime: e,
changeTimeMD: function(e) {
return [ e.getMonth() + 1, e.getDate() ].join(".");
},
changeTimeDate: function(n) {
var o = new Date(), i = new Date(o.getTime() - 864e5);
return e(o) === e(n) ? "今日 " + [ t(n.getHours()), t(n.getMinutes()) ].join(":") : e(i) === e(n) ? "昨日 " + [ t(n.getHours()), t(n.getMinutes()) ].join(":") : [ n.getMonth() + 1, n.getDate() ].join("月") + " " + [ t(n.getHours()), t(n.getMinutes()) ].join(":");
},
caculateQueryHeight: function(e) {
return new Promise(function(t, n) {
wx.createSelectorQuery().select("." + e).boundingClientRect(function(e) {
console.log(e), t({
width: e.width,
height: e.height,
left: e.left,
right: e.right,
top: e.top,
bottom: e.bottom
});
}).exec();
});
},
confirmAlert: function(e, t) {
return new Promise(function(n, o) {
wx.showModal({
title: t || "提示",
content: e,
cancelColor: "#999999",
confirmColor: "#62C4A3",
success: function(e) {
e.confirm ? n(e) : o();
}
});
});
},
changeNum: t,
changeTimeHoursAgo: function(t) {
var n = new Date(), o = new Date(n.getTime() - 864e5);
if (e(n) === e(t)) {
var i = Math.floor((n.getTime() - t.getTime()) / 36e5);
return 0 == i ? Math.floor((n.getTime() - t.getTime()) / 6e4) + "分钟前" : i + "小时前";
}
return e(o) === e(t) ? "昨天" : n.getFullYear() == t.getFullYear() ? [ t.getMonth() + 1, t.getDate() ].join("月") : [ t.getFullYear(), t.getMonth() + 1, t.getDate() ].join(".");
},
showToast: function(e) {
wx.showToast({
title: e,
icon: "none",
duration: 2e3,
mask: !0
});
},
restTime: function(e) {
var t = 1e3 * e - new Date().getTime();
if (t <= 0) return !1;
var n, o, i, r, a = t / 1e3 / 3600 / 24, u = 24 * (a - (n = Math.floor(a))), g = 60 * (u - (o = Math.floor(u))), c = 60 * (g - (i = Math.floor(g)));
return r = Math.floor(c), {
day: (n + "").padStart(2, "0"),
hour: (o + "").padStart(2, "0"),
minute: (i + "").padStart(2, "0"),
second: (r + "").padStart(2, "0")
};
},
replaceDetail: function(e) {
for (var t = ""; -1 != e.indexOf("<img"); ) t += e.substring("0", e.indexOf("<img") + 4),
-1 != (e = e.substring(e.indexOf("<img") + 4)).indexOf("style=") && e.indexOf("style=") < e.indexOf(">") ? (t += e.substring(0, e.indexOf('style="') + 7) + "max-width:100%;height:auto;margin:0 auto;",
e = e.substring(e.indexOf('style="') + 7)) : t += ' style="max-width:100%;height:auto;margin:0 auto;" ';
return t += e;
}
};

116
utils/login.js Normal file
View File

@@ -0,0 +1,116 @@
var e = require("../@babel/runtime/helpers/typeof"), o = (require("./common.js"),
null), a = null;
function t() {
return new Promise(function(e, o) {
return wx.login({
success: e,
fail: o
});
});
}
function n(a) {
var t = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : {};
return wx.showLoading(), new Promise(function(n, c) {
console.log("requestdevicecode", o.globalData.devicecode);
var i = Object.assign({}, {
devicecode: o.globalData.devicecode
}, o.globalData.options, t);
console.log("sendData", a, i), wx.request({
url: a,
data: i,
header: {
"content-type": "application/json",
Accept: "application/json, text/plain",
Cookie: "_miucms_session=" + wx.getStorageSync("_miucms_session"),
token: wx.getStorageSync("session") || ""
},
method: "POST",
success: function(o) {
var t = o.data;
if ("object" != e(t) && null != t) {
t = t.replace("\ufeff", "");
var i = JSON.parse(t);
o.data = i;
}
wx.hideLoading();
var l = o.data;
switch (1 * l.code) {
case 200:
case 888:
n(l);
break;
case 201:
a.indexOf("carwashcoupon/receive") > -1 || wx.showModal({
title: "提示",
content: l.message
}), c(l);
break;
case 404:
wx.showModal({
title: "提示",
content: "未找到当前接口"
}), c(l);
break;
case 401:
var s = getCurrentPages(), r = s[s.length - 1];
console.log(401, a), wx.redirectTo({
url: "/pages/login/login?fromPage=".concat(r.route)
}), c(l);
break;
default:
wx.showModal({
title: "提示",
content: l.message
}), c(l);
}
},
fail: function(e) {
wx.hideLoading(), console.log("reqest error", e), c("fail");
}
});
});
}
function c(e, a) {
console.log("appstart", e), o = a, n("https://jmqf.v0750.com/miniprogram", {
code: e
}, !0).then(function(e) {
var o = e.data;
console.log("总接口", o), a.globalData.user = o.user, wx.setStorageSync("session", o.user.session),
a.globalData.isUserAuthorization = o.user > 0 ? 2 : 1, a.globalData.config = o.config,
a.globalData.servicetel = o.servicetel, a.globalData.canGetData = !0, a.globalData.protocol = o.protocol;
});
}
module.exports = {
initial_url: "https://jmqf.v0750.com/miniprogram",
login: t,
request: n,
pageStart: function(e) {
return new Promise(function(o, t) {
e.globalData.canGetData ? o() : a = setInterval(function() {
e.globalData.canGetData && (clearInterval(a), o());
}, 1e3);
});
},
getLogin: function(e) {
o = e, t().then(function(a) {
console.log("获取用户登录态成功!", a.code), o.globalData.code = a.code, c(a.code, e);
}).catch(function(o) {
c(res.code, e);
});
},
baseUrl: "https://jmqf.v0750.com/",
getDevicecode: function(e, a) {
o = e, n("https://jmqf.v0750.com/miniprogram/identify/reload", a, !0).then(function(e) {
var a = e.data;
console.log("onshow获取到的数据", a), o.globalData.devicecode = a.devicecode || o.globalData.devicecode;
});
}
};

2558
utils/xstat.js Normal file

File diff suppressed because it is too large Load Diff