# wx.addCard(Object object)
Start from base library version 1.1.0. Please remaining backward compatible.
with Promise style call: Supported
Mini Program plugin: Not supported
Add coupons in bulk. Only through Authentication Mini Programs or cultural interaction category of small games to use. For more documentation please refer to WeChat card voucher interface document。
# parameter
# Object object
attribute | type | Default values | Required | Introductions |
---|---|---|---|---|
cardList | Array.<Object> | yes | List of cards and vouchers to add | |
success | function | no | Interface calls the successful callback function | |
fail | function | no | Interface calls failed callback functions | |
complete | function | no | Interface calls the end of the callback function (call success or failure will be executed) |
object.cardList Structure
attribute | type | Default values | Required | Introductions |
---|---|---|---|---|
cardId | string | yes | Card coupon ID | |
cardExt | string | yes | Extended parameters of the coupon. Will need to CardExt object JSON Serialized asCharacter stringto import |
# object.success callback
# parameter
# Object res
attribute | type | Introductions |
---|---|---|
cardList | Array.<Object> | Card coupon add result list |
res.cardList Structure
attribute | type | Introductions |
---|---|---|
code | string | encryption Code, for the user to receive the card coupon code encrypted string, decryption please refer to:code Decode interface |
cardId | string | The user receives the card voucher ID |
cardExt | string | Card coupon extension parameters, structure please refer to the following |
isSuccess | boolean | Successful |
# cardExt Introductions
cardExt Is an extended parameter for the card coupon whose value is a JSON String.
# sample code
wx.addCard({
cardList: [
{
cardId: '',
cardExt: '{"code": "", "openid": "", "timestamp": "", "signature":""}'
}, {
cardId: '',
cardExt: '{"code": "", "openid": "", "timestamp": "", "signature":""}'
}
],
success (res) {
console.log(res.cardList) // Card coupons add results
}
})