diff --git a/components/ActivityItem.vue b/components/ActivityItem.vue new file mode 100644 index 0000000..7adf10a --- /dev/null +++ b/components/ActivityItem.vue @@ -0,0 +1,137 @@ + + + + + \ No newline at end of file diff --git a/components/loginPopup.vue b/components/loginPopup.vue index b5412d2..db166f8 100644 --- a/components/loginPopup.vue +++ b/components/loginPopup.vue @@ -102,6 +102,8 @@ getOpenId(loginRes.code).then(res => { console.log(res.token) this.openId = res.openId + // 保存openId到storage中 + uni.setStorageSync('openId', res.openId) if (res.token) { uni.setStorageSync('token', res.token) // 获取用户信息 @@ -158,6 +160,8 @@ // 如果没有barId,提示去认证 if (!res.user.barId) { + // 从storage中获取openId + 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 }) } } diff --git a/pages.json b/pages.json index 1ae9578..f6d3de5 100644 --- a/pages.json +++ b/pages.json @@ -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" } } } diff --git a/pages/activityList/activityList.vue b/pages/activityList/activityList.vue index 85b9843..d50f213 100644 --- a/pages/activityList/activityList.vue +++ b/pages/activityList/activityList.vue @@ -31,44 +31,17 @@ :refresher-triggered="isRefreshing" @refresherrefresh="onRefresh" > - - - - 活动状态 - 待审核 - 未通过 - - - 招募进行中 - - {{it.remainingDays}}天 - - - - 活动已结束 - - - - - {{ it.breweryName }} - 时间:首次扫码开始累计 {{it.duration}}天内 - 目标:全系列酒款累积扫码 ≥ {{ it.activityTarget}}桶 - - - - - - - - {{it.activityRewardGoods.goodsName}} * {{it.activityRewardCount}} - 啤酒币 * {{it.activityRewardCount}}个 - - - + - + @@ -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 { diff --git a/pages/index/my.vue b/pages/index/my.vue index b1f85f4..72cc409 100644 --- a/pages/index/my.vue +++ b/pages/index/my.vue @@ -22,12 +22,11 @@ 登录/认证 - 请点击认证门店信息 正在认证审核中 - + 请耐心等待 @@ -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() { diff --git a/pages/index/registration.vue b/pages/index/registration.vue index 53d7c4a..2a8b9d7 100644 --- a/pages/index/registration.vue +++ b/pages/index/registration.vue @@ -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); + } } }, diff --git a/pages/index/review.vue b/pages/index/review.vue index af21c43..ca47f13 100644 --- a/pages/index/review.vue +++ b/pages/index/review.vue @@ -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 }) diff --git a/pages/index/scan.vue b/pages/index/scan.vue index 581248f..9f7fa76 100644 --- a/pages/index/scan.vue +++ b/pages/index/scan.vue @@ -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 { + // 兼容旧版本,使用userInfo中的isVerified + 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']) {