# Mini-Program Information Management

This module primarily provides API introductions for obtaining Mini-Program information.

# 1. Get Mini-Program Object Information

# 1.1 Get Running Mini-Program Object Information

Get the object information of the currently running Mini-Program. If no Mini-Program is in memory, returns void.

/**
 * Get Mini-Program information
 * @param appId Mini-Program ID
 * @param apiServer API server address
 * @param appRunId Mini-Program run ID, defaults to empty string
 */

getAppletInfo(appId: string, apiServer?: string, appRunId: string = ''): IFinApplet.IAppletInfo | void

Example code:

const appletInfo = client.getAppletInfo('appid')

# 1.2 Get Mini-Program Local Information

Get Mini-Program information. Searches for Mini-Program object information from the local disk. Returns null if it still does not exist.

/**
 * Get Mini-Program local information
 * @param appId Mini-Program ID
 * @param apiServer API server address
 * @param appletType Mini-Program type
 */
async getAppletLocalInfo(appId: string, apiServer: string, appletType: EAppletType): Promise<IFinApplet.IFinAppResult<IFinApplet.IAppletInfo>>;

Example code:

const appletInfo = await client.getAppletLocalInfo('appid','apiServer',EAppletType.release)

# 2. Get Bound Mini-Program Object Information

Get the list of bound Mini-Programs under a specific apiServer. Can be filtered by Mini-Program classification, status, whether disabled, and pagination parameters.

/**
 * Get the list of bound Mini-Programs.
 * @param fetchBindAppletRequest Request parameters for the bound Mini-Program list.
 * @returns List of bound Mini-Programs or error information.
 */
async getBindApplets(fetchBindAppletRequest: IFinApplet.IFetchBindAppletRequest):
  Promise<IFinApplet.IFinAppResult<IFinApplet.IFetchBindAppletResponse | undefined>>

IFinApplet.IFetchBindAppletRequest Description:

Property Type Required Description
apiServer string Yes Server address.
appClass string No Mini-Program type, defaults to empty string ''.
appStatus IFinApplet.AppletStatus No Mini-Program status, defaults to IFinApplet.AppletStatus.LISTED.
isForbidden boolean No Whether the query result is for disabled Mini-Programs, defaults to false.
pageNo number No Page number, defaults to 1.
pageSize number No Number of items per page, defaults to 20.

IFinApplet.IFetchBindAppletResponse Description:

Property Type Required Description
items IFinApplet.IFetchBindAppletInfo[] Yes List of Mini-Programs.
total number Yes Total count.

IFinApplet.IFetchBindAppletInfo Description:

Property Type Required Description
miniAppId string Yes Mini-Program ID.
name string Yes Mini-Program name.
appClass string Yes Mini-Program type.
displayStatus IFinApplet.AppletStatus Yes Display status.
desc string Yes Mini-Program description.
detailDesc string Yes Mini-Program detailed description.
logo string Yes Mini-Program icon.
isForbidden boolean Yes Whether disabled.
apiServer string Yes Server address.

IFinApplet.AppletStatus Description:

Enum Value Description
ALL All.
LISTED Listed.
UNLISTED Unlisted.
DELISTED Delisted.

Example code:

const res = await client.getBindApplets({
  apiServer: 'apiServer',
  appClass: 'Finance',
  appStatus: IFinApplet.AppletStatus.LISTED,
  isForbidden: false,
  pageNo: 1,
  pageSize: 20
})

# 3. Get Mini-Program Page Screenshot

# 3.1 Get Screenshot of Specified Mini-Program

 /**
   * Get a screenshot of the specified Mini-Program, including native elements like the navigation bar and tabBar. Can only capture within the visible area.
   * @param appId - The ID of the Mini-Program.
   * @param apiServer - The API server associated with the Mini-Program.
   * @param appRunId - The Mini-Program run ID.
   * @returns Image information containing the screenshot or an error result.
   */
async captureAppletPicture(appId: string, apiServer?: string,appRunId?: string): Promise<IFinApplet.IFinAppResult<image.PixelMap>> 

Example code:

Some code omitted

@Component
struct Page {
  @State appletImage: image.PixelMap | null = null

  async captureAppletPicture() {
    const result = await client.captureAppletPicture('appid', 'apiServer')
    this.appletImage = result.data ?? null
  }

