title: Taro.openCard(option)

sidebar_label: openCard

Views cards and offers in WeChat Cards & Offers. It can be used only in Mini Programs or cultural interaction Mini Games that complete verification. For more documents, see API Documentation for WeChat Cards & Offers.

Reference

Type

  1. (option: Option) => Promise<CallbackResult>

Parameters

Option

Property Type Required Description
cardList RequestInfo[] Yes The list of cards and offers to be opened
complete (res: any) => void No The callback function used when the API call completed (always executed whether the call succeeds or fails)
fail (res: any) => void No The callback function for a failed API call
success (res: Result) => void No The callback function for a successful API call

RequestInfo

object.cardList is composed as follows

Property Type Description
cardId string The ID of the card or offer
code string It is obtained after the encrypted code in the objects returned by Taro.addCard is decrypted. For details, see Code Decryption API

Sample Code

  1. Taro.openCard({
  2. cardList: [{
  3. cardId: '',
  4. code: ''
  5. }, {
  6. cardId: '',
  7. code: ''
  8. }],
  9. success: function (res) { }
  10. })

API Support

API WeChat Mini-Program H5 React Native
Taro.openCard ✔️