'use strict' module.exports = { checkSignature:function(){ let signature = this.GET['signature'], timestamp = this.GET['timestamp'], nonce = this.GET['nonce'], echostr = this.GET['echostr']; if(signature && timestamp && nonce && echostr){ if(Wechat.checkSignature(signature,timestamp,nonce)){ this.end(echostr); return; } } this.end('Error'); }, getAccessToken:function(){ Wechat.getAccessToken.call(this,function(err,accessToken){ this.end(accessToken); }); }, getSignature:function(){ if(!this.GET['url'] || !this.GET['url'].match(/(https?):\/\/[-A-Za-z0-9+&@#\/%?=~_|!:,.;]+[-A-Za-z0-9+&@#/%=~_|]/gi)) return this.endAPI(-1,'Please send a current url address'); Wechat.getSignature.call(this,this.GET['url'],function(err,signatureObj){ if(err) return this.endAPI(-1,'getSignature error!'); signatureObj.appId = Config.Wechat.appId; this.endAPI(0,signatureObj); }); }, getCode2Session:function(){ if(!this.GET['code']) return this.endAPI(-1,'JsCode Can Be Empty'); Wechat.getCode2Session.call(this,this.GET['code'],function(err,body){ if(err) return this.endAPI(-1,'getCode2Session error!'); this.endAPI(0,body); }); } }