let getopenid = ()=>{ let deferred = think.defer(); pingpp.wxPubOauth.getOpenid(this.setup.wx_AppID, this.setup.wx_AppSecret, code, function(err, openid){ //console.log(openid); deferred.resolve(openid); // ... // pass openid to extra['open_id'] and create a charge // ... }); return deferred.promise; };
async oauthAction(){ //判断是否是微信浏览器 //微信公众账号内自动登陆 let openid = await this.session("wx_openid"); //let openid = null; if(is_weixin(this.userAgent()) && think.isEmpty(openid)){ this.cookie("cmswing_wx_url",this.http.url); var oauthUrl = pingpp.wxPubOauth.createOauthUrlForCode(this.setup.wx_AppID, `http://${this.http.host}/wechat/getopenid?showwxpaytitle=1`); //console.log(oauthUrl) this.redirect(oauthUrl); } }