修复登录判定和刷新逻辑,优化认证审核中状态处理,修复活动点击跳转和收藏功能

This commit is contained in:
davy 2025-04-06 14:55:47 +08:00
parent e09db16283
commit 9a40cea7fa
3 changed files with 165 additions and 151 deletions

View File

@ -64,36 +64,13 @@
<!-- 累积活动 --> <!-- 累积活动 -->
<view v-if="currentTab == 1"> <view v-if="currentTab == 1">
<scroll-view scroll-y enable-flex class="scroll-container" @scrolltolower="changeActPage"> <scroll-view scroll-y enable-flex class="scroll-container" @scrolltolower="changeActPage">
<view class="activity-item flex" v-for="(it, index) in activityList" :key="index"> <activity-item
<view class="left flex flex-col justify-between align-center"> v-for="(item, index) in activityList"
<image :src="it.brandLogo" style="width: 140rpx;height: 140rpx;"></image> :key="index"
<view class="margin-bottom-xs" style="color: #9E9E9E;font-size: 24rpx;">招募即将结束</view> :item="item"
<view> @click="toActivityDetail"
<text style="font-size: 72rpx; color: #DE3C4B;">{{it.remainingDays}}</text> @review="toReview"
</view> ></activity-item>
</view>
<view class="right">
<!-- <view class="title">{{ it.activityName }}</view> -->
<view class="title">{{ it.breweryName }}</view>
<view class="sub">时间首次扫码开始累计 <text style="color:#DE3C4B">{{it.duration}}天内</text></view>
<view class="sub">目标全系列酒款累积扫码 {{ it.activityTarget}}</view>
<scroll-view v-if="it.beers" scroll-x="true" class="scroll-img">
<view class="beer-box" v-for="(it, index) in it.beers" :key="index"
@click="toReview(it)">
<image v-if="it.cover" :src="it.cover" class="cover"></image>
</view>
</scroll-view>
<view class="flex align-center">
<text
v-if="it.activityRewardType == 2 || (it.activityRewardType == 1 && it.activityRewardGoods)"
class="zeng"></text>
<text v-if="it.activityRewardType == 1 && it.activityRewardGoods"
style="color: #0B0E26;font-size: 24rpx;">{{it.activityRewardGoods.goodsName}} * {{it.activityRewardCount}}</text>
<text v-if="it.activityRewardType == 2" style="color: #0B0E26;font-size: 24rpx;">啤酒币 * {{it.activityRewardCount}}</text>
</view>
</view>
</view>
<view class="cu-load" style="width: 100%;" <view class="cu-load" style="width: 100%;"
:class="loading?'loading': activityList.length == activityTotal ? 'over' :'more'"></view> :class="loading?'loading': activityList.length == activityTotal ? 'over' :'more'"></view>
</scroll-view> </scroll-view>
@ -163,10 +140,11 @@
getBreweryCoinBalance getBreweryCoinBalance
} from '@/api/bar.js' } from '@/api/bar.js'
import loginPopup from '@/components/loginPopup.vue'; import loginPopup from '@/components/loginPopup.vue';
import ActivityItem from '@/components/ActivityItem.vue';
export default { export default {
components: { components: {
loginPopup, loginPopup,
// createPoster ActivityItem
}, },
data() { data() {
return { return {
@ -260,8 +238,13 @@
getBreweryCoinBalanceFun() { getBreweryCoinBalanceFun() {
getBreweryCoinBalance(this.breweryId).then(res => { getBreweryCoinBalance(this.breweryId).then(res => {
if (res.data) { 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 { } else {
this.isFavor = false this.isFavor = false
} }
}).catch(err => {
console.error('获取收藏状态失败:', err)
uni.showToast({
title: err.msg || '获取收藏状态失败,请稍后重试',
icon: 'none'
})
}) })
}, },
// //
@ -299,6 +288,12 @@
getBreweryInfoFun() { getBreweryInfoFun() {
getBreweryInfo(this.breweryId).then(res => { getBreweryInfo(this.breweryId).then(res => {
this.breweryInfo = res.data this.breweryInfo = res.data
}).catch(err => {
console.error('获取品牌方详情失败:', err)
uni.showToast({
title: err.msg || '获取品牌方详情失败,请稍后重试',
icon: 'none'
})
}) })
}, },
// //
@ -316,7 +311,12 @@
this.activityList.push(it) this.activityList.push(it)
}) })
} }
}).catch(() => { }).catch(err => {
console.error('获取累积活动失败:', err)
uni.showToast({
title: err.msg || '获取活动列表失败,请稍后重试',
icon: 'none'
})
this.loading = false this.loading = false
}) })
}, },
@ -337,8 +337,12 @@
this.beerList.push(it) this.beerList.push(it)
}) })
} }
}).catch(err => {
}).catch(() => { console.error('获取在售酒款失败:', err)
uni.showToast({
title: err.msg || '获取酒款列表失败,请稍后重试',
icon: 'none'
})
this.loading = false this.loading = false
}) })
}, },
@ -360,7 +364,12 @@
this.goodsList.push(it) this.goodsList.push(it)
}) })
} }
}).catch(() => { }).catch(err => {
console.error('获取兑换商品失败:', err)
uni.showToast({
title: err.msg || '获取商品列表失败,请稍后重试',
icon: 'none'
})
this.loading = false this.loading = false
}) })
}, },
@ -372,23 +381,91 @@
}, },
// //
favorBreweryFun(status) { 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 = { let data = {
breweryId: this.breweryId, breweryId: this.breweryId,
status status
} }
favorBrewery(data).then(res => { favorBrewery(data).then(res => {
if (status == 1) { if (status == 1) {
this.isFavor = true
uni.showToast({ uni.showToast({
title: '收藏成功', title: '收藏成功',
icon: 'success' icon: 'success'
}) })
} else { } else {
this.isFavor = false
uni.showToast({ uni.showToast({
title: '取消收藏', title: '取消收藏',
icon: 'none' 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 url: "/pagesCoin/goodsDetail?id=" + item.id + "&breweryId=" + item.breweryId
}) })
}, },
// //
toActivityDetail(item) {
uni.navigateTo({
url: "/pagesActivity/activityDetail?id=" + item.id
})
},
//
toReview(it) { toReview(it) {
const token = uni.getStorageSync('token')
if (!token) {
this.$refs.loginRef.open()
return
}
uni.navigateTo({ uni.navigateTo({
url: "/pages/index/review?beerId=" + it.id url: "/pages/index/review?beerId=" + it.id
}) })
@ -488,89 +576,9 @@
} }
// //
.activity-item { .scroll-container {
border-radius: 20rpx; margin-bottom: 50rpx;
background: #FDFDFD; padding: 0 24rpx;
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;
}
}
} }
// //

View File

@ -181,19 +181,39 @@
this.isLoggedIn = true; this.isLoggedIn = true;
this.userInfo = userInfo; this.userInfo = userInfo;
// //
try { await getBarInfo().then(res => {
await Promise.all([ if (res && res.data) {
this.getBarInfoFun(), this.barInfo = res.data;
this.getMyScanDataFun() //
]); if (this.barInfo.authState === 1) {
console.log('所有数据更新完成'); this.myScanData = { scanCount: 0, percent: 0 };
} catch (err) { }
console.error('数据更新失败:', err); }
// }).catch(err => {
uni.showToast({ console.error('获取酒吧信息失败:', err);
title: '数据更新失败', if (err.code === 500 && err.msg.includes('门店未认证')) {
icon: 'none' 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 };
}); });
} }

View File

@ -443,7 +443,7 @@
// //
const barInfo = uni.getStorageSync('barInfo') const barInfo = uni.getStorageSync('barInfo')
if (!barInfo) { if (!barInfo || barInfo.authState === 0) {
uni.showModal({ uni.showModal({
title: '提示', title: '提示',
content: '请先认证门店', content: '请先认证门店',
@ -459,22 +459,7 @@
return return
} }
// if (barInfo.authState === 1) {
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({ uni.showToast({
title: '您的门店正在认证中,请耐心等待', title: '您的门店正在认证中,请耐心等待',
icon: 'none' icon: 'none'
@ -501,6 +486,7 @@
}) })
} }
}).catch(err => { }).catch(err => {
console.error('收藏操作失败:', err)
if (err.code === 500 && err.msg.includes('门店未认证')) { if (err.code === 500 && err.msg.includes('门店未认证')) {
uni.showModal({ uni.showModal({
title: '提示', title: '提示',