SDK菜单添加

master
Your Name 5 years ago
parent 45ff545256
commit 22e7866644

@ -0,0 +1,137 @@
<?php
namespace Admin\Controller;
class PersonalMenusController extends ThinkController{
public function lists()
{
$sdkMenus = M('tool','tab_')->where(['name' => 'personal_menu'])->find();
$config = json_decode($sdkMenus['config'],true);
if(!empty($config))
{
foreach($config as $k => $v)
{
$config[$k]['icon'] = is_https()?'https://':'http://' . $_SERVER['SERVER_NAME'] . $v['icon'];
}
}
$this->assign('list',$config);
$this->meta_title = '个人中心列表';
$this->display('lists');
}
public function add()
{
$sdkMenus = M('tool','tab_')->where(['name' => 'personal_menu'])->find();
$config = json_decode($sdkMenus['config'],true);
if(!empty($config))
{
$config1 = $config;
$id = array_pop($config1);
$id = $id['id'] + 1;
}else
{
$config = [];
$id = 1;
}
if(IS_POST)
{
$post = I('post.');
$post['id'] = $id;
array_push($config,$post);
$sdkMenus['config'] = json_encode($config);
if(empty($sdkMenus['name']))
{
$sdkMenus['name'] = 'personal_menu';
$sdkMenus['title'] = '个人中心列表';
$sdkMenus['status'] = 1;
$sdkMenus['create_time'] = time();
M('tool','tab_')->data($sdkMenus)->add();
}else
{
M('tool','tab_')->where(['name' => 'personal_menu'])->data($sdkMenus)->save();
}
$this->success('新增成功', U('lists'));
}
$data['sort'] = $id;
$this->meta_title = '个人中心列表';
$this->assign('type','add');
$this->assign('data',$data);
$this->display('add');
}
public function edit($id)
{
$sdkMenus = M('tool','tab_')->where(['name' => 'personal_menu'])->find();
$config = json_decode($sdkMenus['config'],true);
if(IS_POST)
{
foreach($config as $k => $v)
{
if($v['id'] == $id)
{
$post = I('post.');
foreach($post as $key => $val)
{
if($key == 'icon')
{
$config[$k][$key] = strstr($val,'/Upload');
}else
{
$config[$k][$key] = $val;
}
}
break;
}
}
$sdkMenus['config'] = json_encode($config);
M('tool','tab_')->where(['name' => 'personal_menu'])->data($sdkMenus)->save();
$this->success('修改成功', U('lists'));
}
$data = [];
foreach($config as $k => $v)
{
if($v['id'] == $id)
{
$v['icon'] = is_https()?'https://':'http://' . $_SERVER['SERVER_NAME'] . $v['icon'];
$data = $v;
break;
}
}
if(empty($data))
{
$this->error('菜单不存在','lists');
}
$this->meta_title = '个人中心列表';
$this->assign('type','edit');
$this->assign('data',$data);
$this->display('add');
}
public function del($id)
{
if(!is_array($id))
{
$data[] = $id;
}else
{
$data = $id;
}
$sdkMenus = M('tool','tab_')->where(['name' => 'personal_menu'])->find();
$config = json_decode($sdkMenus['config'],true);
foreach($config as $k => $v)
{
if(in_array($v['id'], $data))
{
unset($config[$k]);
}
}
$sdkMenus['config'] = json_encode($config);
M('tool','tab_')->where(['name' => 'personal_menu'])->data($sdkMenus)->save();
$this->success('删除成功', U('lists'));
}
}

