to($openid); if ($color) { $template->color($color); } if ($link) { switch ($type) { case 'wechat': $link = sys_config('site_url') . Route::buildUrl($link) ->suffix('') ->domain(false)->build(); break; } $template->url($link); } $res = $template->send($tempCode, $data); if (!$res) { $msg = $type == 'wechat' ? '微信模版消息' : '订阅消息'; Log::error($msg . '发送失败,原因:' . $template->getError() . '----参数:' . json_encode(compact('tempCode', 'openid', 'data', 'link'))); } return true; } catch (\Exception $e) { Log::error($e->getMessage()); return true; } } }