|
@@ -2,6 +2,7 @@
|
|
|
|
|
|
namespace App\Http\Controllers\WeChat;
|
|
namespace App\Http\Controllers\WeChat;
|
|
|
|
|
|
|
|
+use App\Models\Student;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Http\Request;
|
|
use App\Http\Controllers\Controller;
|
|
use App\Http\Controllers\Controller;
|
|
use Illuminate\Support\Facades\Log;
|
|
use Illuminate\Support\Facades\Log;
|
|
@@ -25,7 +26,23 @@ class LoginController extends Controller
|
|
|
|
|
|
$info = $app->encryptor->decryptData($res['session_key'], $iv, $encryptedData);
|
|
$info = $app->encryptor->decryptData($res['session_key'], $iv, $encryptedData);
|
|
|
|
|
|
|
|
+ if(!isset($info['openId'])) {
|
|
|
|
+ return response()->json(['status' => 'error', 'info' => '接口错误']);
|
|
|
|
+ }
|
|
|
|
|
|
- return response()->json(['status' => 'success', 'info' => '操作成功']);
|
|
|
|
|
|
+ $student = Student::firstOrCreate([
|
|
|
|
+ 'open_id' => $info['openId']
|
|
|
|
+ ], [
|
|
|
|
+ 'nickname' => $info['nickname'],
|
|
|
|
+ 'gender' => $info['gender'],
|
|
|
|
+ 'city' => $info['city'],
|
|
|
|
+ 'province' => $info['province'],
|
|
|
|
+ 'country' => $info['country'],
|
|
|
|
+ 'avatar_url' => $info['avatarUrl'],
|
|
|
|
+ 'name' => $info['nickname'],
|
|
|
|
+ 'short_leave_times' => 0,
|
|
|
|
+ 'long_leave_times' => 0,
|
|
|
|
+ ]);
|
|
|
|
+ return response()->json(['status' => 'success', 'info' => '操作成功', 'data' => $student]);
|
|
}
|
|
}
|
|
}
|
|
}
|