发短信 支持native

This commit is contained in:
wkj 2023-12-14 20:26:01 +08:00
parent 69a8732908
commit ebf3210c8f
3 changed files with 6 additions and 7 deletions

View File

@ -1036,7 +1036,7 @@ export async function syncUserInfoWechatMp({ nickname, avatarUrl, encryptedData,
} }
export async function sendCaptcha({ mobile, env, type: type2 }, context) { export async function sendCaptcha({ mobile, env, type: type2 }, context) {
const { type } = env; const { type } = env;
assert(type === 'web'); assert(type === 'web' || type === 'native');
let { visitorId } = env; let { visitorId } = env;
const application = context.getApplication(); const application = context.getApplication();
const { system } = application; const { system } = application;

View File

@ -1045,7 +1045,7 @@ async function syncUserInfoWechatMp({ nickname, avatarUrl, encryptedData, iv, si
exports.syncUserInfoWechatMp = syncUserInfoWechatMp; exports.syncUserInfoWechatMp = syncUserInfoWechatMp;
async function sendCaptcha({ mobile, env, type: type2 }, context) { async function sendCaptcha({ mobile, env, type: type2 }, context) {
const { type } = env; const { type } = env;
(0, assert_1.assert)(type === 'web'); (0, assert_1.assert)(type === 'web' || type === 'native');
let { visitorId } = env; let { visitorId } = env;
const application = context.getApplication(); const application = context.getApplication();
const { system } = application; const { system } = application;

View File

@ -1509,17 +1509,17 @@ export async function sendCaptcha<
{ {
mobile, mobile,
env, env,
type: type2 type: type2,
}: { }: {
mobile: string; mobile: string;
env: WechatMpEnv | WebEnv; env: WechatMpEnv | WebEnv | NativeEnv;
type: 'login' | 'changePassword' | 'confirm'; type: 'login' | 'changePassword' | 'confirm';
}, },
context: Cxt context: Cxt
): Promise<string> { ): Promise<string> {
const { type } = env; const { type } = env;
assert(type === 'web'); assert(type === 'web' || type === 'native');
let { visitorId } = env; let { visitorId } = env;
const application = context.getApplication(); const application = context.getApplication();
const { system } = application!; const { system } = application!;
@ -1591,8 +1591,7 @@ export async function sendCaptcha<
if (process.env.NODE_ENV !== 'production' || mockSend) { if (process.env.NODE_ENV !== 'production' || mockSend) {
closeRootMode(); closeRootMode();
return `验证码[${code}]已创建`; return `验证码[${code}]已创建`;
} } else if ((captcha.$$createAt$$! as number) - now < 60000) {
else if (captcha.$$createAt$$! as number - now < 60000) {
closeRootMode(); closeRootMode();
throw new OakUserException('您的操作太迅捷啦,请稍等再点吧'); throw new OakUserException('您的操作太迅捷啦,请稍等再点吧');
} else { } else {