Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

WeChat small program card coupon


May 18, 2021 WeChat Mini Program Development Document


Table of contents


Vouchers

Description

The small program card interface supports membership cards, tickets, and vouchers (including universal cards) created by appId using the public number in the small program. More ways to use it can be used by referring to the small program and card coupons to get through

Conditions of use

At present, only certification small programs can use the voucher interface, can refer to the guidelines for certification.

Interface

Within the small program, the user can be added a voucher through the wx.addCard interface. Give users the option of an existing voucher through wx.openCard.


Membership card components

Developers can call the interface in a small program to pull up the membership card component, so that users can quickly fill in the membership registration information and receive a card. The interface pulls up the card-opening component without binding the card-opening component and initiating the small program to the same public number in advance, and the developer can call it directly.

The developer must complete the following steps before calling:

  1. Create a WeChat membership card and set it to one-click activation mode;
  2. Set the card opening field;
  3. Get the card opening component parameters;

For more information, please view the introduction of the member card opening component: the member card opening component

Description of the parameters

The name of the argument Type Is it required Description of the parameters
appId String Is Fill in wxeb490c6f9b154ef9, pinned to this appid
extraData Object Is The card opening component parameters, obtained by Step 3, contain the following three parameters
encrypt_card_id String Is Encryption card_id, urldecode is required before it can be passed in
outer_str String Is Membership card to receive channel value, will be in the card collection event back to the merchant
biz String Yes Merchant public account identifies parameters, there must be URLDECode before incoming
success Function no Interface call successful callback function
fail Function Whether The interface calls the failed callback function
complete Function Whether Callback function at end of interface call (call succeeds, fails are executed)

Return parameters

The name of the argument Type Description of the parameters
errMsg String The result of the call

The sample code

wx.navigateToMiniProgram({
  appId: 'wxeb490c6f9b154ef9', //固定为此 appid,不可改动
  extraData: data, // 包括 encrypt_card_id, outer_str, biz三个字段,须从 step3 中获得的链接中获取参数
  success: function() {
  },
  fail: function() {
  },
  complete: function() {
  }
})

The navigateToMiniProgram interface is about to be deobsolete, and the new version uses the navigator component to use this feature

<navigator target="miniProgram" app-id="wxeb490c6f9b154ef9" extra-data="{{data}}">会员卡开卡</navigator>

Return to the description

In App.onShow, determine the data data returned from the member card opening program

  1. Determine whether data.referrerInfo.appId is a card-opening applet app Id wxeb490c6f9b154ef9, or abort judgment if not
  2. Determines whether there is data.referrerInfo.extraData has data, and if not, indicates that the user is not activated to return the direct left slide/point return key, or that the user has been activated
  3. If the user is successfully activated, activate_ticket is available from data.referrerInfo.extraData, card_id code parameter for the next step

Tips:

  1. Calling this API on a developer tool does not actually jump to another gadget, but the developer tool verifies the details of the success of the call jump
  2. The developer tool supports the jumped gadget to handle debugging details of the receive parameters
  3. The card-opening component is an official component developed using wx.navigateToMiniProgram, which can be called directly without having to bind the same public number when jumping