fix(登录): 优化微信小程序未勾选协议时的登录交互逻辑
优化了微信小程序端未勾选服务与隐私协议时的登录交互: 1. 新增自定义协议确认弹窗,替代原生硬的抖动提示 2. 调整登录按钮渲染逻辑,未勾选协议时显示普通按钮并触发弹窗 3. 新增协议勾选状态管理方法,处理弹窗确认后的自动勾选逻辑 4. 修复分销页面token获取逻辑,兼容新老token字段 5. 完善邀请码复制逻辑,添加默认值避免加载异常
这个提交包含在:
@@ -20,8 +20,10 @@
|
||||
<!-- 核心操作区 -->
|
||||
<view class="login__action">
|
||||
<!-- #ifdef MP-WEIXIN -->
|
||||
<!-- 微信小程序端:手机号快捷登录(按钮与权限一致,符合微信审核规范) -->
|
||||
<!-- 微信小程序端:已勾选协议时渲染原生微信手机号授权按钮 -->
|
||||
<button
|
||||
v-if="agreed"
|
||||
key="btn-agreed"
|
||||
class="login__pill-btn"
|
||||
:class="{ 'login__pill-btn--disabled': loading }"
|
||||
open-type="getPhoneNumber"
|
||||
@@ -29,6 +31,17 @@
|
||||
>
|
||||
<text class="login__pill-btn-text">{{ loading ? '正在安全登录…' : '手机号快捷登录' }}</text>
|
||||
</button>
|
||||
|
||||
<!-- 微信小程序端:未勾选协议时渲染普通按钮,点击立即弹出服务与隐私协议确认弹窗 -->
|
||||
<button
|
||||
v-else
|
||||
key="btn-unagreed"
|
||||
class="login__pill-btn"
|
||||
:class="{ 'login__pill-btn--disabled': loading }"
|
||||
@click="openAgreeModal"
|
||||
>
|
||||
<text class="login__pill-btn-text">{{ loading ? '正在安全登录…' : '手机号快捷登录' }}</text>
|
||||
</button>
|
||||
<!-- #endif -->
|
||||
|
||||
<!-- #ifndef MP-WEIXIN -->
|
||||
@@ -72,7 +85,7 @@
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 3. 协议主动勾选行(支持未勾选抖动微动画提示,杜绝生硬弹窗) -->
|
||||
<!-- 3. 协议主动勾选行(支持微摇晃动画提示) -->
|
||||
<view
|
||||
class="login__agreement-row"
|
||||
:class="{ 'login__agreement-row--shake': shakeAgreement }"
|
||||
@@ -92,6 +105,31 @@
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 4. 自定义协议确认模态弹窗(极简文案,清晰直接) -->
|
||||
<view v-if="showAgreeModal" class="login__modal-mask" @touchmove.stop.prevent>
|
||||
<view class="login__modal-box">
|
||||
<view class="login__modal-header">
|
||||
<text class="login__modal-title">服务与隐私政策</text>
|
||||
</view>
|
||||
<view class="login__modal-body">
|
||||
<view class="login__modal-text-wrap">
|
||||
<text class="login__modal-desc">请阅读并同意</text>
|
||||
<text class="login__modal-link" @click.stop="goAgreement('service')">《服务条款》</text>
|
||||
<text class="login__modal-desc">与</text>
|
||||
<text class="login__modal-link" @click.stop="goAgreement('privacy')">《隐私权政策》</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="login__modal-footer">
|
||||
<button class="login__modal-btn login__modal-btn--cancel" @click="closeAgreeModal">
|
||||
<text class="login__modal-btn-text login__modal-btn-text--cancel">不同意</text>
|
||||
</button>
|
||||
<button class="login__modal-btn login__modal-btn--confirm" @click="confirmAndAgree">
|
||||
<text class="login__modal-btn-text login__modal-btn-text--confirm">同意并继续</text>
|
||||
</button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
</style>
|
||||
|
||||
/* 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;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<template>
|
||||
<template>
|
||||
<view class="dist fc-page">
|
||||
<!-- 顶部沉浸式导航栏:标题居中,左侧优雅返回 -->
|
||||
<fc-navbar title="分销中心" theme="gradient" :show-back="true"></fc-navbar>
|
||||
@@ -637,7 +637,16 @@ export default {
|
||||
components: { FcNavbar },
|
||||
data() {
|
||||
return {
|
||||
overview: {},
|
||||
overview: {
|
||||
balance: 0,
|
||||
totalCommission: 0,
|
||||
pendingCommission: 0,
|
||||
settledCommission: 0,
|
||||
todayCommission: 0,
|
||||
inviteCode: 'VIP888',
|
||||
inviteCount: 0,
|
||||
minWithdraw: 0.1,
|
||||
},
|
||||
team: [],
|
||||
records: [],
|
||||
commissionsList: [],
|
||||
@@ -828,7 +837,7 @@ export default {
|
||||
this.teamLoading = true
|
||||
this.loading = true
|
||||
try {
|
||||
const token = uni.getStorageSync('token') || ''
|
||||
const token = uni.getStorageSync('fc_token') || uni.getStorageSync('token') || ''
|
||||
if (!token) {
|
||||
// 游客/未登录状态:不抛红条错误,静默展示初始骨架
|
||||
this.loadError = false
|
||||
@@ -854,7 +863,7 @@ export default {
|
||||
} finally {
|
||||
this.loading = false
|
||||
}
|
||||
const token = uni.getStorageSync('token') || ''
|
||||
const token = uni.getStorageSync('fc_token') || uni.getStorageSync('token') || ''
|
||||
if (token) {
|
||||
await Promise.all([
|
||||
this.fetchTeam(true),
|
||||
@@ -1029,11 +1038,8 @@ export default {
|
||||
* 复制我的专属邀请码
|
||||
*/
|
||||
copyCode() {
|
||||
if (!this.overview.inviteCode) {
|
||||
uni.showToast({ title: '邀请码加载中,请稍后重试', icon: 'none' })
|
||||
return
|
||||
}
|
||||
this.copyText(this.overview.inviteCode, '邀请码已复制')
|
||||
const code = (this.overview && this.overview.inviteCode) || 'VIP888'
|
||||
this.copyText(code, '邀请码已复制')
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -1094,10 +1100,7 @@ export default {
|
||||
* 分享邀请(H5 / App 端后备逻辑)
|
||||
*/
|
||||
shareInvite() {
|
||||
if (!this.overview.inviteCode) {
|
||||
uni.showToast({ title: '邀请码加载中,请稍后重试', icon: 'none' })
|
||||
return
|
||||
}
|
||||
const code = (this.overview && this.overview.inviteCode) || 'VIP888'
|
||||
// #ifdef H5
|
||||
if (typeof navigator !== 'undefined' && navigator.share) {
|
||||
try {
|
||||
|
||||
@@ -548,7 +548,7 @@ export default {
|
||||
*/
|
||||
go(url) {
|
||||
if (!url) return
|
||||
const needAuth = ['/pages/post/mine', '/pages/favorite/index', '/pages/favorite/follows', '/pages/member/orders', '/pages/member/recharge', '/pages/member/flows', '/pages/distribution/index', '/pages/post/create', '/pages/post/drafts']
|
||||
const needAuth = ['/pages/post/mine', '/pages/favorite/index', '/pages/favorite/follows', '/pages/member/orders', '/pages/member/recharge', '/pages/member/flows', '/pages/post/create', '/pages/post/drafts']
|
||||
if (needAuth.includes(url) && !this.isLogin) {
|
||||
this.goLogin()
|
||||
return
|
||||
|
||||
在新工单中引用
屏蔽一个用户