Silent 6 years ago
parent
commit
02769eafaa
2 changed files with 7 additions and 2 deletions
  1. 7 1
      app/Http/Controllers/WeChat/LoginController.php
  2. 0 1
      wechat/app.js

+ 7 - 1
app/Http/Controllers/WeChat/LoginController.php

xqd
@@ -18,7 +18,13 @@ class LoginController extends Controller
         $encryptedData = $request->input('encryptedData');
         $app = app('wechat.mini_program');
         $res = $app->auth->session($code);
-        Log::info($res);
+
+        if(!isset($res['session_key'])) {
+            return response()->json(['status' => 'error', 'info' => '接口错误']);
+        }
+
+        $info = $app->encryptor->decryptData($res['session_key'], $iv, $encryptedData);
+        Log::info($info);
         return response()->json(['status' => 'success', 'info' => '操作成功']);
     }
 }

+ 0 - 1
wechat/app.js

xqd
@@ -30,7 +30,6 @@ App({
   login: function (info) {
     wx.login({
       success: res => {
-        console.log(res.code, info.iv, info.encryptedData)
         wx.request({
           url: api.loginUrl,
           method: 'POST',