获取手机号

This commit is contained in:
2025-11-25 17:28:46 +08:00
parent e1a167b7d9
commit 9c075c20d2
2 changed files with 5 additions and 5 deletions
+4 -4
View File
@@ -9,6 +9,7 @@ use app\common\model\User;
use app\common\logic\UserLogic;
use app\common\utils\Jwt;
use support\exception\BusinessException;
use support\Request;
class UserService
{
@@ -237,12 +238,11 @@ class UserService
$logic = new UserLogic();
$wechatService = new WechatService();
$wxinfo = $wechatService->xcxOpenid($data['code']);
var_dump($wxinfo);
// 用户信息
$user = User::firstOrCreate(
['openid' => $wxinfo['openid']],
['nickname' => '微信用户_'.$wxinfo['openid'], 'name' => '', 'avatar' => getenv('MAIN_DOMAIN').'/avatar.png']
['nickname' => '微信用户_'.$wxinfo['openid'], 'unionid' => $wxinfo['unionid'], 'name' => '', 'avatar' => getenv('MAIN_DOMAIN').'/avatar.png']
);
@@ -258,13 +258,13 @@ class UserService
/**
* 获取手机号
*/
public function miniappPhoneNumber(array $data)
public function miniappPhoneNumber(array $data,Request $request)
{
// 手机号
$wechatService = new WechatService();
$wxinfo = $wechatService->xcxPhoneNumber($data['phone_code']);
$uinfo = User::where('id', $data['user_id'])->first();
$uinfo = User::where('id', $request->user->uid)->first();
$uinfo->phone = $wxinfo['phone_info']['phoneNumber'];
$uinfo->save();