feat: 后端版本迁移修改

This commit is contained in:
Blizzard
2026-05-24 01:38:28 +08:00
parent 058a575e10
commit f8d71ee800
29 changed files with 304 additions and 291 deletions
+10 -38
View File
@@ -30,7 +30,7 @@ Page({
async fetchProfile() {
try {
const res = await request.get('/profile/detail');
const res = await request.get('/plant/profile/detail');
if (res) {
this.setData({ currentSunlight: res.currentSunlight || 0 });
}
@@ -44,7 +44,7 @@ Page({
this.setData({ isLoading: true, current: 1, items: [] });
}
try {
const res = await request.get('/exchange/list', {
const res = await request.get('/plant/exchange/list', {
current: this.data.current,
pageSize: this.data.pageSize,
type: this.data.activeType
@@ -52,35 +52,11 @@ Page({
const rawList = (res && res.list) ? res.list : [];
const total = (res && res.total) ? res.total : 0;
const now = Date.now();
const list = rawList.map(item => {
const hasStart = !!item.startTime;
const hasEnd = !!item.endTime;
const startTs = hasStart ? new Date(item.startTime).getTime() : 0;
const endTs = hasEnd ? new Date(item.endTime).getTime() : 0;
const notStarted = hasStart && now < startTs;
const hasEnded = hasEnd && now > endTs;
const isActive = !notStarted && !hasEnded;
let timeLabel = '';
if (hasStart && hasEnd) {
timeLabel = this.formatDate(item.startTime) + ' ~ ' + this.formatDate(item.endTime);
} else if (hasStart) {
timeLabel = this.formatDate(item.startTime) + ' 起';
} else if (hasEnd) {
timeLabel = '截止 ' + this.formatDate(item.endTime);
}
return {
...item,
hasTimeLimit: hasStart || hasEnd,
timeLabel,
notStarted,
hasEnded,
isActive
};
});
// Backend ExchangeItemInfo: {id, name, desc, imgId, cost, stock, status}
const list = rawList.map(item => ({
...item,
isActive: item.status === 1 || !item.status
}));
this.setData({
items: append ? [...this.data.items, ...list] : list,
@@ -115,12 +91,8 @@ Page({
// Redeem Flow
onItemTap(e) {
const item = e.currentTarget.dataset.item;
if (item.notStarted) {
wx.showToast({ title: '活动尚未开始', icon: 'none' });
return;
}
if (item.hasEnded) {
wx.showToast({ title: '活动已结束', icon: 'none' });
if (!item.isActive) {
wx.showToast({ title: '当前不可兑换', icon: 'none' });
return;
}
if (item.stock === 0) {
@@ -164,7 +136,7 @@ Page({
wx.showLoading({ title: '兑换中...', mask: true });
try {
await request.post('/exchange/redeem', {
await request.post('/plant/exchange/redeem', {
itemId: item.id,
quantity: 1,
...this.data.redeemForm