weizong song 5 months ago
parent 4b370a9ee1
commit 7b517164f6

@ -308,3 +308,4 @@ $accounts = AlipayAccount::withTrashed()->get();
**基于模板**: WechatpayAccount MVC

@ -23,3 +23,4 @@ class AlipayAccountForm extends Form
}

@ -28,3 +28,4 @@ class AlipayAccountController extends CommonController
}

@ -268,13 +268,19 @@ class AuthController extends Controller
// 'errormsg' => "openid为空"
// ], 401);
// }
$config = [
'app_id' => $this->appid,
'secret' => $this->appsecret
];
$app = Factory::miniProgram($config);
$result = $app->phone_number->getUserPhoneNumber($code);
$mobile = $result['phone_info']['purePhoneNumber'] ?? '';
// $config = [
// 'app_id' => $this->appid,
// 'secret' => $this->appsecret
// ];
$url = "https://api.weixin.qq.com/wxa/business/getuserphonenumber?access_token=" . $this->getAccessToken();
$postData = json_encode(['code' => $code]);
$result = curl($url, $postData);
$mobile = '';
if (isset($result['phone_info']['pure_phone_number'])) {
$mobile = $result['phone_info']['pure_phone_number'];
} elseif (isset($result['phone_info']['purePhoneNumber'])) {
$mobile = $result['phone_info']['purePhoneNumber'];
}
if (empty($mobile)) {
return response()->json([
'errorcode' => '4001',

@ -8,3 +8,4 @@ class AlipayAccount extends SoftDeletesModel
}

Loading…
Cancel
Save