Commit 84e8f611 authored by 王炽's avatar 王炽

Merge branch 'feihesanqi_20251014' of...

Merge branch 'feihesanqi_20251014' of http://gitlab2.dui88.com/fh/20250528_FHQ1 into feihesanqi_20251014
parents e32a4b5c 6200480f
......@@ -55,4 +55,13 @@ export const checkParticipation = (data) => api.get('/c/fertility/index', data);
export const doTerminate = () => api.post('/c/user/terminate');
\ No newline at end of file
export const doTerminate = () => api.post('/c/user/terminate');
/**
* 获取积分兑换记录列表(分页)
* @param {Object} params - 请求参数
* @param {number} [params.nextId] - 下一页ID,不传则为第一页
* @returns {Promise} 返回兑换记录列表
*/
export const getExchangeList = (params = {}) => api.get('/c/user/exchange/list', { params });
\ No newline at end of file
......@@ -38,7 +38,6 @@
position: relative;
overflow: hidden;
background-color: #E5D5B0;
z-index: 1; // 设置较低的层级
padding-bottom: 20px;
// 2场秒杀:平分区域
......@@ -238,7 +237,6 @@
border-radius: 0rpx 30rpx 30rpx 30rpx;
background-color: #EDE8D6;
position: relative;
z-index: 2; // 设置较高的层级,覆盖在tabs上方
}
// 场次商品列表容器
......
......@@ -95,7 +95,7 @@
<!-- 立即抢购按钮 -->
<view class="credits_sale_button"
:class="{ disabled: getGoodButtonInfo(good, creditsSaleData.sessions[currentSessionIndex]).disabled }"
@click="!getGoodButtonInfo(good, creditsSaleData.sessions[currentSessionIndex]).disabled && handleCreditsSaleClick(good)">
@click="!getGoodButtonInfo(good, creditsSaleData.sessions[currentSessionIndex]).disabled && handleCreditsSaleClickThrottled(good)">
<text class="credits_sale_button_text">{{ getGoodButtonInfo(good, creditsSaleData.sessions[currentSessionIndex]).text }}</text>
</view>
</view>
......@@ -109,6 +109,7 @@
<script setup>
import { ref, onMounted, computed } from 'vue';
import { useIntegralStore } from '../stores/integral';
import { throttleTap } from '../utils/index';
// Props
const props = defineProps({
......@@ -423,6 +424,9 @@ const handleCreditsSaleClick = (good) => {
emit('credits-sale-click', good);
};
// 创建防连点的点击处理函数
const handleCreditsSaleClickThrottled = throttleTap(handleCreditsSaleClick, 1000);
// 生成测试数据
const generateTestSeckillData = () => {
const now = new Date();
......
......@@ -421,10 +421,21 @@ export default {
},
fail: (err) => {
console.error('微信地址导入失败:', err);
uni.showToast({
title: '导入失败,请重试',
icon: 'none'
});
// 根据错误类型给出不同提示
if (err.errMsg && err.errMsg.includes('requiredPrivateInfos')) {
uni.showModal({
title: '权限提示',
content: '请在微信开发者工具中重新编译项目,或联系开发者检查权限配置',
showCancel: false,
confirmText: '我知道了'
});
} else {
uni.showToast({
title: '导入失败,请重试',
icon: 'none'
});
}
}
});
}
......
......@@ -437,7 +437,7 @@ export default {
width: 680rpx;
height: 100rpx;
right: 34rpx;
top: calc(50% - 100rpx/2 + 670rpx);
top: calc(50% - 100rpx/2 + 610rpx);
background: #D3A458;
border-radius: 66rpx;
......
......@@ -65,6 +65,16 @@
</view>
</view>
<!-- 加载状态 -->
<view v-if="loading" class="loading-container">
<text class="loading-text">加载中...</text>
</view>
<!-- 没有更多数据 -->
<view v-if="!hasMore && orderList.length > 0" class="no-more-container">
<text class="no-more-text">没有更多数据了</text>
</view>
<!-- 空状态 -->
<view v-if="orderList.length === 0" class="empty-state">
<image :src="$baseUrl + 'empty/order_empty.png'" mode="aspectFit" class="empty-image" />
......@@ -74,10 +84,17 @@
</template>
<script>
import { getExchangeList } from '@/api/user.js';
export default {
data() {
return {
orderList: [
orderList: [],
nextId: null,
loading: false,
hasMore: true,
// 模拟数据(用于测试)
mockData: [
{
orderId: '1782993789',
status: 'pending_shipment',
......@@ -123,7 +140,133 @@ export default {
]
}
},
onLoad() {
this.loadExchangeList();
},
onReachBottom() {
if (this.hasMore && !this.loading) {
this.loadMoreData();
}
},
methods: {
// 加载兑换记录列表
async loadExchangeList(isRefresh = false) {
if (this.loading) return;
this.loading = true;
try {
const params = {};
if (isRefresh) {
// 刷新时重置分页
this.nextId = null;
this.hasMore = true;
} else if (this.nextId) {
// 加载更多时传递nextId
params.nextId = this.nextId;
}
const response = await getExchangeList(params);
if (response.ok) {
const newList = this.mapApiDataToOrderList(response.data.list || []);
if (isRefresh) {
this.orderList = newList;
} else {
this.orderList = [...this.orderList, ...newList];
}
// 更新nextId,判断是否还有更多数据
this.nextId = response.data.nextId || null;
this.hasMore = !!this.nextId;
} else {
// API调用失败时使用模拟数据
console.warn('API调用失败,使用模拟数据:', response.msg);
this.orderList = this.mockData;
}
} catch (error) {
console.error('加载兑换记录失败:', error);
// 网络错误时使用模拟数据
this.orderList = this.mockData;
} finally {
this.loading = false;
}
},
// 加载更多数据
loadMoreData() {
this.loadExchangeList(false);
},
// 刷新数据
refreshData() {
this.loadExchangeList(true);
},
// 将API数据映射为订单列表格式
mapApiDataToOrderList(apiList) {
return apiList.map(item => ({
orderId: item.orderNo || '',
status: this.mapFlowStateToStatus(item.flowState),
productType: this.mapBizTypeToProductType(item.bizType),
productName: item.bizDesc || '',
description: item.bizDesc || '',
points: item.credits || 0,
exchangeTime: this.formatTime(item.createTime),
productImage: item.bizIcon || '',
countdown: this.calculateCountdown(item.expireTime),
validUntil: item.expireTime ? this.formatTime(item.expireTime) : null
}));
},
// 映射订单状态
mapFlowStateToStatus(flowState) {
const statusMap = {
'1': 'pending_payment', // 待付款
'2': 'pending_shipment', // 待发货
'3': 'completed', // 已完成
'4': 'cancelled' // 已取消
};
return statusMap[flowState] || 'completed';
},
// 映射业务类型到商品类型
mapBizTypeToProductType(bizType) {
// 根据业务类型判断是实物还是卡券
return bizType === 'coupon' ? 'coupon' : 'physical';
},
// 格式化时间
formatTime(timestamp) {
if (!timestamp) return '';
const date = new Date(timestamp);
return date.toLocaleString('zh-CN', {
year: 'numeric',
month: '2-digit',
day: '2-digit',
hour: '2-digit',
minute: '2-digit',
second: '2-digit'
}).replace(/\//g, '.');
},
// 计算倒计时
calculateCountdown(expireTime) {
if (!expireTime) return '';
const now = new Date().getTime();
const expire = new Date(expireTime).getTime();
const diff = expire - now;
if (diff <= 0) return '00:00:00';
const hours = Math.floor(diff / (1000 * 60 * 60));
const minutes = Math.floor((diff % (1000 * 60 * 60)) / (1000 * 60));
const seconds = Math.floor((diff % (1000 * 60)) / 1000);
return `${hours.toString().padStart(2, '0')}:${minutes.toString().padStart(2, '0')}:${seconds.toString().padStart(2, '0')}`;
},
// 获取状态文本
getStatusText(status) {
const statusMap = {
......@@ -349,6 +492,32 @@ export default {
font-weight: 500;
}
/* 加载状态 */
.loading-container {
display: flex;
justify-content: center;
align-items: center;
padding: 40rpx 0;
}
.loading-text {
font-size: 28rpx;
color: #999999;
}
/* 没有更多数据 */
.no-more-container {
display: flex;
justify-content: center;
align-items: center;
padding: 40rpx 0;
}
.no-more-text {
font-size: 26rpx;
color: #cccccc;
}
/* 空状态 */
.empty-state {
display: flex;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment