Skip to content

node-weixin/node-weixin-jssdk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

node-weixin-jssdk NPM version Build Status Dependency Status Coverage percentage

JSSDK Functions for weixin

Install

$ npm install --save node-weixin-jssdk

Usage

0.2.3之前的版本使用请见这里

jssdk已经更新,不再需要传入auth模板, 一般建议配合 node-weixin-router使用。 单独使用时可参考router里面的实现 代码示例如下:

var router = require('node-weixin-router');
var settings = require('node-weixin-settings');

module.exports = {
  config: function (req, res) {
    var url = null;
    var keys = ['body', 'query', 'params'];
    //1.获取传入的URL
    for (var i = 0; i < keys.length; i++) {
      var k = keys[i];
      if (req[k] && req[k].url) {
        url = req[k].url;
        break;
      }
    }
    //2.获取ID
    var id = router.getId(req);
    //3.获取app,必须初始化时保存或者已经提前保存到settings里面
    var app = settings.get(id, 'app');
    //4. 初始化jssdk匹配
    weixin.jssdk.prepare(app, url, function() {
    });
  }
};

License

Apache-2.0 © calidion

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published