|
|
@ -25,6 +25,8 @@ use app\common\service\BaseService; |
|
|
|
use cores\exception\BaseException; |
|
|
|
use cores\exception\BaseException; |
|
|
|
use think\facade\Cache; |
|
|
|
use think\facade\Cache; |
|
|
|
use yiovo\captcha\facade\CaptchaApi; |
|
|
|
use yiovo\captcha\facade\CaptchaApi; |
|
|
|
|
|
|
|
use EasyWeChat\Factory; |
|
|
|
|
|
|
|
use app\api\model\wxapp\Setting as WxappSettingModel; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 服务类:用户登录 |
|
|
|
* 服务类:用户登录 |
|
|
@ -201,6 +203,7 @@ class Login extends BaseService |
|
|
|
if (empty($form['partyData']['oauth'])) { |
|
|
|
if (empty($form['partyData']['oauth'])) { |
|
|
|
$form['partyData']['oauth'] = 'MP-WEIXIN'; |
|
|
|
$form['partyData']['oauth'] = 'MP-WEIXIN'; |
|
|
|
$form['partyData']['code'] = $form['code']; |
|
|
|
$form['partyData']['code'] = $form['code']; |
|
|
|
|
|
|
|
$form['partyData']['version'] = $form['version']; |
|
|
|
} |
|
|
|
} |
|
|
|
$loginData = [ |
|
|
|
$loginData = [ |
|
|
|
'mobile' => $plainData['purePhoneNumber'], |
|
|
|
'mobile' => $plainData['purePhoneNumber'], |
|
|
@ -215,7 +218,49 @@ class Login extends BaseService |
|
|
|
// 记录登录态 |
|
|
|
// 记录登录态 |
|
|
|
return $this->setSession(); |
|
|
|
return $this->setSession(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 快捷登录:微信小程序用户-5.0 |
|
|
|
|
|
|
|
* @param array $form |
|
|
|
|
|
|
|
* @return bool |
|
|
|
|
|
|
|
* @throws BaseException |
|
|
|
|
|
|
|
* @throws \think\db\exception\DataNotFoundException |
|
|
|
|
|
|
|
* @throws \think\db\exception\DbException |
|
|
|
|
|
|
|
* @throws \think\db\exception\ModelNotFoundException |
|
|
|
|
|
|
|
* @throws \think\Exception |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public function auth(array $form): bool |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
$wxSetting = WxappSettingModel::getConfigBasic(); |
|
|
|
|
|
|
|
$config = [ |
|
|
|
|
|
|
|
'app_id' => $wxSetting['app_id'], |
|
|
|
|
|
|
|
'secret' => $wxSetting['app_secret'], |
|
|
|
|
|
|
|
'response_type' => 'array',// 指定 API 调用返回结果的类型:array(default)/collection/object/raw/自定义类名 |
|
|
|
|
|
|
|
'log' => [ |
|
|
|
|
|
|
|
'level' => 'debug', |
|
|
|
|
|
|
|
'file' => app()->getRuntimePath().'wechat.log', |
|
|
|
|
|
|
|
], |
|
|
|
|
|
|
|
]; |
|
|
|
|
|
|
|
$app = Factory::miniProgram($config); |
|
|
|
|
|
|
|
$phoneData = $app->phone_number->getUserPhoneNumber($form['pcode']); |
|
|
|
|
|
|
|
// 整理登录注册数据 |
|
|
|
|
|
|
|
if (empty($form['partyData']['oauth'])) { |
|
|
|
|
|
|
|
$form['partyData']['oauth'] = 'MP-WEIXIN'; |
|
|
|
|
|
|
|
$form['partyData']['code'] = $form['ucode']; |
|
|
|
|
|
|
|
$form['partyData']['version'] = $form['version']; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
$loginData = [ |
|
|
|
|
|
|
|
'mobile' => $phoneData['phone_info']['purePhoneNumber'] ?? "", |
|
|
|
|
|
|
|
'isParty' => $form['isParty'], |
|
|
|
|
|
|
|
'partyData' => $form['partyData'], |
|
|
|
|
|
|
|
'refereeId' => $form['refereeId'] ?? null, |
|
|
|
|
|
|
|
]; |
|
|
|
|
|
|
|
// 自动登录注册 |
|
|
|
|
|
|
|
$this->register($loginData); |
|
|
|
|
|
|
|
// 保存第三方用户信息 |
|
|
|
|
|
|
|
$this->createUserOauth($this->getUserId(), $loginData['isParty'], $loginData['partyData']); |
|
|
|
|
|
|
|
// 记录登录态 |
|
|
|
|
|
|
|
return $this->setSession(); |
|
|
|
|
|
|
|
} |
|
|
|
/** |
|
|
|
/** |
|
|
|
* 快捷登录:支付宝小程序用户 |
|
|
|
* 快捷登录:支付宝小程序用户 |
|
|
|
* @param array $form |
|
|
|
* @param array $form |
|
|
|