瀏覽代碼

微信扫码登录统一配置

laiguoran 4 年之前
父節點
當前提交
217633afa0
共有 4 個文件被更改,包括 17 次插入1 次删除
  1. 2 1
      app/controller/login_controller.js
  2. 5 0
      config/config.default.js
  3. 5 0
      config/config.local.js
  4. 5 0
      config/config.uat.js

+ 2 - 1
app/controller/login_controller.js

@@ -26,6 +26,7 @@ module.exports = app => {
                 ctx.redirect('/wap');
                 return;
             }
+
             const errorMessage = ctx.session.loginError;
             // 显示完删除
             ctx.session.loginError = null;
@@ -53,7 +54,7 @@ module.exports = app => {
         async wxAuth(ctx) {
             const code = ctx.query.code;
             try {
-                const client = new OAuth('wx5320cd30cecdbd68', 'ca7c0dbd9e94dc3b1c3b0e73865743f4');
+                const client = new OAuth(ctx.app.config.wxCode.appid, ctx.app.config.wxCode.appsecret);
                 const token = await client.getAccessToken(code);
                 // const user = await client.getUser(token.data.openid);
                 // console.log(user);

+ 5 - 0
config/config.default.js

@@ -188,6 +188,11 @@ module.exports = appInfo => {
             payment: false, // enable or disable co-wechat-payment
         },
     };
+    // wx扫码登录
+    config.wxCode = {
+        appid: 'wx5320cd30cecdbd68',
+        appsecret: 'ca7c0dbd9e94dc3b1c3b0e73865743f4',
+    };
 
     config.proxy = true;
 

+ 5 - 0
config/config.local.js

@@ -83,6 +83,11 @@ module.exports = appInfo => {
         consoleLevel: 'WARN',
         disableConsoleAfterReady: false,
     };
+    // wx扫码登录
+    config.wxCode = {
+        appid: 'wx5320cd30cecdbd68',
+        appsecret: 'ca7c0dbd9e94dc3b1c3b0e73865743f4',
+    };
 
     config.is_debug = true;
 

+ 5 - 0
config/config.uat.js

@@ -53,6 +53,11 @@ module.exports = appInfo => {
         //renew: true, // session临近过期更新过期时间
         rolling: true, // 每次都更新session有效期
     };
+    // wx扫码登录
+    config.wxCode = {
+        appid: 'wx5320cd30cecdbd68',
+        appsecret: 'ca7c0dbd9e94dc3b1c3b0e73865743f4',
+    };
 
     return config;
 };