From 9a40cea7fa4f394f124c7e218f74112b561a3293 Mon Sep 17 00:00:00 2001 From: davy Date: Sun, 6 Apr 2025 14:55:47 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=99=BB=E5=BD=95=E5=88=A4?= =?UTF-8?q?=E5=AE=9A=E5=92=8C=E5=88=B7=E6=96=B0=E9=80=BB=E8=BE=91=EF=BC=8C?= =?UTF-8?q?=E4=BC=98=E5=8C=96=E8=AE=A4=E8=AF=81=E5=AE=A1=E6=A0=B8=E4=B8=AD?= =?UTF-8?q?=E7=8A=B6=E6=80=81=E5=A4=84=E7=90=86=EF=BC=8C=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E6=B4=BB=E5=8A=A8=E7=82=B9=E5=87=BB=E8=B7=B3=E8=BD=AC=E5=92=8C?= =?UTF-8?q?=E6=94=B6=E8=97=8F=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/index/brandHome.vue | 250 ++++++++++++++++++++------------------ pages/index/my.vue | 46 +++++-- pages/index/review.vue | 20 +-- 3 files changed, 165 insertions(+), 151 deletions(-) diff --git a/pages/index/brandHome.vue b/pages/index/brandHome.vue index 82ae0be..e2ce2e7 100644 --- a/pages/index/brandHome.vue +++ b/pages/index/brandHome.vue @@ -64,36 +64,13 @@ - - - - 招募即将结束 - - {{it.remainingDays}}天 - - - - - - {{ it.breweryName }} - 时间:首次扫码开始累计 {{it.duration}}天内 - 目标:全系列酒款累积扫码 ≥ {{ it.activityTarget}}桶 - - - - - - - - {{it.activityRewardGoods.goodsName}} * {{it.activityRewardCount}} - 啤酒币 * {{it.activityRewardCount}}个 - - - + @@ -163,10 +140,11 @@ getBreweryCoinBalance } from '@/api/bar.js' import loginPopup from '@/components/loginPopup.vue'; + import ActivityItem from '@/components/ActivityItem.vue'; export default { components: { loginPopup, - // createPoster + ActivityItem }, data() { return { @@ -260,8 +238,13 @@ getBreweryCoinBalanceFun() { getBreweryCoinBalance(this.breweryId).then(res => { if (res.data) { - this.myCoin = res.data.balance + this.myCoin = res.data.balance || 0 + } else { + this.myCoin = 0 } + }).catch(err => { + console.error('获取啤酒币余额失败:', err) + this.myCoin = 0 }) }, // 收藏品牌方状态 @@ -272,6 +255,12 @@ } else { this.isFavor = false } + }).catch(err => { + console.error('获取收藏状态失败:', err) + uni.showToast({ + title: err.msg || '获取收藏状态失败,请稍后重试', + icon: 'none' + }) }) }, // 获取当前年月日 @@ -299,6 +288,12 @@ getBreweryInfoFun() { getBreweryInfo(this.breweryId).then(res => { this.breweryInfo = res.data + }).catch(err => { + console.error('获取品牌方详情失败:', err) + uni.showToast({ + title: err.msg || '获取品牌方详情失败,请稍后重试', + icon: 'none' + }) }) }, // 累积活动 @@ -316,7 +311,12 @@ this.activityList.push(it) }) } - }).catch(() => { + }).catch(err => { + console.error('获取累积活动失败:', err) + uni.showToast({ + title: err.msg || '获取活动列表失败,请稍后重试', + icon: 'none' + }) this.loading = false }) }, @@ -337,8 +337,12 @@ this.beerList.push(it) }) } - - }).catch(() => { + }).catch(err => { + console.error('获取在售酒款失败:', err) + uni.showToast({ + title: err.msg || '获取酒款列表失败,请稍后重试', + icon: 'none' + }) this.loading = false }) }, @@ -360,7 +364,12 @@ this.goodsList.push(it) }) } - }).catch(() => { + }).catch(err => { + console.error('获取兑换商品失败:', err) + uni.showToast({ + title: err.msg || '获取商品列表失败,请稍后重试', + icon: 'none' + }) this.loading = false }) }, @@ -372,23 +381,91 @@ }, // 收藏品牌方 favorBreweryFun(status) { + const token = uni.getStorageSync('token') + if (!token) { + this.$refs.loginRef.open() + return + } + + // 检查认证状态 + const barInfo = uni.getStorageSync('barInfo') + if (!barInfo) { + uni.showModal({ + title: '提示', + content: '请先认证门店', + showCancel: true, + success: (res) => { + if (res.confirm) { + uni.navigateTo({ + url: '/pages/index/registration' + }) + } + } + }) + return + } + + // 处理不同的认证状态 + if (barInfo.authState === 0) { + uni.showModal({ + title: '提示', + content: '请先认证门店', + showCancel: true, + success: (res) => { + if (res.confirm) { + uni.navigateTo({ + url: '/pages/index/registration' + }) + } + } + }) + return + } else if (barInfo.authState === 1) { + uni.showToast({ + title: '您的门店正在认证中,请耐心等待', + icon: 'none' + }) + return + } + let data = { breweryId: this.breweryId, status } favorBrewery(data).then(res => { if (status == 1) { + this.isFavor = true uni.showToast({ title: '收藏成功', icon: 'success' }) } else { + this.isFavor = false uni.showToast({ title: '取消收藏', icon: 'none' }) } - this.getBreweryFavorStatusFun() + }).catch(err => { + if (err.code === 500 && err.msg.includes('门店未认证')) { + uni.showModal({ + title: '提示', + content: '请先认证门店', + showCancel: true, + success: (res) => { + if (res.confirm) { + uni.navigateTo({ + url: '/pages/index/registration' + }) + } + } + }) + } else { + uni.showToast({ + title: err.msg || '操作失败', + icon: 'none' + }) + } }) }, // 跳转详情 @@ -397,8 +474,19 @@ url: "/pagesCoin/goodsDetail?id=" + item.id + "&breweryId=" + item.breweryId }) }, - // 跳转酒评页 + // 跳转活动详情 + toActivityDetail(item) { + uni.navigateTo({ + url: "/pagesActivity/activityDetail?id=" + item.id + }) + }, + // 跳转酒评 toReview(it) { + const token = uni.getStorageSync('token') + if (!token) { + this.$refs.loginRef.open() + return + } uni.navigateTo({ url: "/pages/index/review?beerId=" + it.id }) @@ -488,89 +576,9 @@ } // 累积活动 - .activity-item { - border-radius: 20rpx; - background: #FDFDFD; - box-sizing: border-box; - border: 1px solid #F2F2F2; - width: 702rpx; - margin-bottom: 32rpx; - - .left { - padding: 24rpx 20rpx; - border-radius: 20rpx; - background: #FFFFFF; - box-sizing: border-box; - border: 1px solid #EFEDE9; - width: 180rpx; - margin-top: -10rpx; - margin-bottom: -10rpx; - } - - .right { - padding: 20rpx; - flex: 1; - - .title { - font-family: Source Han Sans; - font-size: 28rpx; - font-weight: bold; - line-height: 30rpx; - color: #0B0E26; - margin-bottom: 20rpx; - } - - .sub { - font-family: Source Han Sans; - font-size: 24rpx; - font-weight: 500; - line-height: 30rpx; - color: #0B0E26; - margin-bottom: 16rpx; - - } - - .scroll-img { - width: 500rpx; - display: flex; - flex-direction: row; - white-space: nowrap; - height: 144rpx; - margin-bottom: 20rpx; - - .beer-box { - width: 100rpx; - background: #FFFFFF; - margin-right: 20rpx; - box-sizing: border-box; - display: inline-block; - - // &:nth-child(1) { - // margin-left: 32rpx; - // } - - .cover { - width: 100rpx; - height: 144rpx; - border-radius: 10rpx; - } - - } - } - - .zeng { - font-family: Source Han Sans; - font-size: 20rpx; - font-weight: bold; - line-height: normal; - text-align: center; - color: #0B0E26; - padding: 8rpx 12rpx; - border-radius: 10rpx; - background: #FEE034; - margin-right: 20rpx; - } - } + .scroll-container { + margin-bottom: 50rpx; + padding: 0 24rpx; } // 在售酒款 diff --git a/pages/index/my.vue b/pages/index/my.vue index c1574e9..76858b8 100644 --- a/pages/index/my.vue +++ b/pages/index/my.vue @@ -181,19 +181,39 @@ this.isLoggedIn = true; this.userInfo = userInfo; - // 获取酒吧信息和扫码数据 - try { - await Promise.all([ - this.getBarInfoFun(), - this.getMyScanDataFun() - ]); - console.log('所有数据更新完成'); - } catch (err) { - console.error('数据更新失败:', err); - // 不重置登录状态,只显示错误提示 - uni.showToast({ - title: '数据更新失败', - icon: 'none' + // 先获取酒吧信息 + await getBarInfo().then(res => { + if (res && res.data) { + this.barInfo = res.data; + // 如果是认证中状态,设置默认的扫码数据 + if (this.barInfo.authState === 1) { + this.myScanData = { scanCount: 0, percent: 0 }; + } + } + }).catch(err => { + console.error('获取酒吧信息失败:', err); + if (err.code === 500 && err.msg.includes('门店未认证')) { + this.barInfo = { + authState: 1, + barName: '', + barNumber: '', + barContactPhone: '' + }; + this.myScanData = { scanCount: 0, percent: 0 }; + } else { + this.barInfo = null; + } + }); + + // 如果不是认证中状态,获取扫码数据 + if (this.barInfo && this.barInfo.authState !== 1) { + await getMyScanData().then(res => { + if (res.code === 200) { + this.myScanData = res.data; + } + }).catch(err => { + console.error('获取扫码数据失败:', err); + this.myScanData = { scanCount: 0, percent: 0 }; }); } diff --git a/pages/index/review.vue b/pages/index/review.vue index a3b46a5..52768b2 100644 --- a/pages/index/review.vue +++ b/pages/index/review.vue @@ -443,7 +443,7 @@ // 检查认证状态 const barInfo = uni.getStorageSync('barInfo') - if (!barInfo) { + if (!barInfo || barInfo.authState === 0) { uni.showModal({ title: '提示', content: '请先认证门店', @@ -459,22 +459,7 @@ return } - // 处理不同的认证状态 - if (barInfo.authState === 0) { - uni.showModal({ - title: '提示', - content: '请先认证门店', - showCancel: true, - success: (res) => { - if (res.confirm) { - uni.navigateTo({ - url: '/pages/index/registration' - }) - } - } - }) - return - } else if (barInfo.authState === 1) { + if (barInfo.authState === 1) { uni.showToast({ title: '您的门店正在认证中,请耐心等待', icon: 'none' @@ -501,6 +486,7 @@ }) } }).catch(err => { + console.error('收藏操作失败:', err) if (err.code === 500 && err.msg.includes('门店未认证')) { uni.showModal({ title: '提示',