feat(passport): 重构短信登录页并提供手机号授权降级入口
- 修复购物车数据库缺失 spec_info 字段问题,新增迁移脚本 - 登录页处理手机号授权失败,按错误类型弹窗引导用户改用短信登录 - 登录页新增长期显示的「使用短信验证码登录」入口,提升用户降级体验 - 注册页同步改造,去除微信小程序环境下短信按钮隐藏问题 - 短信登录页整体 UI 重构,弃用 NutUI 组件,采用原生组件实现 - 短信登录页新增渐变背景、浮动光圈、圆形 logo、卡片输入区设计 - 实现手机号输入、验证码发送、倒计时及登录校验逻辑全覆盖 - 短信登录页新增返回微信快捷登录链接,避免用户被困登录流程 - 新增配套样式文件,实现多重动效及分阶段入场动画 - 保证类型检查和编译无误,增加设计稿 HTML 预览文件
This commit is contained in:
@@ -199,3 +199,47 @@
|
|||||||
- 历史数据清理:提供 `sql/shop_cart_merge_duplicates.sql`,按 (user_id,goods_id,sku_id) 分组合并 cart_num 并删除重复行(sku_id 可能为 NULL,用 `<=>` null-safe 匹配);执行前先备份
|
- 历史数据清理:提供 `sql/shop_cart_merge_duplicates.sql`,按 (user_id,goods_id,sku_id) 分组合并 cart_num 并删除重复行(sku_id 可能为 NULL,用 `<=>` null-safe 匹配);执行前先备份
|
||||||
- 编译验证:Maven compile 成功
|
- 编译验证:Maven compile 成功
|
||||||
- 后端需重启服务才生效
|
- 后端需重启服务才生效
|
||||||
|
|
||||||
|
## 购物车加购报 spec_info 字段缺失
|
||||||
|
- 现象:添加购物车时报 `Unknown column 'spec_info' in 'field list'`
|
||||||
|
- 原因:后端实体 `ShopCart.java` 定义了 `specInfo` 字段(存储"颜色:红色|尺寸:L"这类规格信息),但数据库表 `shop_cart` 未建 `spec_info` 列;`ShopCartParam`、`OrderBusinessService` 均在用该字段,属设计需保留
|
||||||
|
- 修复:新建迁移脚本 `/Users/gxwebsoft/JAVA/guilixu-java/sql/shop_cart_add_spec_info.sql`,`ALTER TABLE shop_cart ADD COLUMN spec_info VARCHAR(500) NULL ... AFTER spec`,需在数据库执行
|
||||||
|
|
||||||
|
## 修复登录页「未授权手机号」无降级入口
|
||||||
|
- 现象:用户反复反馈"又又又登录不了了",截图显示点击「手机号快捷登录」按钮后 toast 弹「未授权手机号」,用户被困在登录页
|
||||||
|
- 根因:`src/passport/login.tsx` 第 162-173 行 `onGetPhoneNumber` 回调里 `detail.code` 为 undefined(用户拒绝授权,errMsg 含 `user deny`/`fail`)时只 toast 了一句生硬文案,没有任何引导。但项目里其实有 `/passport/sms-login` 短信登录页(且在 `app.config.ts` 路由表里),`login.tsx` 却完全没暴露这个入口。`register.tsx` 同样有此问题,且其 weapp 环境下隐藏了短信按钮(原 `{!isWeapp && ...}` 判断)
|
||||||
|
- 修复(2 个文件 + 1 个 scss):
|
||||||
|
1. `src/passport/login.tsx`
|
||||||
|
- 新增 `goSmsLogin()` 函数:透传 `redirect` + 邀请参数(`inviter`/`source`/`t`)跳 `/passport/sms-login`
|
||||||
|
- 新增 `showPhoneAuthFailedModal(errMsg)`:按 errMsg 区分场景弹窗引导
|
||||||
|
- `user deny` → "您已取消微信手机号授权,可改用短信验证码登录"
|
||||||
|
- `privacy` → "微信未授权获取手机号,可改用短信验证码登录"
|
||||||
|
- `no permission` → "小程序暂未获得手机号授权,可改用短信验证码登录"
|
||||||
|
- 其他 → 通用"请尝试使用短信验证码登录"
|
||||||
|
- 弹窗带"短信登录"按钮自动跳 sms-login,"我知道了"关闭
|
||||||
|
- 失败分支从 `Taro.showToast` 改为 `showPhoneAuthFailedModal(errMsg)`
|
||||||
|
- 主登录按钮下方新增长期可见的「使用短信验证码登录」链接(仿 register.tsx 的 goSmsLogin)
|
||||||
|
2. `src/passport/login.scss`
|
||||||
|
- 新增 `.login-methods__alt` / `.login-methods__alt-link` 样式(白色下划线小字,居中)
|
||||||
|
3. `src/passport/register.tsx`
|
||||||
|
- 同步加 `showPhoneAuthFailedModal(errMsg)` 弹窗引导
|
||||||
|
- 去掉 `{!isWeapp && <Button>短信验证码注册/登录</Button>}` 包裹,让 weapp 下也始终显示短信按钮作为降级入口
|
||||||
|
- 类型检查:`npx tsc --noEmit` 无报错
|
||||||
|
- 业务规则:项目当前仅信任微信一键登录作为主路径,短信登录一直是兜底通道。后续如发现用户量大,可考虑直接在登录页主流程就两个按钮并排(不再让微信登录独占)
|
||||||
|
|
||||||
|
## sms-login 页面 UI 重构
|
||||||
|
- 原状:截图显示基本是裸的——只看到两个孤零零的 placeholder 文字,发送验证码按钮和登录按钮都看不见。NutUI 的 `Input` + `Button` 在 Taro 小程序上经常渲染不出边框/背景,外层 `flex justify-between` 也没把验证码按钮挤出来
|
||||||
|
- 改造(2 个文件):
|
||||||
|
1. `src/passport/sms-login.tsx` — 弃用 NutUI 改用 Taro 原生 `View/Text/Input`,重做整页布局
|
||||||
|
- 渐变背景 + 浮动光圈(和 login.tsx 同一套色系 `#667eea → #764ba2`)
|
||||||
|
- 顶部圆形 logo(140rpx 白底圆角 + 阴影)+ 标题 + 副标题
|
||||||
|
- 白色卡片输入区(圆角 28rpx + 阴影):手机号(📞)+ 灰线分隔 + 验证码(🔐 + 绿色胶囊「获取验证码」按钮)
|
||||||
|
- 绿色渐变登录大按钮(圆角 50rpx + 阴影 + 字间距 4rpx)
|
||||||
|
- 「← 返回微信快捷登录」白色下划线链接(一键 navigateBack 回到 login.tsx,避免用户被困)
|
||||||
|
- 底部协议 + 服务协议/隐私政策超链接
|
||||||
|
- 业务逻辑(state、60s 倒计时、handleSendCode/handleLogin 校验、redirect 跳转、邀请参数透传)全部保留
|
||||||
|
2. `src/passport/sms-login.scss`(新文件)— 配套样式:渐变背景、浮动光圈动画(gradientMove + float)、卡片毛玻璃、按钮 hover 效果(scale 0.98)、分阶段入场动画(slideDown / slideUp / fadeIn)
|
||||||
|
- 类型检查:`npx tsc --noEmit` 无报错(项目原本的 `@tarojs/taro` 类型错误与本次无关)
|
||||||
|
- 编译验证:`npx taro build --type weapp` 14.89s 成功
|
||||||
|
- 设计稿预览:`.workbuddy/sms-login-preview.html`(按 375×812 真机尺寸渲染的 mockup,可直接浏览器打开看)
|
||||||
|
- 业务规则:login/register/sms-login 三个页面已统一视觉风格(同一套渐变 + 圆形 logo + 大字标题 + 白色卡片),后续新增 passport 类页面照搬这一套即可
|
||||||
|
|||||||
@@ -56,6 +56,15 @@
|
|||||||
- ⚠️ **`requiredPrivateInfos` 字段只接受位置类 API 白名单**(chooseAddress/chooseLocation/choosePoi/getFuzzyLocation/getLocation/onLocationChange/startLocationUpdate/startLocationUpdateBackground),不要加 `chooseImage`/`chooseMedia` 等非位置类,会导致 app.json 解析失败
|
- ⚠️ **`requiredPrivateInfos` 字段只接受位置类 API 白名单**(chooseAddress/chooseLocation/choosePoi/getFuzzyLocation/getLocation/onLocationChange/startLocationUpdate/startLocationUpdateBackground),不要加 `chooseImage`/`chooseMedia` 等非位置类,会导致 app.json 解析失败
|
||||||
- 直接调 `Taro.chooseImage` 的页面:`pages/order/evaluate/index.tsx`、`pages/after-sale/apply/index.tsx`、`pages/store/orders/index.tsx` —— 这些页面绕过了 `uploadFile`,需要单独加 `ensurePrivacyAuthorized` 预检
|
- 直接调 `Taro.chooseImage` 的页面:`pages/order/evaluate/index.tsx`、`pages/after-sale/apply/index.tsx`、`pages/store/orders/index.tsx` —— 这些页面绕过了 `uploadFile`,需要单独加 `ensurePrivacyAuthorized` 预检
|
||||||
|
|
||||||
|
## 手机号授权登录降级方案(2026-07-15)
|
||||||
|
- **业务现实**:`getPhoneNumber` 按钮被用户拒绝后,微信会短期"记住"用户的选择,再次点击会直接 fail(`errMsg: getPhoneNumber:fail user deny`)。一旦进入这个状态,前端必须提供降级入口
|
||||||
|
- **统一模式**:`passport/login.tsx` 和 `passport/register.tsx` 都有 `getPhoneNumber` 回调,**不允许**只 toast 一句"未授权手机号"就完事
|
||||||
|
- 必做:失败时调 `showPhoneAuthFailedModal(errMsg)`,按 errMsg 区分场景弹窗(user deny / privacy / no permission / 通用)
|
||||||
|
- 弹窗带"短信登录"按钮自动跳 `/passport/sms-login`(透传 redirect + 邀请参数 inviter/source/t)
|
||||||
|
- 必做:主登录按钮**长期可见**地提供"使用短信验证码登录"链接,不要依赖弹窗
|
||||||
|
- **短信登录页**:`/passport/sms-login`(路由表里已有),调 `loginBySms` + `sendSmsCaptcha` 接口
|
||||||
|
- **已落地页面**:`passport/login.tsx`(新增 goSmsLogin + showPhoneAuthFailedModal + alt 链接)、`passport/register.tsx`(新增 showPhoneAuthFailedModal + weapp 下也显示短信按钮)
|
||||||
|
|
||||||
## 分享 / 朋友圈能力(2026-07-13 接入)
|
## 分享 / 朋友圈能力(2026-07-13 接入)
|
||||||
- 统一封装:`src/hooks/useShare.ts`(`useShare({title, path?, query?, imageUrl?, enableTimeline?, enableCopyUrl?})`,一次注册 `useShareAppMessage` + `useShareTimeline` + 可选 `onCopyUrl` 复制链接;自动在 path/query 追加 `inviter=${当前用户id}` 做裂变归因;`isTimelineSinglePage()` 判断朋友圈单页模式 scene===1154)
|
- 统一封装:`src/hooks/useShare.ts`(`useShare({title, path?, query?, imageUrl?, enableTimeline?, enableCopyUrl?})`,一次注册 `useShareAppMessage` + `useShareTimeline` + 可选 `onCopyUrl` 复制链接;自动在 path/query 追加 `inviter=${当前用户id}` 做裂变归因;`isTimelineSinglePage()` 判断朋友圈单页模式 scene===1154)
|
||||||
- 海报组件:`src/components/SharePoster/index.tsx`(Canvas 2D 绘制封面+标题+价格+小程序码,返回临时图路径作 imageUrl)
|
- 海报组件:`src/components/SharePoster/index.tsx`(Canvas 2D 绘制封面+标题+价格+小程序码,返回临时图路径作 imageUrl)
|
||||||
|
|||||||
309
.workbuddy/sms-login-preview.html
Normal file
309
.workbuddy/sms-login-preview.html
Normal file
@@ -0,0 +1,309 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="zh-CN">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>sms-login UI 预览</title>
|
||||||
|
<style>
|
||||||
|
* { box-sizing: border-box; margin: 0; padding: 0; }
|
||||||
|
body {
|
||||||
|
background: #f0f0f3;
|
||||||
|
min-height: 100vh;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
padding: 40px 0 80px;
|
||||||
|
font-family: -apple-system, "PingFang SC", "Helvetica Neue", sans-serif;
|
||||||
|
}
|
||||||
|
h1 { font-size: 18px; color: #666; margin-bottom: 30px; font-weight: 500; }
|
||||||
|
.phone {
|
||||||
|
width: 375px;
|
||||||
|
height: 812px;
|
||||||
|
background: #fff;
|
||||||
|
border-radius: 50px;
|
||||||
|
box-shadow: 0 30px 80px rgba(0,0,0,0.18), 0 0 0 12px #1a1a1a, 0 0 0 14px #2a2a2a;
|
||||||
|
overflow: hidden;
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
.phone::before {
|
||||||
|
content: "";
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
left: 50%;
|
||||||
|
transform: translateX(-50%);
|
||||||
|
width: 150px;
|
||||||
|
height: 28px;
|
||||||
|
background: #1a1a1a;
|
||||||
|
border-radius: 0 0 18px 18px;
|
||||||
|
z-index: 100;
|
||||||
|
}
|
||||||
|
.status-bar {
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
height: 44px;
|
||||||
|
padding: 0 30px;
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
font-size: 15px;
|
||||||
|
color: #1a1a1a;
|
||||||
|
font-weight: 600;
|
||||||
|
z-index: 50;
|
||||||
|
}
|
||||||
|
.status-bar .right {
|
||||||
|
display: flex;
|
||||||
|
gap: 6px;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
.nav-bar {
|
||||||
|
position: absolute;
|
||||||
|
top: 44px;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
height: 44px;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
font-size: 17px;
|
||||||
|
font-weight: 600;
|
||||||
|
color: #1a1a1a;
|
||||||
|
z-index: 50;
|
||||||
|
}
|
||||||
|
.nav-bar::before {
|
||||||
|
content: "<";
|
||||||
|
position: absolute;
|
||||||
|
left: 18px;
|
||||||
|
font-size: 24px;
|
||||||
|
color: #1a1a1a;
|
||||||
|
}
|
||||||
|
.nav-bar::after {
|
||||||
|
content: "···";
|
||||||
|
position: absolute;
|
||||||
|
right: 60px;
|
||||||
|
font-size: 22px;
|
||||||
|
color: #1a1a1a;
|
||||||
|
letter-spacing: 2px;
|
||||||
|
}
|
||||||
|
.screen {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||||
|
position: relative;
|
||||||
|
overflow: hidden;
|
||||||
|
padding-top: 88px;
|
||||||
|
}
|
||||||
|
.bg-circle {
|
||||||
|
position: absolute;
|
||||||
|
border-radius: 50%;
|
||||||
|
background: #fff;
|
||||||
|
opacity: 0.1;
|
||||||
|
}
|
||||||
|
.bg-c1 { width: 400px; height: 400px; top: -150px; right: -100px; }
|
||||||
|
.bg-c2 { width: 300px; height: 300px; bottom: 10%; left: -100px; opacity: 0.08; }
|
||||||
|
.bg-gradient {
|
||||||
|
position: absolute;
|
||||||
|
top: -50%; left: -50%; right: -50%; bottom: -50%;
|
||||||
|
background: radial-gradient(circle at 30% 50%, rgba(255,255,255,0.1) 0%, transparent 50%),
|
||||||
|
radial-gradient(circle at 70% 80%, rgba(255,255,255,0.08) 0%, transparent 50%);
|
||||||
|
}
|
||||||
|
.content {
|
||||||
|
position: relative;
|
||||||
|
z-index: 1;
|
||||||
|
padding: 0 50px;
|
||||||
|
}
|
||||||
|
.header {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
padding-top: 32px;
|
||||||
|
margin-bottom: 60px;
|
||||||
|
}
|
||||||
|
.logo {
|
||||||
|
width: 140px;
|
||||||
|
height: 140px;
|
||||||
|
border-radius: 35px;
|
||||||
|
background: rgba(255,255,255,0.95);
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
margin-bottom: 36px;
|
||||||
|
box-shadow: 0 20px 60px rgba(0,0,0,0.3);
|
||||||
|
}
|
||||||
|
.logo-icon { font-size: 72px; line-height: 1; }
|
||||||
|
.title {
|
||||||
|
font-size: 52px;
|
||||||
|
font-weight: 700;
|
||||||
|
color: #fff;
|
||||||
|
margin-bottom: 18px;
|
||||||
|
text-shadow: 0 2px 10px rgba(0,0,0,0.2);
|
||||||
|
letter-spacing: 2px;
|
||||||
|
}
|
||||||
|
.subtitle {
|
||||||
|
font-size: 26px;
|
||||||
|
color: rgba(255,255,255,0.85);
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
.card {
|
||||||
|
background: rgba(255,255,255,0.98);
|
||||||
|
border-radius: 28px;
|
||||||
|
padding: 12px 32px;
|
||||||
|
margin-bottom: 48px;
|
||||||
|
box-shadow: 0 20px 60px rgba(0,0,0,0.18);
|
||||||
|
}
|
||||||
|
.field {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
height: 110px;
|
||||||
|
}
|
||||||
|
.field-icon { font-size: 36px; margin-right: 20px; line-height: 1; }
|
||||||
|
.field-input {
|
||||||
|
flex: 1;
|
||||||
|
font-size: 30px;
|
||||||
|
color: #333;
|
||||||
|
background: transparent;
|
||||||
|
border: none;
|
||||||
|
outline: none;
|
||||||
|
}
|
||||||
|
.field-input::placeholder { color: #b8b8b8; }
|
||||||
|
.divider {
|
||||||
|
height: 1px;
|
||||||
|
background: linear-gradient(to right, transparent, #e8e8e8 20%, #e8e8e8 80%, transparent);
|
||||||
|
}
|
||||||
|
.send-btn {
|
||||||
|
flex-shrink: 0;
|
||||||
|
height: 64px;
|
||||||
|
padding: 0 22px;
|
||||||
|
border-radius: 32px;
|
||||||
|
background: linear-gradient(135deg, #07c160, #06ad56);
|
||||||
|
color: #fff;
|
||||||
|
font-size: 26px;
|
||||||
|
font-weight: 600;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
margin-left: 16px;
|
||||||
|
box-shadow: 0 6px 20px rgba(7, 193, 96, 0.35);
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
.submit {
|
||||||
|
height: 100px;
|
||||||
|
width: 100%;
|
||||||
|
border-radius: 50px;
|
||||||
|
background: linear-gradient(135deg, #07c160, #06ad56);
|
||||||
|
color: #fff;
|
||||||
|
font-size: 34px;
|
||||||
|
font-weight: 600;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
letter-spacing: 4px;
|
||||||
|
box-shadow: 0 12px 36px rgba(7, 193, 96, 0.4);
|
||||||
|
margin-bottom: 36px;
|
||||||
|
}
|
||||||
|
.back {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
height: 80px;
|
||||||
|
margin-bottom: 32px;
|
||||||
|
}
|
||||||
|
.back-icon { font-size: 30px; color: rgba(255,255,255,0.9); margin-right: 10px; }
|
||||||
|
.back-text {
|
||||||
|
font-size: 28px;
|
||||||
|
color: rgba(255,255,255,0.9);
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
.tips {
|
||||||
|
position: absolute;
|
||||||
|
bottom: 40px;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
padding: 0 50px;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
}
|
||||||
|
.tips-text { font-size: 22px; color: rgba(255,255,255,0.7); }
|
||||||
|
.tips-link { font-size: 22px; color: #fff; text-decoration: underline; margin: 0 4px; }
|
||||||
|
.legend {
|
||||||
|
margin-top: 30px;
|
||||||
|
padding: 20px 28px;
|
||||||
|
background: #fff;
|
||||||
|
border-radius: 12px;
|
||||||
|
box-shadow: 0 4px 12px rgba(0,0,0,0.06);
|
||||||
|
font-size: 13px;
|
||||||
|
color: #555;
|
||||||
|
max-width: 375px;
|
||||||
|
line-height: 1.7;
|
||||||
|
}
|
||||||
|
.legend strong { color: #07c160; }
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>sms-login.tsx 新 UI 预览(按真机 375×812 渲染)</h1>
|
||||||
|
|
||||||
|
<div class="phone">
|
||||||
|
<div class="status-bar">
|
||||||
|
<span>18:36</span>
|
||||||
|
<span class="right">📶 🔋</span>
|
||||||
|
</div>
|
||||||
|
<div class="nav-bar">验证码登录</div>
|
||||||
|
|
||||||
|
<div class="screen">
|
||||||
|
<div class="bg-gradient"></div>
|
||||||
|
<div class="bg-circle bg-c1"></div>
|
||||||
|
<div class="bg-circle bg-c2"></div>
|
||||||
|
|
||||||
|
<div class="content">
|
||||||
|
<div class="header">
|
||||||
|
<div class="logo"><span class="logo-icon">📱</span></div>
|
||||||
|
<div class="title">验证码登录</div>
|
||||||
|
<div class="subtitle">未注册的手机号验证后将自动注册</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="card">
|
||||||
|
<div class="field">
|
||||||
|
<span class="field-icon">📞</span>
|
||||||
|
<input class="field-input" type="text" placeholder="请输入手机号码" maxlength="11" />
|
||||||
|
</div>
|
||||||
|
<div class="divider"></div>
|
||||||
|
<div class="field">
|
||||||
|
<span class="field-icon">🔐</span>
|
||||||
|
<input class="field-input" type="text" placeholder="请输入6位验证码" maxlength="6" />
|
||||||
|
<div class="send-btn">获取验证码</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="submit">登录 / 注册</div>
|
||||||
|
|
||||||
|
<div class="back">
|
||||||
|
<span class="back-icon">←</span>
|
||||||
|
<span class="back-text">返回微信快捷登录</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="tips">
|
||||||
|
<span class="tips-text">登录即代表您已阅读并同意</span>
|
||||||
|
<span class="tips-link">《服务协议》</span>
|
||||||
|
<span class="tips-text">和</span>
|
||||||
|
<span class="tips-link">《隐私政策》</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="legend">
|
||||||
|
<strong>视觉变更:</strong><br>
|
||||||
|
① 紫蓝渐变背景 + 浮动光圈(和 login.tsx 同一套色系)<br>
|
||||||
|
② 顶部圆形 logo + 大字标题 + 副标题<br>
|
||||||
|
③ 白色卡片输入区(圆角 28px + 阴影),手机号/验证码图标 + 灰线分隔<br>
|
||||||
|
④ 验证码右侧绿色胶囊「获取验证码」按钮(倒计时会变成「60s 后重试」)<br>
|
||||||
|
⑤ 绿色渐变登录大按钮(圆角 50px + 阴影)<br>
|
||||||
|
⑥ 「← 返回微信快捷登录」白色下划线链接(避免用户被困住)<br>
|
||||||
|
⑦ 底部协议 + 服务协议/隐私政策超链接<br>
|
||||||
|
<br>
|
||||||
|
<strong>业务逻辑保留:</strong>表单 state、60s 倒计时、handleSendCode/handleLogin 校验、redirect 跳转、邀请参数透传(inviter/source/t)全部不变
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -206,6 +206,21 @@
|
|||||||
margin-top: 10px;
|
margin-top: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 降级登录入口(短信验证码)
|
||||||
|
.login-methods__alt {
|
||||||
|
text-align: center;
|
||||||
|
margin-top: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.login-methods__alt-link {
|
||||||
|
display: inline-block;
|
||||||
|
font-size: 26px;
|
||||||
|
color: rgba(255, 255, 255, 0.85);
|
||||||
|
text-decoration: underline;
|
||||||
|
padding: 8px 16px;
|
||||||
|
letter-spacing: 0.5px;
|
||||||
|
}
|
||||||
|
|
||||||
// 登录按钮
|
// 登录按钮
|
||||||
.login-btn {
|
.login-btn {
|
||||||
height: 96px;
|
height: 96px;
|
||||||
|
|||||||
@@ -158,6 +158,44 @@ const Login = () => {
|
|||||||
await Taro.redirectTo({ url: redirectUrl })
|
await Taro.redirectTo({ url: redirectUrl })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 跳转到短信验证码登录(降级方案) */
|
||||||
|
const goSmsLogin = () => {
|
||||||
|
const params: Record<string, string> = {}
|
||||||
|
if (redirectUrl) params.redirect = redirectUrl
|
||||||
|
// 透传邀请参数,避免从登录页切到短信登录时丢失 inviter
|
||||||
|
const inviteParams = parseInviteParams({ query: router?.params })
|
||||||
|
if (inviteParams?.inviter) params.inviter = inviteParams.inviter
|
||||||
|
if (inviteParams?.source) params.source = inviteParams.source
|
||||||
|
if (inviteParams?.t) params.t = inviteParams.t
|
||||||
|
|
||||||
|
const qs = Object.entries(params)
|
||||||
|
.map(([k, v]) => `${encodeURIComponent(k)}=${encodeURIComponent(String(v))}`)
|
||||||
|
.join('&')
|
||||||
|
Taro.navigateTo({ url: `/passport/sms-login${qs ? `?${qs}` : ''}` })
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 手机号授权失败时弹窗引导走短信登录(区分原因) */
|
||||||
|
const showPhoneAuthFailedModal = (errMsg?: string) => {
|
||||||
|
let content = '请尝试使用短信验证码登录'
|
||||||
|
if (errMsg?.includes('user deny')) {
|
||||||
|
content = '您已取消微信手机号授权,可改用短信验证码登录'
|
||||||
|
} else if (errMsg?.includes('privacy')) {
|
||||||
|
content = '微信未授权获取手机号,可改用短信验证码登录'
|
||||||
|
} else if (errMsg?.includes('no permission')) {
|
||||||
|
content = '小程序暂未获得手机号授权,可改用短信验证码登录'
|
||||||
|
}
|
||||||
|
Taro.showModal({
|
||||||
|
title: '未获取到手机号',
|
||||||
|
content,
|
||||||
|
confirmText: '短信登录',
|
||||||
|
cancelText: '我知道了',
|
||||||
|
confirmColor: '#07c160',
|
||||||
|
success: (res) => {
|
||||||
|
if (res.confirm) goSmsLogin()
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
/** 手机号快捷登录 */
|
/** 手机号快捷登录 */
|
||||||
const handleGetPhoneNumber = async ({ detail }: GetPhoneNumberEvent) => {
|
const handleGetPhoneNumber = async ({ detail }: GetPhoneNumberEvent) => {
|
||||||
if (!isAgree) {
|
if (!isAgree) {
|
||||||
@@ -168,7 +206,7 @@ const Login = () => {
|
|||||||
|
|
||||||
const { code: phoneCode, errMsg } = detail || {}
|
const { code: phoneCode, errMsg } = detail || {}
|
||||||
if (!phoneCode || (errMsg && errMsg.includes('fail'))) {
|
if (!phoneCode || (errMsg && errMsg.includes('fail'))) {
|
||||||
Taro.showToast({ title: '未授权手机号', icon: 'none' })
|
showPhoneAuthFailedModal(errMsg)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -282,8 +320,17 @@ const Login = () => {
|
|||||||
手机号快捷登录
|
手机号快捷登录
|
||||||
</Button>
|
</Button>
|
||||||
|
|
||||||
<View className='login-methods__tip text-gray-200'>
|
{/*<View className='login-methods__tip text-gray-200'>*/}
|
||||||
<Text>点击上方按钮,快速登录</Text>
|
{/* <Text>点击上方按钮,快速登录</Text>*/}
|
||||||
|
{/*</View>*/}
|
||||||
|
|
||||||
|
<View className='login-methods__alt'>
|
||||||
|
<Text
|
||||||
|
className='login-methods__alt-link'
|
||||||
|
onClick={() => goSmsLogin()}
|
||||||
|
>
|
||||||
|
使用短信验证码登录
|
||||||
|
</Text>
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
<View className='login-methods__divider'>
|
<View className='login-methods__divider'>
|
||||||
|
|||||||
@@ -150,6 +150,28 @@ const Register = () => {
|
|||||||
await Taro.redirectTo({ url: redirectUrl })
|
await Taro.redirectTo({ url: redirectUrl })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 手机号授权失败时弹窗引导走短信注册/登录(区分原因) */
|
||||||
|
const showPhoneAuthFailedModal = (errMsg?: string) => {
|
||||||
|
let content = '请尝试使用短信验证码注册/登录'
|
||||||
|
if (errMsg?.includes('user deny')) {
|
||||||
|
content = '您已取消微信手机号授权,可改用短信验证码注册/登录'
|
||||||
|
} else if (errMsg?.includes('privacy')) {
|
||||||
|
content = '微信未授权获取手机号,可改用短信验证码注册/登录'
|
||||||
|
} else if (errMsg?.includes('no permission')) {
|
||||||
|
content = '小程序暂未获得手机号授权,可改用短信验证码注册/登录'
|
||||||
|
}
|
||||||
|
Taro.showModal({
|
||||||
|
title: '未获取到手机号',
|
||||||
|
content,
|
||||||
|
confirmText: '短信注册/登录',
|
||||||
|
cancelText: '我知道了',
|
||||||
|
confirmColor: '#07c160',
|
||||||
|
success: (res) => {
|
||||||
|
if (res.confirm) goSmsLogin()
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
const handleGetPhoneNumber = async ({ detail }: GetPhoneNumberEvent) => {
|
const handleGetPhoneNumber = async ({ detail }: GetPhoneNumberEvent) => {
|
||||||
if (!isAgree) {
|
if (!isAgree) {
|
||||||
Taro.showToast({ title: '请先勾选同意协议', icon: 'none' })
|
Taro.showToast({ title: '请先勾选同意协议', icon: 'none' })
|
||||||
@@ -159,7 +181,7 @@ const Register = () => {
|
|||||||
|
|
||||||
const { code: phoneCode, encryptedData, iv, errMsg } = detail || {}
|
const { code: phoneCode, encryptedData, iv, errMsg } = detail || {}
|
||||||
if (!phoneCode || (errMsg && errMsg.includes('fail'))) {
|
if (!phoneCode || (errMsg && errMsg.includes('fail'))) {
|
||||||
Taro.showToast({ title: '未授权手机号', icon: 'none' })
|
showPhoneAuthFailedModal(errMsg)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -281,11 +303,9 @@ const Register = () => {
|
|||||||
手机号一键注册/登录
|
手机号一键注册/登录
|
||||||
</Button>
|
</Button>
|
||||||
|
|
||||||
{!isWeapp && (
|
<Button type='default' block disabled={!isAgree || loading} onClick={goSmsLogin}>
|
||||||
<Button type='default' block disabled={!isAgree || loading} onClick={goSmsLogin}>
|
短信验证码注册/登录
|
||||||
短信验证码注册/登录
|
</Button>
|
||||||
</Button>
|
|
||||||
)}
|
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
<View className='mt-6 flex text-sm items-center px-1'>
|
<View className='mt-6 flex text-sm items-center px-1'>
|
||||||
|
|||||||
332
src/passport/sms-login.scss
Normal file
332
src/passport/sms-login.scss
Normal file
@@ -0,0 +1,332 @@
|
|||||||
|
// 页面容器
|
||||||
|
.page-sms-login {
|
||||||
|
min-height: 100vh;
|
||||||
|
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
position: relative;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 背景装饰
|
||||||
|
.sms-login-bg {
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
bottom: 0;
|
||||||
|
pointer-events: none;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sms-login-bg__gradient {
|
||||||
|
position: absolute;
|
||||||
|
top: -50%;
|
||||||
|
left: -50%;
|
||||||
|
right: -50%;
|
||||||
|
bottom: -50%;
|
||||||
|
background: radial-gradient(circle at 30% 50%, rgba(255, 255, 255, 0.1) 0%, transparent 50%),
|
||||||
|
radial-gradient(circle at 70% 80%, rgba(255, 255, 255, 0.08) 0%, transparent 50%);
|
||||||
|
animation: gradientMove 15s ease-in-out infinite;
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes gradientMove {
|
||||||
|
0%, 100% {
|
||||||
|
transform: translate(0, 0) rotate(0deg);
|
||||||
|
}
|
||||||
|
33% {
|
||||||
|
transform: translate(30px, -30px) rotate(120deg);
|
||||||
|
}
|
||||||
|
66% {
|
||||||
|
transform: translate(-20px, 20px) rotate(240deg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.sms-login-bg__circle {
|
||||||
|
position: absolute;
|
||||||
|
border-radius: 50%;
|
||||||
|
opacity: 0.1;
|
||||||
|
background: #ffffff;
|
||||||
|
animation: float 20s ease-in-out infinite;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sms-login-bg__circle--1 {
|
||||||
|
width: 400px;
|
||||||
|
height: 400px;
|
||||||
|
top: -150px;
|
||||||
|
right: -100px;
|
||||||
|
animation-delay: 0s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sms-login-bg__circle--2 {
|
||||||
|
width: 300px;
|
||||||
|
height: 300px;
|
||||||
|
bottom: 10%;
|
||||||
|
left: -100px;
|
||||||
|
animation-delay: -7s;
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes float {
|
||||||
|
0%, 100% {
|
||||||
|
transform: translate(0, 0) scale(1);
|
||||||
|
}
|
||||||
|
33% {
|
||||||
|
transform: translate(30px, -30px) scale(1.1);
|
||||||
|
}
|
||||||
|
66% {
|
||||||
|
transform: translate(-20px, 20px) scale(0.9);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 内容区域
|
||||||
|
.sms-login-content {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
min-height: 100vh;
|
||||||
|
padding: 0 50px;
|
||||||
|
position: relative;
|
||||||
|
z-index: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 头部 Logo 和标题
|
||||||
|
.sms-login-header {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
padding-top: 120px;
|
||||||
|
margin-bottom: 60px;
|
||||||
|
animation: slideDown 0.8s ease-out;
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes slideDown {
|
||||||
|
from {
|
||||||
|
opacity: 0;
|
||||||
|
transform: translateY(-30px);
|
||||||
|
}
|
||||||
|
to {
|
||||||
|
opacity: 1;
|
||||||
|
transform: translateY(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.sms-login-logo {
|
||||||
|
width: 140px;
|
||||||
|
height: 140px;
|
||||||
|
border-radius: 35px;
|
||||||
|
background: rgba(255, 255, 255, 0.95);
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
margin-bottom: 36px;
|
||||||
|
box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
|
||||||
|
animation: logoFloat 3s ease-in-out infinite;
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes logoFloat {
|
||||||
|
0%, 100% {
|
||||||
|
transform: translateY(0);
|
||||||
|
}
|
||||||
|
50% {
|
||||||
|
transform: translateY(-8px);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.sms-login-logo__icon {
|
||||||
|
font-size: 72px;
|
||||||
|
line-height: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sms-login-title {
|
||||||
|
font-size: 52px;
|
||||||
|
font-weight: 700;
|
||||||
|
color: #ffffff;
|
||||||
|
margin-bottom: 18px;
|
||||||
|
text-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
|
||||||
|
letter-spacing: 2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sms-login-subtitle {
|
||||||
|
font-size: 26px;
|
||||||
|
color: rgba(255, 255, 255, 0.85);
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 表单卡片
|
||||||
|
.sms-login-card {
|
||||||
|
background: rgba(255, 255, 255, 0.98);
|
||||||
|
border-radius: 28px;
|
||||||
|
padding: 12px 32px;
|
||||||
|
margin-bottom: 48px;
|
||||||
|
box-shadow: 0 20px 60px rgba(0, 0, 0, 0.18);
|
||||||
|
animation: slideUp 0.6s ease-out 0.2s both;
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes slideUp {
|
||||||
|
from {
|
||||||
|
opacity: 0;
|
||||||
|
transform: translateY(20px);
|
||||||
|
}
|
||||||
|
to {
|
||||||
|
opacity: 1;
|
||||||
|
transform: translateY(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.sms-login-field {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
height: 110px;
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sms-login-field--code {
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sms-login-field__icon-wrap {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
flex: 1;
|
||||||
|
min-width: 0;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sms-login-field__icon {
|
||||||
|
font-size: 36px;
|
||||||
|
margin-right: 20px;
|
||||||
|
line-height: 1;
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sms-login-field__input {
|
||||||
|
flex: 1;
|
||||||
|
height: 110px;
|
||||||
|
font-size: 30px;
|
||||||
|
color: #333333;
|
||||||
|
letter-spacing: 1px;
|
||||||
|
background: transparent;
|
||||||
|
border: none;
|
||||||
|
outline: none;
|
||||||
|
padding: 0;
|
||||||
|
min-width: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sms-login-field__placeholder {
|
||||||
|
color: #b8b8b8;
|
||||||
|
font-size: 30px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sms-login-divider {
|
||||||
|
height: 1px;
|
||||||
|
background: linear-gradient(to right, transparent, #e8e8e8 20%, #e8e8e8 80%, transparent);
|
||||||
|
margin: 0 -8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 发送验证码按钮
|
||||||
|
.sms-login-send {
|
||||||
|
flex-shrink: 0;
|
||||||
|
height: 64px;
|
||||||
|
padding: 0 22px;
|
||||||
|
border-radius: 32px;
|
||||||
|
background: linear-gradient(135deg, #07c160, #06ad56);
|
||||||
|
color: #ffffff;
|
||||||
|
font-size: 26px;
|
||||||
|
font-weight: 600;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
margin-left: 16px;
|
||||||
|
box-shadow: 0 6px 20px rgba(7, 193, 96, 0.35);
|
||||||
|
letter-spacing: 0.5px;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sms-login-send--disabled {
|
||||||
|
background: #e0e0e0;
|
||||||
|
color: #999999;
|
||||||
|
box-shadow: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 登录按钮
|
||||||
|
.sms-login-submit {
|
||||||
|
height: 100px;
|
||||||
|
width: 100%;
|
||||||
|
border-radius: 50px;
|
||||||
|
background: linear-gradient(135deg, #07c160, #06ad56);
|
||||||
|
color: #ffffff;
|
||||||
|
font-size: 34px;
|
||||||
|
font-weight: 600;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
letter-spacing: 4px;
|
||||||
|
box-shadow: 0 12px 36px rgba(7, 193, 96, 0.4);
|
||||||
|
margin-bottom: 36px;
|
||||||
|
animation: slideUp 0.6s ease-out 0.35s both;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sms-login-submit--disabled {
|
||||||
|
background: #b8e0c5;
|
||||||
|
color: rgba(255, 255, 255, 0.85);
|
||||||
|
box-shadow: 0 4px 12px rgba(7, 193, 96, 0.15);
|
||||||
|
}
|
||||||
|
|
||||||
|
.sms-login-submit--hover {
|
||||||
|
transform: scale(0.98);
|
||||||
|
opacity: 0.92;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 返回链接
|
||||||
|
.sms-login-back {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
height: 80px;
|
||||||
|
margin-bottom: 32px;
|
||||||
|
animation: fadeIn 0.8s ease-out 0.5s both;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sms-login-back__icon {
|
||||||
|
font-size: 30px;
|
||||||
|
color: rgba(255, 255, 255, 0.9);
|
||||||
|
margin-right: 10px;
|
||||||
|
line-height: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sms-login-back__text {
|
||||||
|
font-size: 28px;
|
||||||
|
color: rgba(255, 255, 255, 0.9);
|
||||||
|
text-decoration: underline;
|
||||||
|
letter-spacing: 1px;
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes fadeIn {
|
||||||
|
from { opacity: 0; }
|
||||||
|
to { opacity: 1; }
|
||||||
|
}
|
||||||
|
|
||||||
|
// 底部协议
|
||||||
|
.sms-login-tips {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
padding: 0 40px;
|
||||||
|
margin-top: auto;
|
||||||
|
padding-bottom: 60px;
|
||||||
|
animation: fadeIn 0.8s ease-out 0.6s both;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sms-login-tips__text {
|
||||||
|
font-size: 22px;
|
||||||
|
color: rgba(255, 255, 255, 0.7);
|
||||||
|
line-height: 1.6;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sms-login-tips__link {
|
||||||
|
font-size: 22px;
|
||||||
|
color: #ffffff;
|
||||||
|
text-decoration: underline;
|
||||||
|
margin: 0 4px;
|
||||||
|
line-height: 1.6;
|
||||||
|
}
|
||||||
@@ -1,10 +1,10 @@
|
|||||||
import {useEffect, useState} from "react";
|
import {useEffect, useState} from "react";
|
||||||
import Taro from '@tarojs/taro'
|
import Taro from '@tarojs/taro'
|
||||||
import { View } from '@tarojs/components'
|
import { View, Text, Input } from '@tarojs/components'
|
||||||
import {Input, Button} from '@nutui/nutui-react-taro'
|
|
||||||
import {loginBySms, sendSmsCaptcha} from "@/api/passport/login";
|
import {loginBySms, sendSmsCaptcha} from "@/api/passport/login";
|
||||||
import {LoginParam} from "@/api/passport/login/model";
|
import {LoginParam} from "@/api/passport/login/model";
|
||||||
import {checkAndHandleInviteRelation, hasPendingInvite, parseInviteParams, saveInviteParams, trackInviteSource} from "@/utils/invite";
|
import {checkAndHandleInviteRelation, hasPendingInvite, parseInviteParams, saveInviteParams, trackInviteSource} from "@/utils/invite";
|
||||||
|
import './sms-login.scss'
|
||||||
|
|
||||||
const SmsLogin = () => {
|
const SmsLogin = () => {
|
||||||
const [loading, setLoading] = useState<boolean>(false)
|
const [loading, setLoading] = useState<boolean>(false)
|
||||||
@@ -55,12 +55,8 @@ const SmsLogin = () => {
|
|||||||
await Taro.redirectTo({ url: redirectUrl })
|
await Taro.redirectTo({ url: redirectUrl })
|
||||||
}
|
}
|
||||||
|
|
||||||
const reload = () => {
|
|
||||||
// sms-login 页面不是 tabBar 页面,无需调用 hideTabBar
|
|
||||||
}
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
reload()
|
// sms-login 页面不是 tabBar 页面,无需调用 hideTabBar
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
// 如果从分享/二维码链接进入短信登录页,先暂存邀请信息
|
// 如果从分享/二维码链接进入短信登录页,先暂存邀请信息
|
||||||
@@ -78,7 +74,7 @@ const SmsLogin = () => {
|
|||||||
|
|
||||||
// 倒计时效果
|
// 倒计时效果
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
let timer: NodeJS.Timeout
|
let timer: ReturnType<typeof setTimeout> | undefined
|
||||||
if (countdown > 0) {
|
if (countdown > 0) {
|
||||||
timer = setTimeout(() => {
|
timer = setTimeout(() => {
|
||||||
setCountdown(countdown - 1)
|
setCountdown(countdown - 1)
|
||||||
@@ -218,52 +214,114 @@ const SmsLogin = () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const phoneValid = validatePhone(formData.phone)
|
||||||
|
const codeValid = formData.code.length === 6
|
||||||
|
const canSubmit = phoneValid && codeValid && !loading
|
||||||
|
const sendDisabled = !phoneValid || sendingCode || countdown > 0
|
||||||
|
|
||||||
|
const sendBtnText = countdown > 0
|
||||||
|
? `${countdown}s 后重试`
|
||||||
|
: sendingCode
|
||||||
|
? '发送中'
|
||||||
|
: '获取验证码'
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<View className='page-sms-login'>
|
||||||
<View className='flex flex-col justify-center px-5 pt-3'>
|
{/* 渐变背景 */}
|
||||||
<View className='flex flex-col justify-between items-center my-2'>
|
<View className='sms-login-bg'>
|
||||||
<Input
|
<View className='sms-login-bg__gradient' />
|
||||||
type='number'
|
<View className='sms-login-bg__circle sms-login-bg__circle--1' />
|
||||||
placeholder='请输入手机号码'
|
<View className='sms-login-bg__circle sms-login-bg__circle--2' />
|
||||||
maxLength={11}
|
</View>
|
||||||
value={formData.phone}
|
|
||||||
onChange={(value) => setFormData({...formData, phone: value})}
|
<View className='sms-login-content'>
|
||||||
style={{backgroundColor: '#ffffff', borderRadius: '8px'}}
|
{/* 头部 Logo 和标题 */}
|
||||||
/>
|
<View className='sms-login-header'>
|
||||||
|
<View className='sms-login-logo'>
|
||||||
|
<Text className='sms-login-logo__icon'>📱</Text>
|
||||||
|
</View>
|
||||||
|
<Text className='sms-login-title'>验证码登录</Text>
|
||||||
|
<Text className='sms-login-subtitle'>未注册的手机号验证后将自动注册</Text>
|
||||||
</View>
|
</View>
|
||||||
<View className='flex justify-between items-center bg-white rounded-lg my-2 pr-2'>
|
|
||||||
<Input
|
{/* 表单卡片 */}
|
||||||
type='number'
|
<View className='sms-login-card'>
|
||||||
placeholder='请输入6位验证码'
|
{/* 手机号 */}
|
||||||
maxLength={6}
|
<View className='sms-login-field'>
|
||||||
value={formData.code}
|
<Text className='sms-login-field__icon'>📞</Text>
|
||||||
onChange={(value) => setFormData({...formData, code: value})}
|
<Input
|
||||||
style={{ backgroundColor: '#ffffff', borderRadius: '8px'}}
|
className='sms-login-field__input'
|
||||||
/>
|
type='number'
|
||||||
<Button
|
placeholder='请输入手机号码'
|
||||||
size='small'
|
placeholderClass='sms-login-field__placeholder'
|
||||||
type={countdown > 0 ? "default" : "primary"}
|
maxLength={11}
|
||||||
loading={sendingCode}
|
value={formData.phone}
|
||||||
disabled={sendingCode || countdown > 0}
|
onInput={(e: any) => setFormData({ ...formData, phone: e.detail.value })}
|
||||||
onClick={handleSendCode}
|
/>
|
||||||
>
|
</View>
|
||||||
{countdown > 0 ? `${countdown}s` : sendingCode ? '发送中...' : '获取验证码'}
|
|
||||||
</Button>
|
<View className='sms-login-divider' />
|
||||||
|
|
||||||
|
{/* 验证码 */}
|
||||||
|
<View className='sms-login-field sms-login-field--code'>
|
||||||
|
<View className='sms-login-field__icon-wrap'>
|
||||||
|
<Text className='sms-login-field__icon'>🔐</Text>
|
||||||
|
<Input
|
||||||
|
className='sms-login-field__input'
|
||||||
|
type='number'
|
||||||
|
placeholder='请输入6位验证码'
|
||||||
|
placeholderClass='sms-login-field__placeholder'
|
||||||
|
maxLength={6}
|
||||||
|
value={formData.code}
|
||||||
|
onInput={(e: any) => setFormData({ ...formData, code: e.detail.value })}
|
||||||
|
/>
|
||||||
|
</View>
|
||||||
|
<View
|
||||||
|
className={`sms-login-send ${sendDisabled ? 'sms-login-send--disabled' : ''}`}
|
||||||
|
onClick={handleSendCode}
|
||||||
|
>
|
||||||
|
{sendBtnText}
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
</View>
|
</View>
|
||||||
<View className='flex justify-center my-5'>
|
|
||||||
<Button
|
{/* 登录按钮 */}
|
||||||
type='info'
|
<View
|
||||||
size='large'
|
className={`sms-login-submit ${canSubmit ? '' : 'sms-login-submit--disabled'}`}
|
||||||
className='w-full rounded-lg p-2'
|
hoverClass={canSubmit ? 'sms-login-submit--hover' : 'none'}
|
||||||
loading={loading}
|
onClick={canSubmit ? handleLogin : undefined}
|
||||||
disabled={loading}
|
>
|
||||||
onClick={handleLogin}
|
{loading ? '登录中...' : '登录 / 注册'}
|
||||||
|
</View>
|
||||||
|
|
||||||
|
{/* 返回微信登录 */}
|
||||||
|
<View
|
||||||
|
className='sms-login-back'
|
||||||
|
onClick={() => Taro.navigateBack({ delta: 1 })}
|
||||||
|
>
|
||||||
|
<Text className='sms-login-back__icon'>←</Text>
|
||||||
|
<Text className='sms-login-back__text'>返回微信快捷登录</Text>
|
||||||
|
</View>
|
||||||
|
|
||||||
|
{/* 协议 */}
|
||||||
|
<View className='sms-login-tips'>
|
||||||
|
<Text className='sms-login-tips__text'>登录即代表您已阅读并同意</Text>
|
||||||
|
<Text
|
||||||
|
className='sms-login-tips__link'
|
||||||
|
onClick={() => Taro.navigateTo({ url: '/passport/agreement?type=terms' })}
|
||||||
>
|
>
|
||||||
{loading ? '登录中...' : '登录'}
|
《服务协议》
|
||||||
</Button>
|
</Text>
|
||||||
|
<Text className='sms-login-tips__text'>和</Text>
|
||||||
|
<Text
|
||||||
|
className='sms-login-tips__link'
|
||||||
|
onClick={() => Taro.navigateTo({ url: '/passport/agreement?type=privacy' })}
|
||||||
|
>
|
||||||
|
《隐私政策》
|
||||||
|
</Text>
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
</>
|
</View>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
export default SmsLogin
|
export default SmsLogin
|
||||||
|
|||||||
Reference in New Issue
Block a user