Commit d5745a9b authored by ZhuChunYang's avatar ZhuChunYang

update

parent 881be1ed
......@@ -78,11 +78,33 @@ class ApplicateRecommendController extends BaseController
{
if(Yii::$app->request->isAjax){
Yii::$app->response->format = 'json';
$data = CoinApplicateRecommend::find()->asArray()->all();
$data = CoinApplicateRecommend::find()->orderBy('sort asc')->asArray()->all();
return [ 'data' =>$data, 'code' => 0];
}
return $this->render('index');
}
public function actionSetSort()
{
if (Yii::$app->request->isAjax) {
Yii::$app->response->format = 'json';
$request = Yii::$app->request;
$id = $request->get('id', '');
$type = $request->get('type','');
$sort = $request->get('sort',1);
if($id && $type){
$recommend = CoinApplicateRecommend::getRecommend($id,$type);
if(!$recommend){
return ['code' => 1,'msg' =>'首页推荐不存在,不能设置排序'];
}
$recommend->sort=$sort;
$recommend->save();
return ['code' => 0,'msg' => '首页推荐排序设置成功'];
}else{
return ['code' => 1 ,'msg' => '首页推荐排序设置失败'];
}
}
}
}
\ No newline at end of file
......@@ -44,7 +44,8 @@
},
{
field: 'sort',
title: '排序'
title: '排序',
edit: 'text'
},
{
......@@ -73,7 +74,19 @@
});
}
});
//监听单元格编辑
table.on('edit(table1)', function(obj){
var value = obj.value; //得到修改后的值
var data = obj.data; //得到所在行所有键值
$.get('/admin/applicate-recommend/set-sort', {id:data.relate_id,type:data.type,sort:value}, function(rev) {
layer.msg(rev.msg);
if (0 == rev.code) {
table.reload('table1',{});
}else{
}
});
});
</script>
\ No newline at end of file
......@@ -156,27 +156,7 @@
field: 'isrecommend',
templet: '#recommendTpl',
},
{
field: 'icon',
title: '图标',
hide:true,
width:50
},
{
field: 'banner_url',
title: 'banner链接',
hide:true,
width:50
},
{
field: 'banner_image_url',
title: 'banner图片链接',
hide:true,
width:50
},
]],
});
......
......@@ -50,6 +50,7 @@
<a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
<a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="add_category">添加所属分类</a>
<a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="image_info">详情图管理</a>
</script>
<script type="text/html" id="recommendTpl">
<input type="checkbox" name="isrecommend" value="{{d.id}}" lay-skin="switch" lay-text="是|否" lay-filter="recommendDemo" {{ d.isrecommend == 1 ? 'checked' : '' }}>
......@@ -130,13 +131,6 @@
field: 'isrecommend',
templet: '#recommendTpl',
},
{
field: 'icon',
title: '图标',
hide:true,
width:50
},
]],
});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment