title: Taro.openCard(option)

sidebar_label: openCard

查看微信卡包中的卡券。只有通过 认证 的小程序或文化互动类目的小游戏才能使用。更多文档请参考 微信卡券接口文档

支持情况:openCard - 图1 openCard - 图2 openCard - 图3

参考文档

类型

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

参数

参数 类型
option Option

Option

参数 类型 必填 说明
cardList RequestInfo[] 需要打开的卡券列表
complete (res: TaroGeneral.CallbackResult) => void 接口调用结束的回调函数(调用成功、失败都会执行)
fail (res: TaroGeneral.CallbackResult) => void 接口调用失败的回调函数
success (res: TaroGeneral.CallbackResult) => void 接口调用成功的回调函数

RequestInfo

需要打开的卡券列表

参数 类型 说明
cardId string 卡券 ID
code string 由 Taro.addCard 的返回对象中的加密 code 通过解密后得到,解密请参照:code 解码接口

示例代码

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