修复登录判定和刷新逻辑,优化认证审核中状态处理,修复活动点击跳转和收藏功能
This commit is contained in:
parent
e09db16283
commit
9a40cea7fa
@ -64,36 +64,13 @@
|
||||
<!-- 累积活动 -->
|
||||
<view v-if="currentTab == 1">
|
||||
<scroll-view scroll-y enable-flex class="scroll-container" @scrolltolower="changeActPage">
|
||||
<view class="activity-item flex" v-for="(it, index) in activityList" :key="index">
|
||||
<view class="left flex flex-col justify-between align-center">
|
||||
<image :src="it.brandLogo" style="width: 140rpx;height: 140rpx;"></image>
|
||||
<view class="margin-bottom-xs" style="color: #9E9E9E;font-size: 24rpx;">招募即将结束</view>
|
||||
<view>
|
||||
<text style="font-size: 72rpx; color: #DE3C4B;">{{it.remainingDays}}</text>天
|
||||
</view>
|
||||
|
||||
</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>
|
||||
<activity-item
|
||||
v-for="(item, index) in activityList"
|
||||
:key="index"
|
||||
:item="item"
|
||||
@click="toActivityDetail"
|
||||
@review="toReview"
|
||||
></activity-item>
|
||||
<view class="cu-load" style="width: 100%;"
|
||||
:class="loading?'loading': activityList.length == activityTotal ? 'over' :'more'"></view>
|
||||
</scroll-view>
|
||||
@ -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;
|
||||
}
|
||||
|
||||
// 在售酒款
|
||||
|
@ -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 };
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -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: '提示',
|
||||
|
Loading…
x
Reference in New Issue
Block a user