|
|
@@ -3,6 +3,7 @@
|
|
|
namespace mall\controllers;
|
|
|
|
|
|
use biz\shop\classes\ShopClass;
|
|
|
+use bizHd\wx\classes\WxOpenClass;
|
|
|
use bizMall\merchant\services\MerchantService;
|
|
|
use bizMall\user\classes\UserClass;
|
|
|
use bizMall\user\services\UserService;
|
|
|
@@ -23,6 +24,38 @@ use yii\helpers\Json;
|
|
|
class AuthController extends PublicController
|
|
|
{
|
|
|
|
|
|
+ //微信手机号一键登录 ssh 20220607
|
|
|
+ public function actionWxMobileLogin()
|
|
|
+ {
|
|
|
+ $post = Yii::$app->request->post();
|
|
|
+ $iv = $post['iv'];
|
|
|
+ $encryptedData = $post['encryptedData'];
|
|
|
+ $merchant = WxOpenClass::getMallWxMiniBase();
|
|
|
+ $appId = $merchant['miniAppId'];
|
|
|
+ $miniOpenId = $post['miniOpenId'] ?? '';
|
|
|
+ if (empty($miniOpenId)) {
|
|
|
+ util::success(['hasNoOpenId' => 1], '登录失败');
|
|
|
+ }
|
|
|
+ $cacheKey = 'MALL_MINI_SESSION_KEY_' . $miniOpenId;
|
|
|
+ $sessionKey = Yii::$app->redis->executeCommand('GET', [$cacheKey]);
|
|
|
+ if (empty($sessionKey)) {
|
|
|
+ util::fail('登录失败了哦');
|
|
|
+ }
|
|
|
+ $wxMiniSecret = Yii::getAlias("@vendor/weixinMiniSecret");
|
|
|
+ require_once($wxMiniSecret . '/wxBizDataCrypt.php');
|
|
|
+ $pc = new \WXBizDataCrypt($appId, $sessionKey);
|
|
|
+ $errCode = $pc->decryptData($encryptedData, $iv, $result);
|
|
|
+ if ($errCode != 0) {
|
|
|
+ util::fail('登录失败...');
|
|
|
+ }
|
|
|
+ $arr = Json::decode($result);
|
|
|
+ $phoneNumber = isset($arr['purePhoneNumber']) ? $arr['purePhoneNumber'] : '';
|
|
|
+ if (empty($phoneNumber)) {
|
|
|
+ util::fail('登录失败了');
|
|
|
+ }
|
|
|
+ util::success(['mobile' => $phoneNumber]);
|
|
|
+ }
|
|
|
+
|
|
|
//准备授权 ssh 2019.11.19
|
|
|
public function actionPrepare()
|
|
|
{
|