Small micro-channel interaction with the user program

Small micro-channel interaction with the user program

A display message box

wx.showToast ({name attributes: Attribute Value})

自定义一个提示框,时间到了会自动关闭

wx.showToast({

    title:"成功",  //必填

    icon: 'success',//图标只支持"success"、"loading" 

    image: '/images/tan.png',//自定义图标的本地路径,image 的优先级高于 icon

    duration: 2000,//提示的延迟时间,单位毫秒,默认:1500 

    mask: false,//是否显示透明蒙层,防止触摸穿透,默认:false 

    success:function(){}, //接口调用成功的回调函数

    fail:function(){}, //接口调用失败的回调函数

    complete:function(){} //接口调用结束的回调函数(调用成功、失败都会执行)

})

wx.showLoading ({name attributes: Attribute Value})

显示Loading提示框,不会自动关闭,需主动调用 wx.hideLoading 才能关闭提示框

wx.showLoading({
  title: '加载中',
})
setTimeout(function () {
  wx.hideLoading()
}, 2000)
Attributes Types of Defaults Mandatory Explanation
title string Yes Tip the contents
mask boolean false no Whether to show transparency mask layer to prevent penetration of touch
success function no Interface call success callback function
fail function no Interface calls the failure callback function
complete function no Interface calls the end of the callback function (call succeeds, the failure will be executed)

wx.hideLoading ({name attributes: Attribute Value})

隐藏 loading 提示框

Attributes Types of Defaults Mandatory Explanation
success function no Interface call success callback function
fail function no Interface calls the failure callback function
complete function no Interface calls the end of the callback function (call succeeds, the failure will be executed)

II. Similarly the html confirm

wx.showModal ({name attributes: Attribute Value})

wx.showModal({
  title: '提示',
  content: '这是一个模态弹窗',
  success (res) {
    if (res.confirm) {
      console.log('用户点击确定')
    } else if (res.cancel) {
      console.log('用户点击取消')
    }
  }
})
Attributes Types of Defaults Mandatory Explanation
title string no Tip title
content string no Tip the contents
showCancel boolean true no Whether to display the Cancel button
cancelText string 'cancel' no Text Cancel button, a maximum of four characters
cancelColor string #000000 no Cancel button text color, the color must be a string of hexadecimal format
confirmText string 'determine' no Text confirmation button, and a maximum of four characters
confirmColor string # 576B95 no Confirm the text color of the button, the color must be a string of hexadecimal format
success function no Interface call success callback function
fail function no Interface calls the failure callback function
complete function no Interface calls the end of the callback function (call succeeds, the failure will be executed)

object.success callback function

Object res

Attributes Types of Explanation Minimum version
confirm boolean When true, indicates that the user clicked the OK button
cancel boolean When true, indicates that the user clicked Cancel (Click for Android system to distinguish between Mongolia layer off or click the Cancel button to close) 1.1.0

III. Display Operation menu

wx.showActionSheet ({name attributes: Attribute Value})

wx.showActionSheet({
  itemList: ['A', 'B', 'C'],
  success (res) {
    console.log(res.tapIndex)
  },
  fail (res) {
    console.log(res.errMsg)
  }
})
Attributes Types of Defaults Mandatory Explanation
itemList Array. Yes Text button array, the maximum array length of 6
itemColor string #000000 no Button text color
success function no Interface call success callback function
fail function no Interface calls the failure callback function
complete function no Interface calls the end of the callback function (call succeeds, the failure will be executed)

object.success callback function

parameter

Object res

Attributes Types of Explanation
tapIndex number The user clicks the button number, top to bottom, starting from 0

note

  • When Android 6.7.2 or lower, or click Cancel layer mask, the callback fail, errMsg as "fail cancel";
  • Android 6.7.2 or later and iOS click on the layer mask does not close the modal pop, so try to avoid using the "Cancel" branch business logic

Guess you like

Origin www.cnblogs.com/pythonywy/p/11589922.html