shish 6 vuotta sitten
vanhempi
commit
bdedfe841c
2 muutettua tiedostoa jossa 12 lisäystä ja 9 poistoa
  1. 8 6
      app/mobile/controllers/AuthController.php
  2. 4 3
      app/mobile/views/main/index.php

+ 8 - 6
app/mobile/controllers/AuthController.php

@@ -17,18 +17,18 @@ use common\components\weixinUtil;
  */
 class AuthController extends PublicController
 {
-	
+
 	public $enableCsrfValidation = false;
-	
+
 	//准备授权 shish 2019.11.19
 	public function actionPrepare()
 	{
-		$post = Yii::$app->request->post();print_r($post);die;
-		$suffixUrl = isset($post['suffixUrl']) && !empty($post['suffixUrl']) ? $post['suffixUrl'] : '';
+		$get = Yii::$app->request->get();
+		$suffixUrl = isset($get['suffixUrl']) && !empty($get['suffixUrl']) ? $get['suffixUrl'] : '';
 		if (empty($suffixUrl)) {
 			util::fail('没有网址');
 		}
-		$account = isset($post['account']) ? $post['account'] : 0;
+		$account = isset($get['account']) ? $get['account'] : 0;
 		$merchant = MerchantService::getById($account);
 		if (empty($merchant)) {
 			util::fail('商家无效');
@@ -40,7 +40,7 @@ class AuthController extends PublicController
 		 * 3.其它情况需要获取用户完整信息的,使用snsapi_userinfo让用户授权获取信息即可
 		 * 4.snsapi_base静默方式使用的场景更多,所以参数authScope默认使用snsapi_base
 		 */
-		$authScope = isset($post['authScope']) ? $post['authScope'] : 'snsapi_base';
+		$authScope = isset($get['authScope']) ? $get['authScope'] : 'snsapi_base';
 		$host = Yii::$app->request->getHostInfo();
 		$url = $host . '/auth/get-user-info?suffixUrl=' . $suffixUrl . '&authScope=' . $authScope;
 		weixinUtil::getToken($url, $merchant, $authScope);
@@ -58,8 +58,10 @@ class AuthController extends PublicController
 		if (isset($get['state']) && $get['state'] == 'authdeny') {
 			util::fail('auth fail');
 		}
+		print_r($get);die;
 		$account = '';
 		$suffixUrlEncode = $get['suffixUrl'];
+		//这里要换成根据前端的数据来转!!!! todo
 		$suffixUrl = stringUtil::urlSafeBase64Decode($suffixUrlEncode);
 		$parse = parse_url($suffixUrl);
 		if (isset($parse['query'])) {

+ 4 - 3
app/mobile/views/main/index.php

@@ -1,7 +1,8 @@
 <body>
 <script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
 <script>
-
+    window.location='<?= $host ?>/auth/prepare?suffixUrl=<?php echo \common\components\stringUtil::urlSafeB64Encode('main/index'); ?>&authScope=snsapi_base&account=12358';
+    /*
     function StandardPost(url,args){
         var form = $("<form method='post'></form>"),
             input;
@@ -22,7 +23,7 @@
     }
 
     var args = { suffixUrl: "#main/index?account=12358",authScope: "snsapi_base"};
-    StandardPost("<?= $host ?>/auth/prepare",args)
-
+    StandardPost("host/auth/prepare",args)
+    */
 </script>
 </body>