diff --git a/uniapp/pages/auth/login.vue b/uniapp/pages/auth/login.vue index 550c009..fb33b8e 100644 --- a/uniapp/pages/auth/login.vue +++ b/uniapp/pages/auth/login.vue @@ -20,8 +20,10 @@ - + + + + @@ -72,7 +85,7 @@ - + + + + + + + + + + @@ -102,7 +140,7 @@ * 1. 按钮明确展示“手机号快捷登录”,调用 open-type="getPhoneNumber" 授权获取手机号; * 2. 授权后通过后端微信官方 API 实时换取手机号并建档登录; * 3. 遵照微信审核规范提供显著的“返回”和“暂不登录,先去逛逛”通道; - * 4. 优化未勾选协议时的交互:采用自然抖动微动效与 Toast 提示,取代生硬阻断的弹窗。 + * 4. 未勾选协议时点击登录:弹出自定义确认弹窗,确认后自动勾选协议,然后用户再次点击登录调起微信手机号授权。 */ import { useUserStore } from '@/common/store/index.js' import authApi from '@/common/api/auth.js' @@ -115,6 +153,7 @@ export default { loading: false, agreed: false, // 协议勾选状态 shakeAgreement: false, // 未勾选时的微摇晃动画 + showAgreeModal: false, // 协议确认模态弹窗显隐 redirectUrl: '', // 登录成功后回跳地址 navTop: 24, // 导航栏顶部安全距离(根据设备动态计算) navBarHeight: 44, // 导航栏标准高度 @@ -217,26 +256,30 @@ export default { }) }, /** - * 检查协议勾选状态(未勾选时触发平滑震动提示) - * @returns {boolean} 是否已勾选协议 + * 未勾选协议时点击登录:打开自定义协议确认模态弹窗 */ - checkAgreement() { - if (this.agreed) { - return true - } + openAgreeModal() { + if (this.loading) return + this.showAgreeModal = true + }, + /** + * 关闭协议确认模态弹窗 + */ + closeAgreeModal() { + this.showAgreeModal = false + }, + /** + * 弹窗中点击“同意并继续”:关闭弹窗,自动勾选协议,并轻提示引导再次点击登录 + */ + confirmAndAgree() { + this.agreed = true + this.showAgreeModal = false this.shakeAgreement = false - this.$nextTick(() => { - this.shakeAgreement = true - setTimeout(() => { - this.shakeAgreement = false - }, 600) - }) uni.showToast({ - title: '请先阅读并勾选协议', + title: '已同意,请点击登录', icon: 'none', duration: 2000, }) - return false }, /** * 获取微信登录临时凭证 code @@ -267,14 +310,16 @@ export default { async onGetPhoneNumber(e) { if (this.loading) return - // 优先检查协议勾选 - if (!this.checkAgreement()) { - return - } + const detail = (e && e.detail) || {} + const phoneCode = detail.code || '' + const errMsg = detail.errMsg || '' - const phoneCode = (e && e.detail && e.detail.code) || '' if (!phoneCode) { - uni.showToast({ title: '已取消授权手机号', icon: 'none' }) + if (errMsg.includes('deny') || errMsg.includes('cancel') || errMsg.includes('reject')) { + uni.showToast({ title: '已取消手机号授权', icon: 'none' }) + } else if (errMsg) { + uni.showToast({ title: '授权异常,请重试', icon: 'none' }) + } return } @@ -307,6 +352,24 @@ export default { this.loading = false } }, + /** + * 检查协议勾选状态(供非微信环境密码登录使用) + * @returns {boolean} 是否已勾选协议 + */ + checkAgreement() { + if (this.agreed) { + return true + } + this.shakeAgreement = false + this.$nextTick(() => { + this.shakeAgreement = true + setTimeout(() => { + this.shakeAgreement = false + }, 600) + }) + this.openAgreeModal() + return false + }, /** * 手机号+密码登录提交处理(供非小程序端调试使用) */ @@ -488,6 +551,7 @@ export default { font-weight: 700; color: #04301e; letter-spacing: 2rpx; + pointer-events: none; } /* 暂不登录辅助入口(极简轻盈,扩大点击判定热区) */ @@ -630,4 +694,137 @@ export default { font-weight: 500; cursor: pointer; } - \ No newline at end of file + +/* 4. 自定义协议确认模态弹窗 */ +.login__modal-mask { + position: fixed; + top: 0; + left: 0; + right: 0; + bottom: 0; + background: rgba(0, 0, 0, 0.62); + z-index: 9999; + display: flex; + align-items: center; + justify-content: center; + padding: 0 48rpx; + box-sizing: border-box; +} + +.login__modal-box { + width: 100%; + background: #ffffff; + border-radius: 32rpx; + padding: 48rpx 40rpx 40rpx; + box-sizing: border-box; + display: flex; + flex-direction: column; + align-items: center; + box-shadow: 0 20rpx 60rpx rgba(0, 0, 0, 0.2); + animation: modalPop 0.2s cubic-bezier(0.16, 1, 0.3, 1); +} + +@keyframes modalPop { + from { + opacity: 0; + transform: scale(0.9); + } + to { + opacity: 1; + transform: scale(1); + } +} + +.login__modal-header { + margin-bottom: 24rpx; +} + +.login__modal-title { + font-size: 34rpx; + font-weight: 700; + color: #1e293b; +} + +.login__modal-body { + display: flex; + flex-direction: column; + align-items: center; + text-align: center; + margin-bottom: 36rpx; +} + +.login__modal-text-wrap { + display: flex; + flex-wrap: wrap; + align-items: center; + justify-content: center; + line-height: 1.6; +} + +.login__modal-desc { + font-size: 28rpx; + color: #475569; +} + +.login__modal-link { + font-size: 28rpx; + font-weight: 600; + color: #00d26a; +} + +.login__modal-footer { + width: 100%; + display: flex; + align-items: center; + justify-content: space-between; + gap: 24rpx; +} + +.login__modal-btn { + flex: 1; + height: 84rpx; + border-radius: 42rpx; + display: flex; + align-items: center; + justify-content: center; + border: none; + padding: 0; + margin: 0; + box-sizing: border-box; + + &::after { + border: none; + } +} + +.login__modal-btn--cancel { + background: #f1f5f9; + + &:active { + background: #e2e8f0; + } +} + +.login__modal-btn--confirm { + background: linear-gradient(90deg, #00e070 0%, #00d26a 100%); + box-shadow: 0 8rpx 20rpx rgba(0, 210, 106, 0.3); + + &:active { + opacity: 0.9; + } +} + +.login__modal-btn-text { + font-size: 28rpx; + font-weight: 600; + pointer-events: none; +} + +.login__modal-btn-text--cancel { + color: #64748b; +} + +.login__modal-btn-text--confirm { + color: #04301e; +} + diff --git a/uniapp/pages/distribution/index.vue b/uniapp/pages/distribution/index.vue index 6e8486e..dc7b4e1 100644 --- a/uniapp/pages/distribution/index.vue +++ b/uniapp/pages/distribution/index.vue @@ -1,4 +1,4 @@ -