Răsfoiți Sursa

上传小程序

shish 6 ani în urmă
părinte
comite
40da464cc3
1 a modificat fișierele cu 14 adăugiri și 1 ștergeri
  1. 14 1
      common/components/wxUtil.php

+ 14 - 1
common/components/wxUtil.php

@@ -1258,6 +1258,19 @@ class wxUtil
 		$curl = new curl\Curl();
 		$mUrl = Yii::$app->params['mHost'];
 		$imgUrl = Yii::$app->params['imgHost'];
+
+		//如果不是https则换成https
+		$has = strpos($mUrl, 'https');
+		if ($has === false) {
+			$mUrl = str_replace('http', 'https', $mUrl);
+		}
+
+		//如果不是https则换成https
+		$has = strpos($imgUrl, 'https');
+		if ($has === false) {
+			$imgUrl = str_replace('http', 'https', $imgUrl);
+		}
+
 		$ext = [
 			'extAppid' => $merchant['miniAppId'],
 			'ext' => [
@@ -1290,7 +1303,7 @@ class wxUtil
 		$result = $curl->get($url);
 		$file = dirUtil::getImgDir() . '/retail/miniExperience/' . $merchant['id'] . '.jpg';
 		file_put_contents($file, $result);
-		echo "<img src='" . Yii::$app->params['imgHost'] . "/retail/miniExperience/" . $merchant['id'] . ".jpg' />";
+		echo "小程序体验码:<b /><img src='" . Yii::$app->params['imgHost'] . "/retail/miniExperience/" . $merchant['id'] . ".jpg' />";
 	}
 
 	//获取授权小程序帐号已设置的类目