In the current version of the applet does not support the function of sending red envelopes, developers are grinning, the heart of MOM sell batch! here, provide a solution that has been practiced.
Detailed analysis, is the following several steps
1, the first is in the small program inside the collar red envelope entrance
2, click to jump WebView, with the current small program token to webview authentication, WebView SRC point to a service number with the ability to obtain the OpenID page, according to the additional token to determine whether the user can receive red envelopes, At this time the user has two OpenID, one is relative to the small program OpenID, one is relative to the service number used to send red envelopes OpenID, such as the following pseudo-code
Pseudo code weixinApi.angerPay.sendRedPacket ({ total_num:1, mch_billno: ' 1000000 ', send_name: ' Test title ', re_openid: ' Xaxadsadas ',//acquired OpenID total_amount:100, wishing: ' Congratulations on fortune, Prosperity ', act_name: ' Sweep code collar red Envelopes ', Remark: ' Memo info ', client_ip: ' 127.0.0.1 ', scene_id: ' Product_2 ' }, (err, result) = { Console.log (err, result) });
3. Return to Collection results
Precautions
1, jump to the WebView src to add to the applet business domain name
2, the link must be the HTTPS protocol
The future of the interface
In the near future, will open a red envelope interface, is wx.sendbizredpacket, usage examples.
Wx.sendbizredpacket ({timestamp:e.timestamp, noncestr:e.noncestr, Package:e.package, Signtype:e.signtype, Paysign:e.paysign, Success:function (res) {Console.log ( ' Red envelope success ') let url = config. Http_prize_url + '/v1/sign_tmp/sendsuccess.do '; Let data = {minipid:that.data.minipid, date:that.data.date} console.log (' The number of interface request parameters after the red packet succeeded According to: ' + json.stringify (data) ') util.request (URL, ' post ', data, ' Loading Date ', function (res) {Console.log (' Red envelope after success The interface returns the result: ' + json.stringify (res.data)}) ' Wx.relaunch ({url: ') '. /my_prize/my_prize_2?reward= ' + Res.data.body.reward,})}, Fail:function (res) {Console.log (' red envelope Fail ')}, Complete:function (res) {Console.log (' Red envelope complete ')//Wx.showmodal ({//title : ' Red envelope complete ',//content: ' Red envelope complete ',//}}})