diff --git a/components/app-tab-bar-toutiao.vue b/components/app-tab-bar-toutiao.vue index 4bc1339..ee93c3b 100644 --- a/components/app-tab-bar-toutiao.vue +++ b/components/app-tab-bar-toutiao.vue @@ -5,19 +5,14 @@ 首页 - - - 商城 - - - - 盒柜 + + 盒柜 - - 我的 + + 我的 @@ -26,7 +21,7 @@ export default { data() { return { - selected: 3 // 默认选中"我的" + selected: 2 // 默认选中"我的" } }, mounted() { @@ -43,9 +38,8 @@ export default { const route = currentPage.route if (route === 'pages/index/index') this.selected = 0 - else if (route === 'pages/shop/index') this.selected = 1 - else if (route === 'pages/cabinet/index') this.selected = 2 - else if (route === 'pages/mine/index') this.selected = 3 + else if (route === 'pages/cabinet/index') this.selected = 1 + else if (route === 'pages/mine/index') this.selected = 2 } }, switchTab(url) { diff --git a/pages/login/index.vue b/pages/login/index.vue index 68d3bdd..f4c9cde 100644 --- a/pages/login/index.vue +++ b/pages/login/index.vue @@ -80,12 +80,14 @@ 抖音快捷登录 使用抖音账号快速登录 + @@ -167,55 +169,6 @@ © 2025 柯大鸭潮玩科技 - - - - - - - - 🔒 - - 隐私说明与登录提示 - - - - - 我们将获取以下信息: - - - 👤 - 抖音昵称和头像 - - - 🆔 - 抖音唯一标识(OpenID) - - - - - - 使用目的: - · 创建您的账号并完成登录 - · 保存您的账户信息和偏好设置 - · 提供更好的个性化服务体验 - - - - 点击「同意并继续」即表示您已阅读并同意 - 《用户协议》 - - 《隐私政策》 - - - - - - - - - - @@ -230,9 +183,6 @@ import { vibrateShort } from '@/utils/vibrate.js' const loading = ref(false) const agreementChecked = ref(false) -// 抖音隐私弹窗相关状态 -const showPrivacyModal = ref(false) - // 登录模式:根据平台设置默认值 // #ifdef MP-WEIXIN const loginMode = ref('wechat') @@ -351,27 +301,6 @@ function toPurchaseAgreement() { uni.navigateTo({ url: '/pages-user/agreement/purchase' }) } -// 显示抖音隐私说明弹窗(第一步) -function showDouyinPrivacyDialog() { - if (!agreementChecked.value) { - uni.showToast({ title: '请先同意用户协议', icon: 'none' }) - vibrateShort() - return - } - showPrivacyModal.value = true -} - -// 关闭隐私弹窗 -function closePrivacyModal() { - showPrivacyModal.value = false -} - -// 确认并开始抖音授权登录(第二步) -function confirmDouyinLogin() { - showPrivacyModal.value = false - handleDouyinLogin() -} - // 发送验证码 async function handleSendCode() { if (!agreementChecked.value) { @@ -612,9 +541,16 @@ async function onGetPhoneNumber(e) { } } -// 抖音登录 - 不需要手机号授权 -async function handleDouyinLogin() { - console.log('[DEBUG] 抖音登录按钮点击') +// 抖音官方授权登录处理函数(响应 open-type="getUserInfo") +async function onGetUserInfo(e) { + console.log('[DEBUG] 抖音 getUserInfo 回调触发:', e) + + // 检查用户是否同意授权 + if (!e.detail.userInfo) { + console.log('[DEBUG] 用户拒绝授权') + uni.showToast({ title: '您取消了授权', icon: 'none' }) + return + } if (!agreementChecked.value) { uni.showToast({ title: '请先同意用户协议', icon: 'none' }) @@ -625,28 +561,38 @@ async function handleDouyinLogin() { loading.value = true try { - // 使用保存的登录 code 或重新登录获取 - const loginCode = uni.getStorageSync('douyin_login_code') - - let loginData - if (!loginCode) { - // 如果没有保存的 code,重新登录获取 - console.log('[DEBUG] 未保存登录 code,开始重新登录...') - const loginRes = await new Promise((resolve, reject) => { - tt.login({ - success: resolve, - fail: reject - }) + // 1. 先调用 tt.login 获取登录凭证 code + console.log('[DEBUG] 开始 tt.login 获取登录凭证...') + const loginRes = await new Promise((resolve, reject) => { + tt.login({ + success: resolve, + fail: reject }) - console.log('[DEBUG] 重新获取抖音登录 code:', loginRes.code) - loginData = await douyinLogin(loginRes.code, null, uni.getStorageSync('inviter_code')) - } else { - console.log('[DEBUG] 使用保存的登录 code:', loginCode) - loginData = await douyinLogin(loginCode, null, uni.getStorageSync('inviter_code')) - } + }) + + console.log('[DEBUG] tt.login 成功,code:', loginRes.code) + + // 2. 获取用户信息(从 e.detail.userInfo 中获取) + const userInfo = e.detail.userInfo + console.log('[DEBUG] 用户信息:', userInfo) + + const { nickName, avatarUrl } = userInfo + + // 3. 调用后端登录接口 + console.log('[DEBUG] 调用后端 douyinLogin 接口...') + const inviterCode = uni.getStorageSync('inviter_code') + const loginData = await douyinLogin(loginRes.code, null, inviterCode) console.log('[DEBUG] 抖音登录成功:', loginData) + // 保存用户基本信息(昵称和头像) + if (nickName) { + uni.setStorageSync('nickname', nickName) + } + if (avatarUrl) { + uni.setStorageSync('avatar', avatarUrl) + } + // 保存登录数据(saveUserData 会自动检查手机号绑定状态) saveUserData(loginData) @@ -660,12 +606,21 @@ async function handleDouyinLogin() { // 如果未绑定手机号,saveUserData 会自动切换到短信登录tab } catch (err) { console.error('[DEBUG] 抖音登录失败:', err) - uni.showToast({ title: err.message || '登录失败,请重试', icon: 'none', duration: 2000 }) + uni.showToast({ + title: err.message || '登录失败,请重试', + icon: 'none', + duration: 2000 + }) } finally { loading.value = false } } +// 抖音登录函数(已弃用,保留以防兼容性问题) +async function handleDouyinLogin() { + console.log('[DEBUG] handleDouyinLogin 已弃用,请使用 onGetUserInfo') +} + function saveUserData(data) { if (!data) return console.log('[DEBUG] 准备执行 saveUserData, payload:', data) @@ -1128,244 +1083,4 @@ function fetchExtraData(userId) { font-size: 22rpx; color: $text-tertiary; } - -/* ============================================ - 抖音隐私说明弹窗样式 - 抖音风格 - ============================================ */ - -.privacy-modal-overlay { - position: fixed; - top: 0; - left: 0; - right: 0; - bottom: 0; - background: rgba(0, 0, 0, 0.85); - backdrop-filter: blur(10rpx); - display: flex; - align-items: center; - justify-content: center; - z-index: 9999; - padding: 32rpx; - animation: fadeInDouyin 0.25s cubic-bezier(0.4, 0, 0.2, 1); -} - -@keyframes fadeInDouyin { - from { - opacity: 0; - } - to { - opacity: 1; - } -} - -.privacy-modal-content { - width: 100%; - max-width: 560rpx; - background: linear-gradient(180deg, #2a2a2a 0%, #1a1a1a 100%); - border-radius: 24rpx; - overflow: hidden; - box-shadow: 0 32rpx 80rpx rgba(0, 0, 0, 0.6); - border: 1rpx solid rgba(255, 255, 255, 0.1); - animation: scaleInDouyin 0.3s cubic-bezier(0.34, 1.56, 0.64, 1); -} - -@keyframes scaleInDouyin { - from { - transform: scale(0.9) translateY(40rpx); - opacity: 0; - } - to { - transform: scale(1) translateY(0); - opacity: 1; - } -} - -/* 弹窗头部 */ -.privacy-modal-header { - padding: 56rpx 40rpx 36rpx; - display: flex; - flex-direction: column; - align-items: center; - background: linear-gradient(180deg, rgba(34, 34, 34, 1) 0%, rgba(26, 26, 26, 0) 100%); - position: relative; -} - -.privacy-modal-header::after { - content: ''; - position: absolute; - bottom: 0; - left: 40rpx; - right: 40rpx; - height: 1rpx; - background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent); -} - -.privacy-icon-wrap { - width: 112rpx; - height: 112rpx; - background: linear-gradient(135deg, #00f2ea 0%, #ff0050 100%); - border-radius: 28rpx; - display: flex; - align-items: center; - justify-content: center; - margin-bottom: 24rpx; - box-shadow: 0 16rpx 48rpx rgba(0, 242, 234, 0.3); - animation: pulseDouyin 2s ease-in-out infinite; -} - -@keyframes pulseDouyin { - 0%, 100% { - transform: scale(1); - box-shadow: 0 16rpx 48rpx rgba(0, 242, 234, 0.3); - } - 50% { - transform: scale(1.05); - box-shadow: 0 20rpx 56rpx rgba(0, 242, 234, 0.4); - } -} - -.privacy-icon { - font-size: 56rpx; - filter: drop-shadow(0 4rpx 8rpx rgba(0, 0, 0, 0.3)); -} - -.privacy-modal-title { - font-size: 36rpx; - font-weight: 700; - color: #ffffff; - text-align: center; - letter-spacing: 1rpx; -} - -/* 弹窗内容 */ -.privacy-modal-body { - padding: 32rpx 40rpx 24rpx; - max-height: 560rpx; - overflow-y: auto; -} - -.privacy-section { - margin-bottom: 32rpx; -} - -.privacy-section-title { - display: block; - font-size: 28rpx; - font-weight: 600; - color: rgba(255, 255, 255, 0.9); - margin-bottom: 20rpx; - padding-left: 4rpx; -} - -.privacy-item-list { - display: flex; - flex-direction: column; - gap: 16rpx; -} - -.privacy-item { - display: flex; - align-items: center; - padding: 24rpx 20rpx; - background: rgba(255, 255, 255, 0.05); - border-radius: 16rpx; - border: 1rpx solid rgba(255, 255, 255, 0.08); - transition: all 0.2s ease; -} - -.privacy-item:active { - background: rgba(255, 255, 255, 0.08); - transform: scale(0.98); -} - -.privacy-item-icon { - font-size: 36rpx; - margin-right: 16rpx; - filter: drop-shadow(0 2rpx 4rpx rgba(0, 0, 0, 0.2)); -} - -.privacy-item-text { - flex: 1; - font-size: 28rpx; - color: rgba(255, 255, 255, 0.85); - font-weight: 500; -} - -.privacy-desc { - display: block; - font-size: 26rpx; - color: rgba(255, 255, 255, 0.6); - line-height: 2; - margin-bottom: 6rpx; - padding-left: 8rpx; -} - -.privacy-agreement-notice { - padding: 28rpx 24rpx; - background: linear-gradient(135deg, rgba(0, 242, 234, 0.08) 0%, rgba(255, 0, 80, 0.08) 100%); - border-radius: 16rpx; - border: 1rpx solid rgba(0, 242, 234, 0.15); - line-height: 2; -} - -.privacy-notice-text { - font-size: 24rpx; - color: rgba(255, 255, 255, 0.7); -} - -.privacy-notice-link { - font-size: 24rpx; - color: #00f2ea; - font-weight: 600; - text-decoration: underline; - text-underline-offset: 4rpx; -} - -/* 弹窗底部 */ -.privacy-modal-footer { - display: flex; - gap: 20rpx; - padding: 24rpx 40rpx 40rpx; -} - -.privacy-btn-cancel, -.privacy-btn-confirm { - flex: 1; - height: 96rpx; - border-radius: 48rpx; - font-size: 30rpx; - font-weight: 600; - border: none; - transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1); - display: flex; - align-items: center; - justify-content: center; - - &::after { - border: none; - } -} - -.privacy-btn-cancel { - background: rgba(255, 255, 255, 0.08); - color: rgba(255, 255, 255, 0.7); - border: 1rpx solid rgba(255, 255, 255, 0.1); - - &:active { - background: rgba(255, 255, 255, 0.12); - transform: scale(0.96); - } -} - -.privacy-btn-confirm { - background: linear-gradient(135deg, #00f2ea 0%, #00c4bd 100%); - color: #000000; - box-shadow: 0 8rpx 32rpx rgba(0, 242, 234, 0.4); - - &:active { - opacity: 0.9; - transform: scale(0.96); - box-shadow: 0 4rpx 24rpx rgba(0, 242, 234, 0.3); - } -}