add clear

This commit is contained in:
as2252258@163.com
2019-08-21 13:34:03 +08:00
parent ad78b85ea0
commit 00f046fba1
+12 -7
View File
@@ -13,6 +13,8 @@ class PublicTemplate extends Miniprogarampage
private $keywords = [];
private $templateId = '';
private $first = '';
private $remark = '';
private $openId = '';
private $defaultUrl = 'http://weixin.qq.com/download';
private $sendUrl = 'https://api.weixin.qq.com/cgi-bin/message/template/send';
@@ -58,21 +60,20 @@ class PublicTemplate extends Miniprogarampage
*/
public function replaceKeyword($name, $context, $color = '')
{
$this->addKeyword($name, $context, $color);
$this->keywords['keyword' . $name] = ['value' => $context, 'color' => $color];
}
/**
* @param $name
* @param $context
* @param null $color
*/
public function addKeyword($name, $context, $color = null)
public function addKeyword($context, $color = null)
{
if (empty($color)) {
$color = '#000';
}
$this->keywords[$name . '.DATA'] = [
$this->keywords['keyword' . count($this->keywords)] = [
'value' => $context,
'color' => $color
];
@@ -84,7 +85,7 @@ class PublicTemplate extends Miniprogarampage
*/
public function setFirst($context, $color = '#f00')
{
$this->keywords['first.DATA'] = [
$this->first = [
'value' => $context,
'color' => $color
];
@@ -96,7 +97,7 @@ class PublicTemplate extends Miniprogarampage
*/
public function setRemark($context, $color = '#000')
{
$this->keywords['remark.DATA'] = [
$this->remark = [
'value' => $context,
'color' => $color
];
@@ -124,11 +125,15 @@ class PublicTemplate extends Miniprogarampage
{
$url = $this->sendUrl . '?access_token=' . $this->getAccessToken();
$keywords = $this->keywords;
$keywords['first'] = $this->first;
$keywords['remark'] = $this->remark;
$default = [
"touser" => $this->openId,
"template_id" => $this->templateId,
"url" => $this->defaultUrl,
"data" => $this->keywords,
"data" => $keywords,
];
if (!empty($this->miniprogram)) {