This commit is contained in:
马梓彭 2026-04-08 16:46:40 +08:00
commit 253c27db4b
10 changed files with 184 additions and 69 deletions

View File

@ -24,12 +24,10 @@ Page({
wx.redirectTo({ url: '/subpackages/mine/login/login' });
return;
}
this.loadProfile();
this.resetAndLoad();
},
onPullDownRefresh() {
this.loadProfile();
this.resetAndLoad()
.finally(() => wx.stopPullDownRefresh());
},
@ -37,7 +35,6 @@ Page({
onRefresh() {
if (this.data.refresherTriggered) return;
this.setData({ refresherTriggered: true });
this.loadProfile();
this.resetAndLoad()
.finally(() => this.setData({ refresherTriggered: false }));
},
@ -102,7 +99,23 @@ Page({
const formatted = rows.map((item, idx) => ({
...item,
id: item.id != null ? item.id : `${activeTab}-${pageNo}-${idx}`,
timeStr: item.createdTime ? formatTime(item.createdTime) : (item.timeStr || '')
// 赛事名称
eventName: item.eventName || '',
// 项目-组别展示,优先用 projectGroupDisplay,否则拼接 projectName + groupName
projectGroupDisplay:
item.projectGroupDisplay ||
[item.projectName, item.groupName].filter(Boolean).join(' - ') ||
'-',
// 证书链接
certificateUrl: item.certificateUrl || '',
// 证书名称(用于查看证书时的标题)
certificateName: item.certificateName || item.eventName || '证书',
// 颁发时间
timeStr: item.issuedTime
? formatTime(item.issuedTime)
: item.createdTime
? formatTime(item.createdTime)
: ''
}));
const newRecords = this.data.records.concat(formatted);

View File

@ -47,12 +47,12 @@
</view>
<view wx:for="{{records}}" wx:key="id" class="record-row">
<view class="td td-event">
<text class="event-name">{{item.title || item.eventTitle || '-'}}</text>
<text class="event-time">{{item.timeStr || item.createdTimeStr || ''}}</text>
<text class="event-name">{{item.eventName || '-'}}</text>
<text class="event-time">{{item.timeStr}}</text>
</view>
<text class="td td-project">{{item.projectInfo || item.projectName || '-'}}</text>
<text class="td td-project">{{item.projectGroupDisplay || '-'}}</text>
<view class="td td-cert">
<text class="cert-link" bindtap="onViewCert" data-url="{{item.certificateUrl || item.url}}" data-name="{{item.title || item.eventTitle || '证书'}}">查看证书</text>
<text class="cert-link" bindtap="onViewCert" data-url="{{item.certificateUrl}}" data-name="{{item.certificateName}}">查看证书</text>
</view>
</view>
</block>

View File

@ -1,51 +1,70 @@
const auth = require('../../../utils/auth');
const { formatTime } = require('../../../utils/format');
const PAGE_SIZE = 10;
// orderStatus 枚举 → 显示文案 & 样式 key
const STATUS_MAP = {
Pending: { text: '待支付', key: 'pending' },
Paid: { text: '交易成功', key: 'success' },
Cancelled: { text: '已取消', key: 'cancelled' },
Refunded: { text: '已退款', key: 'refunded' },
Refunding: { text: '退款中', key: 'pending' }
};
function formatOrder(item) {
const statusInfo = STATUS_MAP[item.orderStatus] || { text: item.orderStatus || '-', key: 'default' };
return {
...item,
statusText: statusInfo.text,
statusKey: statusInfo.key,
payTimeStr: item.paymentTime ? formatTime(item.paymentTime) : (item.createdTime ? formatTime(item.createdTime) : '-'),
actualAmount: item.actualAmount != null ? item.actualAmount : '-',
refundAmount: item.refundAmount != null && item.refundAmount > 0 ? item.refundAmount : ''
};
}
Page({
data: {
loading: false,
noMore: false,
orders: [
{
id: 1,
eventName: '2024上海市学生运动会跳绳比赛',
statusText: '交易成功',
statusKey: 'success',
payTimeStr: '2025-08-05 16:26',
actualAmount: '859',
refundAmount: ''
},
{
id: 2,
eventName: '2024上海市学生运动会跳绳比赛',
statusText: '交易取消',
statusKey: 'cancelled',
payTimeStr: '2025-08-05 16:26',
actualAmount: '859',
refundAmount: '859'
},
{
id: 3,
eventName: '2024上海市学生运动会跳绳比赛',
statusText: '交易成功',
statusKey: 'success',
payTimeStr: '2025-08-05 16:26',
actualAmount: '859',
refundAmount: ''
},
{
id: 4,
eventName: '2024上海市学生运动会跳绳比赛',
statusText: '交易成功',
statusKey: 'success',
payTimeStr: '2025-08-05 16:26',
actualAmount: '859',
refundAmount: ''
}
]
pageNo: 1,
total: 0,
orders: []
},
onLoad() {},
onLoad() {
this.loadOrders(true);
},
onPullDownRefresh() {
wx.stopPullDownRefresh();
this.loadOrders(true).finally(() => wx.stopPullDownRefresh());
},
async loadOrders(refresh = false) {
if (this.data.loading) return;
const pageNo = refresh ? 1 : this.data.pageNo;
if (!refresh && this.data.noMore) return;
this.setData({ loading: true });
try {
const res = await auth.fetchMyOrders({ pageNo, pageSize: PAGE_SIZE });
const rows = (res && res.rows) || [];
const total = (res && res.total) || 0;
const formatted = rows.map(formatOrder);
const newOrders = refresh ? formatted : [...this.data.orders, ...formatted];
const noMore = newOrders.length >= total;
this.setData({
orders: newOrders,
pageNo: pageNo + 1,
total,
noMore
});
} catch (err) {
wx.showToast({ title: err?.message || '加载失败', icon: 'none' });
} finally {
this.setData({ loading: false });
}
},
onBack() {
@ -62,6 +81,6 @@ Page({
},
onLoadMore() {
// TODO: 分页加载
this.loadOrders(false);
}
});

View File

@ -1,5 +1,6 @@
{
"navigationStyle": "custom",
"navigationBarTitleText": "我的订单",
"navigationBarBackgroundColor": "#ffffff",
"enablePullDownRefresh": true,
"usingComponents": {
"mp-navigation-bar": "weui-miniprogram/navigation-bar/navigation-bar"

View File

@ -1,11 +1,11 @@
<view class="order-page">
<mp-navigation-bar
<!-- <mp-navigation-bar
title="我的订单"
background-color="#ffffff"
color="#333"
bind:click-left="onBack"
left-arrow
></mp-navigation-bar>
></mp-navigation-bar> -->
<scroll-view
class="list"

View File

@ -1,18 +1,48 @@
const auth = require('../../../utils/auth');
const PAGE_SIZE = 20;
Page({
data: {
orgName: '上海市跳绳键球协会', // 所在单位,后续接口替换
orgName: '',
loading: false,
teams: [
{ id: 1, name: '队伍名称', memberCount: 9, pendingCount: 0 },
{ id: 2, name: '队伍名称', memberCount: 91, pendingCount: 0 },
{ id: 3, name: '队伍名称', memberCount: 9, pendingCount: 3 }
]
noMore: false,
pageNo: 1,
total: 0,
teams: []
},
onLoad() {},
onLoad() {
this.loadTeams(true);
},
onPullDownRefresh() {
wx.stopPullDownRefresh();
this.loadTeams(true).finally(() => wx.stopPullDownRefresh());
},
async loadTeams(refresh = false) {
if (this.data.loading) return;
const pageNo = refresh ? 1 : this.data.pageNo;
if (!refresh && this.data.noMore) return;
this.setData({ loading: true });
try {
const res = await auth.fetchMyTeams({ pageNo, pageSize: PAGE_SIZE });
const rows = (res && res.rows) || [];
const total = (res && res.total) || 0;
const newTeams = refresh ? rows : [...this.data.teams, ...rows];
const noMore = newTeams.length >= total;
this.setData({
teams: newTeams,
pageNo: pageNo + 1,
total,
noMore
});
} catch (err) {
wx.showToast({ title: err?.message || '加载失败', icon: 'none' });
} finally {
this.setData({ loading: false });
}
},
onBack() {

View File

@ -1,5 +1,5 @@
{
"navigationStyle": "custom",
"navigationBarTitleText": "我的团队",
"enablePullDownRefresh": true,
"usingComponents": {
"mp-navigation-bar": "weui-miniprogram/navigation-bar/navigation-bar"

View File

@ -1,12 +1,4 @@
<view class="team-page">
<!-- 导航栏 -->
<mp-navigation-bar
title="我的团队"
background-color="#ffffff"
color="#333"
bind:click-left="onBack"
left-arrow
></mp-navigation-bar>
<!-- 所在单位卡片 -->
<view class="org-card" wx:if="{{orgName}}">

View File

@ -4,6 +4,10 @@
background: #f5f7fa;
}
view{
box-sizing: border-box;
}
/* ===== 单位卡片 ===== */
.org-card {
position: relative;
@ -109,12 +113,30 @@
border-bottom: none;
}
.team-left {
display: flex;
align-items: center;
gap: 16rpx;
flex: 1;
min-width: 0;
}
.team-name {
font-size: 30rpx;
color: #1a1a1a;
font-weight: 500;
}
.leader-tag {
font-size: 20rpx;
color: #1a56db;
background: rgba(26, 86, 219, 0.1);
border: 1rpx solid rgba(26, 86, 219, 0.3);
border-radius: 8rpx;
padding: 2rpx 12rpx;
flex-shrink: 0;
}
.team-right {
display: flex;
align-items: center;
@ -146,3 +168,15 @@
color: #999;
margin-top: 24rpx;
}
/* ===== 加载更多 ===== */
.list-footer {
display: flex;
justify-content: center;
padding: 32rpx 0;
}
.footer-text {
font-size: 26rpx;
color: #999;
}

View File

@ -259,6 +259,30 @@ async function fetchMyPoints({
});
}
async function fetchMyTeams({ pageNo = 1, pageSize = 20 } = {}) {
return request({
path: API.myTeams,
method: 'GET',
needAuth: true,
data: {
PageNo: pageNo,
PageSize: pageSize
}
});
}
async function fetchMyOrders({ pageNo = 1, pageSize = 10 } = {}) {
return request({
path: API.myOrders,
method: 'GET',
needAuth: true,
data: {
PageNo: pageNo,
PageSize: pageSize
}
});
}
async function fetchMyCertificates({ pageNo = 1, pageSize = 10, type } = {}) {
const data = {
PageNo: pageNo,
@ -286,6 +310,8 @@ module.exports = {
submitMyAuth,
fetchMyRegistrations,
fetchMyPoints,
fetchMyTeams,
fetchMyOrders,
fetchMyCertificates,
refreshAccessToken
};