diff --git a/subpackages/mine/cert/cert.js b/subpackages/mine/cert/cert.js index 4dd35f1..6715a10 100644 --- a/subpackages/mine/cert/cert.js +++ b/subpackages/mine/cert/cert.js @@ -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); diff --git a/subpackages/mine/cert/cert.wxml b/subpackages/mine/cert/cert.wxml index 09b672c..091265d 100644 --- a/subpackages/mine/cert/cert.wxml +++ b/subpackages/mine/cert/cert.wxml @@ -47,12 +47,12 @@ - {{item.title || item.eventTitle || '-'}} - {{item.timeStr || item.createdTimeStr || ''}} + {{item.eventName || '-'}} + {{item.timeStr}} - {{item.projectInfo || item.projectName || '-'}} + {{item.projectGroupDisplay || '-'}} - 查看证书 + 查看证书 diff --git a/subpackages/mine/order/order.js b/subpackages/mine/order/order.js index ced4674..1b250ec 100644 --- a/subpackages/mine/order/order.js +++ b/subpackages/mine/order/order.js @@ -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); } }); diff --git a/subpackages/mine/order/order.json b/subpackages/mine/order/order.json index a5c6c4b..6799bd6 100644 --- a/subpackages/mine/order/order.json +++ b/subpackages/mine/order/order.json @@ -1,5 +1,6 @@ { - "navigationStyle": "custom", + "navigationBarTitleText": "我的订单", + "navigationBarBackgroundColor": "#ffffff", "enablePullDownRefresh": true, "usingComponents": { "mp-navigation-bar": "weui-miniprogram/navigation-bar/navigation-bar" diff --git a/subpackages/mine/order/order.wxml b/subpackages/mine/order/order.wxml index 2025755..7d61ab7 100644 --- a/subpackages/mine/order/order.wxml +++ b/subpackages/mine/order/order.wxml @@ -1,11 +1,11 @@ - + > --> 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() { diff --git a/subpackages/mine/team/team.json b/subpackages/mine/team/team.json index a5c6c4b..b3e6d93 100644 --- a/subpackages/mine/team/team.json +++ b/subpackages/mine/team/team.json @@ -1,5 +1,5 @@ { - "navigationStyle": "custom", + "navigationBarTitleText": "我的团队", "enablePullDownRefresh": true, "usingComponents": { "mp-navigation-bar": "weui-miniprogram/navigation-bar/navigation-bar" diff --git a/subpackages/mine/team/team.wxml b/subpackages/mine/team/team.wxml index 7ef6242..85d83b5 100644 --- a/subpackages/mine/team/team.wxml +++ b/subpackages/mine/team/team.wxml @@ -1,12 +1,4 @@ - - diff --git a/subpackages/mine/team/team.wxss b/subpackages/mine/team/team.wxss index 5a0363e..7bec390 100644 --- a/subpackages/mine/team/team.wxss +++ b/subpackages/mine/team/team.wxss @@ -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; +} diff --git a/utils/auth.js b/utils/auth.js index 828b920..d7cb34e 100644 --- a/utils/auth.js +++ b/utils/auth.js @@ -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 };