From 24db09d7f8e1a854413c255ad7174f9d72fd110c Mon Sep 17 00:00:00 2001 From: Default User Date: Thu, 25 Dec 2025 11:12:02 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=B0=8F=E7=A8=8B=E5=BA=8F?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E5=92=8C=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/buyer/index.js | 21 ++- pages/buyer/index.wxml | 10 +- pages/customer-service/index.js | 258 +++++++++++++++++++---------- pages/customer-service/index.wxml | 53 ++++-- pages/favorites/index.wxml | 18 +- pages/goods-detail/goods-detail.js | 40 ++++- pages/index/index.wxml | 2 +- pages/settlement/index.js | 86 +++++++--- pages/settlement/index.wxml | 32 ++-- pages/settlement/index.wxss | 84 +++++++--- project.private.config.json | 2 +- 11 files changed, 418 insertions(+), 188 deletions(-) diff --git a/pages/buyer/index.js b/pages/buyer/index.js index e10077b..3b6935b 100644 --- a/pages/buyer/index.js +++ b/pages/buyer/index.js @@ -2477,12 +2477,23 @@ Page({ console.error('位置数据上传失败:', err); }); }, - fail() { + fail(err) { wx.hideLoading(); - wx.showToast({ - title: '获取位置失败', - icon: 'none' - }); + console.error('获取位置失败:', err); + // 处理错误码-80418:需要申请位置API权限 + if (err.errCode === -80418) { + wx.showModal({ + title: '位置服务未开通', + content: '该小程序尚未开通位置服务权限,请联系管理员申请开通后再试。', + showCancel: false, + confirmText: '我知道了' + }); + } else { + wx.showToast({ + title: '获取位置失败', + icon: 'none' + }); + } } }); } diff --git a/pages/buyer/index.wxml b/pages/buyer/index.wxml index 3393dea..aa41cab 100644 --- a/pages/buyer/index.wxml +++ b/pages/buyer/index.wxml @@ -59,7 +59,7 @@ {{item.name}} V - + {{item.specification || '无'}} | {{item.yolk || '无'}} | {{item.minOrder || item.quantity || 1}}件 @@ -71,14 +71,14 @@ - 已有 + 已有 {{item.reservedCount || 0}} - 人收藏 + 人收藏 + diff --git a/pages/goods-detail/goods-detail.js b/pages/goods-detail/goods-detail.js index be36cab..ce676f7 100644 --- a/pages/goods-detail/goods-detail.js +++ b/pages/goods-detail/goods-detail.js @@ -273,12 +273,18 @@ Page({ region: formattedGoods.region }); + // 保存预加载数据中的isFavorite状态,确保是布尔值 + const preloadedFavoriteStatus = preloadedData ? (preloadedData.isFavorite || false) : false; + this.setData({ - goodsDetail: formattedGoods + goodsDetail: formattedGoods, + isFavorite: preloadedFavoriteStatus // 优先使用预加载数据中的收藏状态 }); - // 加载商品的收藏状态 - this.loadGoodsFavoriteStatus(productIdStr); + // 只有当没有预加载的收藏状态时,才从服务器加载 + if (!preloadedData || preloadedData.isFavorite === undefined) { + this.loadGoodsFavoriteStatus(productIdStr); + } } else { wx.showToast({ title: '获取商品详情失败', @@ -335,10 +341,33 @@ Page({ // 调用API获取用户收藏列表 API.getFavorites(userPhone) .then(res => { - if (res && res.code === 200 && res.data && Array.isArray(res.data)) { - const favoriteProductIds = res.data.map(item => String(item.productId || item.id)); + if (res && res.code === 200) { + // 检查API返回的数据结构,确保我们获取到正确的收藏列表 + let favoritesList = []; + if (Array.isArray(res.data)) { + favoritesList = res.data; + } else if (res.data && Array.isArray(res.data.favorites)) { + favoritesList = res.data.favorites; + } else if (res.data && Array.isArray(res.data.data)) { + favoritesList = res.data.data; + } + + console.log('获取收藏列表成功,处理后的数据:', favoritesList); + + // 从收藏列表中提取商品ID + const favoriteProductIds = favoritesList.map(item => { + // 尝试从不同的字段名获取商品ID + return String(item.productId || item.id || item.product_id || ''); + }).filter(id => id !== ''); // 过滤掉空字符串 + + console.log('收藏商品ID列表:', favoriteProductIds); + console.log('当前商品ID:', String(productId)); + const isFavorite = favoriteProductIds.includes(String(productId)); + console.log('计算得到的收藏状态:', isFavorite); + // 只有当从收藏列表中明确获取到结果时,才更新收藏状态 + // 避免因为API返回数据结构问题导致收藏状态被错误覆盖 this.setData({ isFavorite: isFavorite }); @@ -346,6 +375,7 @@ Page({ }) .catch(err => { console.error('获取收藏状态失败:', err); + // 注意:这里不要更新isFavorite状态,保持之前的状态 }); }, diff --git a/pages/index/index.wxml b/pages/index/index.wxml index 8951eae..60e25e8 100644 --- a/pages/index/index.wxml +++ b/pages/index/index.wxml @@ -18,7 +18,7 @@ - "中国最专业的鸡蛋现货交易平台" + 专业的鸡蛋现货交易平台 diff --git a/pages/settlement/index.js b/pages/settlement/index.js index 722310a..8e5c083 100644 --- a/pages/settlement/index.js +++ b/pages/settlement/index.js @@ -46,7 +46,9 @@ Page({ showLoginButton: true, // 合作模式帮助弹窗 - showCooperationHelp: false + showCooperationHelp: false, + // 滚动到的位置 + scrollToView: '' }, onLoad(options) { @@ -647,7 +649,7 @@ Page({ city: this.data.city || '', // 城市,确保非空 district: this.data.district || '', // 区县,确保非空 detailedaddress: this.data.detailedaddress || '', // 详细地址(即使为空也要传递) - cooperation: this.data.cooperation === '货源委托' ? 'wholesale' : (this.data.cooperation || ''), // 确保合作模式非空 + cooperation: this.data.cooperation === '代销业务' ? 'wholesale' : (this.data.cooperation || ''), // 确保合作模式非空 phoneNumber: contactPhone || '', // 后端期望的字段名是phoneNumber,确保非空 businesslicenseurl: uploadedFiles.businessLicenseFile || '', // 营业执照URL proofurl: uploadedFiles.animalQuarantineFile || '', // 动物检疫证明或法人身份证URL(两者共用一个字段) @@ -837,6 +839,26 @@ Page({ wx.setStorageSync('applicationId', appId); } + // 修改用户身份为seller + const userId = wx.getStorageSync('userId'); + const app = getApp(); + // 更新本地存储中的用户类型 + wx.setStorageSync('userType', 'seller'); + // 更新全局数据中的用户类型 + if (app.globalData) { + app.globalData.userType = 'seller'; + } + + // 调用API更新用户身份到数据库 + try { + const API = require('../../utils/api'); + await API.updateUserType('seller'); + console.log('用户身份已成功更新为seller并同步到数据库'); + } catch (updateErr) { + console.error('更新用户身份到数据库失败:', updateErr); + // 即使更新失败,也不影响申请提交成功的提示 + } + wx.showToast({ title: '提交成功,等待审核', icon: 'none', @@ -1477,30 +1499,56 @@ Page({ showCooperationDetail(e) { const type = e.currentTarget.dataset.type; const cooperationDetails = { - '货源委托': { - title: '货源委托', - content: '货源委托是指供应商将货源委托给平台销售,平台负责销售和结算,供应商无需自行销售,只需要按照约定时间、数量、质量标准提供货源即可。' + '代销业务': { + title: '代销业务规则', + content: '\n定价规则:代销商户可自主制定所挂货源的销售价格,价格需符合平台物价管控要求,不得恶意定价。\n\n服务费规则:平台对代销挂货收取固定服务费,标准为1 元 / 件,仅在货源成功卖出后收取,未卖出不产生费用。\n\n保证金规则\n\n参与代销业务的商户需按合作车型缴纳保证金,具体标准如下:\n\n4.2 米车型:300 元 / 车\n\n6.8 米车型:500 元 / 车\n\n9.6 米车型:800 元 / 车\n\n挂车车型:1200 元 / 车\n\n保证金仅作为履约担保,合作结束且无违规违约行为的,平台将按原支付路径全额退回。\n\n协议签署要求:商户参与代销业务前,需与平台签订《委托代销协议书》,明确双方权利、义务及违约责任。\n\n销售风险说明:平台仅提供货源展示、交易撮合服务,不保证代销货源一定能够卖出,货源滞销风险由商户自行承担。\n' }, - '自主定价销售': { - title: '自主定价销售', - content: '供应商可以自主制定销售价格,自行负责销售和盈亏,平台提供交易撮合服务,按约定收取服务费。' + '包场合作': { + title: '包销合作规则', + content: '\n(一)包场销售(平台自负盈亏模式)\n\n1. 合作机制:平台与乙方就指定货源协商定价后,由平台全款收购该批货源,按约定时间结算价格,货权归属平台。\n\n2. 乙方义务:乙方需按照合作约定的时间、数量、质量标准提供货源,不得出现拖欠货源、擅自将约定货源自主销售等违约行为。\n\n3. 销售与盈亏:平台自主负责收购货源的销售事宜,独立承担销售过程中的盈利与亏损。\n\n(二)包场销售(乙方自主销售模式)\n\n1. 销售限制:乙方可自主销售约定货源,或委托平台销售,严禁将该批货源委托给平台及乙方之外的第三方销售。\n\n2. 兜底与结算:平台不承担该批货源的销售兜底责任,不设定固定结算周期,实行每日结算。\n\n3. 抽成与利润分配:(委托平台销售)\n\n盈利场景:每日销售盈利部分由甲方与乙方对等分配,平台同步按1元/件标准抽取费用。\n\n亏损场景:若当日销售无盈利或者亏损,平台仍按0.8元/件标准抽取费用(可打折)\n' }, - '区域包场合作': { - title: '区域包场合作', - content: '在指定区域内独家合作,享受区域保护政策,平台提供区域内的独家销售权限和支持。' + '采销联盟合作': { + title: '采销联盟合作规则', + content: '\n1. 合作主体:外部采购公司可通过成立独立的盒子公司,与平台开展货源包场或货源收购合作。\n\n2. 风险承担:盒子公司承担合作过程中产生的各类风险(包括但不限于货源质量风险、销售风险、市场风险等)。\n\n3. 利润分配:合作产生的净利润按以下比例分配:平台占20%、甲方占30%、乙方(盒子公司对应的外部采购公司)占50%。\n' }, '其他': { - title: '其他合作模式', - content: '其他特殊合作模式,需与平台单独协商具体合作条款和条件。' + title: '其他', + content: '其他合作模式' } }; - this.setData({ - selectedCooperationDetail: cooperationDetails[type] || { - title: type, - content: '暂无详细说明' - } - }); + // 切换显示/隐藏功能 + if (this.data.selectedCooperationDetail && this.data.selectedCooperationDetail.title === cooperationDetails[type].title) { + // 再次点击同一个按钮,收起详情 + this.setData({ + selectedCooperationDetail: null + }); + } else { + // 点击不同按钮,显示详情 + this.setData({ + selectedCooperationDetail: cooperationDetails[type] || { + title: type, + content: '暂无详细说明' + } + }); + + // 设置需要滚动到的ID + this.setData({ + scrollToView: 'cooperation-detail-content' + }); + + // 延迟执行一次滚动到底部,确保内容完全可见 + setTimeout(() => { + const query = wx.createSelectorQuery().in(this); + query.select('.cooperation-help-container').node().exec(nodes => { + const container = nodes[0].node; + if (container) { + // 确保滚动到最底部 + container.scrollTop = container.scrollHeight; + } + }); + }, 400); + } }, /** diff --git a/pages/settlement/index.wxml b/pages/settlement/index.wxml index b89c355..d1d367c 100644 --- a/pages/settlement/index.wxml +++ b/pages/settlement/index.wxml @@ -146,28 +146,28 @@ - 货源委托 + 代销业务 - 自主定价销售 + 采销联盟合作 - 区域包场合作 + 包场合作 - + 合作模式说明 - - - - + + + + - + {{selectedCooperationDetail.title}} {{selectedCooperationDetail.content}} - + \ No newline at end of file diff --git a/pages/settlement/index.wxss b/pages/settlement/index.wxss index f9a2e48..f064266 100644 --- a/pages/settlement/index.wxss +++ b/pages/settlement/index.wxss @@ -780,8 +780,9 @@ picker { .cooperation-option.active { border-color: #07C160; - background: #e8f7ed; - box-shadow: 0 2rpx 8rpx rgba(7, 193, 96, 0.15); + border-width: 3rpx; + background: #ffffff; + box-shadow: 0 4rpx 12rpx rgba(7, 193, 96, 0.2); } .cooperation-option:active { @@ -875,18 +876,21 @@ picker { align-items: center; justify-content: center; z-index: 9999; - padding: 20rpx; + padding: 0; } .cooperation-help-container { background-color: #fff; - border-radius: 20rpx; - padding: 50rpx 40rpx; - max-width: 92%; - max-height: 88%; + border-radius: 0; + padding: 50rpx 40rpx 150rpx; + width: 100%; + height: 100%; + max-width: 100%; + max-height: 100%; overflow-y: auto; - box-shadow: 0 12rpx 40rpx rgba(0, 0, 0, 0.2); + box-shadow: none; background: linear-gradient(to bottom, #ffffff, #f8f9fa); + display: block; } /* 自定义滚动条样式 */ @@ -913,9 +917,9 @@ picker { font-size: 38rpx; font-weight: bold; color: #2c3e50; - margin-bottom: 40rpx; + margin-bottom: 20rpx; text-align: center; - padding-bottom: 25rpx; + padding-bottom: 15rpx; border-bottom: 2rpx solid #e8f5e8; letter-spacing: 2rpx; } @@ -924,7 +928,13 @@ picker { font-size: 30rpx; color: #555555; line-height: 56rpx; - margin-bottom: 50rpx; + margin-bottom: 20rpx; + width: 100%; + text-align: center; + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; } /* 一级标题样式 */ @@ -984,18 +994,22 @@ picker { .cooperation-buttons { display: flex; flex-direction: column; - gap: 20rpx; - margin-bottom: 30rpx; + gap: 25rpx; + margin-bottom: 60rpx; + margin-top: 400rpx; + width: 100%; + align-items: center; + justify-content: center; } .cooperation-button { - width: 100%; - padding: 24rpx; + width: 80%; + padding: 30rpx; background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%); color: #333; border: 2rpx solid rgba(7, 193, 96, 0.2); - border-radius: 12rpx; - font-size: 30rpx; + border-radius: 16rpx; + font-size: 32rpx; font-weight: 500; transition: all 0.3s ease; cursor: pointer; @@ -1003,15 +1017,31 @@ picker { display: flex; justify-content: center; align-items: center; + margin: 0 auto; +} + +/* 为帮助弹窗中的合作模式按钮添加选中样式 */ +.cooperation-button.selected { + border-color: #07C160; + border-width: 3rpx; + background: #ffffff; + box-shadow: 0 4rpx 12rpx rgba(7, 193, 96, 0.2); + color: #07C160; + font-weight: 600; } +/* 移除原有的激活状态渐变背景,保持一致的样式 */ .cooperation-button:active { transform: scale(0.98); - background: linear-gradient(135deg, #07C160 0%, #06ae56 100%); - color: white; + background: #ffffff; + color: #07C160; border-color: #07C160; } +.cooperation-button.selected:active { + background: #f8fff8; +} + .cooperation-detail { margin-top: 20rpx; padding: 24rpx; @@ -1038,7 +1068,7 @@ picker { /* 按钮样式优化 */ .cooperation-help-button { - width: 100%; + width: 80%; height: 92rpx; background: linear-gradient(135deg, #07C160 0%, #06b358 100%); color: #fff; @@ -1048,9 +1078,21 @@ picker { font-weight: bold; cursor: pointer; transition: all 0.3s ease; - margin-top: 30rpx; + margin-top: 60rpx; box-shadow: 0 6rpx 20rpx rgba(7, 193, 96, 0.3); letter-spacing: 2rpx; + display: flex; + align-items: center; + justify-content: center; + line-height: 1; + margin-left: auto; + margin-right: auto; + position: sticky; + bottom: 40rpx; + left: 0; + right: 0; + z-index: 10; + background-color: #07C160; } .cooperation-help-button:active { diff --git a/project.private.config.json b/project.private.config.json index aa76ea0..d1719b1 100644 --- a/project.private.config.json +++ b/project.private.config.json @@ -1,6 +1,6 @@ { "libVersion": "3.10.3", - "projectname": "Program-mini", + "projectname": "New2", "setting": { "urlCheck": false, "coverView": true,