|
@@ -105,20 +105,30 @@ class Login extends Api
|
|
|
*/
|
|
|
public function wx_app_login(){
|
|
|
|
|
|
+
|
|
|
+ $config = [
|
|
|
+ 'app_id' => 'wx7936a4e21cee8845',
|
|
|
+ 'secret' => '1039fa3f6ff33e03facca41122c88c75',
|
|
|
+ 'response_type' => 'array',
|
|
|
+ ];
|
|
|
+ $app = Factory::miniProgram($config);
|
|
|
+
|
|
|
if(app()->request->header('Authorization')){
|
|
|
|
|
|
$user_id = $this->check_login();
|
|
|
$avatar=input('avatarUrl');
|
|
|
$nickname=input('nickname');
|
|
|
+ $user=Db::table('q_user')->where('openid',$user_id)->find();
|
|
|
+ $decryptedData = $app->encryptor->decryptData($user['session_key'], input('iv'), input('encryptedData'));
|
|
|
|
|
|
- $res=Db::table('q_user')->where('id',$user_id)->update(['headimg'=>$avatar,'nickname'=>$nickname]);
|
|
|
+ $res=Db::table('q_user')->where('id',$user_id)->update(['headimg'=>$avatar,'nickname'=>$nickname,'phone'=>$decryptedData['phoneNumber']]);
|
|
|
if(empty($res)){
|
|
|
$this->success('授权信息失败,请重新授权');
|
|
|
}else{
|
|
|
$this->success('登陆成功');
|
|
|
}
|
|
|
|
|
|
-//$decryptedData = $app->encryptor->decryptData($data['session_key'], input('iv'), input('encryptedData'));
|
|
|
+
|
|
|
|
|
|
}
|
|
|
|
|
@@ -126,28 +136,13 @@ class Login extends Api
|
|
|
|
|
|
|
|
|
|
|
|
- $config = [
|
|
|
- 'app_id' => 'wx7936a4e21cee8845',
|
|
|
- 'secret' => '1039fa3f6ff33e03facca41122c88c75',
|
|
|
- 'response_type' => 'array',
|
|
|
- ];
|
|
|
|
|
|
$code=input('code');
|
|
|
if(empty($code)){
|
|
|
$this->error('code参数错误');
|
|
|
}
|
|
|
- $app = Factory::miniProgram($config);
|
|
|
$data=$app->auth->session($code);
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
$user=Db::table('q_user')->where('openid',$data['openid'])->find();
|
|
|
if(empty($user)){
|
|
|
$id=Db::table('q_user')->insertGetId(['openid'=>$data['openid'],'session_key'=>$data['session_key']]);
|