The introduction

After finally jumping out of the pit of adding card coupons (see the last wechat small program to add card coupons to jump pit), Party A’s father said, this is not what they want (what?? What about just getting a card? What they want is to get a membership card in the mini program, but also allow users to activate to fill in information. All right, you’re the dad.

demand

To realize the function of the user to activate the membership card and fill in the information after the small program clicks to get the membership card, the process is as follows.

The body of the

Although this function is not mentioned in the wechat applet document, it is introduced by checking the official document and getting through the card – applet.

Wechat provides a card opening component, so we just need to jump to the official card opening mini program.

wx.navigateToMiniProgram({
    appId: ‘wxeb490c6f9b154ef9’, // Fix this appID, immutable
    extraData: data, // there are three fields including encrypt_card_id outer_str biz, and the parameters must be obtained from the link obtained in step3
    success: function() {},fail: function() {},complete: function() {}})Copy the code

Yo ho, this look very simple ah, is not the jump between small programs. Wait, what data does extraData want to transmit? You know what?

Of course, the interface description in the documentation also explains how to obtain these card opening parameters.

The introduction of the documentation is also relatively clear, so I won’t repeat it here. Through this step, We can get the following URL https://mp.weixin.qq.com/bizmall/activatemembercard?action=preshow&&encrypt_card_id=xxx&&outer_str=xxx&biz=xxx&#wechat_r edirect

Encrypt_card_id outer_str biz And then the above url to do urldecode processing, get these three parameters, intact fill in the data inside, you can ~

Another thing to note is that the document states that the applet appID for opening the card must be ‘wxeb490c6f9b154EF9’. This applet is not our own, so it needs to be bound

After this step, you can successfully jump to the card opening component

When the user jumps back to our own mini program after the jump operation, he can judge the data returned from the member card opening mini program in app. onShow

1. Determine whether data.referrerinfo. appId is a small program appId for opening a card'wxeb490c6f9b154ef9', if not suspend judgment 2. Determine whether there is data. ReferrerInfo. ExtraData data, if not, the user is not activated directly left slide/return key to return to, or the user has to activate 3. If the user can activate success, from the data. The referrerInfo. ExtraData derive activate_ticket card_id code parameters used for the next stepsCopy the code

After this step, the plan was killed again, as expected, or the father of the party A will not let us down.