In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces "how to realize the WeChat Mini Programs service notification function". In the daily operation, I believe many people have doubts about how to realize the WeChat Mini Programs service notification function. The editor consulted all kinds of materials and sorted out the simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts about "how to realize the WeChat Mini Programs service notification function". Next, please follow the editor to study!
The following goes directly to the code:
Wxml:
Submit
Js:
/ / pages/index/index.js
Page ({
Data: {
}
/ *
Wechat public platform tests connection to https://mp.weixin.qq.com/debug/
Global error code description: https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1433747234
, /
OnLoad: function (options) {
Var that = this
Wx.login ({
Success: function (data) {
Console.log (data.code, data)
/ / obtain openid
Wx.request ({
Url: 'https://api.weixin.qq.com/sns/jscode2session?appid= your own appid&secret=, your own session_key&js_code=' + data.code
Header: {"Content-Type": "application/x-www-form-urlencoded"}
Method: "post"
Success: function (res) {
Console.log (res, "opind")
That.setData ({
Openid: res.data.openid
Session_key: res.data.session_key
})
}
})
}
})
/ / obtain access_token
Wx.request ({
Url: 'https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid= your own appid&secret=, your own session_key'
Method: "GET"
Success: function (res) {
Console.log (res, "res")
Console.log (res.data.access_token, "access_token")
That.setData ({
Access_token: res.data.access_token
})
}
})
}
/ / Click the execution method
Form: function (e) {
Var that = this
Var fId = e.detail.formId
/ / Network request
Var l = 'https://api.weixin.qq.com/cgi-bin/message/wxopen/template/send?access_token=' + that.data.access_token
/ / parameters to be passed
Var d = {
Touser: that.data.openid, / / user's openid
Template_id: 'XX1hceIwI1XiQaUc5Z4qIrZnYQkYEHElSq5m6yIa0M8',// this is the template message id for the application. The location is added and obtained in the Wechat public platform / template message.
Page:'/ pages/index/index', / / Click the page to notify the jump
Form_id: formId for submit event in the scenario of fId, / / form submission
/ / this must be data. Only people can say that value is OK. The bug may have been repaired by the authorities.
Data: {
"keyword1": {
"value": "Hotel
"color": "# 4a4a4a"
}
"keyword2": {
"value": "2018-03-22"
"color": "# 9b9b9b"
}
"keyword3": {
"value": "$300"
"color": "# 9b9b9b"
}
"keyword4": {
"value": "China"
"color": "# 9b9b9b"
}
}
Color:'# ccc'
Emphasis_keyword: 'keyword1.DATA'
}
Wx.request ({
Url: l
Data: d
Method: 'POST', / / No request headers are allowed here
Success: function (res) {
Console.log (res, "push msg")
}
Fail: function (err) {
Console.log (err, "push err")
}
});
}
})
Finally, click submit to initiate the request. Here you can only debug the phone. The formId I printed out with the development tool: "the formId is a mock one" is not a number string. Real machine testing is required to succeed here
At this point, the study on "how to realize the WeChat Mini Programs service notification function" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.