Skip to content

Basics

env

pz.env

Environmental variables

attribute

string USER_DATA_PATH

User directory path in file system (Local path)

base64ToArrayBuffer

ArrayBuffer pz.base64ToArrayBuffer(string base64)

will Base64 String ArrayBuffer object

parameter

string base64

To translate into ArrayBuffer Object Base64 Character string

Return value

ArrayBuffer

ArrayBuffer object

sample code

javascript
const base64 = 'CxYh'
const arrayBuffer = pz.base64ToArrayBuffer(base64)

arrayBufferToBase64

string pz.arrayBufferToBase64(ArrayBuffer arrayBuffer)

will ArrayBuffer Object conversion Base64 Character string

parameter

ArrayBuffer arrayBuffer

To convert Base64 String ArrayBuffer object

Return value

string

Base64 Character string

sample code

javascript
const arrayBuffer = new Uint8Array([11, 22, 33])
const base64 = pz.arrayBufferToBase64(arrayBuffer)

base64ToTempFilePath

Basic library 1.3.9 is supported, iOS version 2.1.23, Android version 2.1.38

base64ToTempFilePath(Object object)

Save the base64 data of the image to the local sandbox and return the local cache path.

PropertyTypeThe default value isRequiredDescription
xnumber0NoThe upper-left abscissa of the area to be cropped is
ynumber0NoThe upper-left ordinate of the area to be cropped is
widthnumberCanvas width - xNoThe width of the area to be cropped
heightnumberCanvas height -yNoThe height of the area to be cropped is
destWidthnumberwidth x screen pixel densityNoThe width of the output picture is
destHeightnumberheight x screen pixel densityNoThe height of the output picture is
base64DatastringYesThe image is converted into a base64 type string
successfunctionNoThe interface calls the callback function
failfunctionNoInterface call failed callback function
completefunctionNoThe callback function at the end of the interface call (the call succeeds or fails to execute

object.success callback function

Parameter

Object res

PropertyTypeDescription
tempFilePathstringThe local address of the picture

fileToBase64

fileToBase64(Object object)

will file converted to Base64 Character string

Parameter

Object res

PropertyTypeDescription
urlstringFile address

Return value

string

Base64 String

System

getSystemInfoSync

Supported since base library 1.3.9, iOS version 2.1.23, Android version 2.1.38

getSystemInfoSync()

The synchronous version of pz.getSystemInfo

getSystemInfoAsync

pz.getSystemInfoAsync(Object object)

Get system information asynchronously. Need some Phiz client version support, in the unsupported client, will use synchronization to return.

parameter

Object object

attributetypeDefault valuesRequiredIntroductions
successfunctionnoInterface calls the successful callback function
failfunctionnoInterface calls failed callback functions
completefunctionnoCallback function at the end of an interface call (both successful and unsuccessful calls are executed)

object.success callback

parameter

Object res

attributetypeIntroductionsMinimum version
brandstringEquipment brand1.5.0
modelstringDevice model. New models will show unknown for a while, Phiz will adapt as soon as possible.
pixelRationumberDevice pixel ratio
screenWidthnumberScreen width, in px1.1.0
screenHeightnumberScreen height, in px1.1.0
windowWidthnumberAvailable window width, unit px
windowHeightnumberAvailable window height, in px
statusBarHeightnumberHeight of status bar in px1.9.0
languagestringLanguage of Phiz settings
versionstringPhiz version number
systemstringOperating System and Version
platformstringClient platform
fontSizeSettingnumberUser font size in px. Phiz ClientI - Settings - Universal - Font SizeThe settings in1.5.0
SDKVersionstringClient base library version1.1.0
benchmarkLevelnumberEquipment Performance Level (only Android)。 Values are: -2 or 0 (the device cannot run games), -1 (performance unknown),>= 1 (Device Performance Value, higher the value, better device performance, currently up to less than 50)1.8.0
albumAuthorizedbooleanAllow Phiz to use the Photo Album switch (only iOS Effective)2.6.0
cameraAuthorizedbooleanSwitch that allows Phiz to use the camera2.6.0
locationAuthorizedbooleanAllow Phiz to use location switch2.6.0
microphoneAuthorizedbooleanSwitch allowing Phiz to use microphone2.6.0
notificationAuthorizedbooleanSwitch that allows Phiz notifications2.6.0
notificationAlertAuthorizedbooleanAllow Phiz to notify switches with reminders (only iOS Effective)2.6.0
notificationBadgeAuthorizedbooleanAllow Phiz notifications with marked switches (only iOS Effective)2.6.0
notificationSoundAuthorizedbooleanAllow Phiz to notify switches with sound (only iOS Effective)2.6.0
bluetoothEnabledbooleanBluetooth System Switch2.6.0
locationEnabledbooleanGeographic Location System Switch2.6.0
wifiEnabledbooleanWi-Fi System switch2.6.0
safeAreaObjectA safe area in the positive direction of the vertical screen2.7.0
locationReducedAccuracybooleantrue Represents fuzzy positioning,false For precise positioning, only iOS Support
themestringSystem current theme, with a value oflightordark, global configuration'darkmode': trueCan be obtained when otherwise undefined (Small games not supported)2.11.0
enableDebugbooleanWhether debugging is turned on. Available from the top right menu or pz.setEnableDebug Turn on debugging.2.15.0
bundleIdstringThe bundleId of the host app2.15.0
deviceOrientationstringEquipment direction

safeArea Structure

attributetypeIntroductions
leftnumberUpper left abscissa of security area
rightnumberSecurity area lower right abscissa
topnumberTop-left ordinate of security area
bottomnumberLower right ordinate of security area
widthnumberWidth of security area, unit logical pixels
heightnumberHeight of Safe Area, Unit Logical Pixels

theme Legal value

valueIntroductionsMinimum version
darkDark theme
lightLight color theme

host Structure

attributetypeIntroductions
appIdstringhost app Corresponding appId

deviceOrientation Legal value

valueIntroductionsMinimum version
portraitVertical screen
landscapeHorizontal screen

sample code

Preview with Developer Tool

js
pz.getSystemInfoAsync({
  success (res) {
    console.log(res.model)
    console.log(res.pixelRatio)
    console.log(res.windowWidth)
    console.log(res.windowHeight)
    console.log(res.language)
    console.log(res.version)
    console.log(res.platform)
  }
})

getSystemInfo

Supported since base library 1.3.9, iOS version 2.1.23, Android version 2.1.38

getSystemInfo(Object object)

Gets system information.

Parameters

Object object

PropertyTypeDefaultRequiredDescription
successfunctionNoThe callback function for a successful API call
failfunctionNoThe callback function for a failed API call
completefunctionNoThe callback function used when the API call completed (always executed whether the call succeeds or fails)

object.success callback functionParameters

Object res

PropertyTypeDescription
SDKVersionstringBase library version for the Phiz app
runtimeSDKVersionstringApplet SDK version number
brandstringDevice brand
modelstringDevice model
pixelRationumberDevice's pixel ratio
screenWidthnumberScreen width in px
screenHeightnumberScreen height in px
windowWidthnumberAvailable window width in px
windowHeightnumberAvailable window height in px
statusBarHeightnumberStatus bar height in px
languagestringLanguage set in Phiz
versionstringPhiz version
bundleIdstringThe bundleId of the host application
systemstringOperating system and version
platformstringClient platform
inFinChatbooleanIs it in the finchat applet environment
deviceIdstringEquipment identification

Sample Code

javascript
 pz.getSystemInfo({
  success(res) {
    console.log(res.model)
    console.log(res.pixelRatio)
    console.log(res.windowWidth)
    console.log(res.windowHeight)
    console.log(res.language)
    console.log(res.version)
    console.log(res.platform)
  }
})

Updates

getUpdateManager

Supported since base library 1.5.30, iOS version 2.5.6, Android version 2.8.76

ObtainGlobally uniqueThe version update manager for managing phizclip updates. Update on the phizclip mechanism, you can seeOperation mechanismDocumentation.

UpdateManager method

UpdateManager.applyUpdate() Force the phizclip to restart and use the new version. After the new version of the phizclip has been downloaded (i.e. received onUpdateReady Callback) call.

UpdateManager.onCheckForUpdate(function callback) Monitor the Phiz background request to check the update results event. Phiz automatically checks updates when the phizclip is cold started, without the developer taking the initiative to trigger.

UpdateManager.onUpdateReady(function callback) Listening phizclip has a version update event. Active client trigger download (no developer trigger), download success callback

UpdateManager.onUpdateFailed(function callback) Listen for phizclip to update failed events. phizclip has a new version, the client active trigger download (without developer trigger), download failure (may be network reasons, etc.) after the callback

sample code

javascript
const updateManager = pz.getUpdateManager()

updateManager.onCheckForUpdate(function (res) {
  // Callback after requesting new version information
  console.log(res.hasUpdate)
})

updateManager.onUpdateReady(function () {
  pz.showModal({
    title: 'Update tip ',
    content: 'The new version is ready, reboot the app? ' '
    success: function (res) {
      if (res.confirm) {
        // The new version has been downloaded and calls applyUpdate Apply a new version and restart
        updateManager.applyUpdate()
      }
    }
  })
})

updateManager.onUpdateFailed(function () {
  // New version download failed
})

phizclip

getLaunchOptionsSync

Object pz.getLaunchOptionsSync() Gets the parameters for startup of the phizclip. and App.onLaunch The callback parameters of

Return value

Object

Starting parameter

attributetypeIntroductions
pathstringPath to start phizclip (Code packet path)

| query | Object | Start the phizclip query parameter |

| referrerInfo | Object | Source information. From another little program, Official Account message template or App Returns when entering the phizclip. Otherwise return {}。(See below for attention) |

referrerInfo Structure

attributetypeIntroductions
appIdstringThe appId of phizclip
extraDataObjectSource phizclip passed data

getEnterOptionsSync

Object pz.getEnterOptionsSync()

Gets the parameters of this phizclip when it starts. If the current is a cold start, the return value is identical to the App.onLaunch Consistent with the callback parametersIf this is a hot start, the return value is identical to the App.onShow Consistent

Return value

Object

Starting parameter

attributetypeIntroductions
pathstringPath to start phizclip (Code packet path)

| query | Object | Start the phizclip query parameter |

| referrerInfo | Object | Source information. From another little program, Official Account message template or App Returns when entering the phizclip. Otherwise return {}。(See below for attention) |

referrerInfo Structure

attributetypeIntroductions
appIdstringThe appId of phizclip
extraDataObjectSource phizclip passed data

onPageNotFound

pz.onPageNotFound(function callback)

There are no events on the page that the listening phizclip wants to open. This event is related to App.onPageNotFound The timing of the pullback was consistent

parameter

function callback

The callback function for the page that the phizclip opens does not exist

parameter

Object res

attributetypeIntroductions
pathstringNo path to the page (Code packet path)
queryObjectOpen a page that does not exist query parameter
isEntryPagebooleanIs the first page of this launch (for example, from the Share entrance, the first is the developer configuration share page)

Be careful

  • Developers can do page redirection in callbacks, but only in callbacksynchronizationProcessing, asynchronous processing such as setTimeout Asynchronous execution) is invalid.
  • If the developer does not call pz.onPageNotFound Binding listening, no declaration App.onPageNotFound, When the jump page does not exist, will push the Phiz client native page there is no prompt page.
  • If the callback is redirected to another page that does not exist, the original page of Phiz client will be pushed into the page that is not there and there will be no second callback.

