添加订阅消息测试内容
This commit is contained in:
parent
bdbb296aa2
commit
ba392a04c1
@ -22,7 +22,11 @@ namespace app\api\controller;
|
|||||||
|
|
||||||
use app\common\basics\Api;
|
use app\common\basics\Api;
|
||||||
use app\common\logic\SystemNoticeLogic;
|
use app\common\logic\SystemNoticeLogic;
|
||||||
|
use app\common\model\Client_;
|
||||||
|
use app\common\model\user\UserAuth;
|
||||||
use app\common\server\JsonServer;
|
use app\common\server\JsonServer;
|
||||||
|
use app\common\server\WeChatServer;
|
||||||
|
use EasyWeChat\Factory;
|
||||||
|
|
||||||
class Notice extends Api
|
class Notice extends Api
|
||||||
{
|
{
|
||||||
@ -49,4 +53,39 @@ class Notice extends Api
|
|||||||
return JsonServer::success('获取成功', $lists);
|
return JsonServer::success('获取成功', $lists);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 本地生活消息订阅模板ID,需要将template_id放在配置文件中
|
||||||
|
*/
|
||||||
|
public function getLocalLifeTemplateId()
|
||||||
|
{
|
||||||
|
return JsonServer::success('获取成功', ['id' => ['w6LVw0dwdmBWBlj06j-A-s34NZSdFC5xkasFhZbYSfM']]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 将template_id放在配置文件中
|
||||||
|
*/
|
||||||
|
public function sendMsg()
|
||||||
|
{
|
||||||
|
$config = WeChatServer::getMnpConfig();
|
||||||
|
$app = Factory::miniProgram($config);
|
||||||
|
$user = UserAuth::where(['user_id' => $this->user_id, 'client' => Client_::mnp])->find();
|
||||||
|
|
||||||
|
$data = [
|
||||||
|
'template_id' => 'w6LVw0dwdmBWBlj06j-A-s34NZSdFC5xkasFhZbYSfM', // 所需下发的订阅模板id
|
||||||
|
'touser' => $user['openid'], // 接收者(用户)的 openid
|
||||||
|
'page' => '/pages/goods_cate/goods_cate', // 点击模板卡片后的跳转页面,仅限本小程序内的页面。支持带参数,(示例index?foo=bar)。该字段不填则模板无跳转。
|
||||||
|
'data' => [ // 模板内容,格式形如 { "key1": { "value": any }, "key2": { "value": any } }
|
||||||
|
'thing1' => [
|
||||||
|
'value' => '我的店铺',
|
||||||
|
],
|
||||||
|
'thing4' => [
|
||||||
|
'value' => '您的店铺审核成功',
|
||||||
|
],
|
||||||
|
'phrase5' => [
|
||||||
|
'value' => '审核成功'
|
||||||
|
]
|
||||||
|
],
|
||||||
|
];
|
||||||
|
$app->subscribe_message->send($data);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue
Block a user