shish 5 лет назад
Родитель
Сommit
269f674529
1 измененных файлов с 3 добавлено и 2 удалено
  1. 3 2
      app/pt/controllers/WxOpenController.php

+ 3 - 2
app/pt/controllers/WxOpenController.php

@@ -46,11 +46,12 @@ class WxOpenController extends PublicController
         //1只显示公众号 2只显示小程序  3显示公众号和小程序
         $authType = Yii::$app->request->get('authType', 3);
         $pre = wxUtil::getPreAuthCode($open);
-        $appId = $open['appId'];
+        $appId = $open['appId'] ?? '';
+        $openId = $open['id'] ?? 0;
         $oData = [];
         $oData['preAuthCodeTime'] = date("Y-m-d H:i:s");
         //设置预授码过期,让下个用户可以获取新的预授码
-        xhWxOpenService::updateById(1, $oData);
+        xhWxOpenService::updateById($openId, $oData);
         Yii::info('callbackUrl:' . $url);
         echo "<a href='https://mp.weixin.qq.com/cgi-bin/componentloginpage?component_appid={$appId}&pre_auth_code={$pre}&redirect_uri={$url}&auth_type={$authType}'>授权</a>";
     }