diff --git a/pwuniapp/pages/user/index.vue b/pwuniapp/pages/user/index.vue index 26bc44d..497b306 100644 --- a/pwuniapp/pages/user/index.vue +++ b/pwuniapp/pages/user/index.vue @@ -163,8 +163,13 @@ - @@ -444,19 +449,54 @@ const openLoginModal = () => { showLoginModal.value = true; }; -const handleWechatLogin = () => { - uni.showLoading({ title: '正在授权登录...' }); +const executeQuickLogin = (targetUid = 1001, phone = '') => { + uni.showLoading({ title: '正在登录...' }); setTimeout(() => { uni.hideLoading(); showLoginModal.value = false; isLoggedIn.value = true; uni.removeStorageSync('user_has_logged_out'); - uni.setStorageSync('userId', 1001); - loadUserProfile(1001); + uni.setStorageSync('userId', targetUid); + loadUserProfile(targetUid); + if (phone) { + user.value.phone = phone; + } uni.showToast({ title: '登录成功', icon: 'success' }); }, 400); }; +const handleGetPhoneNumber = (e) => { + // #ifdef MP-WEIXIN + if (e && e.detail && (e.detail.code || e.detail.encryptedData)) { + executeQuickLogin(1001, '138****8888'); + } else { + console.warn('[WeChat Auth] 未获得手机号权限或用户拒绝:', e && e.detail ? e.detail.errMsg : ''); + uni.showModal({ + title: '登录提示', + content: '未获取到微信手机号授权(需非个人主体认证小程序支持)。是否使用体验账号直接登录?', + confirmText: '快捷登录', + cancelText: '取消', + confirmColor: '#10B981', + success: (res) => { + if (res.confirm) { + executeQuickLogin(1001); + } + } + }); + } + // #endif + + // #ifndef MP-WEIXIN + executeQuickLogin(1001); + // #endif +}; + +const handleFallbackLogin = () => { + // #ifndef MP-WEIXIN + executeQuickLogin(1001); + // #endif +}; + const switchDemoAccount = async (acc) => { showLoginModal.value = false; uni.showLoading({ title: '正在切换账号...' }); @@ -1991,6 +2031,11 @@ const navTo = (url) => { border-radius: 20rpx; margin-bottom: 28rpx; box-shadow: 0 4rpx 16rpx rgba(7, 193, 96, 0.35); + border: none; + + &::after { + border: none; + } } .demo-accounts-wrap { diff --git a/server/tests/content-security.spec.ts b/server/tests/content-security.spec.ts index a34650a..bd7e57b 100644 --- a/server/tests/content-security.spec.ts +++ b/server/tests/content-security.spec.ts @@ -388,7 +388,9 @@ describe('ContentSecurityService & Compliance Architecture (TDD 微信内容安 expect(content).toContain('login-modal-mask'); expect(content).toContain('退出当前登录'); expect(content).toContain('切换账号'); - expect(content).toContain('微信一键授权快捷登录'); + expect(content).toContain('一键授权快捷登录'); + expect(content).toContain('open-type="getPhoneNumber"'); + expect(content).toContain('@getphonenumber="handleGetPhoneNumber"'); }); it('个人中心核心交互必须包含未登录拦截守护 ensureLoggedIn', () => {