GithubHelp home page GithubHelp logo

wxmsg-tpl's Introduction

fork wxmsg-tpl

微信模版消息,微信jssdk

*****增加getAccessToken函数。提供给api server直接调用 package.json的写法: "wxmsg-tpl": "https://github.com/pailjin/wxmsg-tpl.git",

1 、微信模版消息发送,公众号必须为认证的服务号,开通模版消息流程如下:

(1)、设置模版标题和模版内容,模版内容类型如下格式:
{{result.DATA}}\n\n领奖金额:{{withdrawMoney.DATA}}\n领奖  时间:{{withdrawTime.DATA}}\n银行信息:{{cardInfo.DATA}}\n到账时间:  {{arrivedTime.DATA}}\n{{remark.DATA}}

2 、发送消息:

var WxMsgTpl = require("wxmsg-tpl");
var opt = {
    access_token: "access_token"
};
var msgTpl = new WxMsgTpl(opt);
var body = {
       "touser":"OPENID",
       "template_id":"ngqIpbwh8bUfcSsECmogfXcV14J0tQlEpBO27izEYtY",
       "url":"http://weixin.qq.com/download",            
       "data":{
               "first": {
                   "value":"恭喜你购买成功!",
                   "color":"#173177"
               },
               "keynote1":{
                   "value":"巧克力",
                   "color":"#173177"
               },
               "keynote2": {
                   "value":"39.8元",
                   "color":"#173177"
               },
               "keynote3": {
                   "value":"2014年9月22日",
                   "color":"#173177"
               },
               "remark":{
                   "value":"欢迎再次购买!",
                   "color":"#173177"
               }
       }
   }
msgTpl.sendMessage(body).then(function(data){
    console.log(data);
});

wxmsg-tpl's People

Contributors

yxz1025 avatar pailjin avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.