feat(event): 添加酒局报名审核功能并优化前端组件
- 新增 ApproveEvent API 接口用于审核报名用户
- 在 EventCard 组件中显示待审核状态(⏳ 待审核)
- 实现酒局发起人审核报名用户的完整流程
- 添加用户协议和隐私政策页面
- 优化 FeedCard 组件中的图片展示逻辑
- 修复连续打卡天数计算问题
- 更新 HaveADrink SDK 至 1.0.15 版本
This commit is contained in:
+39
-17
@@ -81,9 +81,9 @@
|
||||
<!-- 底部协议(非登录状态时显示) -->
|
||||
<view v-if="showNotice" class="agreement">
|
||||
<text class="text-tiny">登录即代表同意</text>
|
||||
<text class="text-tiny text-amber">《用户协议》</text>
|
||||
<text class="text-tiny text-amber" @click="openAgreement('user')">《用户协议》</text>
|
||||
<text class="text-tiny">和</text>
|
||||
<text class="text-tiny text-amber">《隐私政策》</text>
|
||||
<text class="text-tiny text-amber" @click="openAgreement('privacy')">《隐私政策》</text>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
@@ -149,6 +149,8 @@ export default {
|
||||
return
|
||||
}
|
||||
this.loginLoading = true
|
||||
let loginOk = false
|
||||
let loginErr = null
|
||||
try {
|
||||
// 1. 获取微信登录 code
|
||||
const loginRes = await this.wxLogin()
|
||||
@@ -162,6 +164,13 @@ export default {
|
||||
avatarUrl: this.avatarUrl || ''
|
||||
}
|
||||
const resp = await client.WechatLogin(loginParams)
|
||||
// errcode 兜底:后端业务错误码非 0 时视为登录失败
|
||||
if (resp && resp.errcode && resp.errcode !== 0) {
|
||||
throw { msg: resp.errmsg || '登录失败' }
|
||||
}
|
||||
if (!resp || !resp.token) {
|
||||
throw { msg: '登录响应缺少 token' }
|
||||
}
|
||||
|
||||
// 3. 保存 token 和用户信息
|
||||
saveAuthTokens(resp)
|
||||
@@ -171,11 +180,16 @@ export default {
|
||||
uni.setStorageSync('is_logged_in', 'true')
|
||||
uni.setStorageSync('is_guest', 'false')
|
||||
uni.setStorageSync('is_first_launch', 'false')
|
||||
|
||||
this.finishLogin()
|
||||
loginOk = true
|
||||
} catch (e) {
|
||||
console.warn('后端登录失败,降级为本地模式:', e)
|
||||
uni.showToast({ title: e.msg || '登录失败,使用本地模式', icon: 'none', duration: 2000 })
|
||||
// 打印完整错误,方便定位具体失败环节
|
||||
console.warn('后端登录失败,降级为本地模式:', e && e.stack ? e.stack : e)
|
||||
loginErr = e
|
||||
}
|
||||
|
||||
if (!loginOk) {
|
||||
const msg = (loginErr && (loginErr.msg || loginErr.message)) || ''
|
||||
uni.showToast({ title: msg ? `登录失败:${msg}` : '登录失败,使用本地模式', icon: 'none', duration: 2000 })
|
||||
// 降级为本地登录
|
||||
const userInfo = {
|
||||
id: `user_${Date.now()}`,
|
||||
@@ -187,10 +201,11 @@ export default {
|
||||
uni.setStorageSync('user_info', JSON.stringify(userInfo))
|
||||
uni.setStorageSync('is_logged_in', 'true')
|
||||
uni.setStorageSync('is_first_launch', 'false')
|
||||
this.finishLogin()
|
||||
} finally {
|
||||
this.loginLoading = false
|
||||
}
|
||||
this.loginLoading = false
|
||||
// 收尾逻辑移出 try/catch:避免 WS 重建/邀请补发等非登录环节异常
|
||||
// 被误判为登录失败(后端已成功却弹"登录失败"的根因)
|
||||
this.finishLogin()
|
||||
},
|
||||
|
||||
// 微信login获取code
|
||||
@@ -209,20 +224,27 @@ export default {
|
||||
uni.setStorageSync('is_first_launch', 'false')
|
||||
// 登录完成后用新 token 重建 WebSocket 连接
|
||||
// (启动时可能用旧 token 连接被拒,不重建会一直用旧 token 重试)
|
||||
const token = uni.getStorageSync('auth_token')
|
||||
if (token) {
|
||||
wsManager.disconnect()
|
||||
wsManager.connect(token)
|
||||
try {
|
||||
const token = uni.getStorageSync('auth_token')
|
||||
if (token) {
|
||||
wsManager.disconnect()
|
||||
wsManager.connect(token)
|
||||
}
|
||||
} catch (e) {
|
||||
console.warn('WS 重建失败,不影响登录:', e)
|
||||
}
|
||||
// 登录完成后补发分享邀请的好友请求(若有暂存的邀请人)
|
||||
handlePendingInvite()
|
||||
try {
|
||||
handlePendingInvite()
|
||||
} catch (e) {
|
||||
console.warn('补发邀请失败,不影响登录:', e)
|
||||
}
|
||||
uni.switchTab({ url: '/pages/index/index' })
|
||||
},
|
||||
|
||||
// ===== 协议查看 =====
|
||||
// ===== 协议查看:跳转协议页(user=用户协议 / privacy=隐私政策)=====
|
||||
openAgreement(type) {
|
||||
const title = type === 'user' ? '用户协议' : '隐私政策'
|
||||
uni.showToast({ title: `${title}页面开发中`, icon: 'none' })
|
||||
uni.navigateTo({ url: `/pages/agreement/agreement?type=${type}` })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user