| xqd
@@ -119,6 +119,27 @@ class CommonController extends Controller
|
|
|
return out($decryptedData);
|
|
|
}
|
|
|
|
|
|
+ public function getUserByCode()
|
|
|
+ {
|
|
|
+ $req = request()->post();
|
|
|
+ $this->validate(request(), [
|
|
|
+ 'wechat_code' => 'required',
|
|
|
+ ]);
|
|
|
+
|
|
|
+ $app = Factory::miniProgram(config('config.wechat_small_program'));
|
|
|
+ $data = $app->auth->session($req['wechat_code']);
|
|
|
+ if (empty($data['openid'])){
|
|
|
+ return out(null, 10001, '微信code错误');
|
|
|
+ }
|
|
|
+
|
|
|
+ $user = User::select(['id', 'status', 'phone', 'nickname', 'avatar'])->where('openid', $data['openid'])->first();
|
|
|
+ if ($user['status'] == 0) {
|
|
|
+ return out(null, 10002, '该账号已被冻结');
|
|
|
+ }
|
|
|
+
|
|
|
+ return out($user);
|
|
|
+ }
|
|
|
+
|
|
|
public function uploadFile()
|
|
|
{
|
|
|
$file = request()->file('file');
|