onError

pz.onError(function callback)

Listens for phizclip error events. Such as a script error or API Call error, etc. This event is related to App.onError The callback timing of the.

parameter

function callback

Callback function for phizclip error event

parameter

string error

Error message, including stack

onAppShow

pz.onAppShow(function callback)

Listen to the phizclip cut foreground events. This event is related to App.onShow The callback parameters of

parameter

function callback

Callback Function for phizclip to Cut Foreground Events

parameter

Object res

attributetypeIntroductions
pathstringphizclip cut the foreground path (Code packet path)
queryObjectphizclip cut the front desk query parameter
referrerInfoObjectSource information. From another little program, Official Account message template or App Returns when entering the phizclip. Otherwise return {}。(See below for attention)

referrerInfo Structure

attributetypeIntroductions
appIdstringThe appId of phizclip
extraDataObjectSource phizclip passed data

Be careful

Partial Version NoreferrerInfoWill return when undefinedRecommended for use options.referrerInfo && options.referrerInfo.appId To judge.

onAppHide

pz.onAppHide(function callback)

Listen to the phizclip cut background events. This event is related to App.onHide The timing of the pullback was consistent.

parameter

function callback

Callback Function for Background Events

offPageNotFound

pz.offPageNotFound(function callback)

The page to be opened by the unlisten phizclip does not have an event

