diff --git a/pages/activity/point/list.vue b/pages/activity/point/list.vue index c706f008..7630fd21 100644 --- a/pages/activity/point/list.vue +++ b/pages/activity/point/list.vue @@ -60,7 +60,7 @@ // 加载更多 function loadMore() { - if (loadStatus !== 'noMore') { + if (loadStatus.value !== 'noMore') { activityPageParams.pageNo += 1; getActivityList(); } diff --git a/pages/commission/commission-ranking.vue b/pages/commission/commission-ranking.vue index d8dd4ab2..5ad0b2ba 100644 --- a/pages/commission/commission-ranking.vue +++ b/pages/commission/commission-ranking.vue @@ -1,249 +1,272 @@ \ No newline at end of file + .people { + text-align: right; + flex: 0.27; + } + } + } + } + } + diff --git a/pages/commission/goods.vue b/pages/commission/goods.vue index 0e02d08b..d868879b 100644 --- a/pages/commission/goods.vue +++ b/pages/commission/goods.vue @@ -63,7 +63,7 @@ import { showShareModal } from '@/sheep/hooks/useModal'; import SpuApi from '@/sheep/api/product/spu'; import BrokerageApi from '@/sheep/api/trade/brokerage'; - import { fen2yuan } from '../../sheep/hooks/useGoods'; + import { fen2yuan } from '@/sheep/hooks/useGoods'; const state = reactive({ pagination: { @@ -104,19 +104,29 @@ pageSize: state.pagination.pageSize, pageNo: state.pagination.pageNo, }); + if (code !== 0) { + state.loadStatus = 'error'; // 处理错误状态 return; } + + // 使用 Promise.all 来等待所有佣金请求完成 + await Promise.all( + data.list.map(async (item) => { + try { + const res = await BrokerageApi.getProductBrokeragePrice(item.id); + item.brokerageMinPrice = res.data.brokerageMinPrice; + item.brokerageMaxPrice = res.data.brokerageMaxPrice; + } catch (error) { + console.error(`获取商品【${item.name}】的佣金时出错:`, error); + } + }), + ); + + // 在所有请求完成后合并列表和更新状态 state.pagination.list = _.concat(state.pagination.list, data.list); state.pagination.total = data.total; state.loadStatus = state.pagination.list.length < state.pagination.total ? 'more' : 'noMore'; - // 补充分佣金额 - data.list.forEach((item) => { - BrokerageApi.getProductBrokeragePrice(item.id).then((res) => { - item.brokerageMinPrice = res.data.brokerageMinPrice; - item.brokerageMaxPrice = res.data.brokerageMaxPrice; - }); - }); } onLoad(() => { diff --git a/pages/commission/order.vue b/pages/commission/order.vue index 51952c8f..a00981fc 100644 --- a/pages/commission/order.vue +++ b/pages/commission/order.vue @@ -128,7 +128,7 @@ state.loadStatus = 'loading'; let { code, data } = await BrokerageApi.getBrokerageRecordPage({ pageSize: state.pagination.pageSize, - pageNo: state.pagination.pageSize, + pageNo: state.pagination.pageNo, bizType: 1, // 获得推广佣金 status: state.currentTab > 0 ? state.currentTab : undefined, }); diff --git a/pages/commission/promoter.vue b/pages/commission/promoter.vue index bdf1e1e7..1fb017c5 100644 --- a/pages/commission/promoter.vue +++ b/pages/commission/promoter.vue @@ -1,297 +1,322 @@ - diff --git a/pages/goods/index.vue b/pages/goods/index.vue index 03298620..e3e3b3b0 100644 --- a/pages/goods/index.vue +++ b/pages/goods/index.vue @@ -85,7 +85,7 @@ {{ fen2yuan(state.selectedSku.price || state.goodsInfo.price) }} - + {{ fen2yuan(state.selectedSku.marketPrice || state.goodsInfo.marketPrice) }} @@ -361,7 +361,7 @@ // 选择有 promotionPrice 且最小的 state.settlementSku = state.goodsInfo.skus .filter((sku) => sku.stock > 0 && sku.promotionPrice > 0) - .reduce((prev, curr) => (prev.promotionPrice < curr.promotionPrice ? prev : curr)); + .reduce((prev, curr) => (prev.promotionPrice < curr.promotionPrice ? prev : curr), []); // 设置满减送活动 if (data.rewardActivity) { diff --git a/pages/goods/point.vue b/pages/goods/point.vue index 475fddf7..7709f1ad 100644 --- a/pages/goods/point.vue +++ b/pages/goods/point.vue @@ -7,7 +7,10 @@ {{ getShowPrice.point }} - {{ !getShowPrice.price || getShowPrice.price === 0 ? '' : `+¥${getShowPrice.price}` }} + {{ + !getShowPrice.price || getShowPrice.price === 0 ? '' : `+¥${getShowPrice.price}` + }} @@ -87,21 +92,19 @@ + 取消申请 + diff --git a/sheep/components/s-uploader/choose-and-upload-file.js b/sheep/components/s-uploader/choose-and-upload-file.js index d3c5bccc..9c7036cb 100644 --- a/sheep/components/s-uploader/choose-and-upload-file.js +++ b/sheep/components/s-uploader/choose-and-upload-file.js @@ -204,32 +204,46 @@ async function uploadFiles(choosePromise, { onChooseFile, onUploadProgress }) { // 如果是前端直连上传 if (UPLOAD_TYPE.CLIENT === import.meta.env.SHOPRO_UPLOAD_TYPE) { - for (const file of files) { - // 1.1 获取文件预签名地址 - const { data: presignedInfo } = await FileApi.getFilePresignedUrl(file.name); - // 1.2 获取二进制文件对象 - const fileBuffer = await convertToArrayBuffer(file); - // 1.3 上传文件 - await uni.request({ - url: presignedInfo.uploadUrl, // 预签名的上传 URL - method: 'PUT', // 使用 PUT 方法 - header: { - 'Content-Type': file.fileType + '/' + file.name.substring(file.name.lastIndexOf('.') + 1), // 设置内容类型 - }, - data: fileBuffer, // 文件的路径,适用于小程序 - success: (res) => { - // 1.4. 记录文件信息到后端(异步) - createFile(presignedInfo, file); - // 1.5. 重新赋值 - file.url = presignedInfo.url; - console.log('上传成功:', res); - }, - fail: (err) => { - console.error('上传失败:', err); - }, - }); - } - return files; + // 为上传创建一组 Promise + const uploadPromises = files.map(async (file) => { + try { + // 1.1 获取文件预签名地址 + const { data: presignedInfo } = await FileApi.getFilePresignedUrl(file.name); + // 1.2 获取二进制文件对象 + const fileBuffer = await convertToArrayBuffer(file); + + // 返回上传的 Promise + return new Promise((resolve, reject) => { + uni.request({ + url: presignedInfo.uploadUrl, // 预签名的上传 URL + method: 'PUT', // 使用 PUT 方法 + header: { + 'Content-Type': + file.fileType + '/' + file.name.substring(file.name.lastIndexOf('.') + 1), // 设置内容类型 + }, + data: fileBuffer, // 文件的路径,适用于小程序 + success: (res) => { + // 1.4. 记录文件信息到后端(异步) + createFile(presignedInfo, file); + // 1.5. 重新赋值 + file.url = presignedInfo.url; + console.log('上传成功:', res); + resolve(file); + }, + fail: (err) => { + console.error('上传失败:', err); + reject(err); + }, + }); + }); + } catch (error) { + console.error('上传失败:', error); + throw error; + } + }); + + // 等待所有上传完成 + return await Promise.all(uploadPromises); // 返回已上传的文件列表 } else { // 后端上传 for (let file of files) { diff --git a/sheep/components/s-uploader/s-uploader.vue b/sheep/components/s-uploader/s-uploader.vue index a459d84f..e0a37e34 100644 --- a/sheep/components/s-uploader/s-uploader.vue +++ b/sheep/components/s-uploader/s-uploader.vue @@ -44,13 +44,7 @@