更新代码:同步最新变更

This commit is contained in:
davy 2025-04-05 14:07:39 +08:00
parent 7c565ff4ad
commit b2bbfcd9e2
8 changed files with 385 additions and 69 deletions

137
components/ActivityItem.vue Normal file
View File

@ -0,0 +1,137 @@
<template>
<view class="activity-item flex" @click="handleClick">
<view class="left flex flex-col justify-between align-center">
<image :src="item.brandLogo" style="width: 140rpx;height: 140rpx;"></image>
<text>活动状态</text>
<view v-if="item.audit_status == 0" style="color: #9E9E9E;font-size: 24rpx;">待审核</view>
<view v-if="item.audit_status == 2" style="color: #DE3C4B;font-size: 24rpx;">未通过</view>
<view v-if="item.audit_status == 1">
<block v-if="item.activity_status == 1">
<view class="margin-bottom-xs" style="color: #9E9E9E;font-size: 24rpx;">招募进行中</view>
<view>
<text style="font-size: 72rpx; color: #DE3C4B;">{{item.remainingDays}}</text>
</view>
</block>
<block v-else>
<view style="color: #9E9E9E;font-size: 24rpx;">活动已结束</view>
</block>
</view>
</view>
<view class="right">
<view class="title">{{ item.breweryName }}</view>
<view class="sub">时间首次扫码开始累计 <text style="color:#DE3C4B">{{item.duration}}天内</text></view>
<view class="sub">目标全系列酒款累积扫码 {{ item.activityTarget}}</view>
<scroll-view v-if="item.beers" scroll-x="true" class="scroll-img">
<view class="beer-box" v-for="(beer, beerIndex) in item.beers" :key="beerIndex" @click.stop="handleReview(beer)">
<image v-if="beer.cover" :src="beer.cover" class="cover"></image>
</view>
</scroll-view>
<view class="flex align-center">
<text v-if="item.activityRewardType == 2 || (item.activityRewardType == 1 && item.activityRewardGoods)" class="zeng"></text>
<text v-if="item.activityRewardType == 1 && item.activityRewardGoods" style="color: #0B0E26;font-size: 24rpx;">{{item.activityRewardGoods.goodsName}} * {{item.activityRewardCount}}</text>
<text v-if="item.activityRewardType == 2" style="color: #0B0E26;font-size: 24rpx;">啤酒币 * {{item.activityRewardCount}}</text>
</view>
</view>
</view>
</template>
<script>
export default {
name: 'activity-item',
props: {
item: {
type: Object,
required: true
}
},
methods: {
handleClick() {
this.$emit('click', this.item)
},
handleReview(beer) {
this.$emit('review', beer)
}
}
}
</script>
<style lang="scss" scoped>
.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;
.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;
}
}
}
</style>

View File

