更新代码:同步最新变更

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

View File

@ -359,7 +359,7 @@
"path" : "addAiad", "path" : "addAiad",
"style" : "style" :
{ {
"navigationBarTitleText" : "修改地址", "navigationBarTitleText" : "联系我们",
"navigationBarBackgroundColor": "#19367A", "navigationBarBackgroundColor": "#19367A",
"navigationBarTextStyle": "white" "navigationBarTextStyle": "white"
} }
@ -376,9 +376,9 @@
], ],
"globalStyle": { "globalStyle": {
"navigationBarTextStyle": "black", "navigationBarTextStyle": "black",
"navigationBarTitleText": "", "navigationBarTitleText": "uni-app",
"navigationBarBackgroundColor": "#FDFDFD" "navigationBarBackgroundColor": "#F8F8F8",
// "navigationStyle": "custom" "backgroundColor": "#F8F8F8"
}, },
"tabBar": { "tabBar": {
"selectedColor": "#1A1A1A", "selectedColor": "#1A1A1A",
@ -429,7 +429,8 @@
"autoscan": true, "autoscan": true,
"custom": { "custom": {
"^u-(.*)": "uview-ui/components/u-$1/u-$1.vue", "^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" :refresher-triggered="isRefreshing"
@refresherrefresh="onRefresh" @refresherrefresh="onRefresh"
> >
<view class="activity-item flex" v-for="(it, index) in activeList" :key="index" @click="toDetail(it)"> <activity-item
<view class="left flex flex-col justify-between align-center"> v-for="(item, index) in activeList"
<image :src="it.brandLogo" style="width: 140rpx;height: 140rpx;"></image> :key="index"
<text>活动状态</text> :item="item"
<view v-if="it.audit_status == 0" style="color: #9E9E9E;font-size: 24rpx;">待审核</view> @click="toDetail"
<view v-if="it.audit_status == 2" style="color: #DE3C4B;font-size: 24rpx;">未通过</view> @review="toReview"
<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>
<view class="cu-load" :class="loading?'loading': activeList.length == total ? 'over' :'more'"></view> <view class="cu-load" :class="loading?'loading': activeList.length == total ? 'over' :'more'"></view>
</scroll-view> </scroll-view>
</view> </view>
<loginPopup ref="loginRef"></loginPopup> <login-popup ref="loginRef"></login-popup>
<!-- 品牌筛选组件 --> <!-- 品牌筛选组件 -->
<brand-filter ref="brandFilterRef" @confirm="onBrandFilterConfirm"></brand-filter> <brand-filter ref="brandFilterRef" @confirm="onBrandFilterConfirm"></brand-filter>
</view> </view>
@ -81,11 +54,13 @@
} from '@/api/bar.js' } from '@/api/bar.js'
import loginPopup from '@/components/loginPopup.vue' import loginPopup from '@/components/loginPopup.vue'
import brandFilter from '@/components/brandFilter.vue' import brandFilter from '@/components/brandFilter.vue'
import ActivityItem from '@/components/ActivityItem.vue'
export default { export default {
components: { components: {
loginPopup, loginPopup,
brandFilter brandFilter,
ActivityItem
}, },
data() { data() {
return { return {

View File

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

View File

@ -602,12 +602,39 @@ export default {
// //
uni.hideLoading(); uni.hideLoading();
//
let errorMessage = error.message || '提交失败';
//
if (errorMessage.includes('手机号') && errorMessage.includes('已注册')) {
errorMessage = '该手机号已注册,请直接登录或使用其他手机号';
} else if (errorMessage.includes('手机号') && errorMessage.includes('存在')) {
errorMessage = '该手机号已存在,请直接登录或使用其他手机号';
}
// //
uni.showToast({ uni.showToast({
title: error.message || '提交失败', title: errorMessage,
icon: 'none', 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') const barInfo = uni.getStorageSync('barInfo')
if (!barInfo || barInfo.authState !== 2) { if (!barInfo) {
uni.showModal({ uni.showModal({
title: '提示', title: '提示',
content: '请先认证门店', content: '请先认证门店',
@ -393,6 +393,29 @@
return 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({ uni.navigateTo({
url: '/pages/index/writeReview?beerId=' + this.beerId url: '/pages/index/writeReview?beerId=' + this.beerId
}) })
@ -420,7 +443,7 @@
// //
const barInfo = uni.getStorageSync('barInfo') const barInfo = uni.getStorageSync('barInfo')
if (!barInfo || barInfo.authState !== 2) { if (!barInfo) {
uni.showModal({ uni.showModal({
title: '提示', title: '提示',
content: '请先认证门店', content: '请先认证门店',
@ -436,6 +459,29 @@
return 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 = {
beerId: this.beerId, beerId: this.beerId,
status status
@ -492,7 +538,7 @@
// //
const barInfo = uni.getStorageSync('barInfo') const barInfo = uni.getStorageSync('barInfo')
if (!barInfo || barInfo.authState !== 2) { if (!barInfo) {
uni.showModal({ uni.showModal({
title: '提示', title: '提示',
content: '请先认证门店', content: '请先认证门店',
@ -508,6 +554,29 @@
return 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({ uni.navigateTo({
url: "/pagesActivity/winelist?beerId=" + this.beerId url: "/pagesActivity/winelist?beerId=" + this.beerId
}) })

View File

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