parameter

function callback

The callback function for the page that the phizclip opens does not exist

offError

pz.offError(function callback)

Cancels listening for phizclip error events

parameter

function callback

Callback function for phizclip error event

offAppShow

pz.offAppShow(function callback)

Cancel the monitor phizclip to cut the foreground event

parameter

function callback

Callback Function for phizclip to Cut Foreground Events

offAppHide

pz.offAppHide(function callback)

Cancel listening phizclip to cut background event

parameter

function callback

Callback Function for Background Events

onThemeChange

pz.onThemeChange(function callback)

Listen for system topic change events

parameter

function callback

Callback function for the system topic change event

onUnhandledRejection

pz.onUnhandledRejection(function callback)

Listen for unprocessed Promise rejection events

parameter

function callback

Callback function for an unhandled Promise rejection event

offUnhandledRejection

pz.offUnhandledRejection(function callback)

Cancel listening for unprocessed Promise rejection events

parameter

function callback

onUnhandledRejection Incoming callback function. If this argument is not passed, all listening functions are removed.

offThemeChange

pz.offThemeChange(function callback)

Cancels listening for system topic change events

parameter

function callback

onThemeChange The callback function passed in. If this parameter is not passed, all listener functions are removed.

debugging

setEnableDebug

pz.setEnableDebug(Object object)

