From 93105767d92ff1871bc6f0083eef3f4501d7574d Mon Sep 17 00:00:00 2001 From: wtto00 Date: Mon, 29 Sep 2025 11:19:59 +0800 Subject: [PATCH 1/2] feat(button): add getRealtimePhoneNumber --- .../src/form-components/button.ts | 38 +++++++++++++++++++ .../test/form-components/button.test-d.ts | 4 ++ 2 files changed, 42 insertions(+) diff --git a/packages/uni-app-types/src/form-components/button.ts b/packages/uni-app-types/src/form-components/button.ts index 7db7a18..818db26 100644 --- a/packages/uni-app-types/src/form-components/button.ts +++ b/packages/uni-app-types/src/form-components/button.ts @@ -45,6 +45,8 @@ type _ButtonFormType = "submit" | "reset"; * * GetPhoneNumber 获取用户手机号,可以从 `@getphonenumber` 回调中获取到用户信息 * + * GetRealtimePhoneNumber 手机号实时验证,可以从 `@getrealtimephonenumber` 回调中获取到用户信息 + * * LaunchApp 小程序中打开APP,可以通过 `app-parameter` 属性设定向 APP 传的参数 * * OpenSetting 打开授权设置页 @@ -97,6 +99,7 @@ type _ButtonOpenType = | "getUserInfo" | "contact" | "getPhoneNumber" + | "getRealtimePhoneNumber" | "launchApp" | "openSetting" | "chooseAvatar" @@ -153,6 +156,15 @@ type _ButtonOnGetphonenumberEvent = CustomEvent<_ButtonOnGetphonenumberDetail>; */ type _ButtonOnGetphonenumber = (event: _ButtonOnGetphonenumberEvent) => void; +/** + * 手机号实时验证回调 + * + * Open-type="getRealtimePhoneNumber" 时有效 + */ +type _ButtonOnGetrealtimephonenumber = ( + event: _ButtonOnGetphonenumberEvent, +) => void; + type _ButtonOnErrorEvent = BaseEvent; /** 使用开放能力发生错误时回调 */ @@ -310,6 +322,8 @@ type _ButtonProps = CommonProps & * * GetPhoneNumber 获取用户手机号,可以从 `@getphonenumber` 回调中获取到用户信息 * + * GetRealtimePhoneNumber 手机号实时验证,可以从 `@getrealtimephonenumber` 回调中获取到用户信息 + * * LaunchApp 小程序中打开APP,可以通过 `app-parameter` 属性设定向 APP 传的参数 * * OpenSetting 打开授权设置页 @@ -355,6 +369,14 @@ type _ButtonProps = CommonProps & * OpenProfile 触发打开用户主页 */ openType: _ButtonOpenType; + /** + * 当手机号快速验证或手机号实时验证额度用尽时, + * 是否对用户展示“申请获取你的手机号,但该功能 + * 使用次数已达当前小程序上限,暂时无法使用”的 + * 提示。 + * @default true + */ + phoneNumberNoQuotaToast?: boolean; /** * 指定按下去的样式类 * @@ -467,6 +489,12 @@ type _ButtonProps = CommonProps & * Open-type="getPhoneNumber" 时有效 */ onGetphonenumber: _ButtonOnGetphonenumber; + /** + * 手机号实时验证回调 + * + * Open-type="getRealtimePhoneNumber" 时有效 + */ + onGetrealtimephonenumber: _ButtonOnGetrealtimephonenumber; /** 使用开放能力发生错误时回调 */ onError: _ButtonOnError; /** @@ -540,6 +568,7 @@ export type { _ButtonOnGetphonenumberDetail as ButtonOnGetphonenumberDetail, _ButtonOnGetphonenumberEvent as ButtonOnGetphonenumberEvent, _ButtonOnGetphonenumber as ButtonOnGetphonenumber, + _ButtonOnGetrealtimephonenumber as ButtonOnGetrealtimephonenumber, _ButtonOnErrorEvent as ButtonOnErrorEvent, _ButtonOnError as ButtonOnError, _ButtonOnOpensettingDetail as ButtonOnOpensettingDetail, @@ -609,6 +638,8 @@ declare global { * * GetPhoneNumber 获取用户手机号,可以从 `@getphonenumber` 回调中获取到用户信息 * + * GetRealtimePhoneNumber 手机号实时验证,可以从 `@getrealtimephonenumber` 回调中获取到用户信息 + * * LaunchApp 小程序中打开APP,可以通过 `app-parameter` 属性设定向 APP 传的参数 * * OpenSetting 打开授权设置页 @@ -675,6 +706,13 @@ declare global { * Open-type="getPhoneNumber" 时有效 */ export interface ButtonOnGetphonenumber extends _ButtonOnGetphonenumber {} + /** + * 手机号实时验证回调 + * + * Open-type="getRealtimePhoneNumber" 时有效 + */ + export interface ButtonOnGetrealtimephonenumber + extends _ButtonOnGetrealtimephonenumber {} export type ButtonOnErrorEvent = _ButtonOnErrorEvent; /** 使用开放能力发生错误时回调 */ export interface ButtonOnError extends _ButtonOnError {} diff --git a/packages/uni-app-types/test/form-components/button.test-d.ts b/packages/uni-app-types/test/form-components/button.test-d.ts index 822f776..9fa375f 100644 --- a/packages/uni-app-types/test/form-components/button.test-d.ts +++ b/packages/uni-app-types/test/form-components/button.test-d.ts @@ -18,6 +18,7 @@ import type { ButtonOnGetphonenumber, ButtonOnGetphonenumberDetail, ButtonOnGetphonenumberEvent, + ButtonOnGetrealtimephonenumber, ButtonOnLaunchapp, ButtonOnLaunchappEvent, ButtonOnLogin, @@ -60,6 +61,9 @@ describe("Button", () => { expectTypeOf().toBeFunction(); expectTypeOf().toEqualTypeOf(); + expectTypeOf().toBeFunction(); + expectTypeOf().toEqualTypeOf(); + expectTypeOf().toBeObject(); expectTypeOf().toEqualTypeOf(); From 7b7ca0fd689c48cff5a39bf2d6a730504ddc61c2 Mon Sep 17 00:00:00 2001 From: wtto00 Date: Mon, 29 Sep 2025 11:46:11 +0800 Subject: [PATCH 2/2] =?UTF-8?q?fix(button):=20bindgetrealtimephonenumber?= =?UTF-8?q?=20=E4=BA=8B=E4=BB=B6=E5=9B=9E=E8=B0=83=E4=B8=AD=EF=BC=8C?= =?UTF-8?q?=E4=BB=85=E4=BC=9A=E8=BF=94=E5=9B=9E=20code=EF=BC=8C=E4=B8=8D?= =?UTF-8?q?=E4=BC=9A=E8=BF=94=E5=9B=9E=20encryptedData=E5=92=8Civ?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/form-components/button.ts | 22 ++++++++++++++++++- .../test/form-components/button.test-d.ts | 8 +++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/packages/uni-app-types/src/form-components/button.ts b/packages/uni-app-types/src/form-components/button.ts index 818db26..aada113 100644 --- a/packages/uni-app-types/src/form-components/button.ts +++ b/packages/uni-app-types/src/form-components/button.ts @@ -156,13 +156,27 @@ type _ButtonOnGetphonenumberEvent = CustomEvent<_ButtonOnGetphonenumberDetail>; */ type _ButtonOnGetphonenumber = (event: _ButtonOnGetphonenumberEvent) => void; +interface _ButtonOnGetrealtimephonenumberDetail { + /** 错误信息 */ + errMsg?: string; + /** 错误码(失败时返回) */ + errno?: number; + /** 动态令牌 */ + code?: string; + /** 敏感数据对应的云 ID,开通云开发的小程序才会返回,可通过云调用直接获取开放数据 */ + cloudID?: string; +} + +type _ButtonOnGetrealtimephonenumberEvent = + CustomEvent<_ButtonOnGetrealtimephonenumberDetail>; + /** * 手机号实时验证回调 * * Open-type="getRealtimePhoneNumber" 时有效 */ type _ButtonOnGetrealtimephonenumber = ( - event: _ButtonOnGetphonenumberEvent, + event: _ButtonOnGetrealtimephonenumberEvent, ) => void; type _ButtonOnErrorEvent = BaseEvent; @@ -568,6 +582,8 @@ export type { _ButtonOnGetphonenumberDetail as ButtonOnGetphonenumberDetail, _ButtonOnGetphonenumberEvent as ButtonOnGetphonenumberEvent, _ButtonOnGetphonenumber as ButtonOnGetphonenumber, + _ButtonOnGetrealtimephonenumberDetail as ButtonOnGetrealtimephonenumberDetail, + _ButtonOnGetrealtimephonenumberEvent as ButtonOnGetrealtimephonenumberEvent, _ButtonOnGetrealtimephonenumber as ButtonOnGetrealtimephonenumber, _ButtonOnErrorEvent as ButtonOnErrorEvent, _ButtonOnError as ButtonOnError, @@ -706,6 +722,10 @@ declare global { * Open-type="getPhoneNumber" 时有效 */ export interface ButtonOnGetphonenumber extends _ButtonOnGetphonenumber {} + export interface ButtonOnGetrealtimephonenumberDetail + extends _ButtonOnGetrealtimephonenumberDetail {} + export type ButtonOnGetrealtimephonenumberEvent = + _ButtonOnGetrealtimephonenumberEvent; /** * 手机号实时验证回调 * diff --git a/packages/uni-app-types/test/form-components/button.test-d.ts b/packages/uni-app-types/test/form-components/button.test-d.ts index 9fa375f..dbd80ee 100644 --- a/packages/uni-app-types/test/form-components/button.test-d.ts +++ b/packages/uni-app-types/test/form-components/button.test-d.ts @@ -19,6 +19,8 @@ import type { ButtonOnGetphonenumberDetail, ButtonOnGetphonenumberEvent, ButtonOnGetrealtimephonenumber, + ButtonOnGetrealtimephonenumberDetail, + ButtonOnGetrealtimephonenumberEvent, ButtonOnLaunchapp, ButtonOnLaunchappEvent, ButtonOnLogin, @@ -61,6 +63,12 @@ describe("Button", () => { expectTypeOf().toBeFunction(); expectTypeOf().toEqualTypeOf(); + expectTypeOf().toBeObject(); + expectTypeOf().toEqualTypeOf(); + + expectTypeOf().toBeObject(); + expectTypeOf().toEqualTypeOf(); + expectTypeOf().toBeFunction(); expectTypeOf().toEqualTypeOf();