|
|
@@ -4,6 +4,7 @@ namespace shop\controllers;
|
|
|
|
|
|
use biz\admin\services\AdminService;
|
|
|
use biz\auth\services\AuthService;
|
|
|
+use biz\weixin\services\WxOpenService;
|
|
|
use common\components\httpUtil;
|
|
|
use common\components\jwt;
|
|
|
use common\components\util;
|
|
|
@@ -161,15 +162,15 @@ class AuthController extends PublicController
|
|
|
if (empty($code)) {
|
|
|
util::fail('没有CODE信息');
|
|
|
}
|
|
|
- $merchant = $this->merchant;
|
|
|
- $account = $this->merchantId;
|
|
|
+ $merchant = WxOpenService::getOpenInfo();
|
|
|
+ $account = $merchant['id'];
|
|
|
$appId = $merchant['miniAppId'];
|
|
|
$appSecret = $merchant['miniAppSecret'];
|
|
|
if (empty($appSecret)) {
|
|
|
util::fail('没有找到小程序的密钥');
|
|
|
}
|
|
|
$url = "https://api.weixin.qq.com/sns/jscode2session?appid={$appId}&secret={$appSecret}&js_code={$code}&grant_type=authorization_code";
|
|
|
-
|
|
|
+
|
|
|
$curl = new curl\Curl();
|
|
|
$result = $curl->get($url);
|
|
|
$arr = Json::decode($result);
|
|
|
@@ -187,11 +188,11 @@ class AuthController extends PublicController
|
|
|
Yii::info(json_encode($userInfo));
|
|
|
$user = UserService::replaceUser($userInfo, $userSource, $account);
|
|
|
}
|
|
|
- $cacheKey = 'SHOP_MINI_SESSION_KEY_' . $openid;
|
|
|
+ $cacheKey = 'MALL_MINI_SESSION_KEY_' . $openid;
|
|
|
Yii::$app->redis->executeCommand('SET', [$cacheKey, $sessionKey]);
|
|
|
$userId = $user['id'];
|
|
|
$token = jwt::getNewToken($userId);
|
|
|
util::success(['token' => $token, 'user' => $user]);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
}
|