fix: 修复微信小程序appid及URL配置错误

修复了微信小程序的appid配置错误,将appid从"wxabe9cc4db1005fcb"更新为"wx3ae63fb09936b379"。同时,将URL从生产环境切换为本地开发环境,修改为"http://127.0.0.1:8080"。此外,优化了http请求的错误处理逻辑,增加了对响应状态码和业务状态码的检查,确保请求失败时能够正确捕获并处理错误。
This commit is contained in:
fuck
2025-04-07 17:18:09 +08:00
parent 60bb924d5c
commit 40f523595b
207 changed files with 2896 additions and 47650 deletions
+289 -214
View File
@@ -3788,7 +3788,8 @@ function createComponentInstance(vnode, parent, suspense) {
$uniElements: /* @__PURE__ */ new Map(),
$templateUniElementRefs: [],
$templateUniElementStyles: {},
$eS: {}
$eS: {},
$eA: {}
};
{
instance.ctx = createDevRenderContext(instance);
@@ -4286,6 +4287,7 @@ function patch(instance, data, oldData) {
}
data = deepCopy(data);
data.$eS = instance.$eS || {};
data.$eA = instance.$eA || {};
const ctx = instance.ctx;
const mpType = ctx.mpType;
if (mpType === "page" || mpType === "component") {
@@ -5116,6 +5118,15 @@ function createApp$1(rootComponent, rootProps = null) {
return createVueApp(rootComponent, rootProps).use(plugin);
}
const createSSRApp = createApp$1;
function getLocaleLanguage$1() {
let localeLanguage = "";
{
const appBaseInfo = wx.getAppBaseInfo();
const language = appBaseInfo && appBaseInfo.language ? appBaseInfo.language : LOCALE_EN;
localeLanguage = normalizeLocale(language) || LOCALE_EN;
}
return localeLanguage;
}
function validateProtocolFail(name, msg) {
console.warn(`${name}: ${msg}`);
}
@@ -5685,7 +5696,9 @@ const $once = defineSyncApi(API_ONCE, (name, callback) => {
const $off = defineSyncApi(API_OFF, (name, callback) => {
if (!isArray(name))
name = name ? [name] : [];
name.forEach((n2) => eventBus.off(n2, callback));
name.forEach((n2) => {
eventBus.off(n2, callback);
});
}, OffProtocol);
const $emit = defineSyncApi(API_EMIT, (name, ...args) => {
eventBus.emit(name, ...args);
@@ -5877,6 +5890,9 @@ function initWrapper(protocols2) {
}
return function wrapper(methodName, method) {
const hasProtocol = hasOwn(protocols2, methodName);
if (!hasProtocol && typeof wx[methodName] !== "function") {
return method;
}
const needWrapper = hasProtocol || isFunction(protocols2.returnValue) || isContextApi(methodName) || isTaskApi(methodName);
const hasMethod = hasProtocol || isFunction(method);
if (!hasProtocol && !method) {
@@ -5916,7 +5932,7 @@ const getLocale = () => {
if (app && app.$vm) {
return app.$vm.$locale;
}
return normalizeLocale(wx.getAppBaseInfo().language) || LOCALE_EN;
return getLocaleLanguage$1();
};
const setLocale = (locale) => {
const app = isFunction(getApp) && getApp();
@@ -5998,9 +6014,9 @@ function populateParameters(fromRes, toRes) {
appVersion: "1.0.0",
appVersionCode: "100",
appLanguage: getAppLanguage(hostLanguage),
uniCompileVersion: "4.45",
uniCompilerVersion: "4.45",
uniRuntimeVersion: "4.45",
uniCompileVersion: "4.57",
uniCompilerVersion: "4.57",
uniRuntimeVersion: "4.57",
uniPlatform: "mp-weixin",
deviceBrand,
deviceModel: model,
@@ -6149,9 +6165,9 @@ const getAppBaseInfo = {
appLanguage: getAppLanguage(hostLanguage),
isUniAppX: false,
uniPlatform: "mp-weixin",
uniCompileVersion: "4.45",
uniCompilerVersion: "4.45",
uniRuntimeVersion: "4.45"
uniCompileVersion: "4.57",
uniCompilerVersion: "4.57",
uniRuntimeVersion: "4.57"
};
extend(toRes, parameters);
}
@@ -6331,11 +6347,23 @@ function createSelectorQuery() {
const query = wx$2.createSelectorQuery();
const oldIn = query.in;
query.in = function newIn(component) {
if (component.$scope) {
return oldIn.call(this, component.$scope);
}
return oldIn.call(this, initComponentMocks(component));
};
return query;
}
const wx$2 = initWx();
if (!wx$2.canIUse("getAppBaseInfo")) {
wx$2.getAppBaseInfo = wx$2.getSystemInfoSync;
}
if (!wx$2.canIUse("getWindowInfo")) {
wx$2.getWindowInfo = wx$2.getSystemInfoSync;
}
if (!wx$2.canIUse("getDeviceInfo")) {
wx$2.getDeviceInfo = wx$2.getSystemInfoSync;
}
let baseInfo = wx$2.getAppBaseInfo && wx$2.getAppBaseInfo();
if (!baseInfo) {
baseInfo = wx$2.getSystemInfoSync();
@@ -6377,84 +6405,48 @@ var protocols = /* @__PURE__ */ Object.freeze({
});
const wx$1 = initWx();
var index = initUni(shims, protocols, wx$1);
const CONSOLE_TYPES = ["log", "warn", "error", "info", "debug"];
let sendConsole = null;
const messageQueue = [];
function sendConsoleMessages(messages) {
if (sendConsole == null) {
messageQueue.push(...messages);
return;
}
sendConsole(JSON.stringify({
type: "console",
data: messages
}));
}
function setSendConsole(value) {
sendConsole = value;
if (value != null && messageQueue.length > 0) {
const messages = messageQueue.slice();
messageQueue.length = 0;
sendConsoleMessages(messages);
}
}
const originalConsole = /* @__PURE__ */ CONSOLE_TYPES.reduce((methods, type) => {
methods[type] = console[type].bind(console);
return methods;
}, {});
const atFileRegex = /^at\s+[\w/./-]+:\d+$/;
function rewriteConsole() {
function wrapConsole(type) {
return function(...args) {
const originalArgs = [...args];
if (originalArgs.length) {
const maybeAtFile = originalArgs[originalArgs.length - 1];
if (typeof maybeAtFile === "string" && atFileRegex.test(maybeAtFile)) {
originalArgs.pop();
}
}
{
originalConsole[type](...originalArgs);
}
sendConsoleMessages([formatMessage(type, args)]);
};
}
if (isConsoleWritable()) {
CONSOLE_TYPES.forEach((type) => {
console[type] = wrapConsole(type);
function initRuntimeSocket(hosts, port, id) {
if (hosts == "" || port == "" || id == "")
return Promise.resolve(null);
return hosts.split(",").reduce((promise, host2) => {
return promise.then((socket) => {
if (socket != null)
return Promise.resolve(socket);
return tryConnectSocket(host2, port, id);
});
return function restoreConsole() {
CONSOLE_TYPES.forEach((type) => {
console[type] = originalConsole[type];
});
};
} else {
const oldLog = index.__f__;
if (oldLog) {
index.__f__ = function(...args) {
const [type, filename, ...rest] = args;
oldLog(type, "", ...rest);
sendConsoleMessages([formatMessage(type, [...rest, filename])]);
};
return function restoreConsole() {
index.__f__ = oldLog;
};
}
}
return function restoreConsole() {
};
}, Promise.resolve(null));
}
function isConsoleWritable() {
const value = console.log;
const sym = Symbol();
try {
console.log = sym;
} catch (ex) {
return false;
}
const isWritable = console.log === sym;
console.log = value;
return isWritable;
const SOCKET_TIMEOUT = 500;
function tryConnectSocket(host2, port, id) {
return new Promise((resolve, reject) => {
const socket = index.connectSocket({
url: `ws://${host2}:${port}/${id}`,
multiple: true,
// 支付宝小程序 是否开启多实例
fail() {
resolve(null);
}
});
const timer = setTimeout(() => {
socket.close({
code: 1006,
reason: "connect timeout"
});
resolve(null);
}, SOCKET_TIMEOUT);
socket.onOpen((e2) => {
clearTimeout(timer);
resolve(socket);
});
socket.onClose((e2) => {
clearTimeout(timer);
resolve(null);
});
socket.onError((e2) => {
clearTimeout(timer);
resolve(null);
});
});
}
function formatMessage(type, args) {
try {
@@ -6463,7 +6455,6 @@ function formatMessage(type, args) {
args: formatArgs(args)
};
} catch (e2) {
originalConsole.error(e2);
}
return {
type,
@@ -6480,7 +6471,67 @@ function formatArg(arg, depth = 0) {
value: "[Maximum depth reached]"
};
}
return ARG_FORMATTERS[typeof arg](arg, depth);
const type = typeof arg;
switch (type) {
case "string":
return formatString(arg);
case "number":
return formatNumber(arg);
case "boolean":
return formatBoolean(arg);
case "object":
return formatObject(arg, depth);
case "undefined":
return formatUndefined();
case "function":
return formatFunction(arg);
case "symbol": {
return formatSymbol(arg);
}
case "bigint":
return formatBigInt(arg);
}
}
function formatFunction(value) {
return {
type: "function",
value: `function ${value.name}() {}`
};
}
function formatUndefined() {
return {
type: "undefined"
};
}
function formatBoolean(value) {
return {
type: "boolean",
value: String(value)
};
}
function formatNumber(value) {
return {
type: "number",
value: String(value)
};
}
function formatBigInt(value) {
return {
type: "bigint",
value: String(value)
};
}
function formatString(value) {
return {
type: "string",
value
};
}
function formatSymbol(value) {
return {
type: "symbol",
value: value.description
};
}
function formatObject(value, depth) {
if (value === null) {
@@ -6488,17 +6539,19 @@ function formatObject(value, depth) {
type: "null"
};
}
if (isComponentPublicInstance(value)) {
return formatComponentPublicInstance(value, depth);
}
if (isComponentInternalInstance(value)) {
return formatComponentInternalInstance(value, depth);
}
if (isUniElement(value)) {
return formatUniElement(value, depth);
}
if (isCSSStyleDeclaration(value)) {
return formatCSSStyleDeclaration(value, depth);
{
if (isComponentPublicInstance(value)) {
return formatComponentPublicInstance(value, depth);
}
if (isComponentInternalInstance(value)) {
return formatComponentInternalInstance(value, depth);
}
if (isUniElement(value)) {
return formatUniElement(value, depth);
}
if (isCSSStyleDeclaration(value)) {
return formatCSSStyleDeclaration(value, depth);
}
}
if (Array.isArray(value)) {
return {
@@ -6564,10 +6617,20 @@ function formatObject(value, depth) {
className: value.name || "Error"
};
}
let className = void 0;
{
const constructor = value.constructor;
if (constructor) {
if (constructor.get$UTSMetadata$) {
className = constructor.get$UTSMetadata$().name;
}
}
}
return {
type: "object",
className,
value: {
properties: Object.entries(value).map(([name, value2]) => formatObjectProperty(name, value2, depth + 1))
properties: Object.entries(value).map((entry) => formatObjectProperty(entry[0], entry[1], depth + 1))
}
};
}
@@ -6628,14 +6691,14 @@ function formatCSSStyleDeclaration(style, depth) {
};
}
function formatObjectProperty(name, value, depth) {
return Object.assign(formatArg(value, depth), {
name
});
const result = formatArg(value, depth);
result.name = name;
return result;
}
function formatArrayElement(value, index2, depth) {
return Object.assign(formatArg(value, depth), {
name: `${index2}`
});
const result = formatArg(value, depth);
result.name = `${index2}`;
return result;
}
function formatSetEntry(value, depth) {
return {
@@ -6648,97 +6711,94 @@ function formatMapEntry(value, depth) {
value: formatArg(value[1], depth)
};
}
const ARG_FORMATTERS = {
function(value) {
return {
type: "function",
value: `function ${value.name}() {}`
};
},
undefined() {
return {
type: "undefined"
};
},
object(value, depth) {
return formatObject(value, depth);
},
boolean(value) {
return {
type: "boolean",
value: String(value)
};
},
number(value) {
return {
type: "number",
value: String(value)
};
},
bigint(value) {
return {
type: "bigint",
value: String(value)
};
},
string(value) {
return {
type: "string",
value
};
},
symbol(value) {
return {
type: "symbol",
value: value.description
const CONSOLE_TYPES = ["log", "warn", "error", "info", "debug"];
let sendConsole = null;
const messageQueue = [];
const messageExtra = {};
function sendConsoleMessages(messages) {
if (sendConsole == null) {
messageQueue.push(...messages);
return;
}
sendConsole(JSON.stringify(Object.assign({
type: "console",
data: messages
}, messageExtra)));
}
function setSendConsole(value, extra = {}) {
sendConsole = value;
Object.assign(messageExtra, extra);
if (value != null && messageQueue.length > 0) {
const messages = messageQueue.slice();
messageQueue.length = 0;
sendConsoleMessages(messages);
}
}
const originalConsole = /* @__PURE__ */ CONSOLE_TYPES.reduce((methods, type) => {
methods[type] = console[type].bind(console);
return methods;
}, {});
const atFileRegex = /^\s*at\s+[\w/./-]+:\d+$/;
function rewriteConsole() {
function wrapConsole(type) {
return function(...args) {
const originalArgs = [...args];
if (originalArgs.length) {
const maybeAtFile = originalArgs[originalArgs.length - 1];
if (typeof maybeAtFile === "string" && atFileRegex.test(maybeAtFile)) {
originalArgs.pop();
}
}
{
originalConsole[type](...originalArgs);
}
sendConsoleMessages([formatMessage(type, args)]);
};
}
};
function initRuntimeSocket(hosts, port, id) {
if (!hosts || !port || !id)
return Promise.resolve(null);
return hosts.split(",").reduce((promise, host2) => {
return promise.then((socket) => {
if (socket)
return socket;
return tryConnectSocket(host2, port, id);
if (isConsoleWritable()) {
CONSOLE_TYPES.forEach((type) => {
console[type] = wrapConsole(type);
});
}, Promise.resolve(null));
}
const SOCKET_TIMEOUT = 500;
function tryConnectSocket(host2, port, id) {
return new Promise((resolve, reject) => {
const socket = index.connectSocket({
url: `ws://${host2}:${port}/${id}`,
// 支付宝小程序 是否开启多实例
multiple: true,
fail() {
resolve(null);
}
});
const timer = setTimeout(() => {
socket.close({
code: 1006,
reason: "connect timeout"
return function restoreConsole() {
CONSOLE_TYPES.forEach((type) => {
console[type] = originalConsole[type];
});
resolve(null);
}, SOCKET_TIMEOUT);
socket.onOpen((e2) => {
clearTimeout(timer);
resolve(socket);
});
socket.onClose((e2) => {
clearTimeout(timer);
resolve(null);
});
socket.onError((e2) => {
clearTimeout(timer);
resolve(null);
});
});
};
} else {
{
if (typeof index !== "undefined" && index.__f__) {
const oldLog = index.__f__;
if (oldLog) {
index.__f__ = function(...args) {
const [type, filename, ...rest] = args;
oldLog(type, "", ...rest);
sendConsoleMessages([formatMessage(type, [...rest, filename])]);
};
return function restoreConsole() {
index.__f__ = oldLog;
};
}
}
}
}
return function restoreConsole() {
};
}
function isConsoleWritable() {
const value = console.log;
const sym = Symbol();
try {
console.log = sym;
} catch (ex) {
return false;
}
const isWritable = console.log === sym;
console.log = value;
return isWritable;
}
let sendError = null;
const errorQueue = /* @__PURE__ */ new Set();
const errorExtra = {};
function sendErrorMessages(errors) {
if (sendError == null) {
errors.forEach((error) => {
@@ -6746,30 +6806,38 @@ function sendErrorMessages(errors) {
});
return;
}
sendError(JSON.stringify({
type: "error",
data: errors.map((err) => {
const isPromiseRejection = err && "promise" in err && "reason" in err;
const prefix = isPromiseRejection ? "UnhandledPromiseRejection: " : "";
if (isPromiseRejection) {
err = err.reason;
const data = errors.map((err) => {
const isPromiseRejection = err && "promise" in err && "reason" in err;
const prefix = isPromiseRejection ? "UnhandledPromiseRejection: " : "";
if (isPromiseRejection) {
err = err.reason;
}
if (err instanceof Error && err.stack) {
if (err.message && !err.stack.includes(err.message)) {
return `${prefix}${err.message}
${err.stack}`;
}
if (err instanceof Error && err.stack) {
return prefix + err.stack;
return `${prefix}${err.stack}`;
}
if (typeof err === "object" && err !== null) {
try {
return prefix + JSON.stringify(err);
} catch (err2) {
return prefix + String(err2);
}
if (typeof err === "object" && err !== null) {
try {
return prefix + JSON.stringify(err);
} catch (err2) {
return prefix + String(err2);
}
}
return prefix + String(err);
})
}));
}
return prefix + String(err);
}).filter(Boolean);
if (data.length > 0) {
sendError(JSON.stringify(Object.assign({
type: "error",
data
}, errorExtra)));
}
}
function setSendError(value) {
function setSendError(value, extra = {}) {
sendError = value;
Object.assign(errorExtra, extra);
if (value != null && errorQueue.size > 0) {
const errors = Array.from(errorQueue);
errorQueue.clear();
@@ -6806,9 +6874,9 @@ function initOnError() {
};
}
function initRuntimeSocketService() {
const hosts = "192.168.10.21,127.0.0.1";
const hosts = "10.8.0.5,192.168.19.1,192.168.47.1,192.168.10.240,127.0.0.1";
const port = "8090";
const id = "mp-weixin_Y_zfuH";
const id = "mp-weixin_kSUXuu";
const lazy = typeof swan !== "undefined";
let restoreError = lazy ? () => {
} : initOnError();
@@ -6970,6 +7038,15 @@ function findVmByVueId(instance, vuePid) {
}
}
}
function getLocaleLanguage() {
let localeLanguage = "";
{
const appBaseInfo = wx.getAppBaseInfo();
const language = appBaseInfo && appBaseInfo.language ? appBaseInfo.language : LOCALE_EN;
localeLanguage = normalizeLocale(language) || LOCALE_EN;
}
return localeLanguage;
}
const MP_METHODS = [
"createSelectorQuery",
"createIntersectionObserver",
@@ -7236,9 +7313,7 @@ function initAppLifecycle(appOptions, vm) {
}
}
function initLocale(appVm) {
const locale = ref(
normalizeLocale(wx.getAppBaseInfo().language) || LOCALE_EN
);
const locale = ref(getLocaleLanguage());
Object.defineProperty(appVm, "$locale", {
get() {
return locale.value;
+11
View File
@@ -15,7 +15,18 @@ const request = (option) => {
"Clientid": common_vendor.index.getStorageSync("client_id")
},
success(res) {
if (res.statusCode !== 200) {
reject({ msg: `请求失败,状态码:${res.statusCode}` });
return;
}
if (res.data.code !== 200) {
reject(res.data);
return;
}
resolve(res.data);
},
fail(err) {
reject(err);
}
});
});
+2 -2
View File
@@ -1,6 +1,6 @@
"use strict";
const URL = "https://notify.gxfs123.com";
const appid = "wxabe9cc4db1005fcb";
const URL = "http://127.0.0.1:8080";
const appid = "wx3ae63fb09936b379";
exports.URL = URL;
exports.appid = appid;
//# sourceMappingURL=../../.sourcemap/mp-weixin/config/url.js.map
+22
View File
@@ -34,9 +34,31 @@ const getDeviceInfo = (deviceNo) => {
method: "get"
});
};
const queryById = (id) => {
return config_http.request({
url: `/app/order/${id}`,
method: "get"
});
};
const overOrderById = (data) => {
return config_http.request({
url: `/app/order/close/${data}`,
method: "get"
});
};
const rentPowerBank = (deviceNo, phone) => {
return config_http.request({
url: "/app/device/rentPowerBank",
method: "post",
data: { deviceNo, phone }
});
};
exports.getDeviceInfo = getDeviceInfo;
exports.getMyIndexInfo = getMyIndexInfo;
exports.getOrderList = getOrderList;
exports.login = login;
exports.overOrderById = overOrderById;
exports.queryById = queryById;
exports.queryHasOrder = queryHasOrder;
exports.rentPowerBank = rentPowerBank;
//# sourceMappingURL=../../.sourcemap/mp-weixin/config/user.js.map
+16 -21
View File
@@ -37,7 +37,7 @@ const _sfc_main = {
},
onLoad(options) {
this.deviceId = options.deviceNo;
common_vendor.index.__f__("log", "at pages/device/detail.vue:125", options.deviceNo);
common_vendor.index.__f__("log", "at pages/device/detail.vue:126", options.deviceNo);
this.getDeviceInfo();
},
methods: {
@@ -119,30 +119,25 @@ const _sfc_main = {
common_vendor.index.showLoading({
title: "处理中"
});
const selectedPkg = this.packages[this.selectedPackage];
const result = await this.$api.createOrder({
deviceId: this.deviceId,
packageId: this.selectedPackage,
duration: selectedPkg.time,
amount: selectedPkg.price,
phone: this.phoneNumber
});
common_vendor.index.hideLoading();
if (result.success) {
common_vendor.index.showToast({
title: "租借成功",
icon: "success"
});
setTimeout(() => {
common_vendor.index.redirectTo({
url: `/pages/return/index?deviceId=${this.deviceId}&orderId=${result.orderId}`
});
}, 1500);
const rentResult = await config_user.rentPowerBank(this.deviceId, this.phoneNumber);
if (rentResult.code !== 200) {
throw new Error(rentResult.msg || "设备租借失败");
}
const order = rentResult.data;
common_vendor.index.hideLoading();
common_vendor.index.showToast({
title: "租借成功",
icon: "success"
});
setTimeout(() => {
common_vendor.index.redirectTo({
url: `/pages/order/index?orderId=${order.orderId}`
});
}, 1500);
} catch (error) {
common_vendor.index.hideLoading();
common_vendor.index.showToast({
title: "租借失败,请重试",
title: error.message || "租借失败,请重试",
icon: "none"
});
}
+68 -30
View File
@@ -1,9 +1,10 @@
"use strict";
const common_vendor = require("../../common/vendor.js");
const config_user = require("../../config/user.js");
const _sfc_main = {
data() {
return {
deviceId: "",
deviceNo: "",
orderInfo: {
orderId: "",
startTime: "",
@@ -15,7 +16,7 @@ const _sfc_main = {
};
},
onLoad(options) {
this.deviceId = options.deviceId;
this.deviceNo = options.deviceNo;
this.getActiveOrder();
},
onUnload() {
@@ -26,13 +27,14 @@ const _sfc_main = {
async getActiveOrder() {
try {
common_vendor.index.showLoading({ title: "加载中" });
const result = await this.$api.getActiveOrder();
if (result.success) {
const result = await config_user.queryHasOrder(this.deviceNo);
if (result.code === 200 && result.data && result.data.length > 0) {
const orderData = result.data[0];
this.orderInfo = {
orderId: result.data.orderId,
startTime: result.data.startTime,
usedTime: result.data.usedTime,
currentFee: result.data.currentFee
orderId: orderData.orderId,
startTime: this.formatTime(orderData.createTime),
usedTime: this.calculateUsedTime(orderData.createTime),
currentFee: orderData.amount || "0.00"
};
this.startTimer();
} else {
@@ -47,6 +49,7 @@ const _sfc_main = {
}, 1500);
}
} catch (error) {
common_vendor.index.__f__("error", "at pages/device/return.vue:112", "获取订单信息失败:", error);
common_vendor.index.showToast({
title: "获取订单信息失败",
icon: "none"
@@ -55,28 +58,30 @@ const _sfc_main = {
common_vendor.index.hideLoading();
}
},
// 处理开锁请求
// 处理归还请求
async handleUnlock() {
if (this.unlocking)
return;
try {
this.unlocking = true;
common_vendor.index.showLoading({ title: "开锁中" });
const result = await this.$api.unlockDevice({
deviceId: this.deviceId,
orderId: this.orderInfo.orderId
});
if (result.success) {
common_vendor.index.showLoading({ title: "归还中" });
const result = await config_user.overOrderById(this.orderInfo.orderId);
if (result.code === 200) {
common_vendor.index.showToast({
title: "开锁成功",
title: "归还成功",
icon: "success"
});
setTimeout(() => {
common_vendor.index.redirectTo({
url: "/pages/order/index"
});
}, 1500);
} else {
throw new Error(result.message || "开锁失败");
throw new Error(result.msg || "归还失败");
}
} catch (error) {
common_vendor.index.showToast({
title: error.message || "开锁失败,请重试",
title: error.message || "归还失败,请重试",
icon: "none"
});
} finally {
@@ -84,17 +89,50 @@ const _sfc_main = {
common_vendor.index.hideLoading();
}
},
// 格式化时间
formatTime(date) {
if (typeof date === "string" && date.match(/\w{3}\s\w{3}\s\d{2}\s\d{2}:\d{2}:\d{2}\s\w{3}\s\d{4}/)) {
date = new Date(date);
} else if (!(date instanceof Date)) {
date = new Date(date);
}
if (isNaN(date.getTime())) {
common_vendor.index.__f__("error", "at pages/device/return.vue:171", "无效的日期格式:", date);
return "无效日期";
}
const year = date.getFullYear();
const month = (date.getMonth() + 1).toString().padStart(2, "0");
const day = date.getDate().toString().padStart(2, "0");
const hour = date.getHours().toString().padStart(2, "0");
const minute = date.getMinutes().toString().padStart(2, "0");
return `${year}-${month}-${day} ${hour}:${minute}`;
},
// 计算使用时长
calculateUsedTime(startTime) {
let start;
if (typeof startTime === "string") {
start = new Date(startTime);
if (isNaN(start.getTime())) {
common_vendor.index.__f__("error", "at pages/device/return.vue:194", "无效的日期格式:", startTime);
return "0小时0分钟";
}
} else if (startTime instanceof Date) {
start = startTime;
} else {
common_vendor.index.__f__("error", "at pages/device/return.vue:200", "无效的日期类型:", startTime);
return "0小时0分钟";
}
const now = /* @__PURE__ */ new Date();
const diffMs = now - start;
const diffHours = Math.floor(diffMs / (1e3 * 60 * 60));
const diffMinutes = Math.floor(diffMs % (1e3 * 60 * 60) / (1e3 * 60));
return `${diffHours}小时${diffMinutes}分钟`;
},
// 更新使用时长
startTimer() {
this.timer = setInterval(async () => {
try {
const result = await this.$api.getOrderStatus(this.orderInfo.orderId);
if (result.success) {
this.orderInfo.usedTime = result.data.usedTime;
this.orderInfo.currentFee = result.data.currentFee;
}
} catch (error) {
common_vendor.index.__f__("error", "at pages/device/return.vue:162", "更新订单状态失败:", error);
this.timer = setInterval(() => {
if (this.orderInfo.orderId) {
this.orderInfo.usedTime = this.calculateUsedTime(this.orderInfo.startTime);
}
}, 6e4);
},
@@ -109,11 +147,11 @@ const _sfc_main = {
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
return {
a: common_vendor.t($data.orderInfo.orderId),
b: common_vendor.t($data.deviceId),
c: common_vendor.t($data.orderInfo.startTime),
b: common_vendor.t($data.deviceNo),
c: common_vendor.t($data.orderInfo.createTime),
d: common_vendor.t($data.orderInfo.usedTime),
e: common_vendor.t($data.orderInfo.currentFee),
f: common_vendor.t($data.unlocking ? "开锁中..." : "开锁归还"),
f: common_vendor.t($data.unlocking ? "归还中..." : "归还设备"),
g: common_vendor.o((...args) => $options.handleUnlock && $options.handleUnlock(...args)),
h: $data.unlocking
};
+1
View File
@@ -8,6 +8,7 @@ const _sfc_main = {
common_vendor.index.scanCode({
success: (res) => {
let deviceNo = util_index.getQueryString(res.path, "deviceNo");
common_vendor.index.__f__("log", "at pages/index/index.vue:58", res.path);
common_vendor.index.navigateTo({
url: `/pages/serve/bagCheck/index?deviceNo=${deviceNo}`
});
+2 -2
View File
@@ -55,8 +55,8 @@ const _sfc_main = {
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
return common_vendor.e({
a: $data.userInfo.avatar || "/static/user.png",
b: $data.userInfo.nickName
}, $data.userInfo.nickName ? {
b: $data.userInfo
}, $data.userInfo ? {
c: common_vendor.t($data.userInfo.nickName),
d: common_vendor.t($data.userInfo.phone || "")
} : {}, {
+49 -3
View File
@@ -28,11 +28,57 @@ const _sfc_main = {
]
};
},
async onLoad() {
const res = await config_user.getOrderList();
common_vendor.index.__f__("log", "at pages/order/index.vue:84", res);
async onLoad(options) {
if (options && options.orderId) {
try {
const res = await config_user.queryById(options.orderId);
if (res.code === 200 && res.data) {
const orderData = res.data;
const formattedOrder = {
orderNo: orderData.orderId,
status: orderData.orderStatus === 2 ? "using" : "finished",
statusText: orderData.orderStatus === 2 ? "使用中" : "已完成",
deviceId: orderData.deviceNo,
startTime: this.formatTime(new Date(orderData.createTime)),
endTime: orderData.endTime ? this.formatTime(new Date(orderData.endTime)) : "",
amount: orderData.amount || "0.00"
};
this.orderList = [formattedOrder, ...this.orderList];
if (orderData.orderStatus === 2) {
this.switchTab(1);
}
}
} catch (error) {
common_vendor.index.__f__("error", "at pages/order/index.vue:111", "获取订单详情失败:", error);
}
}
try {
const res = await config_user.getOrderList();
common_vendor.index.__f__("log", "at pages/order/index.vue:118", res);
if (res.code === 200 && res.data && res.data.records) {
this.orderList = res.data.records.map((item) => ({
orderNo: item.orderId,
status: item.orderStatus === 2 ? "using" : "finished",
statusText: item.orderStatus === 2 ? "使用中" : "已完成",
deviceId: item.deviceNo,
startTime: item.startTime,
endTime: item.endTime ? this.formatTime(new Date(item.endTime)) : "",
amount: item.amount || "0.00"
}));
}
} catch (error) {
common_vendor.index.__f__("error", "at pages/order/index.vue:132", "获取订单列表失败:", error);
}
},
methods: {
formatTime(date) {
const year = date.getFullYear();
const month = (date.getMonth() + 1).toString().padStart(2, "0");
const day = date.getDate().toString().padStart(2, "0");
const hour = date.getHours().toString().padStart(2, "0");
const minute = date.getMinutes().toString().padStart(2, "0");
return `${year}-${month}-${day} ${hour}:${minute}`;
},
switchTab(index) {
this.currentTab = index;
}
+30 -11
View File
@@ -7,19 +7,38 @@ const _sfc_main = {
return {};
},
async onLoad(option) {
if (!common_vendor.index.getStorageSync("token")) {
const res = await util_index.wxLogin();
common_vendor.index.__f__("log", "at pages/serve/bagCheck/index.vue:26", 333, res);
}
const reuslt = await config_user.queryHasOrder(111);
if (reuslt.data.length != 0) {
common_vendor.index.reLaunch({
url: `/pages/device/return?deviceNo=${option.deviceNo}`
try {
common_vendor.index.showLoading({
title: "加载中..."
});
} else {
common_vendor.index.reLaunch({
url: `/pages/device/detail?deviceNo=${option.deviceNo}`
if (!common_vendor.index.getStorageSync("token")) {
await util_index.wxLogin();
}
const result = await config_user.queryHasOrder(option.deviceNo);
common_vendor.index.hideLoading();
if (!option.deviceNo) {
common_vendor.index.showToast({
title: "设备编号不能为空",
icon: "none"
});
return;
}
if (result.data.length != 0) {
common_vendor.index.redirectTo({
url: `/pages/device/return?deviceNo=${option.deviceNo}`
});
} else {
common_vendor.index.redirectTo({
url: `/pages/device/detail?deviceNo=${option.deviceNo}`
});
}
} catch (error) {
common_vendor.index.hideLoading();
common_vendor.index.showToast({
title: "页面加载失败,请重试",
icon: "none"
});
common_vendor.index.__f__("error", "at pages/serve/bagCheck/index.vue:58", "bagCheck onLoad error:", error);
}
},
methods: {}
+3 -4
View File
@@ -15,12 +15,11 @@
"ignore": [],
"disablePlugins": [],
"outputPath": ""
},
"condition": false
}
},
"compileType": "miniprogram",
"libVersion": "3.7.4",
"appid": "wxabe9cc4db1005fcb",
"libVersion": "3.8.0",
"appid": "wx3ae63fb09936b379",
"projectname": "fs",
"condition": {},
"editorSetting": {
+1 -1
View File
@@ -10,7 +10,7 @@ const wxLogin = () => {
if (loginRes.code) {
const result = await config_user.login({
code: loginRes.code,
appid: "wxabe9cc4db1005fcb"
appid: "wx3ae63fb09936b379"
});
if (result.code === 200) {
common_vendor.index.setStorageSync("token", result.data.LoginWxVo.access_token);