style:根据支付分免押规范进行页面样式变更(整体)

This commit is contained in:
2025-06-30 09:09:08 +08:00
parent 8ac1666e6b
commit 7be1e97b7c
77 changed files with 2141 additions and 1420 deletions
+492 -278
View File
@@ -1,313 +1,527 @@
<template>
<view class="order-container">
<!-- 状态切换 -->
<view class="tab-bar">
<view
v-for="(tab, index) in OrderStatusTabs"
:key="index"
class="tab-item"
:class="{ active: currentTab === index }"
@click="switchTab(index)"
>
{{ tab.text }}
</view>
</view>
<view class="order-container">
<!-- 状态切换 -->
<view class="status-tabs">
<view v-for="(tab, index) in orderStatusTabs" :key="index" class="tab-item"
:class="{ active: currentTab === index }" @click="switchTab(index)">
{{ tab.text }}
</view>
</view>
<!-- 订单列表 -->
<view class="order-list">
<view class="order-item" v-for="(order, index) in orderList" :key="index">
<view class="order-header">
<text class="order-no">订单号{{ order.orderNo }}</text>
<text class="order-status" :class="OrderStatusMap[order.status]?.class">{{ OrderStatusMap[order.status]?.text }}</text>
<navigator v-if="order.status === 1" :url="`/pages/return/index?deviceId=${order.deviceId}&orderId=${order.orderNo}`" class="return-btn">归还设备</navigator>
</view>
<view class="order-content">
<view class="device-info">
<text class="device-name">共享风扇</text>
<text class="device-id">设备号{{ order.deviceId }}</text>
</view>
<view class="time-info">
<view class="time-item">
<text class="label">开始时间</text>
<text class="value">{{ order.startTime }}</text>
</view>
<view class="time-item">
<text class="label">结束时间</text>
<text class="value">{{ order.endTime || '-' }}</text>
</view>
</view>
<view class="price-info">
<text class="amount">{{ order.amount }}</text>
</view>
</view>
</view>
</view>
<!-- 订单列表 -->
<view class="order-list">
<view class="empty-state" v-if="orderList.length === 0">
<view class="empty-icon"></view>
<text class="empty-text">暂无订单记录</text>
</view>
<!-- 无数据提示 -->
<view class="empty-tip" v-if="orderList.length === 0">
<view class="empty-icon"></view>
<text>暂无订单记录</text>
</view>
</view>
<view class="order-item" v-for="(order, index) in orderList" :key="index">
<!-- 订单头部信息 -->
<view class="order-header">
<view class="order-id">
<text>订单号{{ order.orderNo }}</text>
</view>
<view class="order-status" :class="orderStatusMap[order.status]?.class">
{{ orderStatusMap[order.status]?.text }}
</view>
</view>
<!-- 订单内容 -->
<view class="order-body">
<view class="device-info">
<view class="device-left">
<view class="device-name">共享风扇</view>
<view class="device-id">设备号{{ order.deviceId }}</view>
</view>
<!-- 支付方式标识 -->
<view class="device-right">
<!-- 微信支付分标识 -->
<view class="payment-badge wx-score" v-if="order.payWay == 'wx_score_pay'">
<image src="/static/images/wxpayflag.png" mode="aspectFit" class="badge-icon"></image>
<view class="badge-text">
<text>微信支付分</text>
<text class="divider">|</text>
<text class="highlight">免押租借</text>
</view>
</view>
<!-- 押金租借标识 -->
<view class="payment-badge deposit" v-else>
<text class="badge-text">押金租借</text>
</view>
</view>
</view>
<!-- 订单时间信息 -->
<view class="order-times">
<view class="time-row">
<text class="time-label">开始时间</text>
<text class="time-value">{{ order.startTime }}</text>
</view>
<view class="time-row">
<text class="time-label">结束时间</text>
<text class="time-value">{{ order.endTime || '-' }}</text>
</view>
</view>
</view>
<!-- 订单底部 -->
<view class="order-footer">
<view class="price">{{ order.amount }}</view>
<view class="actions">
<view v-if="order.status=='in_used'" class="action-item primary" @click="navigateToReturn(order.deviceId, order.orderId)">
归还设备
</view>
<view v-if="order.status === 'waiting_for_payment'" class="action-item secondary"
@click="getOrderStatus(order)">
同步订单状态
</view>
</view>
</view>
</view>
</view>
</view>
</template>
<script>
import {getOrderList, queryById} from '../../config/user.js'
import { OrderStatusMap, OrderStatusTabs } from '../../constants/orderStatus.js'
<script setup>
import {
ref,
reactive,
onMounted
} from 'vue';
import {
onLoad
} from '@dcloudio/uni-app';
import {
getOrderList,
queryById,
getOrderByOrderNoScorePayStatus
} from '../../config/user.js';
export default {
data() {
return {
currentTab: 0,
OrderStatusMap,
OrderStatusTabs,
orderList: []
}
},
async onLoad(options) {
// 如果有传入orderId参数,说明是从设备租借页面跳转过来的
if (options && options.orderId) {
try {
// 获取特定订单信息
const res = await queryById(options.orderId);
if (res.code === 200 && res.data) {
// 将获取到的订单添加到列表中
const orderData = res.data;
console.log('特定订单数据:', JSON.stringify(orderData));
console.log('特定订单的开始时间:', orderData.startTime);
console.log('特定订单的创建时间:', orderData.createTime);
// 使用实际的startTime字段,如果没有则尝试使用createTime
const orderStartTime = orderData.startTime || orderData.createTime || '';
console.log('特定订单最终显示的开始时间:', orderStartTime);
// 格式化订单数据
const formattedOrder = {
orderNo: orderData.orderId,
status: orderData.orderStatus,
deviceId: orderData.deviceNo,
startTime: orderStartTime,
endTime: orderData.endTime || '',
amount: orderData.payAmount || orderData.actualDeviceAmount || '0.00'
};
// 将订单添加到列表开头
this.orderList = [formattedOrder, ...this.orderList];
// 根据订单状态切换到对应标签
const tabIndex = this.OrderStatusTabs.findIndex(tab =>
tab.status.includes(orderData.orderStatus)
);
if (tabIndex !== -1) {
this.switchTab(tabIndex);
}
}
} catch (error) {
console.error('获取订单详情失败:', error);
}
}
// 获取订单列表
await this.getOrderList();
},
methods: {
async getOrderList(statusList = []) {
try {
const res = await getOrderList(statusList);
if (res.code === 200 && res.data && res.data.records) {
console.log('API返回的订单列表数据:', JSON.stringify(res.data.records));
// 处理订单列表数据
this.orderList = res.data.records.map(item => {
console.log(`订单 ${item.orderId} 的开始时间:`, item.startTime);
console.log(`订单 ${item.orderId} 的创建时间:`, item.createTime);
// 使用实际的startTime字段,如果没有则尝试使用createTime
const orderStartTime = item.startTime || item.createTime || '';
console.log(`订单 ${item.orderId} 最终显示的开始时间:`, orderStartTime);
return {
orderNo: item.orderId,
status: item.orderStatus,
deviceId: item.deviceNo,
startTime: orderStartTime,
endTime: item.endTime || '',
amount: item.payAmount || item.actualDeviceAmount || '0.00'
};
});
}
} catch (error) {
console.error('获取订单列表失败:', error);
uni.showToast({
title: '获取订单列表失败',
icon: 'none'
});
}
},
async switchTab(index) {
this.currentTab = index;
// 根据状态获取订单列表
const statusList = this.OrderStatusTabs[index].status;
await this.getOrderList(statusList);
}
}
}
// 初始化状态
const currentTab = ref(0);
const orderList = ref([]);
// 订单状态映射
const orderStatusMap = reactive({
'0': {
text: '待支付',
class: 'status-waiting'
},
'1': {
text: '使用中',
class: 'status-using'
},
'2': {
text: '已完成',
class: 'status-finished'
},
'3': {
text: '已取消',
class: 'status-cancelled'
},
'waiting_for_payment': {
text: '待支付',
class: 'status-waiting'
},
'in_used': {
text: '使用中',
class: 'status-using'
},
'used_done': {
text: '已完成',
class: 'status-finished'
},
'canceled': {
text: '已取消',
class: 'status-cancelled'
}
});
// 订单状态标签
const orderStatusTabs = reactive([{
text: '全部',
status: []
},
{
text: '使用中',
status: ['1', 'in_used']
},
{
text: '已完成',
status: ['2', 'used_done']
},
{
text: '已取消',
status: ['3', 'canceled']
}
]);
// 页面加载
onLoad(async (options) => {
// 如果有传入orderId参数,说明是从设备租借页面跳转过来的
if (options && options.orderId) {
try {
// 获取特定订单信息
const res = await queryById(options.orderId);
if (res.code === 200 && res.data) {
// 获取到的订单数据
const orderData = res.data;
// 使用实际的startTime字段,如果没有则尝试使用createTime
const orderStartTime = orderData.startTime || orderData.createTime || '';
// 格式化订单数据
const formattedOrder = {
orderNo: orderData.orderId,
status: orderData.orderStatus,
deviceId: orderData.deviceNo,
payWay: orderData.payWay,
startTime: orderStartTime,
endTime: orderData.endTime || '',
amount: orderData.payAmount || orderData.actualDeviceAmount || '0.00'
};
// 将订单添加到列表开头
orderList.value = [formattedOrder, ...orderList.value];
// 根据订单状态切换到对应标签
const tabIndex = orderStatusTabs.findIndex(tab =>
tab.status.includes(orderData.orderStatus)
);
if (tabIndex !== -1) {
switchTab(tabIndex);
}
}
} catch (error) {
console.error('获取订单详情失败:', error);
}
}
// 获取订单列表
await loadOrderList();
});
// 切换标签
const switchTab = async (index) => {
currentTab.value = index;
// 根据状态获取订单列表
const statusList = orderStatusTabs[index].status;
await loadOrderList(statusList);
};
// 加载订单列表
const loadOrderList = async (statusList = []) => {
try {
const res = await getOrderList(statusList);
if (res.code === 200 && res.data && res.data.records) {
// 处理订单列表数据
orderList.value = res.data.records.map(item => {
// 使用实际的startTime字段,如果没有则尝试使用createTime
const orderStartTime = item.startTime || item.createTime || '';
return {
orderNo: item.orderNo,
orderId: item.orderId,
status: item.orderStatus,
deviceId: item.deviceNo,
payWay: item.payWay,
startTime: orderStartTime,
endTime: item.endTime || '',
amount: item.payAmount || item.actualDeviceAmount || '0.00'
};
});
}
} catch (error) {
console.error('获取订单列表失败:', error);
uni.showToast({
title: '获取订单列表失败',
icon: 'none'
});
}
};
// 同步订单状态
const getOrderStatus = async (order) => {
try {
const res = await getOrderByOrderNoScorePayStatus(order.orderNo);
if (res.code === 200) {
uni.showToast({
title: '状态同步成功',
icon: 'success'
});
await loadOrderList(orderStatusTabs[currentTab.value].status);
}
} catch (error) {
uni.showToast({
title: '同步状态失败',
icon: 'none'
});
}
};
// 跳转到归还设备页面
const navigateToReturn = (deviceId, orderId) => {
console.log(orderId);
uni.navigateTo({
url: `/pages/return/index?deviceId=${deviceId}&orderId=${orderId}`
});
};
</script>
<style lang="scss" scoped>
.order-container {
min-height: 100vh;
background: #f8f8f8;
.order-container {
min-height: 100vh;
background: #f7f8fa;
padding-bottom: 30rpx;
.tab-bar {
display: flex;
background: #fff;
padding: 20rpx 0;
position: sticky;
top: 0;
z-index: 100;
box-shadow: 0 2rpx 10rpx rgba(0,0,0,0.05);
// 状态标签栏
.status-tabs {
display: flex;
background: #fff;
padding: 0 20rpx;
position: sticky;
top: 0;
z-index: 10;
box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.05);
.tab-item {
flex: 1;
text-align: center;
font-size: 28rpx;
color: #666;
position: relative;
padding: 20rpx 0;
.tab-item {
flex: 1;
height: 90rpx;
display: flex;
align-items: center;
justify-content: center;
font-size: 28rpx;
color: #666;
position: relative;
&.active {
color: #1976D2;
font-weight: 500;
&.active {
color: #1976D2;
font-weight: 500;
&::after {
content: '';
position: absolute;
bottom: 0;
left: 50%;
transform: translateX(-50%);
width: 40rpx;
height: 4rpx;
background: #1976D2;
border-radius: 2rpx;
}
}
}
}
&::after {
content: '';
position: absolute;
bottom: 0;
left: 50%;
transform: translateX(-50%);
width: 40rpx;
height: 4rpx;
background: #1976D2;
border-radius: 2rpx;
}
}
}
}
.order-list {
padding: 20rpx;
// 订单列表
.order-list {
padding: 20rpx;
.order-item {
background: #fff;
border-radius: 20rpx;
margin-bottom: 20rpx;
padding: 30rpx;
box-shadow: 0 4rpx 16rpx rgba(0,0,0,0.04);
// 订单项
.order-item {
background: #fff;
border-radius: 16rpx;
margin-bottom: 20rpx;
overflow: hidden;
box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.04);
.order-header {
display: flex;
justify-content: space-between;
align-items: center;
padding-bottom: 20rpx;
border-bottom: 1rpx solid #f5f5f5;
// 订单头部
.order-header {
display: flex;
justify-content: space-between;
align-items: center;
padding: 24rpx;
border-bottom: 1rpx solid #f0f0f0;
.order-no {
font-size: 26rpx;
color: #666;
}
.order-id {
font-size: 26rpx;
color: #666;
}
.order-status {
font-size: 26rpx;
&.status-waiting {
color: #FF9800;
}
.order-status {
font-size: 26rpx;
font-weight: 500;
&.status-progress {
color: #2196F3;
}
&.status-waiting {
color: #FF9800;
}
&.status-success {
color: #4CAF50;
}
&.status-using {
color: #2196F3;
}
&.status-using {
color: #1976D2;
}
&.status-finished {
color: #4CAF50;
}
&.status-failed {
color: #F44336;
}
&.status-cancelled {
color: #9E9E9E;
}
}
}
&.status-cancelled {
color: #9E9E9E;
}
// 订单内容
.order-body {
padding: 24rpx;
&.status-finished {
color: #4CAF50;
}
}
}
.device-info {
margin-bottom: 20rpx;
display: flex;
justify-content: space-between;
align-items: flex-start;
.order-content {
padding-top: 20rpx;
.device-left {
flex: 1;
margin-right: 20rpx;
.device-info {
margin-bottom: 20rpx;
.device-name {
font-size: 32rpx;
font-weight: 500;
color: #333;
margin-bottom: 6rpx;
}
.device-name {
font-size: 32rpx;
color: #333;
font-weight: 500;
margin-right: 20rpx;
}
.device-id {
font-size: 26rpx;
color: #999;
margin-bottom: 0;
}
}
.device-id {
font-size: 26rpx;
color: #999;
}
}
.device-right {
.time-info {
.time-item {
font-size: 26rpx;
color: #666;
margin-bottom: 10rpx;
// 支付分标识
.payment-badge {
display: inline-flex;
align-items: center;
padding: 6rpx 12rpx;
border-radius: 8rpx;
white-space: nowrap;
.label {
color: #999;
}
}
}
&.wx-score {
background: rgba(7, 193, 96, 0.08);
.price-info {
text-align: right;
margin-top: 20rpx;
.badge-icon {
width: 32rpx;
height: 26rpx;
margin-right: 8rpx;
}
.amount {
font-size: 36rpx;
color: #FF9800;
font-weight: 500;
}
}
}
}
}
.badge-text {
font-size: 22rpx;
color: #07c160;
display: flex;
align-items: center;
.empty-tip {
padding: 100rpx 0;
text-align: center;
color: #999;
font-size: 28rpx;
.divider {
margin: 0 6rpx;
}
.empty-icon {
width: 200rpx;
height: 200rpx;
margin: 0 auto 20rpx;
background: #f0f0f0;
border-radius: 50%;
}
}
}
.highlight {
font-weight: 500;
}
}
}
&.deposit {
background: #f5f5f5;
.badge-text {
font-size: 22rpx;
color: #666;
font-weight: 500;
}
}
}
}
}
.order-times {
.time-row {
display: flex;
font-size: 26rpx;
margin-bottom: 8rpx;
.time-label {
color: #999;
width: 140rpx;
}
.time-value {
color: #333;
flex: 1;
}
}
}
}
// 订单底部
.order-footer {
display: flex;
justify-content: space-between;
align-items: center;
padding: 20rpx 24rpx;
background: #fafafa;
border-top: 1rpx solid #f0f0f0;
.price {
font-size: 34rpx;
font-weight: 500;
color: #ff6b6b;
}
.actions {
display: flex;
.action-item {
font-size: 26rpx;
padding: 10rpx 30rpx;
border-radius: 30rpx;
margin-left: 20rpx;
display: flex;
align-items: center;
justify-content: center;
&.primary {
background: #1976D2;
color: #fff;
}
&.secondary {
background: #f5f5f5;
color: #666;
border: 1rpx solid #e0e0e0;
}
&:active {
opacity: 0.8;
}
}
}
}
}
// 空状态
.empty-state {
padding: 100rpx 0;
text-align: center;
.empty-icon {
width: 180rpx;
height: 180rpx;
margin: 0 auto 30rpx;
background: #f5f5f5;
border-radius: 50%;
}
.empty-text {
font-size: 28rpx;
color: #999;
}
}
}
}
</style>