style:修改页面样式

This commit is contained in:
2025-07-25 14:39:34 +08:00
parent 6494721f81
commit 45f80e469a
21 changed files with 1237 additions and 1375 deletions
+243 -312
View File
@@ -1,29 +1,17 @@
<template>
<view class="details-container">
<!-- 订单状态卡片 -->
<view class="status-card">
<view class="status-icon" :class="orderStatusClass"></view>
<view class="status-text">{{ orderStatusText }}</view>
<view class="status-desc">{{ orderStatusDesc }}</view>
</view>
<view class="return-container">
<!-- 订单信息卡片 -->
<view class="info-card">
<view class="card-title">订单信息</view>
<view class="info-item">
<text class="label">订单号</text>
<text class="value">{{ orderInfo.orderNo || '-' }}</text>
<view class="order-card">
<view class="order-header">
<text class="title">{{ orderStatusText }}</text>
<text class="order-no">订单号{{ orderInfo.orderNo || '-' }}</text>
</view>
<view class="info-item">
<text class="label">设备号</text>
<text class="value">{{ orderInfo.deviceNo || '-' }}</text>
</view>
<view class="info-item">
<text class="label">租借方式</text>
<view class="value payment-method">
<!-- <text>{{ paymentMethod }}</text> -->
<!-- 支付方式标识 -->
<view class="device-info">
<view class="device-left">
<view class="device-name">共享风扇</view>
<view class="device-id">设备号{{ orderInfo.deviceNo || '-' }}</view>
</view>
<view class="device-right">
<view class="payment-badge wx-score" v-if="orderInfo.payWay === 'wx_score_pay'">
<image src="/static/images/wxpayflag.png" mode="aspectFit" class="badge-icon"></image>
<view class="badge-text">
@@ -32,114 +20,76 @@
<text class="highlight">免押租借</text>
</view>
</view>
<!-- 押金租借标识 -->
<view class="payment-badge deposit" v-else>
<text class="badge-text">押金租借</text>
</view>
</view>
</view>
<view class="info-item">
<text class="label">创建时间</text>
<text class="value">{{ orderInfo.createTime || '-' }}</text>
</view>
<view class="info-item">
<text class="label">开始时间</text>
<text class="value">{{ orderInfo.startTime || '-' }}</text>
</view>
<view class="info-item" v-if="orderInfo.endTime">
<text class="label">结束时间</text>
<text class="value">{{ orderInfo.endTime }}</text>
</view>
<view class="info-item" v-if="orderInfo.phone">
<text class="label">联系电话</text>
<text class="value">{{ orderInfo.phone }}</text>
<view class="time-info">
<!-- <view class="time-item">
<text class="label">创建时间</text>
<text class="value">{{ orderInfo.createTime || '-' }}</text>
</view> -->
<view class="time-item">
<text class="label">开始时间</text>
<text class="value">{{ orderInfo.startTime || '-' }}</text>
</view>
<view class="time-item" v-if="orderInfo.endTime">
<text class="label">结束时间</text>
<text class="value">{{ orderInfo.endTime }}</text>
</view>
<view class="time-item" v-if="orderInfo.phone">
<text class="label">联系电话</text>
<text class="value">{{ orderInfo.phone }}</text>
</view>
</view>
</view>
<!-- 费用信息卡片 -->
<view class="info-card">
<view class="card-title">费用信息</view>
<view class="info-item" v-if="orderInfo.depositAmount">
<text class="label">押金</text>
<text class="value">{{ orderInfo.depositAmount }}</text>
</view>
<view class="info-item" v-if="orderInfo.packageTime && orderInfo.packagePrice">
<text class="label">套餐</text>
<text class="value">{{ orderInfo.packagePrice }} / {{ formatTime(orderInfo.packageTime) }}</text>
</view>
<view class="info-item total">
<text class="label">合计</text>
<text class="value">{{ orderInfo.payAmount || 0 }}</text>
<view class="notice-card">
<view class="notice-title">费用信息</view>
<view class="notice-list">
<view class="notice-item" v-if="orderInfo.depositAmount">
<view class="dot"></view>
<text>押金{{ orderInfo.depositAmount }}</text>
</view>
<view class="notice-item" v-if="orderInfo.packageTime && orderInfo.packagePrice">
<view class="dot"></view>
<text>套餐{{ orderInfo.packagePrice }} / {{ formatTime(orderInfo.packageTime) }}</text>
</view>
<view class="notice-item">
<view class="dot"></view>
<text>合计{{ orderInfo.payAmount || 0 }}</text>
</view>
</view>
</view>
<!-- 操作按钮 -->
<view class="action-buttons" v-if="orderInfo.orderStatus === 'waiting_for_payment'">
<view class="btn cancel" @click="handleCancelOrder">取消订单</view>
<view class="btn primary" @click="handlePayment">立即支付</view>
</view>
<view class="action-buttons" v-else-if="orderInfo.orderStatus === 'in_used'">
<view class="btn primary" @click="navigateToReturn">归还设备</view>
</view>
<!-- 底部操作栏 -->
<!-- <view class="bottom-bar">
<view class="action-item secondary" v-if="orderInfo.orderStatus == 'waiting_for_payment'" @click="handleCancelOrder">取消订单</view>
<view class="action-item primary" v-if="orderInfo.orderStatus == 'waiting_for_payment'" @click="handlePayment">立即支付</view>
<view class="action-item primary" v-else-if="orderInfo.orderStatus == 'in_used'" @click="navigateToReturn">归还设备</view>
</view> -->
</view>
</template>
<script setup>
import { ref, computed, onMounted } from 'vue';
import { ref, computed } from 'vue';
import { onLoad } from '@dcloudio/uni-app';
import { queryById, cancelOrder, confirmPaymentAndRent } from '@/config/user.js';
const orderId = ref('');
const orderInfo = ref({});
// 状态计算属性
const orderStatusText = computed(() => {
const status = orderInfo.value.orderStatus;
switch(status) {
case 'waiting_for_payment': return '待支付';
case 'waiting_for_payment': return '待支付';
case 'in_used': return '使用中';
case 'used_done': return '已完成';
case 'order_cancelled': return '已取消';
default: return '未知状态';
default: return '使用中';
}
});
const orderStatusClass = computed(() => {
const status = orderInfo.value.orderStatus;
switch(status) {
case 'waiting_for_payment': return 'status-waiting';
case 'in_used': return 'status-using';
case 'used_done': return 'status-finished';
case 'order_cancelled': return 'status-cancelled';
default: return '';
}
});
const orderStatusDesc = computed(() => {
const status = orderInfo.value.orderStatus;
switch(status) {
case 'waiting_for_payment': return '请在15分钟内完成支付';
case 'in_used': return '设备正在使用中';
case 'used_done': return '感谢您的使用';
case 'order_cancelled': return '该订单已取消';
default: return '';
}
});
const paymentMethod = computed(() => {
const payWay = orderInfo.value.payWay;
if (payWay === 'wx_score_pay') {
return '微信支付分 (免押金)';
} else if (payWay === 'wx_pay') {
return '微信支付';
} else {
return '押金支付';
}
});
// 页面加载
onLoad(async (options) => {
if (options && options.orderId) {
orderId.value = options.orderId;
@@ -155,18 +105,12 @@ onLoad(async (options) => {
}
});
// 加载订单详情
const loadOrderDetails = async () => {
try {
uni.showLoading({
title: '加载中'
});
uni.showLoading({ title: '加载中' });
const res = await queryById(orderId.value);
if (res.code === 200 && res.data) {
orderInfo.value = res.data;
// 格式化时间
if (orderInfo.value.createTime) {
orderInfo.value.createTime = formatDateTime(new Date(orderInfo.value.createTime));
}
@@ -179,7 +123,6 @@ const loadOrderDetails = async () => {
} else {
throw new Error('获取订单详情失败');
}
uni.hideLoading();
} catch (error) {
uni.hideLoading();
@@ -190,7 +133,6 @@ const loadOrderDetails = async () => {
}
};
// 格式化时间
const formatDateTime = (date) => {
const year = date.getFullYear();
const month = (date.getMonth() + 1).toString().padStart(2, '0');
@@ -200,10 +142,8 @@ const formatDateTime = (date) => {
return `${year}-${month}-${day} ${hour}:${minute}`;
};
// 格式化套餐时间
const formatTime = (minutes) => {
if (!minutes) return '';
const mins = parseInt(minutes);
if (mins < 60) {
return `${mins}分钟`;
@@ -214,7 +154,6 @@ const formatTime = (minutes) => {
}
};
// 取消订单
const handleCancelOrder = () => {
uni.showModal({
title: '确认取消',
@@ -223,65 +162,40 @@ const handleCancelOrder = () => {
if (res.confirm) {
try {
uni.showLoading({ title: '处理中' });
const result = await cancelOrder({
orderId: orderId.value
});
const result = await cancelOrder({ orderId: orderId.value });
if (result.code === 200) {
uni.hideLoading();
uni.showToast({
title: '订单已取消',
icon: 'success'
});
// 重新加载订单详情
uni.showToast({ title: '订单已取消', icon: 'success' });
await loadOrderDetails();
} else {
throw new Error(result.msg || '取消订单失败');
}
} catch (error) {
uni.hideLoading();
uni.showToast({
title: error.message || '取消订单失败',
icon: 'none'
});
uni.showToast({ title: error.message || '取消订单失败', icon: 'none' });
}
}
}
});
};
// 立即支付
const handlePayment = async () => {
try {
uni.showLoading({
title: '处理中'
});
uni.showLoading({ title: '处理中' });
const res = await confirmPaymentAndRent(orderId.value);
if (res.code === 200) {
uni.hideLoading();
uni.showToast({
title: '支付成功',
icon: 'success'
});
// 重新加载订单详情
uni.showToast({ title: '支付成功', icon: 'success' });
await loadOrderDetails();
} else {
throw new Error(res.msg || '支付失败');
}
} catch (error) {
uni.hideLoading();
uni.showToast({
title: error.message || '支付失败',
icon: 'none'
});
uni.showToast({ title: error.message || '支付失败', icon: 'none' });
}
};
// 跳转到归还页面
const navigateToReturn = () => {
uni.navigateTo({
url: `/pages/return/index?deviceId=${orderInfo.value.deviceNo}&orderId=${orderId.value}`
@@ -290,209 +204,226 @@ const navigateToReturn = () => {
</script>
<style lang="scss" scoped>
.details-container {
.return-container {
min-height: 100vh;
background: #f7f8fa;
padding: 30rpx;
padding-bottom: 100rpx;
padding-bottom: 180rpx;
box-sizing: border-box;
// 状态卡片
.status-card {
background: #fff;
border-radius: 20rpx;
padding: 40rpx;
display: flex;
flex-direction: column;
align-items: center;
margin-bottom: 30rpx;
box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.04);
.status-icon {
width: 120rpx;
height: 120rpx;
border-radius: 50%;
margin-bottom: 20rpx;
&.status-waiting {
background: #FFF9C4;
}
&.status-using {
background: #E8F5E9;
}
&.status-finished {
background: #E3F2FD;
}
&.status-cancelled {
background: #FFEBEE;
}
}
.status-text {
font-size: 36rpx;
font-weight: 600;
color: #333;
margin-bottom: 10rpx;
}
.status-desc {
font-size: 28rpx;
color: #999;
}
}
// 信息卡片
.info-card {
.order-card {
background: #fff;
border-radius: 20rpx;
padding: 30rpx;
margin-bottom: 30rpx;
box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.04);
.card-title {
font-size: 32rpx;
font-weight: 600;
color: #333;
margin-bottom: 20rpx;
position: relative;
padding-left: 20rpx;
&::before {
content: '';
position: absolute;
left: 0;
top: 50%;
transform: translateY(-50%);
width: 8rpx;
height: 32rpx;
background: #1976D2;
border-radius: 4rpx;
}
}
.info-item {
.order-header {
display: flex;
justify-content: space-between;
align-items: center;
padding: 20rpx 0;
border-bottom: 1px solid #f5f5f5;
&:last-child {
border-bottom: none;
}
.label {
font-size: 28rpx;
color: #666;
}
.value {
font-size: 28rpx;
margin-bottom: 20rpx;
padding-bottom: 16rpx;
border-bottom: 1rpx solid #f0f0f0;
.title {
font-size: 30rpx;
font-weight: bold;
color: #333;
word-break: break-all;
text-align: right;
max-width: 70%;
&.payment-method {
display: flex;
flex-direction: column;
align-items: flex-end;
.payment-badge {
margin-top: 8rpx;
display: flex;
align-items: center;
padding: 4rpx 10rpx;
border-radius: 8rpx;
&.wx-score {
background: rgba(7, 193, 96, 0.08);
.badge-icon {
width: 32rpx;
height: 26rpx;
margin-right: 8rpx;
}
.badge-text {
font-size: 22rpx;
color: #07c160;
display: flex;
align-items: center;
.divider {
margin: 0 6rpx;
}
.highlight {
font-weight: 500;
}
}
}
.order-no {
font-size: 24rpx;
color: #999;
}
}
.device-info {
margin-bottom: 24rpx;
display: flex;
justify-content: space-between;
align-items: flex-start;
.device-left {
flex: 1;
margin-right: 20rpx;
.device-name {
font-size: 32rpx;
font-weight: 500;
color: #333;
margin-bottom: 8rpx;
}
.device-id {
font-size: 26rpx;
color: #999;
margin-bottom: 0;
}
}
.device-right {
.payment-badge {
display: inline-flex;
align-items: center;
padding: 6rpx 12rpx;
border-radius: 8rpx;
white-space: nowrap;
&.wx-score {
background: rgba(7, 193, 96, 0.08);
.badge-icon {
width: 32rpx;
height: 26rpx;
margin-right: 8rpx;
}
&.deposit {
background: #f5f5f5;
.badge-text {
font-size: 22rpx;
color: #666;
.badge-text {
font-size: 22rpx;
color: #07c160;
display: flex;
align-items: center;
.divider {
margin: 0 6rpx;
}
.highlight {
font-weight: 500;
}
}
}
&.deposit {
background: #f5f5f5;
.badge-text {
font-size: 22rpx;
color: #666;
font-weight: 500;
}
}
}
}
&.total {
margin-top: 10rpx;
padding-top: 30rpx;
border-top: 1px solid #f5f5f5;
.label, .value {
font-size: 32rpx;
font-weight: 600;
color: #333;
}
.time-info {
background: #f9f9f9;
border-radius: 16rpx;
padding: 20rpx;
.time-item {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 16rpx;
&:last-child {
margin-bottom: 0;
}
.label {
font-size: 26rpx;
color: #666;
}
.value {
color: #FF5722;
font-size: 26rpx;
color: #333;
&.highlight {
color: #ff6b6b;
font-weight: bold;
}
}
}
}
}
// 操作按钮
.action-buttons {
.notice-card {
background: #fff;
border-radius: 20rpx;
padding: 30rpx;
margin-bottom: 30rpx;
box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.04);
.notice-title {
font-size: 30rpx;
font-weight: bold;
color: #333;
margin-bottom: 20rpx;
}
.notice-list {
.notice-item {
display: flex;
align-items: flex-start;
margin-bottom: 16rpx;
&:last-child {
margin-bottom: 0;
}
.dot {
width: 12rpx;
height: 12rpx;
background: #07c160;
border-radius: 50%;
margin-top: 10rpx;
margin-right: 16rpx;
flex-shrink: 0;
}
text {
font-size: 26rpx;
color: #666;
line-height: 1.5;
}
}
}
}
.bottom-bar {
position: fixed;
left: 0;
right: 0;
bottom: 0;
padding: 20rpx 30rpx;
padding-bottom: calc(20rpx + env(safe-area-inset-bottom));
background: #fff;
box-shadow: 0 -4rpx 16rpx rgba(0, 0, 0, 0.04);
z-index: 10;
display: flex;
justify-content: space-between;
padding: 30rpx 0;
.btn {
flex: 1;
gap: 20rpx;
.action-item {
height: 88rpx;
display: flex;
align-items: center;
justify-content: center;
font-size: 32rpx;
font-weight: 500;
font-size: 30rpx;
border-radius: 44rpx;
&.cancel {
background: #f5f5f5;
color: #666;
margin-right: 20rpx;
}
flex: 1;
&.primary {
background: #1976D2;
background: #07c160;
color: #fff;
&:active {
opacity: 0.8;
}
}
&:active {
opacity: 0.9;
&.secondary {
background: #f5f5f5;
color: #333;
border: 1rpx solid #e0e0e0;
&:active {
opacity: 0.8;
}
}
}
}
+1 -1
View File
@@ -122,7 +122,7 @@ export default {
this.orderId = options.orderId
if (options.totalAmount) {
this.passedTotalAmount = options.totalAmount;
this.passedTotalAmount = options.depositAmount;
}
if (options.depositAmount) {