Sets whether the debug switch is turned on. This switch also works for the official version

parameter

Object object

attributetypeDefault valuesRequiredIntroductions
enableDebugbooleanyesTurn on debugging
successfunctionnoInterface calls the successful callback function
failfunctionnoInterface calls failed callback functions
completefunctionnoCallback function at the end of an interface call (both successful and unsuccessful calls are executed)

sample code

javascript
// Turn on debugging
pz.setEnableDebug({
  enableDebug: true
})

// Close debugging
pz.setEnableDebug({
  enableDebug: false
})

Tips

  • In the official version to open debugging there is a way that is first in the development version or the experience version of the open debugging, and then cut to the formal version can see vConsole.

console

Prints logs to the debugging console. The "console" is a global object and can be accessed directly. In the Phiz app, logs are output to vConsole.

console.debug()

Prints the "debug" log to the debugging panel.

console.error()

Prints the "error" log to the debugging panel.

console.group()

Creates a new group in the debugging panel.

console.groupEnd()

Ends a group created by console.group.

console.info()

Prints the "info" log to the debugging panel.

console.log()

Prints the "log" log to the debugging panel.

console.warn()

Prints the "warn" log to the debugging panel.

LogManager

Log manager instance

LogManager.debug()

write debug journal

LogManager.info()

write info journal

LogManager.log()

write log journal

LogManager.warn()

write warn journal

RealtimeLogManager

Real - time log manager instance

RealtimeLogManager.info()

write info Logging is not supported in plugins

RealtimeLogManager.warn()

write warn Logging is not supported in plugins

RealtimeLogManager.error()

write error Logging is not supported in plugins

RealtimeLogManager.setFilterMsg(string msg)

Set filter keywords, temporarily do not support the use of

RealtimeLogManager.addFilterMsg(string msg)

Add filter keywords, temporarily not supported in plugin use

Account information

getAccountInfoSync

Gets the current account information. Online phizclip version number is only available in the official version of the phizclip, development version and experience version can not be obtained

Return value

Object object

attributetypeDefault valuesRequiredIntroductions
miniProgramObjectyesphizclip account information

Object miniProgram

attributetypeIntroductions
appIdstringphizclip appId
envVersionstringphizclip version