@ -16,7 +16,7 @@ class SdkMenuController extends ThinkController{
}
}
$this->assign('list',$config);
$this->meta_title = 'SDk用户菜单';
$this->meta_title = '悬浮球菜单';
$this->display('lists');
}
@ -44,7 +44,7 @@ class SdkMenuController extends ThinkController{
if(empty($sdkMenus['name']))
{
$sdkMenus['name'] = 'sdk_menu';
$sdkMenus['title'] = 'SDK用户菜单';
$sdkMenus['title'] = '悬浮球菜单';
M('tool','tab_')->data($sdkMenus)->add();
}else
{
@ -54,7 +54,7 @@ class SdkMenuController extends ThinkController{
}
$data['sort'] = $id;
$this->meta_title = 'SDk用户菜单';
$this->meta_title = '悬浮球菜单';
$this->assign('type','add');
$this->assign('data',$data);
$this->display('add');
@ -102,7 +102,7 @@ class SdkMenuController extends ThinkController{
{
$this->error('菜单不存在','lists');
}
$this->meta_title = 'SDk用户菜单';
$this->meta_title = '悬浮球菜单';
$this->assign('type','edit');
$this->assign('data',$data);
$this->display('add');

@ -0,0 +1,152 @@
<extend name="Public/base"/>
<block name="body">
<script type="text/javascript" src="__STATIC__/uploadify/jquery.uploadify.min.js"></script>
<div class="cf main-place top_nav_list navtab_list">
<h3 class="page_title">{$meta_title}</h3>
<p class="description_text"></p>
</div>
<div class="tab-content tabcon1711 tabcon17112">
<IF condition="$type == edit">
<form action="{:U('edit')}" method="post" class="form-horizontal form_info_ml">
<else />
<form action="{:U('add')}" method="post" class="form-horizontal form_info_ml">
</IF>
<table border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td class="l noticeinfo">菜单名称</td>
<td class="r table_radio">
<input type="text" class="" name="name" value="{$data.name|default=''}" >
</td>
</tr>
<tr>
<td class="l noticeinfo">菜单标题</td>
<td class="r table_radio">
<input type="text" class="" name="title" value="{$data.title|default=''}" >
</td>
</tr>
<tr>
<td class="l noticeinfo">菜单链接</td>
<td class="r table_radio">
<input type="text" class="" name="url" value="{$data.url|default=''}" >
</td>
</tr>
<tr>
<td class="l noticeinfo">url类型</td>
<td class="r table_radio">
<span class="form_select">
<select name="type">
<IF condition="$data['type'] == '0'">
<option value="0" selected="selected">h5页面</option>
<option value="1">原生</option>
<ELSE />
<option value="1" selected="selected">原生</option>
<option value="0">h5页面</option>
</IF>
</select>
</span>
</td>
</tr>
<tr>
<td class="l noticeinfo">跳转目标</td>
<td class="r table_radio">
<input type="text" class="" name="act" value="{$data.act|default=''}" placeholder='url类型为原生时填写'>
</td>
</tr>
<tr>
<td class="l noticeinfo">IOS链接</td>
<td class="r table_radio">
<input type="text" class="" name="ios_url" value="{$data.ios_url|default=''}">
</td>
</tr>
<tr>
<td class="l noticeinfo">排序</td>
<td class="r table_radio">
<input type="text" class="" name="sort" value="{$data.sort|default=''}">
</td>
</tr>
<tr class="picbox">
<td class="l noticeinfo">菜单图标</td>
<td class="r table_radio">
<span class="form_icon table_btn table_upload">
<input type="file" id="upload_picture_icon">
<input type="hidden" name="icon" id="cover_id_icon" value="{$data.icon}" />
<div class="upload-img-box">
<notempty name="data['icon']">
<div class="upload-pre-item">
<span class="placeholder-graphic placeholder-graphic_icon"><img src="{$data['icon']}"/></span>
</div>
</notempty>
</div>
</span>
<span class="notice-text" style="left:215px;">菜单图标</span>
</td>
</tr>
</tbody>
</table>
<input type="hidden" name="id" value="{:I('id')}">
<script type="text/javascript">
//上传图片
/* 初始化上传插件 */
//上传游戏图标
/* 初始化上传插件 */
$("#upload_picture_icon").uploadify({
"height" : 30,
"swf" : "__STATIC__/uploadify/uploadify.swf",
"fileObjName" : "download",
"buttonText" : "上传图标",
"uploader" : "{:U('File/uploadPicture',array('session_id'=>session_id()))}",
"width" : 120,
'removeTimeout' : 1,
'fileTypeExts' : '*.jpg; *.jpeg; *.png; *.gif;',
"onUploadSuccess" : upload_picture_icon{$field.name},
'onFallback' : function() {
alert('未检测到兼容版本的Flash.');
}
});
function upload_picture_icon{$field.name}(file, data){
var data = $.parseJSON(data);
var src = '';
if(data.status){
src = data.path || data.url;
$("#cover_id_icon").val(src);
$("#cover_id_icon").parent().find('.upload-img-box').html(
'<div class="upload-pre-item"><span class="placeholder-graphic placeholder-graphic_icon"><img src="' + src + '"/></span></div>'
);
} else {
updateAlert(data.info);
setTimeout(function(){
$('#top-alert').find('button').click();
$(that).removeClass('disabled').prop('disabled',false);
},1500);
}
}
</script>
</form>
<div class="form-item cf">
<button class="submit_btn ajax-post mlspacing" id="submit" type="submit" target-form="form-horizontal">
保存
</button>
<a class="submit_btn " alt="返回上一页" title="返回上一页" href="javascript:window.history.back();" >
返回
</a>
</div>
</div>
</block>
<block name="script">
<script type="text/javascript" charset="utf-8">
//导航高亮
highlight_subnav('{:U('SdkMenu/lists')}');
</script>
</block>

@ -0,0 +1,177 @@
<extend name="Public/base"/>
<block name="body">
<div class="cf main-place top_nav_list navtab_list">
<h3 class="page_title">{$meta_title}</h3>
<p class="description_text"></p>
<div class="fr">
<a href="{:U('SdkMenu/lists')}">悬浮窗菜单</a>
<a class="tabchose" href="{:U('PersonalMenus/lists')}">个人用户中心菜单</a>
</div>
</div>
<div class="cf top_nav_list">
<div class="fl button_list">
<a class="" href="{:U('add')}"><span class="button_icon button_icon1"></span>新增</a>
<a class=" ajax-post confirm" url="{:U('del')}" target-form="ids"><span class="button_icon button_icon2"></span>删 除</a>
</div>
</div>
<div class="data_list">
<table style="text-align:center">
<thead>
<tr>
<th>
<input class="checkbox check-all" type="checkbox">
</th>
<th style="text-align:center">ID</th>
<th style="text-align:center">菜单名称</th>
<th style="text-align:center">菜单标题</th>
<th style="text-align:center">菜单图标</th>
<th style="text-align:center">菜单链接</th>
<th style="text-align:center">url类型</th>
<th style="text-align:center">跳转目标</th>
<th style="text-align:center">IOS链接</th>
<th style="text-align:center">排序</th>
<th style="text-align:center">操作</th>
</tr>
</thead>
<tbody>
<notempty name="list">
<volist name="list" id="channel">
<tr>
<td><input class="ids" type="checkbox" name="id[]" value="{$channel.id}"></td>
<td>{$channel.id}</td>
<td>{$channel.name}</td>
<td>{$channel.title}</td>
<td><img src="{$channel.icon}"></td>
<td>{$channel.url}</td>
<IF condition="$channel.type == 1">
<td>原生</td>
<ELSE />
<td>H5页面</td>
</IF>
<td>{$channel.act}</td>
<td>{$channel.ios_url}</td>
<td>
<div name="sort" data-title="{$channel.game_name} 排序设置" game-id="{$channel.id}" class="tab_not_same editTab">
<span class="w70">{$channel.sort}</span>
</div>
</td>
<td>
<a title="编辑" href="{:U('edit?id='.$channel['id'].'&pid='.$pid)}">编辑</a>
<a class="confirm ajax-get" title="删除" href="{:U('del?id='.$channel['id'])}">删除</a>
</td>
</tr>
</volist>
<else/>
<td colspan="11" class="text-center">aOh! 暂时还没有内容!</td>
</notempty>
</tbody>
</table>
</div>
<div class="page">
{$_page|default=''}
</div>
<div class="common_settings">
<span class="plus_icon"><span><img src="__IMG__/zwmimages/icon_jia.png"></span></span>
<form class="addShortcutIcon">
<input type="hidden" name="title" value="{$m_title}">
<input type="hidden" name="url" value="{$m_url}">
</form>
<a class="ajax-post add-butn <notempty name='commonset'>addSIsetted</notempty>" href="javascript:;" target-form="addShortcutIcon" url="{:U('Think/addShortcutIcon')}"><img src="__IMG__/zwmimages/icon_jia.png"><span><notempty name='commonset'>已添加<else />添加至常用设置</notempty></span></a>
</div>
</block>
<block name="script">
<script src="__STATIC__/layer/layer.js"></script>
<script src="__STATIC__/layer/extend/layer.ext.js"></script>
<script type="text/javascript">
//导航高亮
highlight_subnav('{:U('SdkMenu/lists')}');
Think.setValue('row',"{:I('row',10)}");
$(function() {
//点击排序
$('.list_sort').click(function(){
var url = $(this).attr('url');
var ids = $('.ids:checked');
var param = '';
if(ids.length > 0){
var str = new Array();
ids.each(function(){
str.push($(this).val());
});
param = str.join(',');
}
if(url != undefined && url != ''){
window.location.href = url + '/ids/' + param;
}
});
});
$('.editTab').click(function() {
var that = $(this),num = $.trim(that.children().text());
var id = that.attr('game-id');
var names = that.attr('name');
var title = that.attr('data-title');
layer.prompt({title:title,formType:0},function(value,index) {
if (!/^(?:0|[1-9][0-9]*)$/.test(value)) {
updateAlert('请输入正整数','tip_error');
setTimeout(function(){
$('#tip').find('.tipclose').click();
},2000);
return false;
}
layer.close(index);
var arr = {};
arr.id = id;
arr[names] = value;
$.ajax({
async: false,
url:"{:U('edit')}",
type:"POST",
dataType:"json",
data:arr,
success:function(result){
if(result.status){
//layer.msg('修改成功',{icon: 1});
updateAlert('修改成功');
setTimeout(function(){
$('#tip').find('.tipclose').click();
window.location.reload();
},2000);
}else{
//layer.msg('修改失败',{icon: 2});
updateAlert('修改失败','tip_error');
setTimeout(function(){
$('#tip').find('.tipclose').click();
},2000);
}
},
error:function(){
//layer.msg('服务器异常');
updateAlert('服务器异常','tip_error');
setTimeout(function(){
$('#tip').find('.tipclose').click();
},2000);
}
});
});
return false;
});
</script>
</block>

@ -62,7 +62,7 @@
<tr>
<td class="l noticeinfo">IOS链接</td>
<td class="r table_radio">
<input type="text" class="" name="ios_url" value="{$data.ios_url|default=''}" placeholder='url类型为原生时填写'>
<input type="text" class="" name="ios_url" value="{$data.ios_url|default=''}">
</td>
</tr>
<tr>

@ -6,9 +6,14 @@
<div class="cf main-place top_nav_list navtab_list">
<h3 class="page_title">{$meta_title}</h3>
<p class="description_text"></p>
<div class="fr">
<a class="tabchose" href="{:U('SdkMenu/lists')}">悬浮窗菜单</a>
<a href="{:U('PersonalMenus/lists')}">个人用户中心菜单</a>
</div>
</div>
<div class="cf top_nav_list">
<div class="fl button_list">
<a class="" href="{:U('add')}"><span class="button_icon button_icon1"></span>新增</a>
<a class=" ajax-post confirm" url="{:U('del')}" target-form="ids"><span class="button_icon button_icon2"></span>删 除</a>
@ -63,7 +68,7 @@
</tr>
</volist>
<else/>
<td colspan="9" class="text-center">aOh! 暂时还没有内容!</td>
<td colspan="11" class="text-center">aOh! 暂时还没有内容!</td>
</notempty>
</tbody>
</table>

@ -447,6 +447,7 @@ function showBtn() {
//导航高亮
function highlight_subnav(url){
console.log(url)
$('.side-sub-menu').find('a[href="'+url+'"]').closest('li').addClass('current');
/*显示选中的菜单*/
$('.side-sub-menu').find("a[href='" + url + "']").parent().parent().prev("h3").removeClass('no').find("i").removeClass("icon-fold");

Loading…
Cancel
Save