目录

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.

Name

Type

Default Value

Mandatory

Description

title

string

-

Yes

Dialog content.

duration

number

1500

No

Display duration of the toast, in milliseconds.

The value ranges from 1500 to 10000. A value less than 1500 is automatically changed to 1500 (default value), and a value larger than 10000 is automatically changed to 10000.

success

function

-

No

Callback to be invoked when the API call is successful.

fail

function

-

No

Callback to be invoked when the API call fails.

complete

function

-

No

Callback to be invoked when the API call is complete, regardless of success or failure.

Example

has.showToast({
  title: 'loading',
  duration: 5000
});

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.

Name

Type

Default Value

Mandatory

Description

title

string

-

No

Dialog title.

content

string

-

No

Dialog content.

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 must be a hexadecimal color string that does not contain transparency information.

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 must be a hexadecimal color string that does not contain transparency information.

success

function

-

No

Callback to be invoked when the API call is successful.

fail

function

-

No

Callback to be invoked when the API call fails.

complete

function

-

No

Callback to be invoked when the API call is complete, regardless of success or failure.

Return value of success

Name

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.

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'
});

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.

Name

Type

Default Value

Mandatory

Description

title

string

-

Yes

Dialog content.

mask

boolean

false

No

Whether to display a transparent overlay to block touch events from passing through the underlying content.

success

function

-

No

Callback to be invoked when the API call is successful.

fail

function

-

No

Callback to be invoked when the API call fails.

complete

function

-

No

Callback to be invoked when the API call is complete, regardless of success or failure.

Example

has.showLoading({
  title: 'Loading'
});

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.

Name

Type

Mandatory

Description

success

function

No

Callback to be invoked when the API call is successful.

fail

function

No

Callback to be invoked when the API call fails.

complete

function

No

Callback to be invoked when the API call is complete, regardless of success or failure.

Example

has.hideLoading();

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.

Name

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.

alertText

string

-

No

Alert text.

success

function

-

No

Callback to be invoked when the API call is successful.

fail

function

-

No

Callback to be invoked when the API call fails.

complete

function

-

No

Callback to be invoked when the API call is complete, regardless of success or failure.

Return value of success

Name

Type

Description

tapIndex

number

Zero-based index of a button tapped by the user, ordered from top to bottom.

Example

has.showActionSheet({
  itemList: ['item1', 'item2', 'item3', 'item4'],
  success(res) {
    console.log(res.tapIndex);
  }
});