Home > Article > WeChat Applet > How to send multiple service messages in WeChat applet (code)
The content of this article is about how to send multiple service messages (code) in the WeChat applet. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to you.
After reading the service notification push in the official document, the user must manually trigger it to obtain the fromId, and the user can only obtain one fromId by clicking once. So how can it be obtained if the user clicks once? As for multiple fromIds, this problem troubled me for more than 2 hours at that time. By obtaining the fromId clicked by the user and incrementing the fromId, multiple fromIds can be generated, but WeChat cannot recognize it, and it is not feasible to simulate the user's click method. Then again I tried CSS click penetration, but it couldn't be achieved. Then I suddenly wanted to use a stupid method, that is, nest multiple
<view class='dfbg'> <form name='pushMsgFm' report-submit="true" data-type='submit' bindsubmit='formSubmit'> <button class='Gbtn flex f_center' class='btn' formType="submit"> <view class='aa'> <form name='pushMsgFm' report-submit="true" data-type='submit' bindsubmit='formSubmit'> <button class='Gbtn flex f_center' class='btn' formType="submit"> <view class='aa'> <form name='pushMsgFm' report-submit="true" data-type='submit' bindsubmit='formSubmit'> <button class='Gbtn flex f_center' class='btn' formType="submit"> </button> </form> </view> </button> </form> </view> </button> </form> </view>
under a tag. I wrote 3 here, and I want to generate dozens of them. You can nest it yourself.
Please set the nested from and button styles to opacity: 0
That’s it. It’s very simple.
formSubmit:function(e){ let formId = e.detail.formId; console.log(formId); this.collectFormIds(formId); //保存推送码 //let t = e.detail.target.dataset.type; // 根据type执行点击事件 }, collectFormIds:function (formId) { let formIds = app.globalData.globalFormIds; // 获取全局推送码数组 if (!formIds) formIds = []; let data = { formId: formId, expire: new Date().getTime() + 60480000 // 7天后的过期时间戳 } formIds.push(data); app.globalData.globalFormIds = formIds; if (formIds.length==10){ this.takeInfo(); app.globalData.globalFormIds = []; } }
Okay, it’s that simple.
Related recommendations:
How to push messages on Weibo in a timely manner
The above is the detailed content of How to send multiple service messages in WeChat applet (code). For more information, please follow other related articles on the PHP Chinese website!