|
@@ -1,6 +1,7 @@
|
|
<?php
|
|
<?php
|
|
namespace app\expand\controller;
|
|
namespace app\expand\controller;
|
|
use app\common\service\HelperService;
|
|
use app\common\service\HelperService;
|
|
|
|
+use app\common\service\wechat\decode\WXBizDataCrypt;
|
|
use app\common\service\wechat\UnifiedOrder_pub;
|
|
use app\common\service\wechat\UnifiedOrder_pub;
|
|
use think\Config;
|
|
use think\Config;
|
|
use think\Validate;
|
|
use think\Validate;
|
|
@@ -148,6 +149,53 @@ class Xcx extends BaseAuth
|
|
]);
|
|
]);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ public function getMobileInfo() {
|
|
|
|
+
|
|
|
|
+ $params = $this->_params;
|
|
|
|
+
|
|
|
|
+ $rule = [
|
|
|
|
+ 'code|js获取的code'=>'require',
|
|
|
|
+ 'encryptedData'=>'require',
|
|
|
|
+ 'iv'=>'require'
|
|
|
|
+ ];
|
|
|
|
+
|
|
|
|
+ $validate = new Validate($rule);
|
|
|
|
+ if(!$validate->check($params)){
|
|
|
|
+ HelperService::returnJson(['code'=>400,'msg'=>$validate->getError(),'data'=>[]]);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(empty($this->_Account['Xcx_secret'])){
|
|
|
|
+ HelperService::returnJson(['code'=>400,'msg'=>'Xcx getOpenInfo unauthorized access','data'=>$this->_Account]);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ $secret = $this->_Account['Xcx_secret'];
|
|
|
|
+ $appId = empty($this->_SUBAPPID)?$this->_APPID:$this->_SUBAPPID;
|
|
|
|
+
|
|
|
|
+ $url = "https://api.weixin.qq.com/sns/jscode2session?appid={$appId}&secret={$secret}&js_code={$params['code']}&grant_type=authorization_code";
|
|
|
|
+ $openInfoJson = file_get_contents($url);
|
|
|
|
+ $openInfo = @json_decode($openInfoJson,true);
|
|
|
|
+
|
|
|
|
+ if($openInfo===false || !empty($openInfo['errcode'])){
|
|
|
|
+ HelperService::returnJson([
|
|
|
|
+ 'data'=>$openInfoJson,'msg'=>'fail','code'=>400
|
|
|
|
+ ]);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ $pc = new WXBizDataCrypt($appId, $openInfo['session_key']);
|
|
|
|
+ $errCode = $pc->decryptData($params['encryptedData'], $params['iv'], $data);
|
|
|
|
+ if ($errCode == 0) {
|
|
|
|
+ $data = json_decode($data,true);
|
|
|
|
+ HelperService::returnJson([
|
|
|
|
+ 'data'=> array_merge($openInfo,['appId'=>$appId]),'msg'=>'success','code'=>200
|
|
|
|
+ ]);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ HelperService::returnJson([
|
|
|
|
+ 'data'=>[],'msg'=>'获取手机号失败请重试','code'=>400
|
|
|
|
+ ]);
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 异步通知小程序支付
|
|
* 异步通知小程序支付
|
|
*/
|
|
*/
|