@ -102,6 +102,8 @@
getOpenId(loginRes.code).then(res => {
console.log(res.token)
this.openId = res.openId
// openIdstorage
uni.setStorageSync('openId', res.openId)
if (res.token) {
uni.setStorageSync('token', res.token)
//
@ -158,6 +160,8 @@
// barId
if (!res.user.barId) {
// storageopenId
const openId = uni.getStorageSync('openId') || this.openId
uni.showModal({
title: '提示',
content: '您还未认证门店,请先认证',
@ -166,7 +170,7 @@
if (res.confirm) {
console.log('确定')
uni.navigateTo({
url: '/pages/index/registration?openId=' + this.openId
url: '/pages/index/registration?openId=' + openId
})
}
}

View File

@ -359,7 +359,7 @@
"path" : "addAiad",
"style" :
{
"navigationBarTitleText" : "修改地址",
"navigationBarTitleText" : "联系我们",
"navigationBarBackgroundColor": "#19367A",
"navigationBarTextStyle": "white"
}
@ -376,9 +376,9 @@
],
"globalStyle": {
"navigationBarTextStyle": "black",
"navigationBarTitleText": "",
"navigationBarBackgroundColor": "#FDFDFD"
// "navigationStyle": "custom"
"navigationBarTitleText": "uni-app",
"navigationBarBackgroundColor": "#F8F8F8",
"backgroundColor": "#F8F8F8"
},
"tabBar": {
"selectedColor": "#1A1A1A",
@ -429,7 +429,8 @@
"autoscan": true,
"custom": {
"^u-(.*)": "uview-ui/components/u-$1/u-$1.vue",
"^brand-filter": "@/components/brandFilter.vue"
"^brand-filter": "@/components/brandFilter.vue",
"^activity-item": "@/components/ActivityItem.vue"
}
}
}

View File

@ -31,44 +31,17 @@
:refresher-triggered="isRefreshing"
@refresherrefresh="onRefresh"
>
<view class="activity-item flex" v-for="(it, index) in activeList" :key="index" @click="toDetail(it)">
<view class="left flex flex-col justify-between align-center">
<image :src="it.brandLogo" style="width: 140rpx;height: 140rpx;"></image>
<text>活动状态</text>
<view v-if="it.audit_status == 0" style="color: #9E9E9E;font-size: 24rpx;">待审核</view>
<view v-if="it.audit_status == 2" style="color: #DE3C4B;font-size: 24rpx;">未通过</view>
<view v-if="it.audit_status == 1">
<block v-if="it.activity_status == 1">
<view class="margin-bottom-xs" style="color: #9E9E9E;font-size: 24rpx;">招募进行中</view>
<view>
<text style="font-size: 72rpx; color: #DE3C4B;">{{it.remainingDays}}</text>
</view>
</block>
<block v-else>
<view style="color: #9E9E9E;font-size: 24rpx;">活动已结束</view>
</block>
</view>
</view>
<view class="right">
<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="(beer, beerIndex) in it.beers" :key="beerIndex" @click="toReview(beer)">
<image v-if="beer.cover" :src="beer.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 activeList"
:key="index"
:item="item"
@click="toDetail"
@review="toReview"
/>
<view class="cu-load" :class="loading?'loading': activeList.length == total ? 'over' :'more'"></view>
</scroll-view>
</view>
<loginPopup ref="loginRef"></loginPopup>
<login-popup ref="loginRef"></login-popup>
<!-- 品牌筛选组件 -->
<brand-filter ref="brandFilterRef" @confirm="onBrandFilterConfirm"></brand-filter>
</view>
@ -81,11 +54,13 @@
} from '@/api/bar.js'
import loginPopup from '@/components/loginPopup.vue'
import brandFilter from '@/components/brandFilter.vue'
import ActivityItem from '@/components/ActivityItem.vue'
export default {
components: {
loginPopup,
brandFilter
brandFilter,
ActivityItem
},
data() {
return {

View File

@ -22,12 +22,11 @@
<text>登录/认证</text>
</block>
<block v-else-if="userStatus === 'unverified'">
<!-- <text>您的门店未认证</text> -->
<text>请点击认证门店信息</text>
</block>
<block v-else-if="userStatus === 'verifying'">
<text>正在认证审核中</text>
<!-- <text>请耐心等待</text> -->
<text style="font-size: 24rpx; color: #999;">请耐心等待</text>
</block>
</view>
<text class="cuIcon-right" style="color: #999999; font-size: 32rpx;"></text>
@ -133,6 +132,13 @@
computed: {
//
userStatus() {
//
console.log('计算用户状态:', {
isLoggedIn: this.isLoggedIn,
barInfo: this.barInfo,
authState: this.barInfo ? this.barInfo.authState : 'barInfo为空'
});
if (!this.isLoggedIn) return 'guest' //
if (!this.barInfo || this.barInfo.authState === 0) return 'unverified' //
if (this.barInfo.authState === 1) return 'verifying' //
@ -143,10 +149,15 @@
this.statusBaeHeight = uni.getWindowInfo.statusBarHeight
},
onShow() {
this.checkLoginStatus()
console.log('页面显示,检查登录状态');
this.checkLoginStatus();
if (this.isLoggedIn) {
this.getBarInfoFun()
this.getMyScanDataFun()
console.log('已登录,获取酒吧信息和扫码数据');
this.getBarInfoFun();
this.getMyScanDataFun();
} else {
console.log('未登录,不获取数据');
}
},
methods: {
@ -177,42 +188,104 @@
this.userInfo = userInfo
}
//
console.log('登录状态检查:', {
token: token,
isLoggedIn: this.isLoggedIn,
userInfo: this.userInfo
})
this.loading = false
},
loginSuccess() {
this.userInfo = uni.getStorageSync('userInfo')
this.getBarInfoFun()
this.getMyScanDataFun()
console.log('登录成功,开始更新页面数据');
//
this.isLoggedIn = true;
this.userInfo = uni.getStorageSync('userInfo');
// 使 Promise.all
Promise.all([
this.getBarInfoFun(),
this.getMyScanDataFun()
]).then(() => {
console.log('所有数据更新完成');
//
this.$forceUpdate();
//
uni.showToast({
title: '登录成功',
icon: 'success',
duration: 1500
});
}).catch(err => {
console.error('数据更新失败:', err);
uni.showToast({
title: '数据更新失败',
icon: 'none'
});
});
},
//
getBarInfoFun() {
if (!this.isLoggedIn) return
if (!this.isLoggedIn) {
console.log('用户未登录,不获取酒吧信息')
return
}
getBarInfo().then(res => {
if (res.code === 200) {
console.log('获取酒吧信息成功:', res)
if (res && res.data) {
this.barInfo = res.data
//
if (this.barInfo.authState === 2) {
//
this.isVerified = true
this.isVerifying = false
} else if (this.barInfo.authState === 1) {
//
this.isVerified = false
this.isVerifying = true
} else {
//
this.isVerified = false
this.isVerifying = false
}
//
this.$forceUpdate()
} else {
console.log('获取酒吧信息成功,但数据为空')
this.barInfo = null
this.isVerified = false
this.isVerifying = false
}
}).catch(err => {
console.error('获取酒吧信息失败:', err)
uni.showToast({
title: '获取酒吧信息失败',
icon: 'none'
})
this.barInfo = null
this.isVerified = false
this.isVerifying = false
})
},
//
getMyScanDataFun() {
if (!this.isLoggedIn) return
getMyScanData().then(res => {
if (!this.isLoggedIn) {
return Promise.reject('未登录');
}
return getMyScanData().then(res => {
if (res.code === 200) {
this.myScanData = res.data
this.myScanData = res.data;
return this.myScanData;
} else {
return Promise.reject(res);
}
}).catch(err => {
console.error('获取扫码数据失败:', err)
console.error('获取扫码数据失败:', err);
uni.showToast({
title: '获取扫码数据失败',
icon: 'none'
})
})
});
return Promise.reject(err);
});
},
//
handleUserBoxClick() {

View File

@ -602,12 +602,39 @@ export default {
//
uni.hideLoading();
//
let errorMessage = error.message || '提交失败';
//
if (errorMessage.includes('手机号') && errorMessage.includes('已注册')) {
errorMessage = '该手机号已注册,请直接登录或使用其他手机号';
} else if (errorMessage.includes('手机号') && errorMessage.includes('存在')) {
errorMessage = '该手机号已存在,请直接登录或使用其他手机号';
}
//
uni.showToast({
title: error.message || '提交失败',
title: errorMessage,
icon: 'none',
duration: 2000
duration: 3000
});
//
if (errorMessage.includes('手机号') && (errorMessage.includes('已注册') || errorMessage.includes('已存在'))) {
setTimeout(() => {
uni.showModal({
title: '提示',
content: '是否前往登录页面?',
success: (res) => {
if (res.confirm) {
uni.navigateTo({
url: '/pages/index/phoneLogin'
});
}
}
});
}, 1500);
}
}
},

View File

@ -377,7 +377,7 @@
//
const barInfo = uni.getStorageSync('barInfo')
if (!barInfo || barInfo.authState !== 2) {
if (!barInfo) {
uni.showModal({
title: '提示',
content: '请先认证门店',
@ -393,6 +393,29 @@
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
}
uni.navigateTo({
url: '/pages/index/writeReview?beerId=' + this.beerId
})
@ -420,7 +443,7 @@
//
const barInfo = uni.getStorageSync('barInfo')
if (!barInfo || barInfo.authState !== 2) {
if (!barInfo) {
uni.showModal({
title: '提示',
content: '请先认证门店',
@ -436,6 +459,29 @@
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 = {
beerId: this.beerId,
status
@ -492,7 +538,7 @@
//
const barInfo = uni.getStorageSync('barInfo')
if (!barInfo || barInfo.authState !== 2) {
if (!barInfo) {
uni.showModal({
title: '提示',
content: '请先认证门店',
@ -508,6 +554,29 @@
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
}
uni.navigateTo({
url: "/pagesActivity/winelist?beerId=" + this.beerId
})

View File

@ -128,6 +128,7 @@
barInfo: null,
isLoggedIn: false,
isVerified: false,
isVerifying: false,
navHeight: 0,
};
},
@ -149,11 +150,32 @@
this.isLoggedIn = !!token
this.userInfo = userInfo
this.barInfo = barInfo
this.isVerified = barInfo && barInfo.authState === 2
//
if (barInfo) {
if (barInfo.authState === 2) {
//
this.isVerified = true
this.isVerifying = false
} else if (barInfo.authState === 1) {
//
this.isVerified = false
this.isVerifying = true
} else {
//
this.isVerified = false
this.isVerifying = false
}
} else {
// 使userInfoisVerified
this.isVerified = userInfo?.isVerified === 1
this.isVerifying = false
}
console.log('【checkLoginStatus】登录状态:', {
isLoggedIn: this.isLoggedIn,
isVerified: this.isVerified,
isVerifying: this.isVerifying,
userInfo: this.userInfo,
barInfo: this.barInfo
})
@ -182,7 +204,7 @@
return
}
if (!this.isVerified) {
if (!this.isVerified && !this.isVerifying) {
uni.showModal({
title: '提示',
content: '请先认证门店',
@ -198,6 +220,14 @@
return
}
if (this.isVerifying) {
uni.showToast({
title: '您的门店正在认证中,请耐心等待',
icon: 'none'
})
return
}
uni.getSetting({
success: (res) => {
if (!res.authSetting['scope.userLocation']) {