From f7456aafa2a0f35da26af8bbbf3b6a621a3c5b47 Mon Sep 17 00:00:00 2001 From: huliyong <2783385703@qq.com> Date: Fri, 27 Jun 2025 19:03:55 +0800 Subject: [PATCH] =?UTF-8?q?feat(wallet):=20=E5=AE=9E=E7=8E=B0=E9=92=B1?= =?UTF-8?q?=E5=8C=85=E6=B5=81=E6=B0=B4=E9=A1=B5=E9=9D=A2=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=E5=B9=B6=E4=BC=98=E5=8C=96=E7=94=A8=E6=88=B7=E4=BD=93=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit refactor(withdraw): 重构提现页面使用组件和动态数据 perf(recycle): 优化回收页面价格计算和单位显示逻辑 fix(App): 调整全局请求数量配置 --- App.vue | 5 +- api/model/recyclingDestination.js | 7 + pages/component/my.vue | 1768 ++++++++++++++++++------------------- pages/component/recycle.vue | 89 +- pages/subcomponent/wallet.vue | 778 ++++++++++------ pages/subcomponent/withdraw.vue | 64 +- 6 files changed, 1501 insertions(+), 1210 deletions(-) diff --git a/App.vue b/App.vue index 839c098..90b210a 100644 --- a/App.vue +++ b/App.vue @@ -24,7 +24,7 @@ globalDataLoaded: false, loadingProgress: 0, loadedCount: 0, - totalRequests: 4 // 总共需要加载的请求数量 + totalRequests: 3 // 总共需要加载的请求数量 } }, globalData: { @@ -61,9 +61,8 @@ this.getBannerList(), this.getPricePreviewList(), this.getConfigData(), - this.getQrCode() ] - + this.getQrCode() await Promise.all(promises) // 确保进度达到100% diff --git a/api/model/recyclingDestination.js b/api/model/recyclingDestination.js index e7d7615..53cd16f 100644 --- a/api/model/recyclingDestination.js +++ b/api/model/recyclingDestination.js @@ -18,6 +18,13 @@ const api = { method: 'GET', auth : false, }, + // 联系客服问题相关详情 + withdraw: { + url: '/recycle-admin/applet/money/withdraw', + method: 'POST', + auth : true, + }, + } export default api \ No newline at end of file diff --git a/pages/component/my.vue b/pages/component/my.vue index 0518940..ac19a7e 100644 --- a/pages/component/my.vue +++ b/pages/component/my.vue @@ -1,1011 +1,997 @@ \ No newline at end of file + \ No newline at end of file diff --git a/pages/component/recycle.vue b/pages/component/recycle.vue index 67d4b78..b004398 100644 --- a/pages/component/recycle.vue +++ b/pages/component/recycle.vue @@ -73,7 +73,7 @@ ¥ {{item.price}} - /件 + /{{ item.unit || '件' }} @@ -111,7 +111,7 @@ - 已选 {{totalCount}} 件 预计回收可得 + 已选 {{totalCount}} {{ totalUnitText }} 预计回收可得 @@ -142,7 +142,7 @@ {{item.name}} 品牌:{{item.brandName}} {{item.service}} - ¥{{item.price}}/件 + ¥{{item.price}}/{{ item.unit || '件' }} @@ -154,7 +154,7 @@ - 已选 {{totalCount}} 件 预计回收可得 + 已选 {{totalCount}} {{ totalUnitText }} 预计回收可得 @@ -172,7 +172,7 @@ 回收规则 - + + @@ -267,10 +268,11 @@ 温馨提示 - 1.当前回收快递免费上门,由于快递成本较高,为避免不必要的成本及资源二次浪费不属于可回收品类或不符合回收标准的物品请勿寄出。 + + @@ -364,6 +366,14 @@ export default { const item = getApp().globalData.configData.find(i => i.keyName === 'recycle_banner') return item ? item.keyContent : '' }, + recycle_toast() { + const item = getApp().globalData.configData.find(i => i.keyName === 'recycle_toast') + return item ? item.keyContent : '' + }, + huodong_text() { + const item = getApp().globalData.configData.find(i => i.keyName === 'huodong_text') + return item ? item.keyContent : '' + }, // 当前分类的商品列表 recycleList() { const currentCategoryId = this.categories[this.currentCategory]?.id @@ -382,10 +392,34 @@ export default { }, 0) }, 0) }, - // 计算总价格 - totalPrice() { - const total = Object.values(this.allProducts).reduce((categoryTotal, categoryItems) => { - return categoryTotal + categoryItems.reduce((sum, item) => { + // 计算总单位文本 + totalUnitText() { + // 获取所有已选商品的单位 + const units = new Set() + Object.values(this.allProducts).forEach(categoryItems => { + categoryItems.forEach(item => { + let hasQuantity = false + if (item.brandQuantities && Object.keys(item.brandQuantities).length > 0) { + hasQuantity = Object.values(item.brandQuantities).some(qty => qty > 0) + } else { + hasQuantity = (item.quantity || 0) > 0 + } + + if (hasQuantity) { + units.add(item.unit || '件') + } + }) + }) + + // 如果只有一种单位,显示单位;如果混合多种单位,显示"项" + if (units.size === 0) return '件' + if (units.size === 1) return Array.from(units)[0] + return '项' + }, + // 计算总价格范围 + totalPriceRange() { + const result = Object.values(this.allProducts).reduce((categoryTotal, categoryItems) => { + return categoryItems.reduce((sum, item) => { let itemQuantity = 0 // 如果商品有品牌数量,汇总所有品牌的数量 if (item.brandQuantities && Object.keys(item.brandQuantities).length > 0) { @@ -393,10 +427,26 @@ export default { } else { itemQuantity = item.quantity || 0 } - return sum + itemQuantity * Number(item.price) - }, 0) - }, 0) - return total.toFixed(1) + + if (itemQuantity > 0) { + const minPrice = Number(item.price) || 0 + const maxPrice = Number(item.maxPrice) || Number(item.price) || 0 + sum.min += itemQuantity * minPrice + sum.max += itemQuantity * maxPrice + } + + return sum + }, categoryTotal) + }, { min: 0, max: 0 }) + + return { + min: result.min.toFixed(1), + max: result.max.toFixed(1) + } + }, + // 计算总价格 (保持兼容性,使用最低价格) + totalPrice() { + return this.totalPriceRange.min }, // 计算价格范围 priceRange() { @@ -406,10 +456,7 @@ export default { max: '0.0' } } - const total = Number(this.totalPrice) - const min = Math.max(0, (total - 2.2)).toFixed(1) - const max = (total + 2.2).toFixed(1) - return { min, max } + return this.totalPriceRange }, selectedProducts() { // 返回所有分类下所有已选商品,按品牌分组 @@ -647,7 +694,7 @@ export default { if (this.totalCount < 3) { uni.showToast({ - title: '各品类混合需要满3件才能回收哦', + title: `各品类混合需要满3${this.totalUnitText}才能回收哦`, icon: 'none' }) return diff --git a/pages/subcomponent/wallet.vue b/pages/subcomponent/wallet.vue index 9200308..b740a5c 100644 --- a/pages/subcomponent/wallet.vue +++ b/pages/subcomponent/wallet.vue @@ -1,314 +1,596 @@ \ No newline at end of file + \ No newline at end of file diff --git a/pages/subcomponent/withdraw.vue b/pages/subcomponent/withdraw.vue index 8cdd674..cddcca3 100644 --- a/pages/subcomponent/withdraw.vue +++ b/pages/subcomponent/withdraw.vue @@ -1,7 +1,7 @@