  build(){
    Image(this.appletImage)
  }
}

# 3.2 Get Screenshot of Specified Mini-Program (Supports Long Screenshot)

/**
 * Get a screenshot of the specified Mini-Program, excluding native elements like the navigation bar and tabBar. Can control capturing outside the visible area via parameters.
 * @param appId - The ID of the Mini-Program.
 * @param snapShotWholePage - Whether to capture the entire Mini-Program page (including outside the visible area).
 * @param apiServer - The API server associated with the Mini-Program.
 * @param appRunId - The Mini-Program run ID.
 * @returns Image information containing the screenshot or an error result.
 */
async captureAppletPictureV2(appId: string, snapShotWholePage: boolean, apiServer?: string,appRunId?: string): Promise<IFinApplet.IFinAppResult<image.PixelMap>> 

Example code:

Some code omitted

@Component
struct Page {
  @State appletImage: image.PixelMap | null = null

  async captureAppletPicture() {
    const result = await client.captureAppletPictureV2('appid', true, 'apiServer')
    this.appletImage = result.data ?? null
  }

  build(){
    Image(this.appletImage)
  }
}

# 4. Search Mini-Programs

To search for Mini-Programs, two steps are required:

  1. Ensure that the server information is configured when initializing the SDK;
  2. Call the search interface to search for Mini-Programs.
 /**
   * Search Mini-Programs
   * @param apiServer - The API server to search.
   * @param searchText - Search content
   * @param pageNo - Page number
   * @param pageSize - Page size
   * @returns Result of searching Mini-Programs
   */
  async searchApplets(apiServer: string, searchText: string, pageNo: number, pageSize: number): Promise<IFinApplet.IFinAppResult<IFinOpenAPI.ISearchAppletsRes | undefined>>
/**
 * Entity class returned by searching Mini-Programs
 *
 * @param list Collection of searched Mini-Programs
 * @param total Number of searched Mini-Programs
 */
interface ISearchAppletsRes {
  list?: ISearchAppletInfo[]
  total: number
}

/**
 * Mini-Program information entity class returned by searching Mini-Programs
 *
 * @param appId Mini-Program ID
 * @param appName Mini-Program name
 * @param desc Mini-Program description information
 * @param highLights Highlighted text
 * @param logo Mini-Program logo
 * @param organName Enterprise name
 * @param pageUrl Page path found for the Mini-Program
 * @param showText Display content
 */
interface ISearchAppletInfo {
    appId?: string
    appName?: string
    desc?: string
    highLights?: IHighLight[]
    logo?: string
    organName?: string
    pageUrl?: string
    showText?: string
  }

/**
 * Highlighted text
 *
 * @param key Key of the highlighted text
 * @param value Value of the highlighted text
 */
interface IHighLight {
  key?: string,
  value?: string
}

Example code:

Some code omitted

const searchRes = await client.searchApplets('apiServer', 'Tools', 1, 10)

# 5. Get List of Favorite Mini-Programs

/**
   * Get the list of favorite Mini-Programs
   * @param apiServer - The API server to search.
   * @param pageNo - Page number (pass 0 to get all favorite Mini-Programs)
   * @param pageSize - Page size (pass 0 to get all favorite Mini-Programs)
   * @returns Result of getting the Mini-Program favorites list
   */
  public async getFavoriteApplets(apiServer: string, pageNo: number, pageSize: number): Promise<IFinApplet.IFinAppResult<IFinOpenAPI.IFavoriteApplets | undefined>>
interface IFavoriteApplets {
  /** List of favorite Mini-Programs */
  list?: IFavoriteAppletsItem[]
  /** Total number of favorites */
  total: number
  /** Server address */
  apiServer: string
}

interface IFavoriteAppletsItem {
  /** Mini-Program ID */
  appId?: string
  /** Mini-Program name */
  name?: string
  /** Current user ID */
  currentUserId?: string
  /** Mini-Program icon */
  logo?: string
  createTime?: number
  /** Encrypted user ID */
  encryptedUserId?: string
}

Example code:

Some code omitted

const res = await client.getFavoriteApplets(this.apiServer, 1, 10)
© FinClip with ❤ , Since 2017