feat: 添加订单支付和成功页面,更新订单状态逻辑

新增了订单支付页面和支付成功页面,分别用于处理用户的支付流程和展示支付结果。同时,更新了订单状态的逻辑,确保在订单列表中正确显示各个状态。调整了设备租借逻辑,优化了扫码处理流程,提升用户体验。
This commit is contained in:
8vd8
2025-04-10 14:18:43 +08:00
parent aebd6c0459
commit 3fecd77739
53 changed files with 2049 additions and 702 deletions
+3 -8
View File
@@ -119,21 +119,16 @@ const _sfc_main = {
common_vendor.index.showLoading({
title: "处理中"
});
const selectedPkg = this.packages[this.selectedPackage];
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"
common_vendor.index.redirectTo({
url: `/pages/order/payment?orderId=${order.orderId}&packageTime=${selectedPkg.time}&packagePrice=${selectedPkg.price}`
});
setTimeout(() => {
common_vendor.index.redirectTo({
url: `/pages/order/index?orderId=${order.orderId}`
});
}, 1500);
} catch (error) {
common_vendor.index.hideLoading();
common_vendor.index.showToast({
-1
View File
@@ -1 +0,0 @@
<view class="return-container data-v-df932504"><view class="order-card data-v-df932504"><view class="order-header data-v-df932504"><text class="title data-v-df932504">使用中</text><text class="order-no data-v-df932504">订单号:{{a}}</text></view><view class="device-info data-v-df932504"><text class="device-name data-v-df932504">共享风扇</text><text class="device-id data-v-df932504">设备号:{{b}}</text></view><view class="time-info data-v-df932504"><view class="time-item data-v-df932504"><text class="label data-v-df932504">开始时间</text><text class="value data-v-df932504">{{c}}</text></view><view class="time-item data-v-df932504"><text class="label data-v-df932504">已使用时长</text><text class="value highlight data-v-df932504">{{d}}</text></view><view class="time-item data-v-df932504"><text class="label data-v-df932504">当前费用</text><text class="value data-v-df932504">¥{{e}}</text></view></view></view><view class="notice-card data-v-df932504"><view class="notice-title data-v-df932504">归还说明</view><view class="notice-list data-v-df932504"><view class="notice-item data-v-df932504"><view class="dot data-v-df932504"></view><text class="data-v-df932504">请确保设备完好无损</text></view><view class="notice-item data-v-df932504"><view class="dot data-v-df932504"></view><text class="data-v-df932504">请在指定区域内归还设备</text></view><view class="notice-item data-v-df932504"><view class="dot data-v-df932504"></view><text class="data-v-df932504">归还后押金将自动退还</text></view></view></view><view class="bottom-bar data-v-df932504"><button class="unlock-btn data-v-df932504" bindtap="{{g}}" disabled="{{h}}">{{f}}</button></view></view>
+46 -12
View File
@@ -4,22 +4,56 @@ const util_index = require("../../util/index.js");
const common_assets = require("../../common/assets.js");
const _sfc_main = {
methods: {
handleScan() {
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);
async handleScan() {
try {
const scanResult = await new Promise((resolve, reject) => {
common_vendor.index.scanCode({
success: resolve,
fail: reject
});
});
let deviceNo = util_index.getQueryString(scanResult.path, "deviceNo");
common_vendor.index.__f__("log", "at pages/index/index.vue:64", "扫码路径:", scanResult.path);
const inUseRes = await common_vendor.index.request({
url: `${common_vendor.index.getStorageSync("baseUrl") || "http://127.0.0.1:8080"}/app/order/inUse`,
method: "GET",
header: {
"Authorization": "Bearer " + common_vendor.index.getStorageSync("token"),
"Clientid": common_vendor.index.getStorageSync("client_id")
}
});
if (inUseRes.statusCode === 200 && inUseRes.data.code === 200 && inUseRes.data.data) {
const inUseOrder = inUseRes.data.data;
common_vendor.index.navigateTo({
url: `/pages/return/index?orderId=${inUseOrder.orderId}&deviceId=${deviceNo}`
});
return;
}
const orderRes = await common_vendor.index.request({
url: `${common_vendor.index.getStorageSync("baseUrl") || "http://127.0.0.1:8080"}/app/order/unpaid`,
method: "GET",
header: {
"Authorization": "Bearer " + common_vendor.index.getStorageSync("token"),
"Clientid": common_vendor.index.getStorageSync("client_id")
}
});
if (orderRes.statusCode === 200 && orderRes.data.code === 200 && orderRes.data.data) {
const unpaidOrder = orderRes.data.data;
common_vendor.index.navigateTo({
url: `/pages/order/payment?orderId=${unpaidOrder.orderId}`
});
} else {
common_vendor.index.navigateTo({
url: `/pages/serve/bagCheck/index?deviceNo=${deviceNo}`
});
},
fail: (err) => {
common_vendor.index.showToast({
title: "扫码失败",
icon: "none"
});
}
});
} catch (error) {
common_vendor.index.__f__("error", "at pages/index/index.vue:108", "扫码处理失败:", error);
common_vendor.index.showToast({
title: "扫码失败",
icon: "none"
});
}
}
}
};
+42 -57
View File
@@ -1,31 +1,14 @@
"use strict";
const common_vendor = require("../../common/vendor.js");
const config_user = require("../../config/user.js");
const constants_orderStatus = require("../../constants/orderStatus.js");
const _sfc_main = {
data() {
return {
currentTab: 0,
tabs: ["全部", "使用中", "已完成"],
orderList: [
{
orderNo: "ORDER202403200001",
status: "using",
statusText: "使用中",
deviceId: "FAN001",
startTime: "2024-03-20 15:30",
endTime: "",
amount: "2.00"
},
{
orderNo: "ORDER202403190001",
status: "finished",
statusText: "已完成",
deviceId: "FAN002",
startTime: "2024-03-19 13:00",
endTime: "2024-03-19 15:00",
amount: "4.00"
}
]
OrderStatusMap: constants_orderStatus.OrderStatusMap,
OrderStatusTabs: constants_orderStatus.OrderStatusTabs,
orderList: []
};
},
async onLoad(options) {
@@ -36,69 +19,71 @@ const _sfc_main = {
const orderData = res.data;
const formattedOrder = {
orderNo: orderData.orderId,
status: orderData.orderStatus === 2 ? "using" : "finished",
statusText: orderData.orderStatus === 2 ? "使用中" : "已完成",
status: orderData.orderStatus,
deviceId: orderData.deviceNo,
startTime: this.formatTime(new Date(orderData.createTime)),
endTime: orderData.endTime ? this.formatTime(new Date(orderData.endTime)) : "",
startTime: orderData.createTime,
endTime: orderData.endTime || "",
amount: orderData.amount || "0.00"
};
this.orderList = [formattedOrder, ...this.orderList];
if (orderData.orderStatus === 2) {
this.switchTab(1);
const tabIndex = this.OrderStatusTabs.findIndex(
(tab) => tab.status.includes(orderData.orderStatus)
);
if (tabIndex !== -1) {
this.switchTab(tabIndex);
}
}
} catch (error) {
common_vendor.index.__f__("error", "at pages/order/index.vue:111", "获取订单详情失败:", error);
common_vendor.index.__f__("error", "at pages/order/index.vue:97", "获取订单详情失败:", 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);
}
await this.getOrderList();
},
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}`;
async getOrderList(statusList = []) {
try {
const res = await config_user.getOrderList(statusList);
if (res.code === 200 && res.data && res.data.records) {
this.orderList = res.data.records.map((item) => ({
orderNo: item.orderId,
status: item.orderStatus,
deviceId: item.deviceNo,
startTime: item.createTime,
endTime: item.endTime || "",
amount: item.amount || "0.00"
}));
}
} catch (error) {
common_vendor.index.__f__("error", "at pages/order/index.vue:120", "获取订单列表失败:", error);
common_vendor.index.showToast({
title: "获取订单列表失败",
icon: "none"
});
}
},
switchTab(index) {
async switchTab(index) {
this.currentTab = index;
const statusList = this.OrderStatusTabs[index].status;
await this.getOrderList(statusList);
}
}
};
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
return common_vendor.e({
a: common_vendor.f($data.tabs, (tab, index, i0) => {
a: common_vendor.f($data.OrderStatusTabs, (tab, index, i0) => {
return {
a: common_vendor.t(tab),
a: common_vendor.t(tab.text),
b: index,
c: $data.currentTab === index ? 1 : "",
d: common_vendor.o(($event) => $options.switchTab(index), index)
};
}),
b: common_vendor.f($data.orderList, (order, index, i0) => {
var _a, _b;
return {
a: common_vendor.t(order.orderNo),
b: common_vendor.t(order.statusText),
c: common_vendor.n(order.status),
b: common_vendor.t((_a = $data.OrderStatusMap[order.status]) == null ? void 0 : _a.text),
c: common_vendor.n((_b = $data.OrderStatusMap[order.status]) == null ? void 0 : _b.class),
d: common_vendor.t(order.deviceId),
e: common_vendor.t(order.startTime),
f: common_vendor.t(order.endTime || "-"),
+17 -2
View File
@@ -84,10 +84,25 @@
.order-container .order-list .order-item .order-header .order-status.data-v-17a44f9d {
font-size: 26rpx;
}
.order-container .order-list .order-item .order-header .order-status.using.data-v-17a44f9d {
.order-container .order-list .order-item .order-header .order-status.status-waiting.data-v-17a44f9d {
color: #FF9800;
}
.order-container .order-list .order-item .order-header .order-status.status-progress.data-v-17a44f9d {
color: #2196F3;
}
.order-container .order-list .order-item .order-header .order-status.status-success.data-v-17a44f9d {
color: #4CAF50;
}
.order-container .order-list .order-item .order-header .order-status.status-using.data-v-17a44f9d {
color: #1976D2;
}
.order-container .order-list .order-item .order-header .order-status.finished.data-v-17a44f9d {
.order-container .order-list .order-item .order-header .order-status.status-failed.data-v-17a44f9d {
color: #F44336;
}
.order-container .order-list .order-item .order-header .order-status.status-cancelled.data-v-17a44f9d {
color: #9E9E9E;
}
.order-container .order-list .order-item .order-header .order-status.status-finished.data-v-17a44f9d {
color: #4CAF50;
}
.order-container .order-list .order-item .order-content.data-v-17a44f9d {
+271
View File
@@ -0,0 +1,271 @@
"use strict";
const common_vendor = require("../../common/vendor.js");
const config_user = require("../../config/user.js");
const _sfc_main = {
data() {
return {
orderId: null,
orderInfo: {},
packageInfo: {
time: "",
price: "0.00"
},
orderStatus: {
text: "等待支付",
desc: "请在15分钟内完成支付",
class: "waiting"
},
paymentMethods: [
{
name: "微信支付",
icon: "wechat"
},
{
name: "支付宝",
icon: "alipay"
}
],
selectedMethod: 0
};
},
computed: {
totalAmount() {
const deposit = parseFloat(this.orderInfo.deposit || 99);
const amount = parseFloat(this.orderInfo.amount || this.packageInfo.price || 0);
return (deposit + amount).toFixed(2);
}
},
onLoad(options) {
if (options && options.orderId) {
this.orderId = options.orderId;
if (options.packageTime && options.packagePrice) {
this.packageInfo = {
time: options.packageTime,
price: options.packagePrice
};
}
this.loadOrderInfo();
} else {
common_vendor.index.showToast({
title: "订单信息不存在",
icon: "none"
});
setTimeout(() => {
common_vendor.index.redirectTo({
url: "/pages/index/index"
});
}, 1500);
}
},
methods: {
// 加载订单信息
async loadOrderInfo() {
try {
common_vendor.index.showLoading({
title: "加载中"
});
const res = await config_user.queryById(this.orderId);
if (res.code === 200 && res.data) {
const orderData = res.data;
this.orderInfo = {
orderNo: orderData.orderNo || orderData.orderId,
deviceNo: orderData.deviceNo,
createTime: orderData.createTime,
phone: orderData.phone,
deposit: "99.00",
// 假设押金固定为99元
amount: orderData.amount || this.packageInfo.price || "0.00"
};
if (!orderData.packageTime && this.packageInfo.time) {
this.orderInfo.packageTime = this.packageInfo.time;
this.orderInfo.packagePrice = this.packageInfo.price;
}
} else {
throw new Error("获取订单信息失败");
}
common_vendor.index.hideLoading();
} catch (error) {
common_vendor.index.hideLoading();
common_vendor.index.showToast({
title: error.message || "获取订单信息失败",
icon: "none"
});
}
},
// 选择支付方式
selectMethod(index) {
this.selectedMethod = index;
},
// 处理支付
async handlePayment() {
try {
common_vendor.index.showLoading({
title: "处理中"
});
const res = await common_vendor.index.request({
url: `${common_vendor.index.getStorageSync("baseUrl") || "http://127.0.0.1:8080"}/app/wx-payment/create/${this.orderInfo.orderNo}`,
method: "GET",
header: {
"Authorization": "Bearer " + common_vendor.index.getStorageSync("token"),
"Clientid": common_vendor.index.getStorageSync("client_id")
}
});
if (res.statusCode === 200 && res.data.code === 200) {
common_vendor.index.hideLoading();
common_vendor.index.redirectTo({
url: `/pages/order/success?orderId=${this.orderId}`
});
} else {
throw new Error(res.data.msg || "支付失败");
}
} catch (error) {
common_vendor.index.hideLoading();
common_vendor.index.showToast({
title: error.message || "支付失败",
icon: "none"
});
}
},
// 发送租借指令
async sendRentCommand() {
try {
common_vendor.index.showLoading({
title: "处理中"
});
const res = await this.sendRentRequest();
if (res.code === 200) {
common_vendor.index.hideLoading();
common_vendor.index.showToast({
title: "租借成功",
icon: "success"
});
setTimeout(() => {
common_vendor.index.redirectTo({
url: `/pages/order/index?orderId=${this.orderId}`
});
}, 1500);
} else {
throw new Error(res.msg || "租借失败");
}
} catch (error) {
common_vendor.index.hideLoading();
common_vendor.index.showToast({
title: error.message || "租借失败",
icon: "none"
});
}
},
// 发送租借请求
sendRentRequest() {
return new Promise((resolve, reject) => {
common_vendor.index.request({
url: `${common_vendor.index.getStorageSync("baseUrl") || "http://127.0.0.1:8080"}/app/device/sendRentCommand`,
method: "POST",
data: {
orderId: this.orderId
},
header: {
"Content-Type": "application/x-www-form-urlencoded",
"Authorization": "Bearer " + common_vendor.index.getStorageSync("token"),
"Clientid": common_vendor.index.getStorageSync("client_id")
},
success(res) {
if (res.statusCode === 200) {
resolve(res.data);
} else {
reject(new Error("请求失败"));
}
},
fail(err) {
reject(err);
}
});
});
},
// 格式化时间
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}`;
},
// 轮询订单状态
async pollOrderStatus() {
let retryCount = 0;
const maxRetries = 10;
const interval = 1e3;
const checkStatus = async () => {
try {
const res = await common_vendor.index.request({
url: `${common_vendor.index.getStorageSync("baseUrl") || "http://127.0.0.1:8080"}/app/payment/status/${this.orderInfo.orderNo}`,
method: "GET",
header: {
"Authorization": "Bearer " + common_vendor.index.getStorageSync("token"),
"Clientid": common_vendor.index.getStorageSync("client_id")
}
});
if (res.statusCode === 200 && res.data.code === 200) {
const orderData = res.data.data;
if (orderData.orderStatus === "IN_USED") {
common_vendor.index.showToast({
title: "支付成功",
icon: "success"
});
setTimeout(() => {
common_vendor.index.redirectTo({
url: `/pages/order/success?orderId=${this.orderId}`
});
}, 1500);
return;
}
}
if (retryCount < maxRetries) {
retryCount++;
setTimeout(checkStatus, interval);
} else {
throw new Error("订单状态查询超时");
}
} catch (error) {
common_vendor.index.showToast({
title: error.message || "查询订单状态失败",
icon: "none"
});
}
};
checkStatus();
}
}
};
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
return {
a: common_vendor.n($data.orderStatus.class),
b: common_vendor.t($data.orderStatus.text),
c: common_vendor.t($data.orderStatus.desc),
d: common_vendor.t($data.orderInfo.orderNo || "-"),
e: common_vendor.t($data.orderInfo.deviceNo || "-"),
f: common_vendor.t($data.orderInfo.createTime || "-"),
g: common_vendor.t($data.orderInfo.phone || "-"),
h: common_vendor.t($data.orderInfo.deposit || "99.00"),
i: common_vendor.t($data.packageInfo.time),
j: common_vendor.t($data.packageInfo.price),
k: common_vendor.t($data.orderInfo.amount || $data.packageInfo.price),
l: common_vendor.t($options.totalAmount),
m: common_vendor.f($data.paymentMethods, (method, index, i0) => {
return {
a: common_vendor.n(method.icon),
b: common_vendor.t(method.name),
c: index,
d: $data.selectedMethod === index ? 1 : "",
e: common_vendor.o(($event) => $options.selectMethod(index), index)
};
}),
n: common_vendor.t($options.totalAmount),
o: common_vendor.o((...args) => $options.handlePayment && $options.handlePayment(...args)),
p: common_vendor.o((...args) => _ctx.navigateBack && _ctx.navigateBack(...args))
};
}
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-13c3fb22"]]);
wx.createPage(MiniProgramPage);
//# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/order/payment.js.map
+6
View File
@@ -0,0 +1,6 @@
{
"navigationBarTitleText": "订单支付",
"navigationBarBackgroundColor": "#ffffff",
"navigationBarTextStyle": "black",
"usingComponents": {}
}
+1
View File
@@ -0,0 +1 @@
<view class="payment-container data-v-13c3fb22"><view class="status-card data-v-13c3fb22"><view class="{{['status-icon', 'data-v-13c3fb22', a]}}"></view><view class="status-text data-v-13c3fb22">{{b}}</view><view class="status-desc data-v-13c3fb22">{{c}}</view></view><view class="order-card data-v-13c3fb22"><view class="card-title data-v-13c3fb22">订单信息</view><view class="info-item data-v-13c3fb22"><text class="label data-v-13c3fb22">订单号</text><text class="value data-v-13c3fb22">{{d}}</text></view><view class="info-item data-v-13c3fb22"><text class="label data-v-13c3fb22">设备号</text><text class="value data-v-13c3fb22">{{e}}</text></view><view class="info-item data-v-13c3fb22"><text class="label data-v-13c3fb22">创建时间</text><text class="value data-v-13c3fb22">{{f}}</text></view><view class="info-item data-v-13c3fb22"><text class="label data-v-13c3fb22">联系电话</text><text class="value data-v-13c3fb22">{{g}}</text></view></view><view class="price-card data-v-13c3fb22"><view class="card-title data-v-13c3fb22">费用信息</view><view class="price-item data-v-13c3fb22"><text class="label data-v-13c3fb22">押金</text><text class="value data-v-13c3fb22">¥{{h}}</text></view><view class="price-item data-v-13c3fb22"><text class="label data-v-13c3fb22">套餐</text><text class="value data-v-13c3fb22">{{i}} (¥{{j}})</text></view><view class="price-item data-v-13c3fb22"><text class="label data-v-13c3fb22">租借费用</text><text class="value data-v-13c3fb22">¥{{k}}</text></view><view class="price-item total data-v-13c3fb22"><text class="label data-v-13c3fb22">合计</text><text class="value data-v-13c3fb22">¥{{l}}</text></view></view><view class="payment-methods data-v-13c3fb22"><view class="card-title data-v-13c3fb22">支付方式</view><view wx:for="{{m}}" wx:for-item="method" wx:key="c" class="{{['method-item', 'data-v-13c3fb22', method.d && 'active']}}" bindtap="{{method.e}}"><view class="{{['method-icon', 'data-v-13c3fb22', method.a]}}"></view><view class="method-name data-v-13c3fb22">{{method.b}}</view><view class="method-check data-v-13c3fb22"></view></view></view><view class="bottom-bar data-v-13c3fb22"><view class="total-amount data-v-13c3fb22"><text class="data-v-13c3fb22">合计:</text><text class="amount data-v-13c3fb22">¥{{n}}</text></view><button class="pay-btn data-v-13c3fb22" bindtap="{{o}}">立即支付</button></view><view class="back-btn data-v-13c3fb22" bindtap="{{p}}"><text class="data-v-13c3fb22">返回设备详情</text></view> methods: { navigateBack() { uni.redirectTo({ url: `/pages/device/detail?deviceId=${this.deviceId}` }) } } </view>
+217
View File
@@ -0,0 +1,217 @@
/**
* 这里是uni-app内置的常用样式变量
*
* uni-app 官方扩展插件及插件市场(https://ext.dcloud.net.cn)上很多三方插件均使用了这些样式变量
* 如果你是插件开发者,建议你使用scss预处理,并在插件代码中直接使用这些变量(无需 import 这个文件),方便用户通过搭积木的方式开发整体风格一致的App
*
*/
/**
* 如果你是App开发者(插件使用者),你可以通过修改这些变量来定制自己的插件主题,实现自定义主题功能
*
* 如果你的项目同样使用了scss预处理,你也可以直接在你的 scss 代码中使用如下变量,同时无需 import 这个文件
*/
/* 颜色变量 */
/* 行为相关颜色 */
/* 文字基本颜色 */
/* 背景颜色 */
/* 边框颜色 */
/* 尺寸变量 */
/* 文字尺寸 */
/* 图片尺寸 */
/* Border Radius */
/* 水平间距 */
/* 垂直间距 */
/* 透明度 */
/* 文章场景相关 */
.payment-container.data-v-13c3fb22 {
min-height: 100vh;
background: #f8f8f8;
padding: 30rpx;
padding-bottom: 180rpx;
box-sizing: border-box;
}
.payment-container .status-card.data-v-13c3fb22 {
background: #fff;
border-radius: 24rpx;
padding: 40rpx 30rpx;
margin-bottom: 30rpx;
display: flex;
flex-direction: column;
align-items: center;
box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.04);
}
.payment-container .status-card .status-icon.data-v-13c3fb22 {
width: 120rpx;
height: 120rpx;
border-radius: 50%;
background: #f5f5f5;
margin-bottom: 20rpx;
}
.payment-container .status-card .status-icon.waiting.data-v-13c3fb22 {
background: #FFF9C4;
}
.payment-container .status-card .status-icon.success.data-v-13c3fb22 {
background: #E8F5E9;
}
.payment-container .status-card .status-icon.failed.data-v-13c3fb22 {
background: #FFEBEE;
}
.payment-container .status-card .status-text.data-v-13c3fb22 {
font-size: 36rpx;
font-weight: 600;
color: #333;
margin-bottom: 10rpx;
}
.payment-container .status-card .status-desc.data-v-13c3fb22 {
font-size: 28rpx;
color: #999;
}
.payment-container .order-card.data-v-13c3fb22, .payment-container .price-card.data-v-13c3fb22 {
background: #fff;
border-radius: 24rpx;
padding: 30rpx;
margin-bottom: 30rpx;
box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.04);
}
.payment-container .order-card .card-title.data-v-13c3fb22, .payment-container .price-card .card-title.data-v-13c3fb22 {
font-size: 32rpx;
font-weight: 600;
color: #333;
margin-bottom: 20rpx;
position: relative;
padding-left: 20rpx;
}
.payment-container .order-card .card-title.data-v-13c3fb22::before, .payment-container .price-card .card-title.data-v-13c3fb22::before {
content: "";
position: absolute;
left: 0;
top: 50%;
transform: translateY(-50%);
width: 8rpx;
height: 32rpx;
background: #1976D2;
border-radius: 4rpx;
}
.payment-container .order-card .info-item.data-v-13c3fb22, .payment-container .order-card .price-item.data-v-13c3fb22, .payment-container .price-card .info-item.data-v-13c3fb22, .payment-container .price-card .price-item.data-v-13c3fb22 {
display: flex;
justify-content: space-between;
align-items: center;
padding: 20rpx 0;
border-bottom: 1px solid #f5f5f5;
}
.payment-container .order-card .info-item.data-v-13c3fb22:last-child, .payment-container .order-card .price-item.data-v-13c3fb22:last-child, .payment-container .price-card .info-item.data-v-13c3fb22:last-child, .payment-container .price-card .price-item.data-v-13c3fb22:last-child {
border-bottom: none;
}
.payment-container .order-card .info-item .label.data-v-13c3fb22, .payment-container .order-card .price-item .label.data-v-13c3fb22, .payment-container .price-card .info-item .label.data-v-13c3fb22, .payment-container .price-card .price-item .label.data-v-13c3fb22 {
font-size: 28rpx;
color: #666;
}
.payment-container .order-card .info-item .value.data-v-13c3fb22, .payment-container .order-card .price-item .value.data-v-13c3fb22, .payment-container .price-card .info-item .value.data-v-13c3fb22, .payment-container .price-card .price-item .value.data-v-13c3fb22 {
font-size: 28rpx;
color: #333;
}
.payment-container .order-card .info-item.total.data-v-13c3fb22, .payment-container .order-card .price-item.total.data-v-13c3fb22, .payment-container .price-card .info-item.total.data-v-13c3fb22, .payment-container .price-card .price-item.total.data-v-13c3fb22 {
margin-top: 10rpx;
padding-top: 30rpx;
border-top: 1px solid #f5f5f5;
}
.payment-container .order-card .info-item.total .label.data-v-13c3fb22, .payment-container .order-card .info-item.total .value.data-v-13c3fb22, .payment-container .order-card .price-item.total .label.data-v-13c3fb22, .payment-container .order-card .price-item.total .value.data-v-13c3fb22, .payment-container .price-card .info-item.total .label.data-v-13c3fb22, .payment-container .price-card .info-item.total .value.data-v-13c3fb22, .payment-container .price-card .price-item.total .label.data-v-13c3fb22, .payment-container .price-card .price-item.total .value.data-v-13c3fb22 {
font-size: 32rpx;
font-weight: 600;
color: #333;
}
.payment-container .order-card .info-item.total .value.data-v-13c3fb22, .payment-container .order-card .price-item.total .value.data-v-13c3fb22, .payment-container .price-card .info-item.total .value.data-v-13c3fb22, .payment-container .price-card .price-item.total .value.data-v-13c3fb22 {
color: #FF5722;
}
.payment-container .payment-methods.data-v-13c3fb22 {
background: #fff;
border-radius: 24rpx;
padding: 30rpx;
margin-bottom: 30rpx;
box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.04);
}
.payment-container .payment-methods .method-item.data-v-13c3fb22 {
display: flex;
align-items: center;
padding: 30rpx 20rpx;
border-bottom: 1px solid #f5f5f5;
position: relative;
}
.payment-container .payment-methods .method-item.data-v-13c3fb22:last-child {
border-bottom: none;
}
.payment-container .payment-methods .method-item.active.data-v-13c3fb22 {
background: #F5F5F5;
}
.payment-container .payment-methods .method-item.active .method-check.data-v-13c3fb22 {
background: #1976D2;
}
.payment-container .payment-methods .method-item.active .method-check.data-v-13c3fb22::after {
content: "";
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
width: 12rpx;
height: 12rpx;
background: #fff;
border-radius: 50%;
}
.payment-container .payment-methods .method-item .method-icon.data-v-13c3fb22 {
width: 48rpx;
height: 48rpx;
margin-right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TMzOSBMNy4wMzU1MzM5MSwxOS4wMzU1MzM5IEwxMS4wMzU1MzM5LDE1LjAzNTUzMzkgWiBNOS4wMzU1MzM5MSw5LjAzNTUzMzkxIEwxMS4wMzU1MzM5LDExLjAzNTUzMzkgTDcuMDM1NTMzOTEsMTUuMDM1NTMzOSBMNS4wMzU1MzM5MSwxMy4wMzU1MzM5IEw5LjAzNTUzMzkxLDkuMDM1NTMzOTEgWiBNMy4wMzU1MzM5MSwxMS4wMzU1MzM5IEw1LjAzNTUzMzkxLDEzLjAzNTUzMzkgTDMuMDM1NTMzOTEsMTUuMDM1NTMzOSBMMS4wMzU1MzM5MSwxMy4wMzU1MzM5IEwzLjAzNTUzMzkxLDExLjAzNTUzMzkgWiBNMTMuMDM1NTMzOSw3LjAzNTUzMzkxIEwxNS4wMzU1MzM5LDkuMDM1NTMzOTEgTDExLjAzNTUzMzksMTMuMDM1NTMzOSBMOS4wMzU1MzM5MSwxMS4wMzU1MzM5IEwxMy4wMzU1MzM5LDcuMDM1NTMzOTEgWiBNMTcuMDM1NTMzOSwzLjAzNTUzMzkxIEwxOS4wMzU1MzM5LDUuMDM1NTMzOTEgTDE1LjAzNTUzMzksOS4wMzU1MzM5MSBMMTMuMDM1NTMzOSw3LjAzNTUzMzkxIEwxNy4wMzU1MzM5LDMuMDM1NTMzOTEgWiBNMjEuMDM1NTMzOSw3LjAzNTUzMzkxIEwyMy4wMzU1MzM5LDkuMDM1NTMzOTEgTDE5LjAzNTUzMzksMTMuMDM1NTMzOSBMMTcuMDM1NTMzOSwxMS4wMzU1MzM5IEwyMS4wMzU1MzM5LDcuMDM1NTMzOTEgWiIvPjwvc3ZnPg==") no-repeat center/contain;
}
.payment-container .payment-methods .method-item .method-name.data-v-13c3fb22 {
flex: 1;
font-size: 28rpx;
color: #333;
}
.payment-container .payment-methods .method-item .method-check.data-v-13c3fb22 {
width: 32rpx;
height: 32rpx;
border-radius: 50%;
border: 2rpx solid #ddd;
position: relative;
}
.payment-container .bottom-bar.data-v-13c3fb22 {
position: fixed;
left: 0;
right: 0;
bottom: 0;
background: #fff;
padding: 20rpx 30rpx;
padding-bottom: calc(20rpx + env(safe-area-inset-bottom));
display: flex;
align-items: center;
justify-content: space-between;
box-shadow: 0 -4rpx 16rpx rgba(0, 0, 0, 0.04);
}
.payment-container .bottom-bar .total-amount.data-v-13c3fb22 {
font-size: 28rpx;
color: #666;
}
.payment-container .bottom-bar .total-amount .amount.data-v-13c3fb22 {
font-size: 36rpx;
font-weight: 600;
color: #FF5722;
margin-left: 10rpx;
}
.payment-container .bottom-bar .pay-btn.data-v-13c3fb22 {
background: #1976D2;
color: #fff;
font-size: 32rpx;
font-weight: 600;
padding: 20rpx 60rpx;
border-radius: 100rpx;
border: none;
}
.payment-container .bottom-bar .pay-btn.data-v-13c3fb22:active {
opacity: 0.9;
}
+85
View File
@@ -0,0 +1,85 @@
"use strict";
const common_vendor = require("../../common/vendor.js");
const config_user = require("../../config/user.js");
const _sfc_main = {
data() {
return {
orderId: "",
orderInfo: {}
};
},
onLoad(options) {
if (options && options.orderId) {
this.orderId = options.orderId;
this.loadOrderInfo();
} else {
common_vendor.index.showToast({
title: "订单信息不存在",
icon: "none"
});
setTimeout(() => {
this.goToHome();
}, 1500);
}
},
methods: {
async loadOrderInfo() {
try {
common_vendor.index.showLoading({
title: "加载中"
});
const res = await config_user.queryById(this.orderId);
if (res.code === 200 && res.data) {
const orderData = res.data;
this.orderInfo = {
orderNo: orderData.orderNo || orderData.orderId,
deviceNo: orderData.deviceNo,
amount: orderData.amount,
payTime: this.formatTime(/* @__PURE__ */ new Date())
};
} else {
throw new Error("获取订单信息失败");
}
common_vendor.index.hideLoading();
} catch (error) {
common_vendor.index.hideLoading();
common_vendor.index.showToast({
title: error.message || "获取订单信息失败",
icon: "none"
});
}
},
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");
const second = date.getSeconds().toString().padStart(2, "0");
return `${year}-${month}-${day} ${hour}:${minute}:${second}`;
},
goToHome() {
common_vendor.index.switchTab({
url: "/pages/index/index"
});
},
goToOrderList() {
common_vendor.index.redirectTo({
url: "/pages/order/index"
});
}
}
};
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
return {
a: common_vendor.t($data.orderInfo.orderNo || "-"),
b: common_vendor.t($data.orderInfo.deviceNo || "-"),
c: common_vendor.t($data.orderInfo.amount || "0.00"),
d: common_vendor.t($data.orderInfo.payTime || "-"),
e: common_vendor.o((...args) => $options.goToHome && $options.goToHome(...args)),
f: common_vendor.o((...args) => $options.goToOrderList && $options.goToOrderList(...args))
};
}
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-2795c576"]]);
wx.createPage(MiniProgramPage);
//# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/order/success.js.map
+6
View File
@@ -0,0 +1,6 @@
{
"navigationBarTitleText": "支付成功",
"navigationBarBackgroundColor": "#ffffff",
"navigationBarTextStyle": "black",
"usingComponents": {}
}
+1
View File
@@ -0,0 +1 @@
<view class="success-container data-v-2795c576"><view class="status-card data-v-2795c576"><view class="status-icon success data-v-2795c576"></view><view class="status-text data-v-2795c576">支付成功</view><view class="status-desc data-v-2795c576">您的订单已支付成功</view></view><view class="order-card data-v-2795c576"><view class="card-title data-v-2795c576">订单信息</view><view class="info-item data-v-2795c576"><text class="label data-v-2795c576">订单号</text><text class="value data-v-2795c576">{{a}}</text></view><view class="info-item data-v-2795c576"><text class="label data-v-2795c576">设备号</text><text class="value data-v-2795c576">{{b}}</text></view><view class="info-item data-v-2795c576"><text class="label data-v-2795c576">支付金额</text><text class="value data-v-2795c576">¥{{c}}</text></view><view class="info-item data-v-2795c576"><text class="label data-v-2795c576">支付时间</text><text class="value data-v-2795c576">{{d}}</text></view></view><view class="button-group data-v-2795c576"><button class="primary-btn data-v-2795c576" bindtap="{{e}}">返回首页</button><button class="secondary-btn data-v-2795c576" bindtap="{{f}}">查看订单</button></view></view>
+123
View File
@@ -0,0 +1,123 @@
/**
* 这里是uni-app内置的常用样式变量
*
* uni-app 官方扩展插件及插件市场(https://ext.dcloud.net.cn)上很多三方插件均使用了这些样式变量
* 如果你是插件开发者,建议你使用scss预处理,并在插件代码中直接使用这些变量(无需 import 这个文件),方便用户通过搭积木的方式开发整体风格一致的App
*
*/
/**
* 如果你是App开发者(插件使用者),你可以通过修改这些变量来定制自己的插件主题,实现自定义主题功能
*
* 如果你的项目同样使用了scss预处理,你也可以直接在你的 scss 代码中使用如下变量,同时无需 import 这个文件
*/
/* 颜色变量 */
/* 行为相关颜色 */
/* 文字基本颜色 */
/* 背景颜色 */
/* 边框颜色 */
/* 尺寸变量 */
/* 文字尺寸 */
/* 图片尺寸 */
/* Border Radius */
/* 水平间距 */
/* 垂直间距 */
/* 透明度 */
/* 文章场景相关 */
.success-container.data-v-2795c576 {
padding: 20px;
background-color: #f5f5f5;
min-height: 100vh;
}
.status-card.data-v-2795c576 {
background-color: #fff;
border-radius: 12px;
padding: 30px;
text-align: center;
margin-bottom: 20px;
}
.status-card .status-icon.data-v-2795c576 {
width: 60px;
height: 60px;
margin: 0 auto 16px;
background-color: #07c160;
border-radius: 50%;
position: relative;
}
.status-card .status-icon.data-v-2795c576::after {
content: "";
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
width: 30px;
height: 20px;
border: 3px solid #fff;
border-top: none;
border-right: none;
transform-origin: center;
transform: translate(-50%, -70%) rotate(-45deg);
}
.status-card .status-text.data-v-2795c576 {
font-size: 24px;
font-weight: bold;
color: #07c160;
margin-bottom: 8px;
}
.status-card .status-desc.data-v-2795c576 {
font-size: 14px;
color: #666;
}
.order-card.data-v-2795c576 {
background-color: #fff;
border-radius: 12px;
padding: 20px;
margin-bottom: 20px;
}
.order-card .card-title.data-v-2795c576 {
font-size: 16px;
font-weight: bold;
margin-bottom: 16px;
color: #333;
}
.order-card .info-item.data-v-2795c576 {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 12px;
}
.order-card .info-item .label.data-v-2795c576 {
color: #666;
font-size: 14px;
}
.order-card .info-item .value.data-v-2795c576 {
color: #333;
font-size: 14px;
}
.button-group.data-v-2795c576 {
margin-top: 30px;
display: flex;
flex-direction: column;
gap: 16px;
}
.button-group .primary-btn.data-v-2795c576 {
background-color: #07c160;
color: #fff;
border: none;
border-radius: 24px;
padding: 12px;
font-size: 16px;
}
.button-group .primary-btn.data-v-2795c576:active {
opacity: 0.8;
}
.button-group .secondary-btn.data-v-2795c576 {
background-color: #fff;
color: #07c160;
border: 1px solid #07c160;
border-radius: 24px;
padding: 12px;
font-size: 16px;
}
.button-group .secondary-btn.data-v-2795c576:active {
background-color: #f5f5f5;
}
@@ -4,11 +4,11 @@ const config_user = require("../../config/user.js");
const _sfc_main = {
data() {
return {
deviceNo: "",
deviceId: "",
orderInfo: {
orderId: "",
startTime: "",
usedTime: "",
usedTime: "0分钟",
currentFee: "0.00"
},
unlocking: false,
@@ -16,55 +16,102 @@ const _sfc_main = {
};
},
onLoad(options) {
this.deviceNo = options.deviceNo;
this.getActiveOrder();
this.deviceId = options.deviceId || "";
this.orderInfo.orderId = options.orderId || "";
this.getOrderDetails();
this.startTimer();
},
onUnload() {
this.clearTimer();
},
methods: {
// 获取进行中的订单信息
async getActiveOrder() {
// 获取订单详情
async getOrderDetails() {
try {
common_vendor.index.showLoading({ title: "加载中" });
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: orderData.orderId,
startTime: this.formatTime(orderData.createTime),
usedTime: this.calculateUsedTime(orderData.createTime),
currentFee: orderData.amount || "0.00"
};
this.startTimer();
if (!this.orderInfo.orderId) {
throw new Error("订单ID不能为空");
}
const result = await config_user.queryById(this.orderInfo.orderId);
if (result.code === 200 && result.data) {
const orderData = result.data;
this.orderInfo.startTime = this.formatTime(new Date(orderData.createTime));
this.calculateUsedTime(orderData.createTime);
this.orderInfo.currentFee = orderData.amount || "0.00";
} else {
common_vendor.index.showToast({
title: "没有进行中的订单",
icon: "none"
});
setTimeout(() => {
common_vendor.index.reLaunch({
url: "/pages/index/index"
});
}, 1500);
throw new Error("获取订单详情失败");
}
} catch (error) {
common_vendor.index.__f__("error", "at pages/device/return.vue:112", "获取订单信息失败:", error);
common_vendor.index.showToast({
title: "获取订单信息失败",
title: error.message || "获取订单信息失败",
icon: "none"
});
setTimeout(() => {
common_vendor.index.reLaunch({
url: "/pages/index/index"
});
}, 1500);
} finally {
common_vendor.index.hideLoading();
}
},
// 处理归还请求
// 格式化时间
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}`;
},
// 计算使用时长
calculateUsedTime(startTime) {
const start = new Date(startTime);
const now = /* @__PURE__ */ new Date();
const diffMs = now - start;
const minutes = Math.floor(diffMs / (1e3 * 60));
if (minutes < 60) {
this.orderInfo.usedTime = `${minutes}分钟`;
} else {
const hours = Math.floor(minutes / 60);
const remainMinutes = minutes % 60;
this.orderInfo.usedTime = `${hours}小时${remainMinutes}分钟`;
}
},
// 更新使用时长的定时器
startTimer() {
this.timer = setInterval(() => {
this.getOrderDetails();
}, 6e4);
},
// 清除定时器
clearTimer() {
if (this.timer) {
clearInterval(this.timer);
this.timer = null;
}
},
// 处理开锁归还
async handleUnlock() {
if (this.unlocking)
return;
try {
this.unlocking = true;
common_vendor.index.showLoading({ title: "归还中" });
common_vendor.index.showLoading({ title: "开锁中" });
const confirmResult = await new Promise((resolve) => {
common_vendor.index.showModal({
title: "确认归还",
content: "确定要归还设备吗?",
success: (res) => {
resolve(res.confirm);
}
});
});
if (!confirmResult) {
this.unlocking = false;
common_vendor.index.hideLoading();
return;
}
const result = await config_user.overOrderById(this.orderInfo.orderId);
if (result.code === 200) {
common_vendor.index.showToast({
@@ -72,8 +119,8 @@ const _sfc_main = {
icon: "success"
});
setTimeout(() => {
common_vendor.index.redirectTo({
url: "/pages/order/index"
common_vendor.index.reLaunch({
url: "/pages/index/index"
});
}, 1500);
} else {
@@ -88,74 +135,21 @@ const _sfc_main = {
this.unlocking = false;
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(() => {
if (this.orderInfo.orderId) {
this.orderInfo.usedTime = this.calculateUsedTime(this.orderInfo.startTime);
}
}, 6e4);
},
clearTimer() {
if (this.timer) {
clearInterval(this.timer);
this.timer = null;
}
}
}
};
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
return {
a: common_vendor.t($data.orderInfo.orderId),
b: common_vendor.t($data.deviceNo),
c: common_vendor.t($data.orderInfo.createTime),
b: common_vendor.t($data.deviceId),
c: common_vendor.t($data.orderInfo.startTime),
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
};
}
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-df932504"]]);
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-6d22bdf8"]]);
wx.createPage(MiniProgramPage);
//# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/device/return.js.map
//# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/return/index.js.map
+1
View File
@@ -0,0 +1 @@
<view class="return-container data-v-6d22bdf8"><view class="order-card data-v-6d22bdf8"><view class="order-header data-v-6d22bdf8"><text class="title data-v-6d22bdf8">使用中</text><text class="order-no data-v-6d22bdf8">订单号:{{a}}</text></view><view class="device-info data-v-6d22bdf8"><text class="device-name data-v-6d22bdf8">共享风扇</text><text class="device-id data-v-6d22bdf8">设备号:{{b}}</text></view><view class="time-info data-v-6d22bdf8"><view class="time-item data-v-6d22bdf8"><text class="label data-v-6d22bdf8">开始时间</text><text class="value data-v-6d22bdf8">{{c}}</text></view><view class="time-item data-v-6d22bdf8"><text class="label data-v-6d22bdf8">已使用时长</text><text class="value highlight data-v-6d22bdf8">{{d}}</text></view><view class="time-item data-v-6d22bdf8"><text class="label data-v-6d22bdf8">当前费用</text><text class="value data-v-6d22bdf8">¥{{e}}</text></view></view></view><view class="notice-card data-v-6d22bdf8"><view class="notice-title data-v-6d22bdf8">归还说明</view><view class="notice-list data-v-6d22bdf8"><view class="notice-item data-v-6d22bdf8"><view class="dot data-v-6d22bdf8"></view><text class="data-v-6d22bdf8">请确保设备完好无损</text></view><view class="notice-item data-v-6d22bdf8"><view class="dot data-v-6d22bdf8"></view><text class="data-v-6d22bdf8">请在指定区域内归还设备</text></view><view class="notice-item data-v-6d22bdf8"><view class="dot data-v-6d22bdf8"></view><text class="data-v-6d22bdf8">归还后押金将自动退还</text></view></view></view><view class="bottom-bar data-v-6d22bdf8"><button class="unlock-btn data-v-6d22bdf8" bindtap="{{g}}" disabled="{{h}}">{{f}}</button></view></view>
@@ -23,101 +23,102 @@
/* 垂直间距 */
/* 透明度 */
/* 文章场景相关 */
.return-container.data-v-df932504 {
.return-container.data-v-6d22bdf8 {
min-height: 100vh;
background: #f8f8f8;
padding: 30rpx;
padding-bottom: 180rpx;
box-sizing: border-box;
}
.return-container .order-card.data-v-df932504 {
.return-container .order-card.data-v-6d22bdf8 {
background: #fff;
border-radius: 24rpx;
padding: 30rpx;
margin-bottom: 30rpx;
box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.04);
}
.return-container .order-card .order-header.data-v-df932504 {
.return-container .order-card .order-header.data-v-6d22bdf8 {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 30rpx;
}
.return-container .order-card .order-header .title.data-v-df932504 {
.return-container .order-card .order-header .title.data-v-6d22bdf8 {
font-size: 36rpx;
font-weight: 600;
color: #1976D2;
}
.return-container .order-card .order-header .order-no.data-v-df932504 {
.return-container .order-card .order-header .order-no.data-v-6d22bdf8 {
font-size: 24rpx;
color: #999;
}
.return-container .order-card .device-info.data-v-df932504 {
margin-bottom: 30rpx;
.return-container .order-card .device-info.data-v-6d22bdf8 {
margin-bottom: 20rpx;
}
.return-container .order-card .device-info .device-name.data-v-df932504 {
.return-container .order-card .device-info .device-name.data-v-6d22bdf8 {
font-size: 32rpx;
font-weight: 500;
color: #333;
margin-right: 20rpx;
}
.return-container .order-card .device-info .device-id.data-v-df932504 {
.return-container .order-card .device-info .device-id.data-v-6d22bdf8 {
font-size: 24rpx;
color: #666;
}
.return-container .order-card .time-info .time-item.data-v-df932504 {
.return-container .order-card .time-info .time-item.data-v-6d22bdf8 {
display: flex;
justify-content: space-between;
margin-bottom: 20rpx;
margin-bottom: 16rpx;
}
.return-container .order-card .time-info .time-item.data-v-df932504:last-child {
.return-container .order-card .time-info .time-item.data-v-6d22bdf8:last-child {
margin-bottom: 0;
}
.return-container .order-card .time-info .time-item .label.data-v-df932504 {
.return-container .order-card .time-info .time-item .label.data-v-6d22bdf8 {
font-size: 28rpx;
color: #666;
}
.return-container .order-card .time-info .time-item .value.data-v-df932504 {
.return-container .order-card .time-info .time-item .value.data-v-6d22bdf8 {
font-size: 28rpx;
color: #333;
}
.return-container .order-card .time-info .time-item .value.highlight.data-v-df932504 {
.return-container .order-card .time-info .time-item .value.highlight.data-v-6d22bdf8 {
color: #1976D2;
font-weight: 500;
}
.return-container .notice-card.data-v-df932504 {
.return-container .notice-card.data-v-6d22bdf8 {
background: #fff;
border-radius: 24rpx;
padding: 30rpx;
margin-bottom: 30rpx;
box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.04);
}
.return-container .notice-card .notice-title.data-v-df932504 {
.return-container .notice-card .notice-title.data-v-6d22bdf8 {
font-size: 32rpx;
font-weight: 600;
color: #333;
margin-bottom: 24rpx;
}
.return-container .notice-card .notice-list .notice-item.data-v-df932504 {
.return-container .notice-card .notice-list .notice-item.data-v-6d22bdf8 {
display: flex;
align-items: center;
margin-bottom: 16rpx;
}
.return-container .notice-card .notice-list .notice-item.data-v-df932504:last-child {
.return-container .notice-card .notice-list .notice-item.data-v-6d22bdf8:last-child {
margin-bottom: 0;
}
.return-container .notice-card .notice-list .notice-item .dot.data-v-df932504 {
.return-container .notice-card .notice-list .notice-item .dot.data-v-6d22bdf8 {
width: 12rpx;
height: 12rpx;
background: #1976D2;
border-radius: 50%;
margin-right: 16rpx;
}
.return-container .notice-card .notice-list .notice-item text.data-v-df932504 {
.return-container .notice-card .notice-list .notice-item text.data-v-6d22bdf8 {
font-size: 28rpx;
color: #666;
line-height: 1.5;
}
.return-container .bottom-bar.data-v-df932504 {
.return-container .bottom-bar.data-v-6d22bdf8 {
position: fixed;
left: 0;
right: 0;
@@ -126,14 +127,15 @@
padding: 20rpx 30rpx;
padding-bottom: calc(20rpx + env(safe-area-inset-bottom));
display: flex;
align-items: center;
justify-content: center;
box-shadow: 0 -4rpx 16rpx rgba(0, 0, 0, 0.04);
}
.return-container .bottom-bar .unlock-btn.data-v-df932504 {
width: 80%;
.return-container .bottom-bar .unlock-btn.data-v-6d22bdf8 {
width: 100%;
height: 88rpx;
background: linear-gradient(135deg, #1976D2, #42A5F5);
border-radius: 44rpx;
background: linear-gradient(135deg, #FF9800, #FFB74D);
color: #fff;
font-size: 32rpx;
font-weight: 600;
@@ -142,10 +144,9 @@
justify-content: center;
border: none;
}
.return-container .bottom-bar .unlock-btn.data-v-df932504:active {
.return-container .bottom-bar .unlock-btn.data-v-6d22bdf8:active {
transform: scale(0.98);
}
.return-container .bottom-bar .unlock-btn[disabled].data-v-df932504 {
background: #ccc;
transform: none;
.return-container .bottom-bar .unlock-btn.data-v-6d22bdf8:disabled {
opacity: 0.7;
}
+5 -4
View File
@@ -14,16 +14,17 @@ const _sfc_main = {
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.hideLoading();
common_vendor.index.showToast({
title: "设备编号不能为空",
icon: "none"
});
return;
}
if (result.data.length != 0) {
const result = await config_user.queryHasOrder(option.deviceNo);
common_vendor.index.hideLoading();
if (result.data && result.data.data && result.data.data.length > 0) {
common_vendor.index.redirectTo({
url: `/pages/device/return?deviceNo=${option.deviceNo}`
});
@@ -38,7 +39,7 @@ const _sfc_main = {
title: "页面加载失败,请重试",
icon: "none"
});
common_vendor.index.__f__("error", "at pages/serve/bagCheck/index.vue:60", "bagCheck onLoad error:", error);
common_vendor.index.__f__("error", "at pages/serve/bagCheck/index.vue:62", "bagCheck onLoad error:", error);
}
},
methods: {}