This API is called using wx.login(Object object).
Property | Type | Default value | Required | Description |
success | function | - | False | Callback function for successful API calls. |
fail | function | - | False | Callback function for failed API calls. |
complete | function | - | False | Callback function executed after API call ends (regardless of success or failure). |
wx.login({success(res) {console.log(res ,"---------------info, host app return");}})
This API is called using wx.checkSession(Object object).
Property | Type | Default value | Required | Description |
success | function | - | False | Callback function for successful API calls. |
fail | function | - | False | Callback function for failed API calls. |
complete | function | - | False | Callback function executed after API call ends (regardless of success or failure). |
wx.checkSession({success () {// The session_key has not expired and remains valid for this lifecycle.},fail () {// The session_key has expired, and the login process needs to be executed again.wx.login() // Log in again.}})
This API is called using Object wx.getAccountInfoSync().
Property | Type | Description |
miniProgram | Object | Mini game account information. |
Structural property | Type | Description |
appId | string | Mini game appId. |
envVersion | string | Mini game version. Valid values: develop: The development version trial: The Preview release: The released version |
version | string | Online mini game version number. |
This API is called using wx.getUserInfo(Object object).
Property | Type | Default value | Required | Description |
lang | string | en | False | The language used to display the user information. Valid values: en: English zh_CN: Simplified Chinese zh_TW: Traditional Chinese |
success | function | - | False | Callback function for successful API calls. |
fail | function | - | False | Callback function for failed API calls. |
complete | function | - | False | Callback function executed after API call ends (regardless of success or failure). |
Property | Type | Description |
userInfo | UserInfo | User information object. |
// Must be called when the user has already authorized.wx.getUserInfo({success: function(res) {var userInfo = res.userInfovar nickName = userInfo.nickNamevar avatarUrl = userInfo.avatarUrl}})
Property | Type | Description |
nickName | string | User’s nickname. |
avatarUrl | string | The URL of the user's profile photo. The last number in the URL represents the size of the square profile photo (options are 0, 46, 64, 96, 132; 0 represents a 640x640 square profile photo, 46 represents a 46x46 square profile photo, and so on. The default value is 132.) This field is left blank if the user has no profile photo. If the user changes the profile photo, the original profile photo URL will become invalid. |
gender | number | User's gender. No longer returned. Valid values are: 0: Unknown 1: Male 2: Female |
country | string | The user’s country. No longer returned. |
province | string | The user's province. No longer returned. |
city | string | The user's city. No longer returned. |
language | string | The language used to display the country, province, and city. Always returns "zh_CN". Valid values: en: English zh_CN: Simplified Chinese zh_TW: Traditional Chinese |
Property | Description |
boolean scope.userInfo | Whether the user has authorized access to their information. Corresponds to wx.getUserInfo. |
boolean scope.writePhotosAlbum | Whether the user has authorized saving images to their photo album. Corresponds to wx.saveImageToPhotosAlbum. |
boolean scope.userLocation | Whether the user has authorized access to their precise location. Corresponds to wx.getLocation. |
boolean scope.userFuzzyLocation | Whether the user has authorized access to their approximate location. Corresponds to wx.getFuzzyLocation. |
This API is called using wx.getSetting(Object object).
Property | Type | Default value | Required | Description |
success | function | - | False | Callback function for successful API calls. |
fail | function | - | False | Callback function for failed API calls. |
complete | function | - | False | Callback function executed after API call ends (regardless of success or failure). |
Property | Type | Description |
authSetting | User authorization result. |
wx.getSetting({success(res) {console.log(res.authSetting)// res.authSetting = {// "scope.userInfo": true,// "scope.userLocation": true// }}})
This API is called using wx.openSetting(Object object).
Property | Type | Default value | Required | Description |
success | function | - | False | Callback function for successful API calls. |
fail | function | - | False | Callback function for failed API calls. |
complete | function | - | False | Callback function executed after API call ends (regardless of success or failure). |
Property | Type | Description |
authSetting | AuthSetting | User authorization result. |
wx.openSetting({success(res) {console.log(res.authSetting)// res.authSetting = {// "scope.userInfo": true,// "scope.userLocation": true// }}})
This API is called using wx.authorize(Object object).
Property | Type | Default value | Required | Description |
scope | string | - | True | |
success | function | - | False | Callback function for successful API calls. |
fail | function | - | False | Callback function for failed API calls. |
complete | function | - | False | Callback function executed after API call ends (regardless of success or failure). |
// You can query whether the user has authorized the scope of "scope.userLocation" using wx.getSetting.wx.getSetting({success(res) {if (!res.authSetting['scope.userLocation']) {wx.authorize({scope: 'scope.userLocation',success() {wx.getLocation()}})}}})
This API is called using wx.requirePrivacyAuthorize(Object object).
Property | Type | Default value | Required | Description |
success | function | - | False | Callback function for successful API calls. |
fail | function | - | False | Callback function for failed API calls. |
complete | function | - | False | Callback function executed after API call ends (regardless of success or failure). |
wx.requirePrivacyAuthorize({success: () => {// The user agrees to the authorization.// runGame () Continue the game logic.},fail: () => {}, // The user desagrees to the authorization.complete: () => {}})
This API is called using wx.onNeedPrivacyAuthorization(function listener).
Property | Type | Description |
referrer | string | The name of the API or component that triggered this onNeedPrivacyAuthorization event (e.g. “getUserInfo”). |
Property | Type | Description |
event | string | The type of user operation. |
event | Description |
exposureAuthorization | Exposure of custom privacy pop-up window. |
agree | User agrees to privacy authorization. |
disagree | The user denies the privacy authorization. |
wx.onNeedPrivacyAuthorization((resolve, eventInfo) => {console.log('The API that triggered this event is ' + eventInfo.referrer)// ------ Custom pop-up logic ------ //showCustomPopup()// -------After the pop-up window appears, the following logical is implemented based on user operations After the popup, handle user actions ------- //// Developer displays the custom privacy popup and calls resolve to notify the platform that the popup has been shown.resolve({ event: 'exposureAuthorization' })// After the user taps Agree, the developer calls resolve to inform the platform about the user’s authorization.resolve({ event: 'agree' })// After the user taps Disagree the developer calls resolve to inform the platform that the user has denied the authorization.resolve({ event: 'disagree' })})