sdk菜单配置修改

master
zhanglingsheng 5 years ago
parent 14e36e31bb
commit 3453de757f

@ -2,7 +2,8 @@
namespace Admin\Controller;
class SdkMenuController extends ThinkController{
class SdkMenuController extends ThinkController
{
public $but_type = [
'0' => 'h5页面',
@ -22,10 +23,8 @@ class SdkMenuController extends ThinkController{
$menu_name = I('get.menu_name', 'sdk_menu');
$sdkMenus = M('tool', 'tab_')->where(['name' => $menu_name])->find();
$config = json_decode($sdkMenus['config'], true);
if(!empty($config))
{
foreach($config as $k => $v)
{
if (!empty($config)) {
foreach ($config as $k => $v) {
$config[$k]['icon'] = is_https() ? 'https://' : 'http://' . $_SERVER['HTTP_HOST'] . $v['icon'];
$config[$k]['type'] = $this->but_type[$v['type']];
$config[$k]['menu_version'] = $this->menu_version[$v['menu_version']];
@ -43,32 +42,27 @@ class SdkMenuController extends ThinkController{
$menu_name = I('get.menu_name', 'sdk_menu');
$sdkMenus = M('tool', 'tab_')->where(['name' => $menu_name])->find();
$config = json_decode($sdkMenus['config'], true);
if(!empty($config))
{
if (!empty($config)) {
$config1 = $config;
$id = array_pop($config1);
$id = $id['id'] + 1;
}else
{
} else {
$config = [];
$id = 1;
}
if(IS_POST)
{
if (IS_POST) {
$post = I('post.');
$cover = $_REQUEST['icon'];
$post['cover'] = $cover;
$post['cover'] = $post['icon'];
$post['id'] = $id;
$post['icon'] = get_cover($post['icon'], "path");
array_push($config, $post);
$sdkMenus['config'] = json_encode($config);
if(empty($sdkMenus['name']))
{
if (empty($sdkMenus['name'])) {
$sdkMenus['name'] = $menu_name;
$sdkMenus['title'] = '悬浮球菜单';
M('tool', 'tab_')->data($sdkMenus)->add();
}else
{
} else {
M('tool', 'tab_')->where(['name' => $menu_name])->data($sdkMenus)->save();
}
$this->success('新增成功', U('lists', ['menu_name' => $menu_name]));
@ -89,25 +83,16 @@ class SdkMenuController extends ThinkController{
$menu_name = I('get.menu_name', 'sdk_menu');
$sdkMenus = M('tool', 'tab_')->where(['name' => $menu_name])->find();
$config = json_decode($sdkMenus['config'], true);
if(IS_POST)
{
foreach($config as $k => $v)
{
if($v['id'] == $id)
{
if (IS_POST) {
foreach ($config as $k => $v) {
if ($v['id'] == $id) {
$post = I('post.');
foreach($post as $key => $val)
{
if($key == 'icon')
{
$picRes = M('picture')->where(['id'=>intval($val)])->find();
$path = $picRes['path'];
$config[$k][$key] = $path;
$config[$k]['cover'] = $val;
}else
{
$config[$k][$key] = $val;
$config[$k]['cover'] = '';
foreach ($post as $key => $val) {
if ($key == 'icon') {
$config[$k]['cover'] = $post['icon'];
$config[$k]['icon'] = get_cover($post['icon'], "path");
} else {
$config[$k][$key] = $post[$key];
}
}
break;
@ -118,17 +103,13 @@ class SdkMenuController extends ThinkController{
$this->success('修改成功', U('lists', ['menu_name' => $menu_name]));
}
$data = [];
foreach($config as $k => $v)
{
if($v['id'] == $id)
{
$v['icon'] = is_https()?'https://':'http://' . $_SERVER['HTTP_HOST'] . $v['icon'];
foreach ($config as $k => $v) {
if ($v['id'] == $id) {
$data = $v;
break;
}
}
if(empty($data))
{
if (empty($data)) {
$this->error('菜单不存在', 'lists');
}
$img[0] = $data['cover'];
@ -142,23 +123,18 @@ class SdkMenuController extends ThinkController{
$this->display('add');
}
public function del($id)
{
$menu_name = I('get.menu_name', 'sdk_menu');
if(!is_array($id))
{
if (!is_array($id)) {
$data[] = $id;
}else
{
} else {
$data = $id;
}
$sdkMenus = M('tool', 'tab_')->where(['name' => $menu_name])->find();
$config = json_decode($sdkMenus['config'], true);
foreach($config as $k => $v)
{
if(in_array($v['id'], $data))
{
foreach ($config as $k => $v) {
if (in_array($v['id'], $data)) {
unset($config[$k]);
}
}

Loading…
Cancel
Save