This method is used via wx.login(Object object).
Attribute | Type | Default value | Required | Description |
success | function | - | No | Callback Function of Successful Interface Call |
fail | function | - | No | Callback Function of Failing Interface Call |
complete | function | - | No | Callback function executed upon the completion of the interface invocation (both successful and unsuccessful invocations) |
wx.login({success(res) {console.log(res ,"---------------info, host app return");}})
This API is used via wx.checkSession(Object object).
Attribute | Type | Default value | Required | Description |
success | function | - | No | Callback Function of Successful Interface Call |
fail | function | - | No | Callback Function of Failing Interface Call |
complete | function | - | No | Callback function executed upon the completion of the interface invocation (both successful and unsuccessful invocations) |
wx.checkSession({success() {// The session_key has not expired and remains valid throughout its lifecycle.},fail () {// The session_key has become invalid and the login process needs to be executed again.wx.login() // Log in again.}})
This API is used via Object wx.getAccountInfoSync().
Attribute | Type | Description |
miniProgram | Object | Mini program account information. |
Structure attributes | Type | Description |
appId | string | Mini program appId |
envVersion | string | Mini program version, whose valid values are: develop: Development Version trial: Trial Version release: Official Version |
version | string | Online Mini Program Version Number |
This API is used via wx.getUserProfile(Object object).
Attribute | Type | Default value | Required | Description |
lang | string | en | No | The language for displaying user information, whose valid values are: en: English zh_CN: Simplified Chinese zh_TW: Traditional Chinese |
desc | string | - | Yes | Declare the purpose of obtaining user personal information, not exceeding 30 characters. |
success | function | - | No | Callback Function of Successful Interface Call |
fail | function | - | No | Callback Function of Failing Interface Call |
complete | function | - | No | Callback function executed upon the completion of the interface invocation (both successful and unsuccessful invocations) |
This API is used via wx.getUserInfo(Object object).
Attribute | Type | Default value | Required | Description |
lang | string | en | No | The language for displaying user information, whose valid values are: en: English zh_CN: Simplified Chinese zh_TW: Traditional Chinese |
success | function | - | No | Callback Function of Successful Interface Call |
fail | function | - | No | Callback Function of Failing Interface Call |
complete | function | - | No | Callback function executed upon the completion of the interface invocation (both successful and unsuccessful invocations) |
Attribute | Type | Description |
userInfo | UserInfo | User information object |
<!-- If only displaying user avatar and nickname, the <open-data /> component can be used --><open-data type="userAvatarUrl"></open-data><open-data type="userNickName"></open-data><!-- The button must be used for login authorization --><button wx:if="{{canIUse}}" open-type="getUserInfo" bindgetuserinfo="bindGetUserInfo">Login authorization</button><view wx:else>Please upgrade the host client version.</view>
Page({data: {canIUse: wx.canIUse('button.open-type.getUserInfo')},onLoad: function() {// Check if authorization is granted.wx.getSetting({success(res) {if (res.authSetting['scope.userInfo']) {// Authorization has been granted and getUserInfo can be directly invoked to get avatar and nickname.wx.getUserInfo({success: function(res) {console.log(res.userInfo)}})}}})},bindGetUserInfo (e) {console.log(e.detail.userInfo)}})
// Must be invoked under the condition that the user has already granted authorization.wx.getUserInfo({success: function(res) {var userInfo = res.userInfovar nickName = userInfo.nickNamevar avatarUrl = userInfo.avatarUrl}})
Attribute | Type | Description |
nickName | string | User Nickname |
avatarUrl | string | The URL of the user's avatar image. The last digit in the URL represents the size of the square avatar (options include 0, 46, 64, 96, 132; 0 represents a 640x640 square avatar, 46 represents a 46x46 square avatar, and the remaining values follow this pattern. The default selection is 132). This field is empty if the user does not have an avatar. If the user changes their avatar, the original avatar URL will become invalid. |
gender | number | User gender, no longer returned. Valid values are: 0: Unknown 1: Male 2: Female |
country | string | The country where the user is located. No longer returned. |
province | string | The province where the user is located. No longer returned. |
city | string | The city where the user is located. No longer returned. |
language | string | The language used to display country, province, city. "zh_CN" is forcibly returned. Valid values are: en: English zh_CN: Simplified Chinese zh_TW: Traditional Chinese |
Attribute | Description |
boolean scope.userLocation | Whether to authorize geographical location, corresponding to the interface wx.getLocation
Whether to authorize geographical location, corresponding to the interface wx.chooseLocation |
boolean scope.writePhotosAlbum | Whether to authorize saving to the album wx.saveImageToPhotosAlbum |
boolean scope.camera | Whether to authorize the camera, corresponding to the <camera /> component. |
boolean scope.addFriend |
This API is used via wx.getSetting(Object object).
Attribute | Type | Default value | Required | Description |
success | function | - | No | Callback Function of Successful Interface Call |
fail | function | - | No | Callback Function of Failing Interface Call |
complete | function | - | No | Callback function executed upon the completion of the interface invocation (both successful and unsuccessful invocations) |
Attribute | Type | Description |
authSetting | AuthSetting | User Authorization Results |
wx.getSetting({success(res) {console.log(res.authSetting)// res.authSetting = {// "scope.userInfo": true,// "scope.userLocation": true// }}})
This API is used via wx.openSetting(Object object).
Attribute | Type | Default value | Required | Description |
success | function | - | No | Callback Function of Successful Interface Call |
fail | function | - | No | Callback Function of Failing Interface Call |
complete | function | - | No | Callback function executed upon the completion of the interface invocation (both successful and unsuccessful invocations) |
Attribute | Type | Description |
authSetting | AuthSetting | User Authorization Results |
wx.openSetting({success(res) {console.log(res.authSetting)// res.authSetting = {// "scope.userInfo": true,// "scope.userLocation": true// }}})
wx.openSetting({success(res) {console.log(res.authSetting)// res.authSetting = {// "scope.userInfo": true,// "scope.userLocation": true// }}})
This API is used via wx.checkIsSoterEnrolledInDevice(Object object).
Attribute | Type | Default value | Required | Description |
success | function | - | No | Callback Function of Successful Interface Call |
fail | function | - | No | Callback Function of Failing Interface Call |
complete | function | - | No | Callback function executed upon the completion of the interface invocation (both successful and unsuccessful invocations) |
Attribute | Type | Description |
isEnrolled | boolean | Whether information has been entered. |
errMsg | string | Error Message |
wx.checkIsSoterEnrolledInDevice({success(res) {console.log(res.isEnrolled)}})
This method is used via wx.checkIsSupportSoterAuthentication(Object object).
Attribute | Type | Default value | Required | Description |
success | function | - | No | Callback Function of Successful Interface Call |
fail | function | - | No | Callback Function of Failing Interface Call |
complete | function | - | No | Callback function executed upon the completion of the interface invocation (both successful and unsuccessful invocations) |
wx.checkIsSupportSoterAuthentication({success() {// Supports biometric authentication.}})
This method is used via wx.startSoterAuthentication(Object object).
Attribute | Type | Default value | Required | Description |
authContent | string | '' | No | This is the verification description, meaning the dialog box prompt content will be displayed on the interface during the identification process. |
success | function | - | No | Callback Function of Successful Interface Call |
fail | function | - | No | Callback Function of Failing Interface Call |
complete | function | - | No | Callback function executed upon the completion of the interface invocation (both successful and unsuccessful invocations) |
wx.startSoterAuthentication({authContent: 'Unlock via Biometric Authentication',success() {// Authentication successful}})
This API is used via wx.authorize(Object object).
Attribute | Type | Default value | Required | Description |
scope | string | - | Yes | |
success | function | - | No | Callback Function of Successful Interface Call |
fail | function | - | No | Callback Function of Failing Interface Call |
complete | function | - | No | Callback function executed upon the completion of the interface invocation (both successful and unsuccessful invocations) |
// You can first query whether the user has authorized the "scope.record" scope using wx.getSetting.wx.getSetting({success(res) {if (!res.authSetting['scope.record']) {wx.authorize({scope: 'scope.record',success() {// The user has already agreed to the mini program's use of the recording function, so subsequent calls to the wx.startRecord interface will not prompt a pop-up query.wx.startRecord()}})}}})
Was this page helpful?