Skip to content

Commit 20bfd32

Browse files
ZaneL1uChen-jj
andauthored
feat(weapp): 增加open-type获取头像昵称 (#11402)
* feat(weapp): 增加open-type获取头像昵称 * fix: 完善注释及ts声明 * chore: 更正描述 * test: 更新快照 * chore: fix ci Co-authored-by: ezreeeeal <zhenze@leju.com> Co-authored-by: chenjiajian <798095202@qq.com>
1 parent a5c5c58 commit 20bfd32

21 files changed

+45
-0
lines changed

packages/taro-components-rn/src/components/Button/index.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
* - show-message-card
2121
* - bindcontact
2222
* - bindgetphonenumber
23+
* - bindchooseavatar
2324
* - app-parameter
2425
* - binderror
2526
* - bindopensetting

packages/taro-components/types/Button.d.ts

+16
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,13 @@ interface ButtonProps extends StandardProps {
168168
*/
169169
onGetPhoneNumber?: CommonEventFunction<ButtonProps.onGetPhoneNumberEventDetail>
170170

171+
/** 获取头像信息
172+
*
173+
* 生效时机:`open-type="chooseavatar"`
174+
* @supported weapp
175+
*/
176+
onChooseAvatar?: CommonEventFunction<ButtonProps.onChooseAvatarEventDetail>
177+
171178
/** 获取用户实名
172179
*
173180
* 生效时机:`open-type="getRealnameAuthInfo"`
@@ -238,6 +245,10 @@ declare namespace ButtonProps {
238245
* @see https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/getPhoneNumber.html
239246
*/
240247
getPhoneNumber
248+
/** 获取用户头像,可以从 bindchooseavatar 回调中获取到头像信息
249+
* @see https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/userProfile.html
250+
*/
251+
chooseAvatar
241252
/** 获取用户信息,可以从 bindgetuserinfo 回调中获取到用户信息 */
242253
getUserInfo
243254
/** 用户实名信息授权,已经弃用 */
@@ -363,6 +374,11 @@ declare namespace ButtonProps {
363374
iv: string
364375
}
365376

377+
interface onChooseAvatarEventDetail {
378+
/* 获取用户头像的临时链接 */
379+
avatarUrl: string
380+
}
381+
366382
interface onOpenSettingEventDetail {
367383
/* 打开授权设置页的调用状态 */
368384
errMsg: string

packages/taro-mini-runner/src/__tests__/__snapshots__/babel.spec.ts.snap

+1
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ require(\\"./taro\\");
9191
bindGetUserInfo: _empty,
9292
bindContact: _empty,
9393
bindGetPhoneNumber: _empty,
94+
bindChooseAvatar: _empty,
9495
bindError: _empty,
9596
bindOpenSetting: _empty,
9697
bindLaunchApp: _empty

packages/taro-mini-runner/src/__tests__/__snapshots__/common-style.spec.ts.snap

+1
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ require(\\"./taro\\");
9191
bindGetUserInfo: _empty,
9292
bindContact: _empty,
9393
bindGetPhoneNumber: _empty,
94+
bindChooseAvatar: _empty,
9495
bindError: _empty,
9596
bindOpenSetting: _empty,
9697
bindLaunchApp: _empty

packages/taro-mini-runner/src/__tests__/__snapshots__/compiler-macros.spec.ts.snap

+1
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ require(\\"./taro\\");
9191
bindGetUserInfo: _empty,
9292
bindContact: _empty,
9393
bindGetPhoneNumber: _empty,
94+
bindChooseAvatar: _empty,
9495
bindError: _empty,
9596
bindOpenSetting: _empty,
9697
bindLaunchApp: _empty

packages/taro-mini-runner/src/__tests__/__snapshots__/config.spec.ts.snap

+3
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ require(\\"./taro\\");
9191
bindGetUserInfo: _empty,
9292
bindContact: _empty,
9393
bindGetPhoneNumber: _empty,
94+
bindChooseAvatar: _empty,
9495
bindError: _empty,
9596
bindOpenSetting: _empty,
9697
bindLaunchApp: _empty
@@ -2406,6 +2407,7 @@ require(\\"./taro\\");
24062407
bindGetUserInfo: _empty,
24072408
bindContact: _empty,
24082409
bindGetPhoneNumber: _empty,
2410+
bindChooseAvatar: _empty,
24092411
bindError: _empty,
24102412
bindOpenSetting: _empty,
24112413
bindLaunchApp: _empty
@@ -4659,6 +4661,7 @@ require(\\"./taro\\");
46594661
bindGetUserInfo: _empty,
46604662
bindContact: _empty,
46614663
bindGetPhoneNumber: _empty,
4664+
bindChooseAvatar: _empty,
46624665
bindError: _empty,
46634666
bindOpenSetting: _empty,
46644667
bindLaunchApp: _empty

packages/taro-mini-runner/src/__tests__/__snapshots__/css-modules.spec.ts.snap

+2
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ require(\\"./taro\\");
9191
bindGetUserInfo: _empty,
9292
bindContact: _empty,
9393
bindGetPhoneNumber: _empty,
94+
bindChooseAvatar: _empty,
9495
bindError: _empty,
9596
bindOpenSetting: _empty,
9697
bindLaunchApp: _empty
@@ -2248,6 +2249,7 @@ require(\\"./taro\\");
22482249
bindGetUserInfo: _empty,
22492250
bindContact: _empty,
22502251
bindGetPhoneNumber: _empty,
2252+
bindChooseAvatar: _empty,
22512253
bindError: _empty,
22522254
bindOpenSetting: _empty,
22532255
bindLaunchApp: _empty

packages/taro-mini-runner/src/__tests__/__snapshots__/custom-tabbar.spec.ts.snap

+1
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ require(\\"./taro\\");
8585
bindGetUserInfo: _empty,
8686
bindContact: _empty,
8787
bindGetPhoneNumber: _empty,
88+
bindChooseAvatar: _empty,
8889
bindError: _empty,
8990
bindOpenSetting: _empty,
9091
bindLaunchApp: _empty

packages/taro-mini-runner/src/__tests__/__snapshots__/parse-html.spec.ts.snap

+1
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ require(\\"./taro\\");
9191
bindGetUserInfo: _empty,
9292
bindContact: _empty,
9393
bindGetPhoneNumber: _empty,
94+
bindChooseAvatar: _empty,
9495
bindError: _empty,
9596
bindOpenSetting: _empty,
9697
bindLaunchApp: _empty

packages/taro-mini-runner/src/__tests__/__snapshots__/prerender.spec.ts.snap

+3
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ require(\\"./taro\\");
9191
bindGetUserInfo: _empty,
9292
bindContact: _empty,
9393
bindGetPhoneNumber: _empty,
94+
bindChooseAvatar: _empty,
9495
bindError: _empty,
9596
bindOpenSetting: _empty,
9697
bindLaunchApp: _empty
@@ -3598,6 +3599,7 @@ require(\\"./taro\\");
35983599
bindGetUserInfo: _empty,
35993600
bindContact: _empty,
36003601
bindGetPhoneNumber: _empty,
3602+
bindChooseAvatar: _empty,
36013603
bindError: _empty,
36023604
bindOpenSetting: _empty,
36033605
bindLaunchApp: _empty
@@ -7105,6 +7107,7 @@ require(\\"./taro\\");
71057107
bindGetUserInfo: _empty,
71067108
bindContact: _empty,
71077109
bindGetPhoneNumber: _empty,
7110+
bindChooseAvatar: _empty,
71087111
bindError: _empty,
71097112
bindOpenSetting: _empty,
71107113
bindLaunchApp: _empty

packages/taro-mini-runner/src/__tests__/__snapshots__/qq.spec.ts.snap

+2
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ require(\\"./taro\\");
118118
bindGetUserInfo: _empty,
119119
bindContact: _empty,
120120
bindGetPhoneNumber: _empty,
121+
bindChooseAvatar: _empty,
121122
bindError: _empty,
122123
bindOpenSetting: _empty,
123124
bindLaunchApp: _empty
@@ -2582,6 +2583,7 @@ require(\\"./taro\\");
25822583
bindGetUserInfo: _empty,
25832584
bindContact: _empty,
25842585
bindGetPhoneNumber: _empty,
2586+
bindChooseAvatar: _empty,
25852587
bindError: _empty,
25862588
bindOpenSetting: _empty,
25872589
bindLaunchApp: _empty

packages/taro-mini-runner/src/__tests__/__snapshots__/react.spec.ts.snap

+1
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ require(\\"./taro\\");
9191
bindGetUserInfo: _empty,
9292
bindContact: _empty,
9393
bindGetPhoneNumber: _empty,
94+
bindChooseAvatar: _empty,
9495
bindError: _empty,
9596
bindOpenSetting: _empty,
9697
bindLaunchApp: _empty

packages/taro-mini-runner/src/__tests__/__snapshots__/sass.spec.ts.snap

+4
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ require(\\"./taro\\");
9191
bindGetUserInfo: _empty,
9292
bindContact: _empty,
9393
bindGetPhoneNumber: _empty,
94+
bindChooseAvatar: _empty,
9495
bindError: _empty,
9596
bindOpenSetting: _empty,
9697
bindLaunchApp: _empty
@@ -2231,6 +2232,7 @@ require(\\"./taro\\");
22312232
bindGetUserInfo: _empty,
22322233
bindContact: _empty,
22332234
bindGetPhoneNumber: _empty,
2235+
bindChooseAvatar: _empty,
22342236
bindError: _empty,
22352237
bindOpenSetting: _empty,
22362238
bindLaunchApp: _empty
@@ -4371,6 +4373,7 @@ require(\\"./taro\\");
43714373
bindGetUserInfo: _empty,
43724374
bindContact: _empty,
43734375
bindGetPhoneNumber: _empty,
4376+
bindChooseAvatar: _empty,
43744377
bindError: _empty,
43754378
bindOpenSetting: _empty,
43764379
bindLaunchApp: _empty
@@ -6511,6 +6514,7 @@ require(\\"./taro\\");
65116514
bindGetUserInfo: _empty,
65126515
bindContact: _empty,
65136516
bindGetPhoneNumber: _empty,
6517+
bindChooseAvatar: _empty,
65146518
bindError: _empty,
65156519
bindOpenSetting: _empty,
65166520
bindLaunchApp: _empty

packages/taro-mini-runner/src/__tests__/__snapshots__/subpackages.spec.ts.snap

+1
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ require(\\"./taro\\");
8585
bindGetUserInfo: _empty,
8686
bindContact: _empty,
8787
bindGetPhoneNumber: _empty,
88+
bindChooseAvatar: _empty,
8889
bindError: _empty,
8990
bindOpenSetting: _empty,
9091
bindLaunchApp: _empty

packages/taro-mini-runner/src/__tests__/__snapshots__/tabbar.spec.ts.snap

+1
Original file line numberDiff line numberDiff line change
@@ -1785,6 +1785,7 @@ require(\\"./taro\\");
17851785
bindGetUserInfo: _empty,
17861786
bindContact: _empty,
17871787
bindGetPhoneNumber: _empty,
1788+
bindChooseAvatar: _empty,
17881789
bindError: _empty,
17891790
bindOpenSetting: _empty,
17901791
bindLaunchApp: _empty

packages/taro-mini-runner/src/__tests__/__snapshots__/ts.spec.ts.snap

+1
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ require(\\"./taro\\");
9191
bindGetUserInfo: _empty,
9292
bindContact: _empty,
9393
bindGetPhoneNumber: _empty,
94+
bindChooseAvatar: _empty,
9495
bindError: _empty,
9596
bindOpenSetting: _empty,
9697
bindLaunchApp: _empty

packages/taro-mini-runner/src/__tests__/__snapshots__/vue.spec.ts.snap

+1
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ require(\\"./taro\\");
8787
bindGetUserInfo: _empty,
8888
bindContact: _empty,
8989
bindGetPhoneNumber: _empty,
90+
bindChooseAvatar: _empty,
9091
bindError: _empty,
9192
bindOpenSetting: _empty,
9293
bindLaunchApp: _empty

packages/taro-mini-runner/src/__tests__/__snapshots__/vue3.spec.ts.snap

+1
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ require(\\"./taro\\");
8989
bindGetUserInfo: _empty,
9090
bindContact: _empty,
9191
bindGetPhoneNumber: _empty,
92+
bindChooseAvatar: _empty,
9293
bindError: _empty,
9394
bindOpenSetting: _empty,
9495
bindLaunchApp: _empty

packages/taro-mini-runner/src/__tests__/__snapshots__/wx-hybrid.spec.ts.snap

+1
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ require(\\"./taro\\");
8585
bindGetUserInfo: _empty,
8686
bindContact: _empty,
8787
bindGetPhoneNumber: _empty,
88+
bindChooseAvatar: _empty,
8889
bindError: _empty,
8990
bindOpenSetting: _empty,
9091
bindLaunchApp: _empty

packages/taro-weapp/src/components.ts

+1
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ export const components = {
5050
bindGetUserInfo: _empty,
5151
bindContact: _empty,
5252
bindGetPhoneNumber: _empty,
53+
bindChooseAvatar: _empty,
5354
bindError: _empty,
5455
bindOpenSetting: _empty,
5556
bindLaunchApp: _empty

packages/taroize/src/events.ts

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
export const specialEvents = new Map<string, string>()
22
specialEvents.set('bindtimeupdate', 'onTimeUpdate')
33
specialEvents.set('bindgetphoneNumber', 'onGetPhoneNumber')
4+
specialEvents.set('bindchooseavatar', 'onChooseAvatar')
45
specialEvents.set('bindgetrealnameauthinfo', 'onGetRealnameAuthInfo')
56
specialEvents.set('bindopensetting', 'onOpenSetting')
67
specialEvents.set('bindscancode', 'onScanCode')

0 commit comments

Comments
 (0)