ソースを参照

小程序业务域名

shish 6 年 前
コミット
8bc50d47b5
2 ファイル変更16 行追加29 行削除
  1. 3 1
      app/saas/controllers/MerchantController.php
  2. 13 28
      common/components/wxUtil.php

+ 3 - 1
app/saas/controllers/MerchantController.php

@@ -77,11 +77,13 @@ class MerchantController extends BaseController
 		//查询公众号 小程序的绑定情况
 		if ($id == 3) {
 			$return = wxUtil::getOpenAccount($wxAppId, $merchant);
+			echo "公众号绑定情况:<br />";
 			print_r($return);
 			$return = wxUtil::getOpenAccount($miniAppId, $merchant, true);
+			echo "小程序绑定情况:<br />";
 			print_r($return);
 		}
-		
+
 		//设置小程序服务器域名
 		if ($id == 4) {
 			wxUtil::setDomain($merchant);

+ 13 - 28
common/components/wxUtil.php

@@ -1216,23 +1216,14 @@ class wxUtil
 		$accessToken = self::getMiniProgramAccessToken($merchant);
 		$url = "https://api.weixin.qq.com/wxa/modify_domain?access_token=" . $accessToken;
 		$curl = new curl\Curl();
-		if ($merchant['merchantName'] == '花美灵') {
-			$data = [
-				"action" => "set",
-				"requestdomain" => ['https://mini.huaml.com'],
-				"wsrequestdomain" => ['https://mini.huaml.com'],
-				"uploaddomain" => ['https://mini.huaml.com'],
-				"downloaddomain" => ['https://mini.huaml.com'],
-			];
-		} else {
-			$data = [
-				"action" => "set",
-				"requestdomain" => ['https://mini.huahb.com'],
-				"wsrequestdomain" => ['https://mini.huahb.com'],
-				"uploaddomain" => ['https://mini.huahb.com'],
-				"downloaddomain" => ['https://mini.huahb.com'],
-			];
-		}
+		$mHost = Yii::$app->params['mHost'];
+		$data = [
+			"action" => "set",
+			"requestdomain" => [$mHost],
+			"wsrequestdomain" => [$mHost],
+			"uploaddomain" => [$mHost],
+			"downloaddomain" => [$mHost],
+		];
 		$result = $curl->setOption(CURLOPT_POSTFIELDS, Json::encode($data))->post($url);
 		$respond = Json::decode($result);
 		print_r($respond);
@@ -1244,17 +1235,11 @@ class wxUtil
 		$accessToken = self::getMiniProgramAccessToken($merchant);
 		$url = "https://api.weixin.qq.com/wxa/setwebviewdomain?access_token=" . $accessToken;
 		$curl = new curl\Curl();
-		if ($merchant['merchantName'] == '花美灵') {
-			$data = [
-				"action" => "set",
-				"webviewdomain" => ['https://mini.huaml.com'],
-			];
-		} else {
-			$data = [
-				"action" => "set",
-				"webviewdomain" => ['https://mini.huahb.com'],
-			];
-		}
+		$mHost = Yii::$app->params['mHost'];
+		$data = [
+			"action" => "set",
+			"webviewdomain" => [$mHost],
+		];
 		$result = $curl->setOption(CURLOPT_POSTFIELDS, Json::encode($data))->post($url);
 		$respond = Json::decode($result);
 		print_r($respond);