微信小程序服务通知模板的实现(微信小程序消息通知)

微信小程序服务通知模板的实现(微信小程序消息通知) 3次播放   00:00

项目经理微信二维码

扫码咨询/索取案例

专注社交新零售系统开发,助力传统企业转型移动互联网!

联系电话:13022089681

微信小程序服务通知模板的实现(微信小程序消息通知)

//pages/index/index.js

Page({

data:{

},

onLoad:function(options){

varthat=this

wx.login({

success:function(data){

console.log(data.code,data)

//获取openid

wx.request({

url:'你的自己的appid&secret=你自己的session_key&js_code='+data.code,

header:{"Content-Type":"application/x-"},

method:"post",

success:function(res){

console.log(res,"opind")

that.setData({

openid:res.data.openid,

session_key:res.data.session_key,

})

}

})

}

})

//获取access_token

wx.request({

url:'你的自己的appid&secret=你自己的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,

})

}

})

},

//点击执行方法

form:function(e){

varthat=this;

varfId=e.detail.formId;

//网络请求

varl=''+that.data.access_token;

//需要传的参数

vard={

touser:that.data.openid,//用户的openid

template_id:'XX1hceIwI1XiQaUc5Z4qIrZnYQkYEHElSq5m6yIa0M8',//这个是申请的模板消息id,位置在微信公众平台/模板消息中添加并获取

page:'/pages/index/index',//点击通知跳转的页面

form_id:fId,//表单提交场景下,为submit事件带上的formId

//此处必须为data,只有人说value也可以,可能官方已经修复这个bug

data:{

"keyword1":{

"value":"酒店",

"color":"#4a4a4a"

},

"keyword2":{

"value":"2018-03-22",

"color":"#9b9b9b",

},

"keyword3":{

"value":"$300",

"color":"#9b9b9b"

},

"keyword4":{

"value":"中国",

"color":"#9b9b9b"

},

},

color:'#ccc',

emphasis_keyword:'keyword1.DATA'

}

wx.request({

url:l,

data:d,

method:'POST',//此处不能有请求头

success:function(res){

console.log(res,"pushmsg");

},

fail:function(err){

console.log(err,"pusherr");

}

});

},

})

大家都在看

波浪线

发表评论

波浪线

您必须 登录 才能发表评论!

评论 (0)

波浪线
还没有评论,发表第一个评论吧
您好,我是您的专属产品顾问
扫码添加我的微信,免费体验系统
(工作日09:00 - 18:00)
业务咨询
系统演示
行业方案
客户案例

请按ESC键关闭