目录

Interaction

has.showToast

has.showToast(Object object)

Shows the toast.

Since: 1.0.0

Parameters

The input parameter is an object containing the following fields.

Parameter Type Default Value Mandatory Description
title string - Yes Toast content.
duration number 1500 No

Display duration of the toast, in milliseconds.

The default value is 1500 ms. The value range is 1500 ms to 10000 ms. If a value less than 1500 ms is set, the default value is used. If the value greater than 10000 ms is set, the upper limit 10000 ms is used.

success function - No Callback triggered when the API call is successful.
fail function - No Callback triggered when the API call fails.
complete function - No Callback triggered when the API call is complete, regardless of success or failure.

Error code information

Error Code Error Message
102

Parameter error. Possible causes:

1. title is required.

2.check type is invalid.

30000401

showToast error.

For details, see API Call Error Codes.

Example:

has.showToast({
  title: 'loading',
  duration: 5000,
  success: () => {
    console.info('showToast success');
  },
  fail: (err) => {
    console.error('showToast fail', err);
  },
  complete: (res) => {
    console.info('showToast complete', res);
  }
});

has.hideToast

has.hideToast(Object object)

Hides a toast.

Since: 1.0.21

Parameters

The input parameter is an object containing the following fields.

Parameter Type Mandatory Description
success function No Callback triggered when the API call is successful.
fail function No Callback triggered when the API call fails.
complete function No Callback triggered when the API call is complete, regardless of success or failure.

Error code information

Error Code Error Message
30002201

Hide Toast error. Possible causes: HideToast is not supported on this device, 18 and higher sdk is required.

For details, see API Call Error Codes.

Example:

has.hideToast({
  success: () => {
    console.info('hideToast success');
  },
  fail: (err) => {
    console.error('hideToast fail', err);
  },
  complete: (res) => {
    console.info('hideToast complete', res);
  }
});

has.showModal

has.showModal(Object object)

Displays the modal dialog box.

Since: 1.0.0

Parameters

The input parameter is an object containing the following fields.

Parameter Type Default Value Mandatory Description
title string - No Dialog title.
content string - No

Dialog title.

Note: At least one of title and content must be set.

showCancel boolean true No Whether to display the cancel button.
cancelText string Cancel No Text on the cancel button. The value contains up to four characters.
cancelColor string #000000 No Color of the text on the cancel button. The value can be a hexadecimal color string that contains or does not contain transparency information. The format is #RRGGBBAA.
confirmText string Confirm No Text on the confirm button. The value contains up to four characters.
confirmColor string #576B95 No Color of the text on the confirm button. The value can be a hexadecimal color string that contains or does not contain transparency information. The format is #RRGGBBAA.
success function - No Callback triggered when the API call is successful.
fail function - No Callback triggered when the API call fails.
complete function - No Callback triggered when the API call is complete, regardless of success or failure.

Return value of success

Parameter Type Description
confirm boolean The value true indicates that the user taps the confirm button.
cancel boolean The value true indicates that the user taps the cancel button.

Error code information

Error Code Error Message
102

Parameter error. Possible causes:

1.check type is invalid.

2.title and content is required at least one.

3.cancelText is too long.

4.confirmText is too long.

30000301

showToast error.

For details, see API Call Error Codes.

Example:

has.showModal({
  title: 'Dialog title',
  content: 'Dialog content, informing the current status, details, and resolution steps. Keep the description concise, ideally within three lines of text',
  showCancel: false,
  confirmText: 'Confirm'
  success: (res) => {
    console.info('showModal success', res);
  },
  fail: (err) => {
    console.error('showModal fail', err);
  },
  complete: (res) => {
    console.info('showModal complete', res);
  }
});

has.showLoading

has.showLoading(Object object)

Shows the loading dialog box. The dialog box can be closed only after has.hideLoading is called.

Since: 1.0.0

Parameters

The input parameter is an object containing the following fields.

Parameter Type Default Value Mandatory Description
title string - Yes Dialog title.
mask boolean false No Whether to display a transparent overlay to block touch events from passing through the underlying content.
success function - No Callback triggered when the API call is successful.
fail function - No Callback triggered when the API call fails.
complete function - No Callback triggered when the API call is complete, regardless of success or failure.

Error code information

Error Code Error Message
102

Parameter error. Possible causes:

1.title is required.

2.check type is invalid.

30000101

Show loading error.

For details, see API Call Error Codes.

Example:

has.showLoading({
  title: 'Loading'
  success: () => {
    console.info('showLoading success');
  },
  fail: (err) => {
    console.error('showLoading fail', err);
  },
  complete: (res) => {
    console.info('showLoading complete', res);
  }
});

has.hideLoading

has.hideLoading(Object object)

Hides the loading dialog box.

Since: 1.0.0

Parameters

The input parameter is an object containing the following fields.

Parameter Type Mandatory Description
success function No Callback triggered when the API call is successful.
fail function No Callback triggered when the API call fails.
complete function No Callback triggered when the API call is complete, regardless of success or failure.

Error code information

Error Code Error Message
30000201

Hide loading error.

For details, see API Call Error Codes.

Example:

has.hideLoading({
  success: () => {
    console.info('hideLoading success');
  },
  fail: (err) => {
    console.error('hideLoading fail', err);
  },
  complete: (res) => {
    console.info('hideLoading complete', res);
  }
});

has.showActionSheet

has.showActionSheet(Object object)

Shows the operation menu. It is recommended that the number of menu items be greater than or equal to 3. If the number of items is less than 3, use has.showModal.

Since: 1.0.4

Parameters

The input parameter is an object containing the following fields.

Parameter Type Default Value Mandatory Description
itemList Array<string> - Yes Array of the text on the button. The maximum array length is 6.
itemColor string #000000 No Color of the text on the button. The value can be a hexadecimal color string that contains or does not contain transparency information. The format is #RRGGBBAA.
alertText string - No Alert text.
success function - No Callback triggered when the API call is successful.
fail function - No Callback triggered when the API call fails.
complete function - No Callback triggered when the API call is complete, regardless of success or failure.

Return value of success

Parameter Type Description
tapIndex number Zero-based index of a button tapped by the user, ordered from top to bottom.

Error code information

Error Code Error Message
102

Parameter error. Possible causes:

1.itemList is required.

2.check type is invalid.

30001501

showActionSheet error.

For details, see API Call Error Codes.

Example:

has.showActionSheet({
  itemList: ['item1', 'item2', 'item3', 'item4'],
  success: (res) => {
    console.info('showActionSheet success', res);
  },
  fail: (err) => {
    console.error('showActionSheet fail', err);
  },
  complete: (res) => {
    console.info('showActionSheet complete', res);
  }
});