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
+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: {}