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.
Type
(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
Taro.openCard({
cardList: [{
cardId: '',
code: ''
}, {
cardId: '',
code: ''
}],
success: function (res) { }
})
API Support
API | WeChat Mini-Program | H5 | React Native |
---|---|---|---|
Taro.openCard | ✔️ |