>[info] 这个相信大部分小伙伴都开发,但是这里借助了Easyweichat框架的[菜单](https://www.easywechat.com/4.x/official-account/menu.html)特性,使得开发变得更简单,如下所示:
#### 温馨提示:下面只是我按照Easyweichat框架的[菜单](https://www.easywechat.com/4.x/official-account/menu.html)特性调整的一个适合我自己的菜单风格来做的,中间涉及到了,view事件以及click事件,这些事件的处理在后面章节进行讲解。
~~~
/**
* 设置菜单
* /api/Easycenter/memu
*/
public function memu()
{
$baseurl = $this->request->domain();
$buttons = [
[
"type" => "view",
"name" => "永久订阅",
"url" => "https://mp.weixin.qq.com/s?__biz=MzIyMzY2MDUzNw==&mid=2247484298&idx=1&sn=0721f30fccbd72bfd4514d217ca2af02&chksm=e81b931cdf6c1a0a9189a153c6cb822ac0d6d732128f9dc2c9e48e8850a6fa2484fa49f97686#rd"
],
[
"name" => "神仙操作",
"sub_button" => [
[
"type" => "click",
"name" => "线路一闸刀",
"key" => "Line1"
],
[
"type" => "click",
"name" => "线路二闸刀",
"key" => "Line2"
],
[
"type" => "click",
"name" => "线路三闸刀",
"key" => "Line3"
],
[
"type" => "view",
"name" => "1小时总览",
"url" => $baseurl."/api/index/index?id=3"
],
[
"type" => "click",
"name" => "发送统计",
"key" => "SendNum"
],
/*[
"type" => "click",
"name" => "接收线报",
"key" => "GetMsg"
],
[
"type" => "click",
"name" => "拒收线报",
"key" => "RefuseMsg"
],*/
],
],
[
"name" => "看我码子",
"sub_button" => [
[
"type" => "click",
"name" => "永久码子",
"key" => "MyCodeForever"
],
[
"type" => "click",
"name" => "当前码子",
"key" => "MyCode"
],
],
]/*,
[
"type" => "click",
"name" => "看我码子",
"key" => "MyCode"
]*/
];
$app = $this->app;
$ret = $app->menu->create($buttons);
var_dump($ret);
}
~~~