WeChat Open Platform

Mini Programs Documentation

Cards

wx.addCard(OBJECT)

Bulk adds cards.

Object parameter descriptions:

Parameter Type Required Description
cardList ObjectArray Yes List of cards that need to be added
success Function No Callback function for successful interface call
fail Function No Callback function for failed interface call
complete Function No Callback function for interface call results (will be executed if call succeeds or fails)

For more information, please see the WeChat Card Interface Document

Tip

  1. Only certified Mini Programs are currently able to use the card interface, you can refer to the guide to carry out certification.

Callback results:

Callback type errMsg Description
success addCard:ok Card added successfully
fail addCard:fail cancel User canceled adding card
fail addCard:fail (detail message) Failed to add card, wherein detail message is the detailed failure reason returned by the backend

success return parameters:

Parameter Type Description
cardList ObjectArray Add card result

Sample code:

wx.addCard({
  cardList: [
    {
      cardId: '',
      cardExt: '{"code": "", "openid": "", "timestamp": "", "signature":""}'
    }, {
      cardId: '',
      cardExt: '{"code": "", "openid": "", "timestamp": "", "signature":""}'
    }
  ],
  success: function(res) {
    console.log(res.cardList) // Add card result
  }
})

wx.openCard(OBJECT)

View the cards in the WeChat card package.

Object parameter descriptions:

Parameter Type Required Description
cardList ObjectArray Yes List of cards that need to be opened
success Function No Callback function for successful interface call
fail Function No Callback function for failed interface call
complete Function No Callback function for interface call results (will be executed if call succeeds or fails)

For more information, please see the WeChat Card Interface Document

Sample code:

wx.openCard({
  cardList: [
    {
      cardId: '',
      code: ''
    }, {
      cardId: '',
      code: ''
    }
  ],
  success: function(res) {
  }
})