weizong song 5 months ago
parent 4b370a9ee1
commit 7b517164f6

@ -308,3 +308,4 @@ $accounts = AlipayAccount::withTrashed()->get();
**基于模板**: WechatpayAccount MVC **基于模板**: 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为空" // 'errormsg' => "openid为空"
// ], 401); // ], 401);
// } // }
$config = [ // $config = [
'app_id' => $this->appid, // 'app_id' => $this->appid,
'secret' => $this->appsecret // 'secret' => $this->appsecret
]; // ];
$app = Factory::miniProgram($config); $url = "https://api.weixin.qq.com/wxa/business/getuserphonenumber?access_token=" . $this->getAccessToken();
$result = $app->phone_number->getUserPhoneNumber($code); $postData = json_encode(['code' => $code]);
$mobile = $result['phone_info']['purePhoneNumber'] ?? ''; $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)) { if (empty($mobile)) {
return response()->json([ return response()->json([
'errorcode' => '4001', 'errorcode' => '4001',

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

Loading…
Cancel
Save