Commit 8e67668c authored by ZhuChunYang's avatar ZhuChunYang

update

parent da9cd7a3
......@@ -150,5 +150,26 @@ class ApplicationCategoryController extends BaseController
return ['code' => 1, 'msg' => 'failed'];
}
public function actionSetEnable()
{
if (Yii::$app->request->isAjax) {
Yii::$app->response->format = 'json';
$request = Yii::$app->request;
$id = $request->get('id', '');
$enable = $request->get('enable',1);
if($id){
$category = CoinApplicationCategory::getCategoryById($id);
if(!$category){
return ['code' => 1,'msg' =>'分类不存在,不能设置启用状态'];
}
$category->enable = $enable;
$category->save();
return ['code' => 0,'msg' => '分类使用状态设置成功'];
}else{
return ['code' => 1 ,'msg' => '分类使用状态设置失败'];
}
}
}
}
\ No newline at end of file
......@@ -240,4 +240,25 @@ class ApplicationController extends BaseController
}
}
public function actionSetEnable()
{
if (Yii::$app->request->isAjax) {
Yii::$app->response->format = 'json';
$request = Yii::$app->request;
$id = $request->get('id', '');
$enable = $request->get('enable',1);
if($id){
$applicate = CoinApplication::getApplicate($id);
if(!$applicate){
return ['code' => 1,'msg' =>'应用不存在,不能设置启用状态'];
}
$applicate->enable = $enable;
$applicate->save();
return ['code' => 0,'msg' => '应用使用状态设置成功'];
}else{
return ['code' => 1 ,'msg' => '应用使用状态设置失败'];
}
}
}
}
\ No newline at end of file
......@@ -110,7 +110,10 @@
<a class="layui-btn layui-btn-normal layui-btn-xs" href="/admin/application-category/banner-index?id={{d.id}}" >banner图管理</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' : '' }}>
<input type="checkbox" name="isrecommend" value="{{d.id}}" lay-skin="switch" lay-text="是|否" lay-filter="recommendDemo" {{ d.isrecommend == 1 ? 'checked' : '' }}>
</script>
<script type="text/html" id="enableTpl">
<input type="checkbox" name="isenable" value="{{d.id}}" lay-skin="switch" lay-text="启用|禁用" lay-filter="enableDemo" {{ d.enable == 1 ? 'checked' : '' }}>
</script>
<script type="text/javascript">
......@@ -159,6 +162,13 @@
title: '首页推荐',
field: 'isrecommend',
templet: '#recommendTpl',
width: 100
},
{
title: '状态',
field: 'enable',
templet: '#enableTpl',
width: 100
},
]],
......@@ -334,6 +344,23 @@
}
});
form.on('switch(enableDemo)', function(obj){
var enable = 1;
if(obj.elem.checked){
enable = 1
}else{
enable = 0;
}
$.get('/admin/application-category/set-enable', {id:this.value,enable:enable}, function(rev) {
layer.msg(rev.msg);
if (0 == rev.code) {
}else{
}
});
});
//监听单元格编辑
table.on('edit(table1)', function(obj){
var value = obj.value; //得到修改后的值
......
......@@ -63,6 +63,9 @@
<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' : '' }}>
</script>
<script type="text/html" id="enableTpl">
<input type="checkbox" name="isenable" value="{{d.id}}" lay-skin="switch" lay-text="启用|禁用" lay-filter="enableDemo" {{ d.enable == 1 ? 'checked' : '' }}>
</script>
<script type="text/javascript">
var form = layui.form;
form.render();
......@@ -139,6 +142,13 @@
title: '首页推荐',
field: 'isrecommend',
templet: '#recommendTpl',
width: 100
},
{
title: '状态',
field: 'enable',
templet: '#enableTpl',
width: 100
},
]],
});
......@@ -236,6 +246,22 @@
}
});
form.on('switch(enableDemo)', function(obj){
var enable = 1;
if(obj.elem.checked){
enable = 1
}else{
enable = 0;
}
$.get('/admin/application/set-enable', {id:this.value,enable:enable}, function(rev) {
layer.msg(rev.msg);
if (0 == rev.code) {
}else{
}
});
});
//监听单元格编辑
table.on('edit(table1)', function(obj){
var value = obj.value; //得到修改后的值
......
......@@ -91,7 +91,7 @@ class CoinApplication extends BaseActiveRecord
{
$coin_applicate_Model = CoinApplication::find();
$query = $coin_applicate_Model->JoinWith(['appCate'], false)
->select(CoinApplication::tableName().'.id,name,icon,type,native_url,h5_url,android_url,ios_url,app_store_url,advertise,description,redirect_type,'.CoinAppCate::tableName().'.sort as sort')
->select(CoinApplication::tableName().'.id,name,icon,type,native_url,h5_url,android_url,ios_url,app_store_url,advertise,description,enable,redirect_type,'.CoinAppCate::tableName().'.sort as sort')
->orderBy(CoinAppCate::tableName().'.sort asc')->where(['cate_id' => $category_id]);
$count = $query->count();
$data = $query->offset(($page - 1) * 10)->limit($limit)->asArray()->all();
......
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