lrf vor 1 Jahr
Ursprung
Commit
2f84c815f3
1 geänderte Dateien mit 10 neuen und 10 gelöschten Zeilen
  1. 10 10
      app/service/weixin.js

+ 10 - 10
app/service/weixin.js

@@ -18,10 +18,9 @@ class WeixinAuthService extends AxiosService {
     assert(code);
     const { wxapi } = this.app.config;
     const res = await this.httpGet('/api/fetch', { code });
+    console.log(res);
     if (res.errcode && res.errcode !== 0) {
-      this.ctx.logger.error(
-        `[WeixinAuthService] fetch open by code fail, errcode: ${res.errcode}, errmsg: ${res.errmsg}`
-      );
+      this.ctx.logger.error(`[WeixinAuthService] fetch open by code fail, errcode: ${res.errcode}, errmsg: ${res.errmsg}`);
       throw new BusinessError(ErrorCode.SERVICE_FAULT, '获得微信认证信息失败');
     }
     this.ctx.logger.info(`auth=>${JSON.stringify(res)}`);
@@ -34,10 +33,10 @@ class WeixinAuthService extends AxiosService {
     // };
     // const res = await this.httpGet(reqUrl, params);
 
-    if (res.errcode && res.errcode !== 0) {
-      this.ctx.logger.error(`[WeixinAuthService] fetch open by code fail, errcode: ${res.errcode}, errmsg: ${res.errmsg}`);
-      throw new BusinessError(ErrorCode.SERVICE_FAULT, '获得微信认证信息失败');
-    }
+    // if (res.errcode && res.errcode !== 0) {
+    //   this.ctx.logger.error(`[WeixinAuthService] fetch open by code fail, errcode: ${res.errcode}, errmsg: ${res.errmsg}`);
+    //   throw new BusinessError(ErrorCode.SERVICE_FAULT, '获得微信认证信息失败');
+    // }
     // const { openid } = res;
     return res;
   }
@@ -198,7 +197,8 @@ class WeixinAuthService extends AxiosService {
       // 需要回执的时候进行保存处理
       _url = this.ctx.app.config.baseUrl + '/api/train/auth?state=1&redirect_uri=' + this.ctx.app.config.baseUrl + '/classinfo/&type=9&objid=' + tourl + '&msgid=' + res.id;
     }
-    const requestData = { // 发送模板消息的数据
+    const requestData = {
+      // 发送模板消息的数据
       touser: openid,
       template_id: templateid,
       url: _url,
@@ -235,7 +235,8 @@ class WeixinAuthService extends AxiosService {
   async sendTemplateDesign(templateid, openid, first, keyword1, keyword2, remark, tourl) {
     const { wxapi } = this.ctx.app.config;
     const url = wxapi.sendDirMq + wxapi.appid;
-    const requestData = { // 发送模板消息的数据
+    const requestData = {
+      // 发送模板消息的数据
       touser: openid,
       template_id: templateid,
       url: tourl,
@@ -291,6 +292,5 @@ class WeixinAuthService extends AxiosService {
 
     return openid;
   }
-
 }
 module.exports = WeixinAuthService;