Преглед изворни кода

申请会员的小程序码

shish пре 6 година
родитељ
комит
a011ae5d97
1 измењених фајлова са 13 додато и 21 уклоњено
  1. 13 21
      common/components/wxUtil.php

+ 13 - 21
common/components/wxUtil.php

@@ -22,12 +22,7 @@ class wxUtil
 		$this->access_token = !empty($merchant) ? self::getAuthorizerAccessToken($merchant) : '';
 	}
 	
-	/**
-	 * 获取用户基本信息
-	 * @param $accessToken
-	 * @param $openId
-	 * @return array
-	 */
+	//获取用户基本信息
 	public static function userInfo($openId, $merchant)
 	{
 		$accessToken = self::getAuthorizerAccessToken($merchant);
@@ -138,10 +133,7 @@ class wxUtil
 		return $result;
 	}
 	
-	/**
-	 * 查询所有分组
-	 * @param unknown $accessToken
-	 */
+	//查询所有分组
 	public static function groupList($accessToken)
 	{
 		$url = "https://api.weixin.qq.com/cgi-bin/groups/get?access_token=$accessToken";
@@ -457,7 +449,7 @@ class wxUtil
 			return false;
 		}
 	}
-
+	
 	//客服接口发消息
 	public static function sendMsg($content, $merchant, $openId)
 	{
@@ -469,7 +461,7 @@ class wxUtil
 		$result = Json::decode($result);
 		return $result;
 	}
-
+	
 	public static function sendImgMsg($mediaId, $merchant, $openId)
 	{
 		$token = self::getAuthorizerAccessToken($merchant);
@@ -1252,19 +1244,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' => [
@@ -1299,7 +1291,7 @@ class wxUtil
 		file_put_contents($file, $result);
 		echo "小程序体验码:<b /><img src='" . Yii::$app->params['imgHost'] . "/retail/miniExperience/" . $merchant['id'] . ".jpg' />";
 	}
-
+	
 	//获取授权小程序帐号已设置的类目
 	public static function getMiniCategory($merchant)
 	{
@@ -1387,8 +1379,8 @@ class wxUtil
 		echo "<pre>";
 		print_r($respond);
 	}
-	
-	//生成申请会员的小程序码
+
+	//申请会员的小程序码
 	public static function generateMemberCode($merchant)
 	{
 		$accessToken = self::getMiniProgramAccessToken($merchant);
@@ -1400,11 +1392,11 @@ class wxUtil
 			"width" => 1000,
 		];
 		$result = $curl->setOption(CURLOPT_POSTFIELDS, Json::encode($data))->post($url);
-		$file = util::getRootDir() . '/resource/images/miniExperience/' . $merchant['id'] . '_member.jpg';
+		$file = dirUtil::getImgDir() . '/retail/miniExperience/' . $merchant['id'] . '_apply_member.jpg';
 		file_put_contents($file, $result);
-		echo "<img src='" . Yii::$app->params['imgHost'] . "/miniExperience/" . $merchant['id'] . "_member.jpg' />";
+		echo "<img src='" . Yii::$app->params['imgHost'] . "/retail/miniExperience/" . $merchant['id'] . "_member.jpg' />";
 	}
-	
+
 	/**
 	 * 微信开放平台获取component_access_token
 	 */