|
|
@@ -17,6 +17,43 @@ class AdminController extends BaseController
|
|
|
|
|
|
public $guestAccess = ['recent-shop', 'mini-full-info', 'mini-mobile', 'login-detail'];
|
|
|
|
|
|
+ //绑定帐号自动登录 shish 20210121
|
|
|
+ public function actionBindAutoLogin()
|
|
|
+ {
|
|
|
+ $post = Yii::$app->request->post();
|
|
|
+ $iv = isset($post['iv']) ? $post['iv'] : '';
|
|
|
+ $encryptedData = isset($post['encryptedData']) ? $post['encryptedData'] : '';
|
|
|
+ $merchant = WxOpenClass::getGhsWxInfo();
|
|
|
+ $appId = $merchant['miniAppId'];
|
|
|
+ $miniOpenId = $post['miniOpenId'];
|
|
|
+ if (empty($miniOpenId)) {
|
|
|
+ util::fail('绑定失败');
|
|
|
+ }
|
|
|
+ $cacheKey = 'GHS_SHOP_MINI_SESSION_KEY_' . $miniOpenId;
|
|
|
+ $sessionKey = Yii::$app->redis->executeCommand('GET', [$cacheKey]);
|
|
|
+ $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::info($result . ' ' . $errCode);
|
|
|
+ util::fail('绑定失败了');
|
|
|
+ }
|
|
|
+ Yii::info('小程序获取用户信息:' . $result);
|
|
|
+ $wxInfo = Json::decode($result);
|
|
|
+ $nickName = $wxInfo['nickName'] ?? '';
|
|
|
+ if (empty($nickName)) {
|
|
|
+ util::fail('绑定失败');
|
|
|
+ }
|
|
|
+ $admin = $this->admin ?? [];
|
|
|
+ if (empty($admin)) {
|
|
|
+ util::fail('绑定失败');
|
|
|
+ }
|
|
|
+ $admin->miniOpenId = $miniOpenId;
|
|
|
+ $admin->save();
|
|
|
+ util::complete();
|
|
|
+ }
|
|
|
+
|
|
|
//修改保存安卓clientId
|
|
|
public function actionReplaceClientId()
|
|
|
{
|