|
|
@@ -9,7 +9,7 @@ use bizGhs\item\classes\LabelClass;
|
|
|
use bizHd\admin\classes\ShopAdminClass;
|
|
|
use bizGhs\shop\services\ShopAdminService;
|
|
|
use bizGhs\admin\services\AdminService;
|
|
|
-use bizHd\wx\classes\WxOpenClass;
|
|
|
+use biz\wx\classes\WxOpenClass;
|
|
|
use common\components\dict;
|
|
|
use common\components\httpUtil;
|
|
|
use common\components\imgUtil;
|
|
|
@@ -29,6 +29,43 @@ use yii\helpers\Json;
|
|
|
class AuthController extends PublicController
|
|
|
{
|
|
|
|
|
|
+ //获取手机号
|
|
|
+ public function actionGetMobile()
|
|
|
+ {
|
|
|
+ $post = Yii::$app->request->post();
|
|
|
+ $iv = $post['iv'];
|
|
|
+ $encryptedData = $post['encryptedData'];
|
|
|
+ $merchant = WxOpenClass::getGhsWxInfo();
|
|
|
+ $appId = $merchant['miniAppId'];
|
|
|
+ $miniOpenId = $post['miniOpenId'] ?? '';
|
|
|
+ if (empty($miniOpenId)) {
|
|
|
+ util::success(['hasNoOpenId' => 1], '登录失败,没有miniOpenId');
|
|
|
+ }
|
|
|
+ $cacheKey = 'GHS_SHOP_MINI_SESSION_KEY_' . $miniOpenId;
|
|
|
+ $sessionKey = Yii::$app->redis->executeCommand('GET', [$cacheKey]);
|
|
|
+ if (empty($sessionKey)) {
|
|
|
+ Yii::$app->redis->executeCommand('DEL', [$cacheKey]);
|
|
|
+ util::success(['hasNoOpenId' => 1], '登录失败!');
|
|
|
+ }
|
|
|
+ $wxMiniSecret = Yii::getAlias("@vendor/weixinMiniSecret");
|
|
|
+ require_once($wxMiniSecret . '/wxBizDataCrypt.php');
|
|
|
+ $pc = new \WXBizDataCrypt($appId, $sessionKey);
|
|
|
+ $errCode = $pc->decryptData($encryptedData, $iv, $result);
|
|
|
+ if ($errCode != 0) {
|
|
|
+ Yii::$app->redis->executeCommand('DEL', [$cacheKey]);
|
|
|
+ util::success(['hasNoOpenId' => 1], '登录失败...');
|
|
|
+ }
|
|
|
+ $arr = Json::decode($result);
|
|
|
+ $phoneNumber = isset($arr['purePhoneNumber']) ? $arr['purePhoneNumber'] : '';
|
|
|
+ if (empty($phoneNumber)) {
|
|
|
+ Yii::$app->redis->executeCommand('DEL', [$cacheKey]);
|
|
|
+ util::success(['hasNoOpenId' => 1], '登录失败了哦');
|
|
|
+ }
|
|
|
+ $cacheKey = 'getMobile_' . $phoneNumber;
|
|
|
+ Yii::$app->redis->executeCommand('SETEX', [$cacheKey, 300, 1]);
|
|
|
+ util::success(['mobile' => $phoneNumber]);
|
|
|
+ }
|
|
|
+
|
|
|
//微信手机号一键登录 ssh 20210121
|
|
|
public function actionWxMobileLogin()
|
|
|
{
|