lrf402788946 4 년 전
부모
커밋
ed67f81e9c
2개의 변경된 파일4개의 추가작업 그리고 0개의 파일을 삭제
  1. 1 0
      app/controller/weixin.js
  2. 3 0
      app/service/weixin.js

+ 1 - 0
app/controller/weixin.js

@@ -203,6 +203,7 @@ class WeixinController extends Controller {
   // GET 签到小程序请求用户
   // GET 签到小程序请求用户
   async appAuth() {
   async appAuth() {
     const { js_code, login = true } = this.ctx.query;
     const { js_code, login = true } = this.ctx.query;
+    console.warn(`js_code=>${js_code}`);
     const appopenid = await this.ctx.service.weixin.appAuth(js_code);
     const appopenid = await this.ctx.service.weixin.appAuth(js_code);
     if (!login) this.ctx.ok(appopenid);
     if (!login) this.ctx.ok(appopenid);
     const res = await this.findByAppOpenid(appopenid);
     const res = await this.findByAppOpenid(appopenid);

+ 3 - 0
app/service/weixin.js

@@ -288,12 +288,15 @@ class WeixinAuthService extends AxiosService {
       query = `${query}&${key}=${wxapp[key]}`;
       query = `${query}&${key}=${wxapp[key]}`;
     }
     }
     url = `${url}${query}`;
     url = `${url}${query}`;
+    console.warn(`url=>${url}`);
     const res = await this.ctx.curl(url, {
     const res = await this.ctx.curl(url, {
       method: 'get',
       method: 'get',
       headers: {
       headers: {
         'content-type': 'application/json',
         'content-type': 'application/json',
       },
       },
     });
     });
+    console.warn('res=>');
+    console.warn(res);
     const { openid } = res.data;
     const { openid } = res.data;
     if (!openid) throw new BusinessError(ErrorCode.BUSINESS, '未获取到openid', '未获取到openid');
     if (!openid) throw new BusinessError(ErrorCode.BUSINESS, '未获取到openid', '未获取到openid');
     return openid;
     return openid;