Skip to main content
Version: 3.x

Taro.openCard(option)

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

(option: Option) => Promise<CallbackResult>

Parameters

Option

PropertyTypeRequiredDescription
cardListRequestInfo[]YesThe list of cards and offers to be opened
complete(res: any) => voidNoThe callback function used when the API call completed (always executed whether the call succeeds or fails)
fail(res: any) => voidNoThe callback function for a failed API call
success(res: Result) => voidNoThe callback function for a successful API call

RequestInfo

object.cardList is composed as follows

PropertyTypeDescription
cardIdstringThe ID of the card or offer
codestringIt is obtained after the encrypted code in the objects returned by Taro.addCard is decrypted. For details, see Code Decryption API

Sample Code

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

API Support

APIWeChat Mini-ProgramH5React Native
Taro.openCard✔️