public function menu() { $menuMdl = D('Menu'); $wxin_info_check = false; if ($this->weixin['appid'] != '' && $this->weixin['appsecret'] != '') { $wechat = new \Common\Lib\Wechat(); $access_token = $wechat->checkAuth($this->weixin['appid'], $this->weixin['appsecret']); if ($access_token) { $wxin_info_check = true; } } $list = $menuMdl->getList(0); $count = count($list); if ($count > 0) { foreach ($list as $key => $val) { $list[$key]['msg_data'] = unserialize(@$val['msg_data']); $sec_list = $menuMdl->getList($val['id']); if ($sec_list) { foreach ($sec_list as $s_k => $s_v) { $sec_list[$s_k]['msg_data'] = unserialize($s_v['msg_data']); } } $list[$key]['sec'] = $sec_list; } } $this->assign('menus', $list); $this->assign('count', $count); $this->assign('wxin', $this->weixin); $this->assign('k', 'menu'); $this->assign('wxin_info_check', $wxin_info_check); $this->display(); }
/** * 删除自定义菜单(所有的) get * $info 服务号的appid,appsecret */ function deleteMenu($info) { // https://api.weixin.qq.com/cgi-bin/menu/delete?access_token=ACCESS_TOKEN $weixinApi = new \Common\Lib\Wechat(); $weixinApi->checkAuth($info['appid'], $info['appsecret']); $res = $weixinApi->deleteMenu(); if ($res) { $return = array('status' => 'success'); } else { $return = array('status' => 'error', 'msg' => $weixinApi->errMsg); } return $return; }