fix: order-list
All checks were successful
构建并部署前端到生产环境 / build-and-deploy (push) Successful in 45s

This commit is contained in:
sexygoat
2026-04-15 16:50:35 +08:00
parent 427b25cabd
commit 17e4b84e4c

View File

@@ -1,13 +1,8 @@
<template> <template>
<view class="container"> <view class="container">
<view class="filter-tabs"> <view class="filter-tabs">
<view <view v-for="(item, index) in filterOptions" :key="index" class="tab-item"
v-for="(item, index) in filterOptions" :class="{ active: filterIndex === index }" @tap="onFilterChange(index)">
:key="index"
class="tab-item"
:class="{ active: filterIndex === index }"
@tap="onFilterChange(index)"
>
{{ item.label }} {{ item.label }}
<view v-if="filterIndex === index" class="tab-line"></view> <view v-if="filterIndex === index" class="tab-line"></view>
</view> </view>
@@ -44,9 +39,9 @@
<view class="info-value amount">¥{{ formatMoney(item.total_amount) }}</view> <view class="info-value amount">¥{{ formatMoney(item.total_amount) }}</view>
</view> </view>
</view> </view>
<view class="divider"></view> <view class="divider"></view>
<view class="package-section"> <view class="package-section">
<view class="section-label">套餐名称</view> <view class="section-label">套餐名称</view>
<view class="package-list"> <view class="package-list">
@@ -55,6 +50,10 @@
</view> </view>
</view> </view>
</view> </view>
<view v-if="item.payment_status === 1" class="card-footer">
<button class="btn-pay" @tap="handleOrderPayment(item)">立即支付</button>
</view>
</view> </view>
</view> </view>
@@ -68,9 +67,17 @@
</template> </template>
<script setup> <script setup>
import { ref, reactive, onMounted } from 'vue'; import {
import { orderApi } from '@/api/index.js'; ref,
import { useUserStore } from '@/store/index.js'; reactive,
onMounted
} from 'vue';
import {
orderApi
} from '@/api/index.js';
import {
useUserStore
} from '@/store/index.js';
const userStore = useUserStore(); const userStore = useUserStore();
@@ -80,12 +87,26 @@
let page = ref(1); let page = ref(1);
const pageSize = 10; const pageSize = 10;
let filterIndex = ref(0); let filterIndex = ref(0);
let filterOptions = [ let filterOptions = [{
{ label: '全部', value: null }, label: '全部',
{ label: '待支付', value: 1 }, value: null
{ label: '已支付', value: 2 }, },
{ label: '已取消', value: 3 }, {
{ label: '已退款', value: 4 } label: '待支付',
value: 1
},
{
label: '已支付',
value: 2
},
{
label: '已取消',
value: 3
},
{
label: '已退款',
value: 4
}
]; ];
const formatMoney = (amount) => { const formatMoney = (amount) => {
@@ -126,7 +147,9 @@
const newData = (data.items || []).map(item => ({ const newData = (data.items || []).map(item => ({
...item, ...item,
payment_status_name: item.payment_status === 1 ? '待支付' : item.payment_status === 2 ? '已支付' : item.payment_status === 3 ? '已取消' : item.payment_status === 4 ? '已退款' : '未知', payment_status_name: item.payment_status === 1 ? '待支付' : item.payment_status === 2 ?
'已支付' : item.payment_status === 3 ? '已取消' : item.payment_status === 4 ? '已退款' :
'未知',
created_at: item.created_at ? item.created_at.split('T').join(' ').slice(0, 19) : '' created_at: item.created_at ? item.created_at.split('T').join(' ').slice(0, 19) : ''
})); }));
@@ -153,6 +176,111 @@
} }
}; };
const handleOrderPayment = async (order) => {
uni.showLoading({
title: '处理中...',
mask: true
});
try {
const payData = await orderApi.pay(order.order_id, 'wechat');
uni.hideLoading();
if (!payData.pay_config || !payData.pay_config.package) {
uni.showToast({
title: '支付参数获取失败',
icon: 'none'
});
return;
}
// #ifdef H5
if (typeof WeixinJSBridge === 'undefined') {
uni.showToast({
title: '请在微信中打开',
icon: 'none'
});
return;
}
WeixinJSBridge.invoke('getBrandWCPayRequest', {
appId: payData.pay_config.app_id,
timeStamp: payData.pay_config.timestamp,
nonceStr: payData.pay_config.nonce_str,
package: payData.pay_config.package,
signType: payData.pay_config.sign_type,
paySign: payData.pay_config.pay_sign
}, function(res) {
if (res.err_msg === 'get_brand_wcpay_request:ok') {
uni.showToast({
title: '支付成功',
icon: 'success'
});
setTimeout(() => {
page.value = 1;
noMore.value = false;
loadOrderList();
}, 1500);
} else if (res.err_msg === 'get_brand_wcpay_request:cancel') {
uni.showToast({
title: '已取消支付',
icon: 'none'
});
} else {
uni.showToast({
title: '支付失败',
icon: 'none'
});
}
});
// #endif
// #ifndef H5
uni.requestPayment({
timeStamp: payData.pay_config.timestamp,
nonceStr: payData.pay_config.nonce_str,
package: payData.pay_config.package,
signType: payData.pay_config.sign_type,
paySign: payData.pay_config.pay_sign,
success: () => {
uni.showToast({
title: '支付成功',
icon: 'success'
});
setTimeout(() => {
page.value = 1;
noMore.value = false;
loadOrderList();
}, 1500);
},
fail: (err) => {
if (err.errMsg && (err.errMsg.includes('cancel') || err.errMsg.includes('用户取消'))) {
uni.showToast({
title: '已取消支付',
icon: 'none'
});
} else {
uni.showToast({
title: '支付失败',
icon: 'none'
});
}
}
});
// #endif
} catch (e) {
uni.hideLoading();
console.error('支付失败', e);
const errorMsg = e.msg || e.message || '支付失败,请稍后重试';
uni.showToast({
title: errorMsg,
icon: 'none'
});
}
};
onMounted(() => { onMounted(() => {
loadOrderList(); loadOrderList();
}); });
@@ -173,6 +301,7 @@
top: 0; top: 0;
border-radius: 10rpx; border-radius: 10rpx;
z-index: 10; z-index: 10;
.tab-item { .tab-item {
position: relative; position: relative;
flex: 1; flex: 1;
@@ -181,11 +310,13 @@
color: #999; color: #999;
padding: 28rpx 0; padding: 28rpx 0;
transition: all 0.2s; transition: all 0.2s;
&.active { &.active {
color: #333; color: #333;
font-weight: 600; font-weight: 600;
font-size: 30rpx; font-size: 30rpx;
} }
.tab-line { .tab-line {
position: absolute; position: absolute;
bottom: 0; bottom: 0;
@@ -209,9 +340,25 @@
align-items: center; align-items: center;
justify-content: center; justify-content: center;
padding: 200rpx 40rpx; padding: 200rpx 40rpx;
.empty-icon { font-size: 120rpx; margin-bottom: 30rpx; opacity: 0.6; }
.empty-title { font-size: 32rpx; font-weight: 600; color: #333; margin-bottom: 16rpx; } .empty-icon {
.empty-desc { font-size: 26rpx; color: #999; text-align: center; } font-size: 120rpx;
margin-bottom: 30rpx;
opacity: 0.6;
}
.empty-title {
font-size: 32rpx;
font-weight: 600;
color: #333;
margin-bottom: 16rpx;
}
.empty-desc {
font-size: 26rpx;
color: #999;
text-align: center;
}
} }
.order-card { .order-card {
@@ -227,19 +374,19 @@
align-items: flex-start; align-items: flex-start;
padding: 28rpx 28rpx 24rpx; padding: 28rpx 28rpx 24rpx;
border-bottom: 1rpx solid #f0f0f0; border-bottom: 1rpx solid #f0f0f0;
.header-left { .header-left {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
gap: 10rpx; gap: 10rpx;
} }
.header-row { .header-row {
display: flex; display: flex;
align-items: center; align-items: center;
gap: 12rpx; gap: 12rpx;
} }
.field-tag { .field-tag {
font-size: 20rpx; font-size: 20rpx;
color: #999; color: #999;
@@ -247,14 +394,14 @@
padding: 2rpx 10rpx; padding: 2rpx 10rpx;
border-radius: 4rpx; border-radius: 4rpx;
} }
.order-no { .order-no {
font-size: 26rpx; font-size: 26rpx;
font-weight: 600; font-weight: 600;
color: #333; color: #333;
font-family: monospace; font-family: monospace;
} }
.order-id { .order-id {
font-size: 24rpx; font-size: 24rpx;
color: #666; color: #666;
@@ -264,21 +411,23 @@
.card-body { .card-body {
padding: 24rpx 28rpx; padding: 24rpx 28rpx;
.info-grid { .info-grid {
display: grid; display: grid;
grid-template-columns: 1fr 1fr; grid-template-columns: 1fr 1fr;
gap: 20rpx; gap: 20rpx;
.info-item { .info-item {
.info-label { .info-label {
font-size: 22rpx; font-size: 22rpx;
color: #999; color: #999;
margin-bottom: 8rpx; margin-bottom: 8rpx;
} }
.info-value { .info-value {
font-size: 26rpx; font-size: 26rpx;
color: #333; color: #333;
&.amount { &.amount {
color: #ff6b6b; color: #ff6b6b;
font-weight: 700; font-weight: 700;
@@ -300,13 +449,14 @@
color: #999; color: #999;
margin-bottom: 16rpx; margin-bottom: 16rpx;
} }
.package-list { .package-list {
.package-item { .package-item {
display: flex; display: flex;
align-items: center; align-items: center;
gap: 12rpx; gap: 12rpx;
padding: 8rpx 0; padding: 8rpx 0;
.package-name { .package-name {
font-size: 26rpx; font-size: 26rpx;
color: #333; color: #333;
@@ -314,6 +464,28 @@
} }
} }
} }
.card-footer {
margin-top: 24rpx;
padding-top: 24rpx;
border-top: 1rpx solid #f0f0f0;
display: flex;
justify-content: flex-end;
.btn-pay {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: #fff;
border: none;
border-radius: 40rpx;
padding: 16rpx 40rpx;
font-size: 26rpx;
font-weight: 500;
&::after {
border: none;
}
}
}
} }
} }
@@ -322,19 +494,22 @@
border-radius: 30rpx; border-radius: 30rpx;
font-size: 22rpx; font-size: 22rpx;
font-weight: 500; font-weight: 500;
&.tag-warning { &.tag-warning {
background: #fff7e6; background: #fff7e6;
color: #fa8c16; color: #fa8c16;
} }
&.tag-success { &.tag-success {
background: #e6f7ff; background: #e6f7ff;
color: #1890ff; color: #1890ff;
} }
&.tag-secondary { &.tag-secondary {
background: #f5f5f5; background: #f5f5f5;
color: #999; color: #999;
} }
&.tag-info { &.tag-info {
background: #f0f0f0; background: #f0f0f0;
color: #666; color: #666;