feat: 小程序登录样式调整适配密码登录变化

This commit is contained in:
lxy 2025-11-14 11:27:51 +08:00
parent 3f690e6725
commit a1ed3c7ca7
33 changed files with 176 additions and 88 deletions

View File

@ -292,7 +292,7 @@ export default OakComponent({
}
break;
case 'wechatMp':
if (['wechatPublic', 'wechatWeb', 'wechatMpForWeb', 'wechatPublicForWeb'].includes(pType)) {
if (['wechatPublic', 'wechatWeb', 'wechatMpForWeb', 'wechatPublicForWeb', 'oauth'].includes(pType)) {
return {
disabled: true,
disabledTip: '当前application不支持该登录方式',
@ -300,7 +300,7 @@ export default OakComponent({
}
break;
case 'wechatPublic':
if (['wechatMp', 'wechatWeb', 'wechatMpForWeb', 'wechatPublicForWeb'].includes(pType)) {
if (['wechatMp', 'wechatWeb', 'wechatMpForWeb', 'wechatPublicForWeb', 'oauth'].includes(pType)) {
return {
disabled: true,
disabledTip: '当前application不支持该登录方式',
@ -308,7 +308,7 @@ export default OakComponent({
}
break;
case 'native':
if (['wechatMp', 'wechatPublic', 'wechatWeb', 'wechatMpForWeb', 'wechatPublicForWeb'].includes(pType)) {
if (['wechatMp', 'wechatPublic', 'wechatWeb', 'wechatMpForWeb', 'wechatPublicForWeb', 'oauth'].includes(pType)) {
return {
disabled: true,
disabledTip: '当前application不支持该登录方式',

View File

@ -5,5 +5,8 @@ declare const _default: (props: import("oak-frontend-base").ReactComponentProps<
callback: (() => void) | undefined;
setLoginMode: (value: string) => void;
digit: number;
allowSms: boolean;
allowPassword: boolean;
allowWechatMp: boolean;
}>) => React.ReactElement;
export default _default;

View File

@ -25,6 +25,9 @@ export default OakComponent({
callback: undefined, // 登录成功回调,排除微信登录方式
setLoginMode: (value) => undefined,
digit: 4, //验证码位数
allowSms: false, //小程序切换手机号验证码登录
allowPassword: false, //小程序切换密码登录
allowWechatMp: false, //小程序切换授权登录
},
formData({ features, props }) {
const { lastSendAt } = this.state;

View File

@ -2,14 +2,13 @@
<oak-icon name="mobilephone" size="28" color="#808080" />
<l-input
hide-label="{{true}}"
placeholder="{{t('placeholder.Mobile')}}"
placeholder="{{t('placeholder.Email')}}"
clear="{{true}}"
showRow="{{false}}"
l-class="my-input"
style="flex:1;"
data-attr="mobile"
maxlength="11"
value="{{mobile}}"
data-attr="email"
value="{{email}}"
bind:lininput="inputChangeMp"
bind:linclear="inputChangeMp"
/>
@ -17,13 +16,13 @@
<view class="inputItem">
<l-input
hide-label="{{true}}"
placeholder="{{t('placeholder.Captcha')}}"
placeholder="输入{{digit}}位验证码"
clear="{{true}}"
showRow="{{false}}"
l-class="my-input"
width="380"
data-attr="captcha"
maxlength="4"
maxlength="{{digit}}"
value="{{captcha}}"
bind:lininput="inputChangeMp"
bind:linclear="inputChangeMp"
@ -39,5 +38,9 @@
<view class="methods">
<view wx:if="{{allowWechatMp}}" style="color:#8F976A" bindtap="changeLoginMp" data-value="wechatMp">一键登录</view>
<view wx:else></view>
<view wx:if="{{allowPassword}}" style="color:#835D01" bindtap="changeLoginMp" data-value="password">密码登录</view>
<view style="color:#835D01; display:flex; align-items:center; justify-content:flex-end; gap:8rpx">
<view wx:if="{{allowSms}}" bindtap="changeLoginMp" data-value="sms">短信登录</view>
<view wx:if="{{allowSms && allowPassword}}">/</view>
<view wx:if="{{allowPassword}}" bindtap="changeLoginMp" data-value="password">密码登录</view>
</view>
</view>

View File

@ -2,7 +2,7 @@
"Login": "登录",
"Send": "发送验证码",
"placeholder": {
"Captcha": "输入4位验证码",
"Captcha": "输入%{digit}位验证码",
"Email": "请输入邮箱"
},
"resendAfter": "秒后可重发"

View File

@ -9,7 +9,7 @@ export default function Render(props) {
const { sendCaptcha, loginByEmail, t, inputChange } = methods;
return (<Form colon={true}>
<Form.Item name="email">
<Input allowClear value={email} type="email" size="large" prefix={<MailOutlined />} placeholder={t('placeholder.Email')} onChange={(e) => {
<Input allowClear value={email} type="email" size="large" prefix={<MailOutlined />} placeholder={t('placeholder.Email', { digit })} onChange={(e) => {
inputChange('email', e.target.value);
}} className={Style['loginbox-input']}/>
</Form.Item>

View File

@ -13,11 +13,12 @@ export default OakComponent({
inputOptions: [],
scanOptions: [],
oauthOptions: [],
allowMobile: false, //密码登录允许使用手机号
allowEmail: false, //密码登录允许使用邮箱
allowLoginName: false, //密码登录允许使用账号
pwdAllowMobile: false, //密码登录允许使用手机号
pwdAllowEmail: false, //密码登录允许使用邮箱
pwdAllowLoginName: false, //密码登录允许使用账号
allowPassword: false,
allowSms: false, //小程序使用
allowEmail: false, //小程序使用
allowWechatMp: false,
setLoginModeMp(value) { this.setLoginMode(value); },
smsDigit: 4, //短信验证码位数
@ -26,7 +27,7 @@ export default OakComponent({
allowRegister: false, //开启账号登录且允许注册
},
properties: {
onlyCaptcha: false,
onlyCaptcha: false, //仅支持手机号验证码登录
onlyPassword: false,
disabled: '',
redirectUri: '', // 微信登录后的redirectUri要指向wechatUser/login去处理
@ -192,12 +193,13 @@ export default OakComponent({
appId = config2?.wechat?.appId;
domain = config2?.wechat?.domain;
}
const allowMobile = smsAP && smsAP?.allowPwd;
const allowEmail = emailAP && emailAP?.allowPwd;
const allowLoginName = loginNameAP && loginNameAP?.allowPwd;
const pwdAllowMobile = smsAP && smsAP?.allowPwd;
const pwdAllowEmail = emailAP && emailAP?.allowPwd;
const pwdAllowLoginName = loginNameAP && loginNameAP?.allowPwd;
const allowWechatMp = passportTypes.includes('wechatMp') && !onlyCaptcha && !onlyPassword;
const allowPassword = !onlyCaptcha && showPassword;
const allowSms = passportTypes.includes('sms') && !onlyPassword;
const allowEmail = passportTypes.includes('email') && !onlyPassword && !onlyCaptcha;
const allowRegister = loginNameAP && loginNameAP?.passport?.config?.register;
this.setState({
loginMode,
@ -208,11 +210,12 @@ export default OakComponent({
inputOptions,
scanOptions,
oauthOptions,
allowMobile,
allowEmail,
allowLoginName,
pwdAllowMobile,
pwdAllowEmail,
pwdAllowLoginName,
allowPassword,
allowSms,
allowEmail,
allowWechatMp,
allowRegister,
smsDigit,
@ -229,7 +232,7 @@ export default OakComponent({
});
},
changeLoginMp() {
const { allowSms, allowPassword } = this.state;
const { allowSms, allowPassword, allowEmail } = this.state;
let loginMode = 'wechatMp';
if (allowSms) {
loginMode = 'sms';
@ -237,6 +240,9 @@ export default OakComponent({
else if (allowPassword) {
loginMode = 'password';
}
else if (allowEmail) {
loginMode = 'email';
}
this.setLoginMode(loginMode);
},
async loginByWechatMp() {

View File

@ -6,6 +6,7 @@
"l-segment": "@oak-frontend-base/miniprogram_npm/lin-ui/segment/index",
"l-segment-item": "@oak-frontend-base/miniprogram_npm/lin-ui/segment-item/index",
"password": "../login/password/index",
"sms": "../login/sms/index"
"sms": "../login/sms/index",
"email": "../login/email/index"
}
}

View File

@ -7,6 +7,7 @@
callback="{{callback}}"
class="login-body"
allowPassword="{{allowPassword}}"
allowEmail="{{allowEmail}}"
allowWechatMp="{{allowWechatMp}}"
setLoginMode="{{setLoginModeMp}}"
/>
@ -18,6 +19,22 @@
callback="{{callback}}"
class="login-body"
allowSms="{{allowSms}}"
allowEmail="{{allowEmail}}"
allowWechatMp="{{allowWechatMp}}"
pwdAllowMobile="{{pwdAllowMobile}}"
pwdAllowEmail="{{pwdAllowEmail}}"
pwdAllowLoginName="{{pwdAllowLoginName}}"
setLoginMode="{{setLoginModeMp}}"
/>
</block>
<block wx:elif="{{loginMode ==='email'}}">
<email
disabled="{{disabled}}"
url="{{url}}"
callback="{{callback}}"
class="login-body"
allowSms="{{allowSms}}"
allowPassword="{{allowPassword}}"
allowWechatMp="{{allowWechatMp}}"
setLoginMode="{{setLoginModeMp}}"
/>
@ -26,7 +43,7 @@
<l-button type="default" size="long" disabled="{{loading}}" bind:lintap="loginByWechatMp" style="width:100%">
授权登录
</l-button>
<view wx:if="{{allowSms || allowPassword}}" style="font-size:28rpx; margin-top:28rpx; color:#8F976A" bind:tap="changeLoginMp">其他方式登录</view>
<view wx:if="{{allowSms || allowPassword || allowEmail}}" style="font-size:28rpx; margin-top:28rpx; color:#8F976A" bind:tap="changeLoginMp">其他方式登录</view>
</view>
</view>
</view>

View File

@ -4,10 +4,11 @@ declare const _default: (props: import("oak-frontend-base").ReactComponentProps<
redirectUri: string;
url: string;
callback: (() => void) | undefined;
allowMobile: boolean;
allowEmail: boolean;
allowLoginName: boolean;
pwdAllowMobile: boolean;
pwdAllowEmail: boolean;
pwdAllowLoginName: boolean;
allowSms: boolean;
allowEmail: boolean;
allowWechatMp: boolean;
setLoginMode: (value: string) => void;
pwdMode: string;

View File

@ -3,15 +3,15 @@ import { encryptPasswordSha1 } from "../../../../utils/password";
export default OakComponent({
isList: false,
formData({ features, props }) {
const { allowMobile, allowEmail, allowLoginName } = this.props;
const { pwdAllowMobile, pwdAllowEmail, pwdAllowLoginName } = this.props;
let tips = [];
if (allowLoginName) {
if (pwdAllowLoginName) {
tips.push(this.t('placeholder.LoginName'));
}
if (allowMobile) {
if (pwdAllowMobile) {
tips.push(this.t('placeholder.Mobile'));
}
if (allowEmail) {
if (pwdAllowEmail) {
tips.push(this.t('placeholder.Email'));
}
const accountPlaceholder = tips.length > 0 ? this.t('placeholder.Account') + tips.join('/') : this.t('placeholder.Account');
@ -36,10 +36,11 @@ export default OakComponent({
redirectUri: '', // 微信登录后的redirectUri要指向wechatUser/login去处理
url: '', // 登录系统之后要返回的页面
callback: undefined, // 登录成功回调,排除微信登录方式
allowMobile: false,
allowEmail: false,
allowLoginName: false,
pwdAllowMobile: false,
pwdAllowEmail: false,
pwdAllowLoginName: false,
allowSms: false, //小程序切换手机号验证码登录
allowEmail: false, //小程序切换邮箱登录
allowWechatMp: false, //小程序切换授权登录
setLoginMode: (value) => undefined,
pwdMode: 'all', //密码明文密文存储模式

View File

@ -35,5 +35,10 @@
<view class="methods">
<view wx:if="{{allowWechatMp}}" style="color:#8F976A" bindtap="changeLoginMp" data-value="wechatMp">一键登录</view>
<view wx:else></view>
<view wx:if="{{allowSms}}" style="color:#835D01" bindtap="changeLoginMp" data-value="sms">短信登录</view>
<!-- <view wx:if="{{allowSms}}" style="color:#835D01" bindtap="changeLoginMp" data-value="sms">短信登录</view> -->
<view style="color:#835D01; display:flex; align-items:center; justify-content:flex-end; gap:8rpx">
<view wx:if="{{allowSms}}" bindtap="changeLoginMp" data-value="sms">短信登录</view>
<view wx:if="{{allowSms && allowEmail}}">/</view>
<view wx:if="{{allowEmail}}"bindtap="changeLoginMp" data-value="email">邮箱登录</view>
</view>
</view>

View File

@ -4,6 +4,7 @@ declare const _default: (props: import("oak-frontend-base").ReactComponentProps<
url: string;
callback: (() => void) | undefined;
allowPassword: boolean;
allowEmail: boolean;
allowWechatMp: boolean;
setLoginMode: (value: string) => void;
digit: number;

View File

@ -24,6 +24,7 @@ export default OakComponent({
url: '', // 登录系统之后要返回的页面
callback: undefined, // 登录成功回调,排除微信登录方式
allowPassword: false, //小程序切换密码登录
allowEmail: false, //小程序切换邮箱登录
allowWechatMp: false, //小程序切换授权登录
setLoginMode: (value) => undefined,
digit: 4 //验证码位数,

View File

@ -39,5 +39,10 @@
<view class="methods">
<view wx:if="{{allowWechatMp}}" style="color:#8F976A" bindtap="changeLoginMp" data-value="wechatMp">一键登录</view>
<view wx:else></view>
<view wx:if="{{allowPassword}}" style="color:#835D01" bindtap="changeLoginMp" data-value="password">密码登录</view>
<!-- <view wx:if="{{allowPassword}}" style="color:#835D01" bindtap="changeLoginMp" data-value="password">密码登录</view> -->
<view style="color:#835D01; display:flex; align-items:center; justify-content:flex-end; gap:8rpx">
<view wx:if="{{allowPassword}}" bindtap="changeLoginMp" data-value="password">密码登录</view>
<view wx:if="{{allowPassword && allowEmail}}">/</view>
<view wx:if="{{allowEmail}}" bindtap="changeLoginMp" data-value="email">邮箱登录</view>
</view>
</view>

View File

@ -21,9 +21,9 @@ export default function Render(props: WebComponentProps<EntityDict, 'token', fal
scanOptions: Option[];
smsDigit: number;
emailDigit: number;
allowMobile: boolean;
allowEmail: boolean;
allowLoginName: boolean;
pwdAllowMobile: boolean;
pwdAllowEmail: boolean;
pwdAllowLoginName: boolean;
pwdMode: 'all' | 'plain' | 'sha1';
allowRegister: boolean;
oauthOptions: {

View File

@ -13,7 +13,7 @@ import PasswordLogin from './password';
import EmailLogin from './email';
export default function Render(props) {
const { data, methods } = props;
const { width, loading, loginMode, appId, domain, isSupportWechatGrant, disabled, redirectUri, url, passportTypes, callback, inputOptions, scanOptions, smsDigit, emailDigit, allowMobile, allowEmail, allowLoginName, pwdMode, allowRegister, oauthOptions, goRegister, goOauthLogin, } = data;
const { width, loading, loginMode, appId, domain, isSupportWechatGrant, disabled, redirectUri, url, passportTypes, callback, inputOptions, scanOptions, smsDigit, emailDigit, pwdAllowMobile, pwdAllowEmail, pwdAllowLoginName, pwdMode, allowRegister, oauthOptions, goRegister, goOauthLogin, } = data;
const { t, setLoginMode, } = methods;
let redirectUri2 = redirectUri;
if (!(redirectUri.startsWith('https') || redirectUri.startsWith('http'))) {
@ -113,7 +113,7 @@ export default function Render(props) {
<div className={Style['loginbox-password']} style={{
display: loginMode === 'password' ? 'block' : 'none',
}}>
<PasswordLogin disabled={disabled} url={url} callback={callback} allowMobile={allowMobile} allowEmail={allowEmail} allowLoginName={allowLoginName} pwdMode={pwdMode}/>
<PasswordLogin disabled={disabled} url={url} callback={callback} pwdAllowMobile={pwdAllowMobile} pwdAllowEmail={pwdAllowEmail} pwdAllowLoginName={pwdAllowLoginName} pwdMode={pwdMode}/>
{allowRegister && (<div className={Style['loginbox-register']}>
{/* <Button type='link' iconPosition='end' icon={<RightOutlined />}>去注册</Button> */}
<Button type='link' onClick={() => {

View File

@ -659,7 +659,7 @@ const i18ns = [
"Login": "登录",
"Send": "发送验证码",
"placeholder": {
"Captcha": "输入4位验证码",
"Captcha": "输入%{digit}位验证码",
"Email": "请输入邮箱"
},
"resendAfter": "秒后可重发"

View File

@ -661,7 +661,7 @@ const i18ns = [
"Login": "登录",
"Send": "发送验证码",
"placeholder": {
"Captcha": "输入4位验证码",
"Captcha": "输入%{digit}位验证码",
"Email": "请输入邮箱"
},
"resendAfter": "秒后可重发"

View File

@ -336,7 +336,7 @@ export default OakComponent({
}
break;
case 'wechatMp':
if (['wechatPublic', 'wechatWeb', 'wechatMpForWeb', 'wechatPublicForWeb'].includes(pType)) {
if (['wechatPublic', 'wechatWeb', 'wechatMpForWeb', 'wechatPublicForWeb', 'oauth'].includes(pType)) {
return {
disabled: true,
disabledTip: '当前application不支持该登录方式',
@ -344,7 +344,7 @@ export default OakComponent({
}
break;
case 'wechatPublic':
if (['wechatMp', 'wechatWeb', 'wechatMpForWeb', 'wechatPublicForWeb'].includes(pType)) {
if (['wechatMp', 'wechatWeb', 'wechatMpForWeb', 'wechatPublicForWeb', 'oauth'].includes(pType)) {
return {
disabled: true,
disabledTip: '当前application不支持该登录方式',
@ -352,7 +352,7 @@ export default OakComponent({
}
break;
case 'native':
if (['wechatMp', 'wechatPublic', 'wechatWeb', 'wechatMpForWeb', 'wechatPublicForWeb'].includes(pType)) {
if (['wechatMp', 'wechatPublic', 'wechatWeb', 'wechatMpForWeb', 'wechatPublicForWeb', 'oauth'].includes(pType)) {
return {
disabled: true,
disabledTip: '当前application不支持该登录方式',

View File

@ -29,6 +29,9 @@ export default OakComponent({
callback: undefined as (() => void) | undefined, // 登录成功回调,排除微信登录方式
setLoginMode: (value: string) => undefined as void,
digit: 4, //验证码位数
allowSms: false, //小程序切换手机号验证码登录
allowPassword: false, //小程序切换密码登录
allowWechatMp: false, //小程序切换授权登录
},
formData({ features, props }) {
const { lastSendAt } = this.state;

View File

@ -2,14 +2,13 @@
<oak-icon name="mobilephone" size="28" color="#808080" />
<l-input
hide-label="{{true}}"
placeholder="{{t('placeholder.Mobile')}}"
placeholder="{{t('placeholder.Email')}}"
clear="{{true}}"
showRow="{{false}}"
l-class="my-input"
style="flex:1;"
data-attr="mobile"
maxlength="11"
value="{{mobile}}"
data-attr="email"
value="{{email}}"
bind:lininput="inputChangeMp"
bind:linclear="inputChangeMp"
/>
@ -17,13 +16,13 @@
<view class="inputItem">
<l-input
hide-label="{{true}}"
placeholder="{{t('placeholder.Captcha')}}"
placeholder="输入{{digit}}位验证码"
clear="{{true}}"
showRow="{{false}}"
l-class="my-input"
width="380"
data-attr="captcha"
maxlength="4"
maxlength="{{digit}}"
value="{{captcha}}"
bind:lininput="inputChangeMp"
bind:linclear="inputChangeMp"
@ -39,5 +38,9 @@
<view class="methods">
<view wx:if="{{allowWechatMp}}" style="color:#8F976A" bindtap="changeLoginMp" data-value="wechatMp">一键登录</view>
<view wx:else></view>
<view wx:if="{{allowPassword}}" style="color:#835D01" bindtap="changeLoginMp" data-value="password">密码登录</view>
<view style="color:#835D01; display:flex; align-items:center; justify-content:flex-end; gap:8rpx">
<view wx:if="{{allowSms}}" bindtap="changeLoginMp" data-value="sms">短信登录</view>
<view wx:if="{{allowSms && allowPassword}}">/</view>
<view wx:if="{{allowPassword}}" bindtap="changeLoginMp" data-value="password">密码登录</view>
</view>
</view>

View File

@ -2,7 +2,7 @@
"Login": "登录",
"Send": "发送验证码",
"placeholder": {
"Captcha": "输入4位验证码",
"Captcha": "输入%{digit}位验证码",
"Email": "请输入邮箱"
},
"resendAfter": "秒后可重发"

View File

@ -52,7 +52,7 @@ export default function Render(
type="email"
size="large"
prefix={<MailOutlined />}
placeholder={t('placeholder.Email')}
placeholder={t('placeholder.Email', { digit })}
onChange={(e) => {
inputChange('email', e.target.value);
}}

View File

@ -6,6 +6,7 @@
"l-segment": "@oak-frontend-base/miniprogram_npm/lin-ui/segment/index",
"l-segment-item": "@oak-frontend-base/miniprogram_npm/lin-ui/segment-item/index",
"password": "../login/password/index",
"sms": "../login/sms/index"
"sms": "../login/sms/index",
"email": "../login/email/index"
}
}

View File

@ -26,11 +26,12 @@ export default OakComponent({
value: string,
logo?: string,
}[],
allowMobile: false, //密码登录允许使用手机号
allowEmail: false, //密码登录允许使用邮箱
allowLoginName: false, //密码登录允许使用账号
pwdAllowMobile: false, //密码登录允许使用手机号
pwdAllowEmail: false, //密码登录允许使用邮箱
pwdAllowLoginName: false, //密码登录允许使用账号
allowPassword: false,
allowSms: false, //小程序使用
allowEmail: false, //小程序使用
allowWechatMp: false,
setLoginModeMp(value: string) { this.setLoginMode(value) },
smsDigit: 4, //短信验证码位数
@ -39,7 +40,7 @@ export default OakComponent({
allowRegister: false, //开启账号登录且允许注册
},
properties: {
onlyCaptcha: false,
onlyCaptcha: false, //仅支持手机号验证码登录
onlyPassword: false,
disabled: '',
redirectUri: '', // 微信登录后的redirectUri要指向wechatUser/login去处理
@ -211,12 +212,13 @@ export default OakComponent({
domain = config2?.wechat?.domain;
}
const allowMobile = smsAP && smsAP?.allowPwd;
const allowEmail = emailAP && emailAP?.allowPwd;
const allowLoginName = loginNameAP && loginNameAP?.allowPwd;
const pwdAllowMobile = smsAP && smsAP?.allowPwd;
const pwdAllowEmail = emailAP && emailAP?.allowPwd;
const pwdAllowLoginName = loginNameAP && loginNameAP?.allowPwd;
const allowWechatMp = passportTypes.includes('wechatMp') && !onlyCaptcha && !onlyPassword;
const allowPassword = !onlyCaptcha && showPassword;
const allowSms = passportTypes.includes('sms') && !onlyPassword;
const allowEmail = passportTypes.includes('email') && !onlyPassword && !onlyCaptcha;
const allowRegister = loginNameAP && loginNameAP?.passport?.config?.register;
this.setState(
@ -229,11 +231,12 @@ export default OakComponent({
inputOptions,
scanOptions,
oauthOptions,
allowMobile,
allowEmail,
allowLoginName,
pwdAllowMobile,
pwdAllowEmail,
pwdAllowLoginName,
allowPassword,
allowSms,
allowEmail,
allowWechatMp,
allowRegister,
smsDigit,
@ -252,12 +255,14 @@ export default OakComponent({
});
},
changeLoginMp() {
const { allowSms, allowPassword } = this.state;
const { allowSms, allowPassword, allowEmail } = this.state;
let loginMode = 'wechatMp';
if (allowSms) {
loginMode = 'sms';
} else if (allowPassword) {
loginMode = 'password';
} else if (allowEmail) {
loginMode = 'email';
}
this.setLoginMode(loginMode);
},

View File

@ -7,6 +7,7 @@
callback="{{callback}}"
class="login-body"
allowPassword="{{allowPassword}}"
allowEmail="{{allowEmail}}"
allowWechatMp="{{allowWechatMp}}"
setLoginMode="{{setLoginModeMp}}"
/>
@ -18,6 +19,22 @@
callback="{{callback}}"
class="login-body"
allowSms="{{allowSms}}"
allowEmail="{{allowEmail}}"
allowWechatMp="{{allowWechatMp}}"
pwdAllowMobile="{{pwdAllowMobile}}"
pwdAllowEmail="{{pwdAllowEmail}}"
pwdAllowLoginName="{{pwdAllowLoginName}}"
setLoginMode="{{setLoginModeMp}}"
/>
</block>
<block wx:elif="{{loginMode ==='email'}}">
<email
disabled="{{disabled}}"
url="{{url}}"
callback="{{callback}}"
class="login-body"
allowSms="{{allowSms}}"
allowPassword="{{allowPassword}}"
allowWechatMp="{{allowWechatMp}}"
setLoginMode="{{setLoginModeMp}}"
/>
@ -26,7 +43,7 @@
<l-button type="default" size="long" disabled="{{loading}}" bind:lintap="loginByWechatMp" style="width:100%">
授权登录
</l-button>
<view wx:if="{{allowSms || allowPassword}}" style="font-size:28rpx; margin-top:28rpx; color:#8F976A" bind:tap="changeLoginMp">其他方式登录</view>
<view wx:if="{{allowSms || allowPassword || allowEmail}}" style="font-size:28rpx; margin-top:28rpx; color:#8F976A" bind:tap="changeLoginMp">其他方式登录</view>
</view>
</view>
</view>

View File

@ -8,15 +8,15 @@ import { encryptPasswordSha1 } from "../../../../utils/password";
export default OakComponent({
isList: false,
formData({ features, props }) {
const { allowMobile, allowEmail, allowLoginName } = this.props;
const { pwdAllowMobile, pwdAllowEmail, pwdAllowLoginName } = this.props;
let tips = [];
if (allowLoginName) {
if (pwdAllowLoginName) {
tips.push(this.t('placeholder.LoginName'));
}
if (allowMobile) {
if (pwdAllowMobile) {
tips.push(this.t('placeholder.Mobile'));
}
if (allowEmail) {
if (pwdAllowEmail) {
tips.push(this.t('placeholder.Email'));
}
const accountPlaceholder = tips.length > 0 ? this.t('placeholder.Account') + tips.join('/') : this.t('placeholder.Account');
@ -41,10 +41,11 @@ export default OakComponent({
redirectUri: '', // 微信登录后的redirectUri要指向wechatUser/login去处理
url: '', // 登录系统之后要返回的页面
callback: undefined as (() => void) | undefined, // 登录成功回调,排除微信登录方式
allowMobile: false,
allowEmail: false,
allowLoginName: false,
pwdAllowMobile: false,
pwdAllowEmail: false,
pwdAllowLoginName: false,
allowSms: false, //小程序切换手机号验证码登录
allowEmail: false, //小程序切换邮箱登录
allowWechatMp: false, //小程序切换授权登录
setLoginMode: (value: string) => undefined as void,
pwdMode: 'all', //密码明文密文存储模式

View File

@ -35,5 +35,10 @@
<view class="methods">
<view wx:if="{{allowWechatMp}}" style="color:#8F976A" bindtap="changeLoginMp" data-value="wechatMp">一键登录</view>
<view wx:else></view>
<view wx:if="{{allowSms}}" style="color:#835D01" bindtap="changeLoginMp" data-value="sms">短信登录</view>
<!-- <view wx:if="{{allowSms}}" style="color:#835D01" bindtap="changeLoginMp" data-value="sms">短信登录</view> -->
<view style="color:#835D01; display:flex; align-items:center; justify-content:flex-end; gap:8rpx">
<view wx:if="{{allowSms}}" bindtap="changeLoginMp" data-value="sms">短信登录</view>
<view wx:if="{{allowSms && allowEmail}}">/</view>
<view wx:if="{{allowEmail}}"bindtap="changeLoginMp" data-value="email">邮箱登录</view>
</view>
</view>

View File

@ -28,6 +28,7 @@ export default OakComponent({
url: '', // 登录系统之后要返回的页面
callback: undefined as (() => void) | undefined, // 登录成功回调,排除微信登录方式
allowPassword: false, //小程序切换密码登录
allowEmail: false, //小程序切换邮箱登录
allowWechatMp: false, //小程序切换授权登录
setLoginMode: (value: string) => undefined as void,
digit: 4 //验证码位数,

View File

@ -39,5 +39,10 @@
<view class="methods">
<view wx:if="{{allowWechatMp}}" style="color:#8F976A" bindtap="changeLoginMp" data-value="wechatMp">一键登录</view>
<view wx:else></view>
<view wx:if="{{allowPassword}}" style="color:#835D01" bindtap="changeLoginMp" data-value="password">密码登录</view>
<!-- <view wx:if="{{allowPassword}}" style="color:#835D01" bindtap="changeLoginMp" data-value="password">密码登录</view> -->
<view style="color:#835D01; display:flex; align-items:center; justify-content:flex-end; gap:8rpx">
<view wx:if="{{allowPassword}}" bindtap="changeLoginMp" data-value="password">密码登录</view>
<view wx:if="{{allowPassword && allowEmail}}">/</view>
<view wx:if="{{allowEmail}}" bindtap="changeLoginMp" data-value="email">邮箱登录</view>
</view>
</view>

View File

@ -55,9 +55,9 @@ export default function Render(
scanOptions: Option[];
smsDigit: number;
emailDigit: number;
allowMobile: boolean;
allowEmail: boolean;
allowLoginName: boolean;
pwdAllowMobile: boolean;
pwdAllowEmail: boolean;
pwdAllowLoginName: boolean;
pwdMode: 'all' | 'plain' | 'sha1';
allowRegister: boolean;
oauthOptions: {
@ -90,9 +90,9 @@ export default function Render(
scanOptions,
smsDigit,
emailDigit,
allowMobile,
allowEmail,
allowLoginName,
pwdAllowMobile,
pwdAllowEmail,
pwdAllowLoginName,
pwdMode,
allowRegister,
oauthOptions,
@ -255,9 +255,9 @@ export default function Render(
disabled={disabled}
url={url}
callback={callback}
allowMobile={allowMobile}
allowEmail={allowEmail}
allowLoginName={allowLoginName}
pwdAllowMobile={pwdAllowMobile}
pwdAllowEmail={pwdAllowEmail}
pwdAllowLoginName={pwdAllowLoginName}
pwdMode={pwdMode}
/>
{allowRegister && (

View File

@ -661,7 +661,7 @@ const i18ns: I18n[] = [
"Login": "登录",
"Send": "发送验证码",
"placeholder": {
"Captcha": "输入4位验证码",
"Captcha": "输入%{digit}位验证码",
"Email": "请输入邮箱"
},
"resendAfter": "秒后可重发"