public function del_special_menu()
 {
     $id = $_GET['id'];
     $menuid = array();
     $menuid['menuid'] = $id;
     $menuid = json_encode_cn($menuid);
     //dump($menuid);die();
     $access_token = get_access_token();
     $url_post = 'https://api.weixin.qq.com/cgi-bin/menu/delconditional?access_token=' . $access_token;
     //$header [] = "content-type: application/x-www-form-urlencoded; charset=UTF-8";
     $res = D('CustomMenu')->curlGet($url_post, $method = 'post', $data = $menuid);
     $res = json_decode($res, true);
     if ($res['errcode'] == 0) {
         $result = D('CustomMenuType')->set_menu_local(2, $id);
         if ($result) {
             $this->success('菜单删除成功,数据更新成功!');
         } else {
             $this->error('菜单删除成功,数据更新失败!');
         }
     } else {
         $this->error(error_msg($res));
     }
 }
Beispiel #2
0
 function writeCatesToJs()
 {
     C('DEBUG', 0);
     $db = M('linkage_category');
     $lcgid = $db->field('lcgid')->findall();
     $city = $db->table('city')->field('id,pid,name')->findall();
     $str = 'var city=' . json_encode_cn(formatParentData2($city, array('id', 'pid', 'name'))) . ',';
     //城市的数据
     foreach ($lcgid as $value) {
         $condition = array('lcgid' => $value['lcgid']);
         $result = $this->data_model->getCateLinkage($condition, 'laid,title,pid');
         $str .= 'linkage_' . $value['lcgid'] . ' = ' . json_encode_cn(formatParentData($result)) . ',';
     }
     $str = rtrim($str, ',') . ';';
     $file_name = PATH_ROOT . '/caches/js/linkage_data.js';
     file_put_contents($file_name, $str);
 }
 private function json_menu($list)
 {
     foreach ($list as $val) {
         $button['name'] = $val['title'];
         $type = $val['type'];
         if ($type != 'none') {
             $button['type'] = $type;
             if ($type == 'view') {
                 $_key = 'url';
                 $_val = $val['url'];
             } else {
                 $_key = 'key';
                 $_val = $val['keyword'];
             }
             $button[$_key] = $_val;
         } else {
             foreach ($val['child'] as $child) {
                 if ($child['type'] == 'view') {
                     $_child_key = 'url';
                     $_child_val = $child['url'];
                 } else {
                     $_child_key = 'key';
                     $_child_val = $child['keyword'];
                 }
                 $sub_button[] = array('type' => $child['type'], 'name' => $child['title'], $_child_key => $_child_val);
             }
             $button['sub_button'] = $sub_button;
             unset($sub_button);
         }
         $send['button'][] = $button;
         unset($button);
     }
     return json_encode_cn($send);
 }
 /**
  * 判断如果是已经发布的菜单,重新编辑发布的话,先删除微信端以前发布过的菜单
  */
 function del_wweixinmenu_now($id)
 {
     //用户分组列表
     $map['token'] = get_token();
     $map['show'] = 1;
     $map['id'] = $id;
     $result = $this->where($map)->getField('menuid');
     if ($result) {
         $id = $result;
         $menuid = array();
         $menuid['menuid'] = $id;
         $menuid = json_encode_cn($menuid);
         //dump($menuid);die();
         $access_token = get_access_token();
         $url_post = 'https://api.weixin.qq.com/cgi-bin/menu/delconditional?access_token=' . $access_token;
         //$header [] = "content-type: application/x-www-form-urlencoded; charset=UTF-8";
         $res = D('CustomMenu')->curlGet($url_post, $method = 'post', $data = $menuid);
     }
 }