Commit 5a848615 authored by shajiaiming's avatar shajiaiming

Merge branch 'feature/optimize' into 'master'

Feature/optimize See merge request !64
parents 7a940eae ad418f78
...@@ -31,8 +31,22 @@ class ApplicationController extends BaseController ...@@ -31,8 +31,22 @@ class ApplicationController extends BaseController
} }
$recommendData = ApplicationBusiness::getRecommendList($condition); $recommendData = ApplicationBusiness::getRecommendList($condition);
foreach($recommendData as $j => &$val){
$name_arr = json_decode($val['name'], true);
$val['name'] = $name_arr[$this->lang];
}
$data['recommend'] =$recommendData; $data['recommend'] =$recommendData;
$cate_app_data = ApplicationBusiness::getCategoryAppList($condition); $cate_app_data = ApplicationBusiness::getCategoryAppList($condition);
foreach ($cate_app_data as $key => &$val){
$name = json_decode($val['name'], true);
$val['name'] = $name[$this->lang];
if(!empty($val['apps'])){
foreach($val['apps'] as $j => &$value){
$name = json_decode($value['name'], true);
$value['name'] = $name[$this->lang];
}
}
}
$data['cate_app_data'] = $cate_app_data; $data['cate_app_data'] = $cate_app_data;
$data['banner'] = ApplicationBusiness::getBannerList($condition); $data['banner'] = ApplicationBusiness::getBannerList($condition);
$result['code'] = 0; $result['code'] = 0;
...@@ -48,6 +62,16 @@ class ApplicationController extends BaseController ...@@ -48,6 +62,16 @@ class ApplicationController extends BaseController
{ {
$result['code'] = 0; $result['code'] = 0;
$result['data'] = ApplicationBusiness::getCategoryAppList(); $result['data'] = ApplicationBusiness::getCategoryAppList();
foreach ($result['data'] as $key => &$val){
$name = json_decode($val['name'], true);
$val['name'] = $name[$this->lang];
if(!empty($val['apps'])){
foreach($val['apps'] as $j => &$value){
$name = json_decode($value['name'], true);
$value['name'] = $name[$this->lang];
}
}
}
return $result; return $result;
} }
...@@ -59,7 +83,11 @@ class ApplicationController extends BaseController ...@@ -59,7 +83,11 @@ class ApplicationController extends BaseController
$request = Yii::$app->request; $request = Yii::$app->request;
$id = $request->post('id',0); $id = $request->post('id',0);
if($id){ if($id){
return ApplicationBusiness::appInfo($id); $result = ApplicationBusiness::appInfo($id);
$data = $result['data'];
$name = json_decode($data['name'], true);
$data['name'] = $name[$this->lang];
return ['code' => 0,'data' => $data];
}else{ }else{
return ['code' => 1,'data' => [],'msg' => 'id不能为空']; return ['code' => 1,'data' => [],'msg' => 'id不能为空'];
} }
...@@ -126,6 +154,8 @@ class ApplicationController extends BaseController ...@@ -126,6 +154,8 @@ class ApplicationController extends BaseController
$icon_Items = array_column($appItems,'icon'); $icon_Items = array_column($appItems,'icon');
$icon_Infos = CoinImage::getItemsByIds($icon_Items); $icon_Infos = CoinImage::getItemsByIds($icon_Items);
foreach($appItems as &$value){ foreach($appItems as &$value){
$name = json_decode($value['name'], true);
$value['name'] = $name[$this->lang];
if($value['icon']){ if($value['icon']){
$value['icon'] = $icon_Infos[$value['icon']]['base_url'].$icon_Infos[$value['icon']]['file_url']; $value['icon'] = $icon_Infos[$value['icon']]['base_url'].$icon_Infos[$value['icon']]['file_url'];
}else{ }else{
...@@ -138,7 +168,9 @@ class ApplicationController extends BaseController ...@@ -138,7 +168,9 @@ class ApplicationController extends BaseController
$cate_id = $item['cate_id']; $cate_id = $item['cate_id'];
$app_id = $item['app_id']; $app_id = $item['app_id'];
$cate_app_items[$cate_id]['cate_id'] = $cate_id; $cate_app_items[$cate_id]['cate_id'] = $cate_id;
$cate_app_items[$cate_id]['name'] = $item['name']; $name_arr = json_decode($item['name'], true);
$name = $name_arr[$this->lang];
$cate_app_items[$cate_id]['name'] = $name;
$cate_app_items[$cate_id]['apps'][] = $appItems[$app_id]; $cate_app_items[$cate_id]['apps'][] = $appItems[$app_id];
} }
foreach ($cate_app_items as $item){ foreach ($cate_app_items as $item){
...@@ -159,13 +191,16 @@ class ApplicationController extends BaseController ...@@ -159,13 +191,16 @@ class ApplicationController extends BaseController
$cate_id = $request->get('cate_id',''); $cate_id = $request->get('cate_id','');
if($cate_id){ if($cate_id){
$cate_info = CoinApplicationCategory::getCategoryById($cate_id); $cate_info = CoinApplicationCategory::getCategoryById($cate_id);
$name = $cate_info->name[$this->lang];
$cate_info_data['id'] = $cate_info->id; $cate_info_data['id'] = $cate_info->id;
$cate_info_data['name'] = $cate_info->name; $cate_info_data['name'] = $name;
$appItems = ApplicationBusiness::getCateAppInfo(0,[['cate_id' => $cate_id]]); $appItems = ApplicationBusiness::getCateAppInfo(0,[['cate_id' => $cate_id]]);
if($appItems){ if($appItems){
$appItems = array_shift($appItems); $appItems = array_shift($appItems);
foreach($appItems as &$value){ foreach($appItems as &$value){
$value['app_user_num'] = ApplicationBusiness::getAppUserNum($value['app_id']); $value['app_user_num'] = ApplicationBusiness::getAppUserNum($value['app_id']);
$name_arr = json_decode($value['name'], true);
$value['name'] = $name_arr[$this->lang];
} }
$cate_info_data['apps'] = $appItems; $cate_info_data['apps'] = $appItems;
return ['code' => 0,'data' => $cate_info_data]; return ['code' => 0,'data' => $cate_info_data];
......
<?php
/**
* Created By Sublime Text 3
*
* @authors rlgy <rlgyzhcn@qq.com>
* @date 2018-09-07 17:41:04
*/
namespace backend\assets\applicationCategory;
use yii\web\AssetBundle;
use yii\web\View;
class IndexAsset extends AssetBundle
{
public $sourcePath = '@backend/web/js/application-category';
public $js = [
'index.js',
];
public $jsOptions = [
'position' => View::POS_END,
];
}
\ No newline at end of file
This diff is collapsed.
<?php
/**
* Created by PhpStorm.
* User: rlgyzhcn
* Date: 18-5-31
* Time: 下午6:23
*/
?>
<h4>添加应用分类</h4>
<style>
.layui-form-label {
width: 100px;
}
</style>
<div class="layui-row" style="padding: 5px;">
<div class="layui-col-md12">
<form class="layui-form" method="post" action="" id="application-category-edit">
<input name="_csrf" type="hidden" value="<?= Yii::$app->request->getCsrfToken() ?>">
<input name="id" type="hidden" value="">
<div class="layui-inline">
<label class="layui-form-label">中文名</label>
<div class="layui-input-block" style="width: 250px">
<input class="layui-input" name="name[]" required lay-verify="required" placeholder=""
autocomplete="off" value=""
class="layui-input">
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label">英文名</label>
<div class="layui-input-block" style="width: 250px">
<input class="layui-input" name="name[]" value="">
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label">日文名</label>
<div class="layui-input-block" style="width: 250px">
<input class="layui-input" name="name[]" value="">
</div>
</div>
<div class="layui-form-item layui-form-text">
<label class="layui-form-label">排序</label>
<div class="layui-input-block" style="width: 250px">
<input type="text" name="sort" required lay-verify="required" placeholder=""
autocomplete="off" value=""
class="layui-input">
</div>
</div>
<div class="layui-form-item">
<div class="layui-inline">
<label class="layui-form-label">图标</label>
<div class="layui-input-block">
<img src="" style="margin-top: 11px; max-width: 32px; max-height: 32px"
id="icon1">
</div>
<input type="hidden" name="icon" value="">
</div>
<div class="layui-inline" style="margin-left: 50px;">
<button type="button" class="layui-btn" id="upload1" style="">
<i class="layui-icon">&#xe67c;</i>上传新图片
</button>
</div>
</div>
<div class="layui-form-item">
<div class="layui-inline">
<label class="layui-form-label">banner</label>
<div class="layui-input-block">
<img src="" style="margin-top: 11px; max-width: 32px; max-height: 32px" id="icon2">
</div>
<input type="hidden" name="banner" value="">
</div>
<div class="layui-inline" style="margin-left: 50px;">
<button type="button" class="layui-btn" id="upload2" style="">
<i class="layui-icon">&#xe67c;</i>上传新图片
</button>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">banner链接</label>
<div class="layui-input-block" style="width: 500px">
<input type="text" name="banner_url" required lay-verify="required" placeholder=""
autocomplete="off" class="layui-input" value="">
</div>
</div>
<div class="layui-form-item">
<button class="layui-btn">提交</button>
</div>
</form>
</div>
</div>
<script>
var laydate = layui.laydate;
laydate.render({
elem: "#time1"
});
//图片上传
var uploader = layui.upload;
$_csrf = $("input[name='_csrf']").val();
uploader.render({
elem: "#upload1",
url: '/admin/image/upload',
data: {_csrf: $_csrf},
done: function (res) {
if(res.code == 0){
$("input[name='icon']").val(res.data.image_id);
$("#icon1").attr('src', res.data.image_src);
}
},
error: function (res) {
}
});
uploader.render({
elem: "#upload2",
url: '/admin/image/upload',
data: {_csrf: $_csrf,image_type:2},
done: function (res) {
if(res.code == 0){
$("input[name='banner']").val(res.data.image_id);
$("#icon2").attr('src', res.data.image_src);
}
},
error: function (res) {
}
});
//form render
var form = layui.form;
form.render();
</script>
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
width: 100px; width: 100px;
} }
</style> </style>
<h4>所属分类---<?= $applicate_category->name ?></h4> <h4>所属分类---<?= $applicate_category->name["zh-CN"] ?></h4>
<div class="layui-row" style="padding: 5px;"> <div class="layui-row" style="padding: 5px;">
<div class="layui-tab layui-tab-card"> <div class="layui-tab layui-tab-card">
<ul class="layui-tab-title"> <ul class="layui-tab-title">
......
<?php
/**
* Created by PhpStorm.
* User: rlgyzhcn
* Date: 18-5-31
* Time: 下午6:23
*/
?>
<style>
.layui-form-label {
width: 100px;
}
</style>
<div class="layui-row" style="padding: 5px;">
<div class="layui-col-md12">
<form class="layui-form" method="post" action="" id="application-category-edit">
<input name="_csrf" type="hidden" value="<?= Yii::$app->request->getCsrfToken() ?>">
<input name="id" type="hidden" value="<?= $model['id'] ?>">
<div class="layui-inline">
<label class="layui-form-label">中文名</label>
<div class="layui-input-block" style="width: 250px">
<input class="layui-input" name="name[]" value="<?= $model['name_zh'] ?>">
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label">英文名</label>
<div class="layui-input-block" style="width: 250px">
<input class="layui-input" name="name[]" value="<?= $model['name_en'] ?>">
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label">日文名</label>
<div class="layui-input-block" style="width: 250px">
<input class="layui-input" name="name[]" value="<?= $model['name_ja'] ?>">
</div>
</div>
<div class="layui-form-item layui-form-text">
<label class="layui-form-label">排序</label>
<div class="layui-input-block" style="width: 250px">
<input type="text" name="sort" required lay-verify="required" placeholder=""
autocomplete="off" value="<?= $model['sort'] ?>"
class="layui-input">
</div>
</div>
<div class="layui-form-item">
<div class="layui-inline">
<label class="layui-form-label">图标</label>
<div class="layui-input-block">
<img src="<?= $model['icon_url'] ?>" style="margin-top: 11px; max-width: 32px; max-height: 32px"
id="icon1">
</div>
<input type="hidden" name="icon" value="<?= $model['icon'] ?>">
</div>
<div class="layui-inline" style="margin-left: 50px;">
<button type="button" class="layui-btn" id="upload1" style="">
<i class="layui-icon">&#xe67c;</i>上传新图片
</button>
</div>
</div>
<div class="layui-form-item">
<div class="layui-inline">
<label class="layui-form-label">banner</label>
<div class="layui-input-block">
<img src="<?= $model['banner_image_url'] ?>" style="margin-top: 11px; max-width: 32px; max-height: 32px" id="icon2">
</div>
<input type="hidden" name="banner" value="<?= $model['banner'] ?>">
</div>
<div class="layui-inline" style="margin-left: 50px;">
<button type="button" class="layui-btn" id="upload2" style="">
<i class="layui-icon">&#xe67c;</i>上传新图片
</button>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">banner链接</label>
<div class="layui-input-block">
<input type="text" name="banner_url" required lay-verify="required" placeholder=""
autocomplete="off" class="layui-input" value="<?= $model['banner_url'] ?>">
</div>
</div>
</form>
</div>
</div>
<script>
var laydate = layui.laydate;
laydate.render({
elem: "#time1"
});
//图片上传
var uploader = layui.upload;
$_csrf = $("input[name='_csrf']").val();
uploader.render({
elem: "#upload1",
url: '/admin/image/upload',
data: {_csrf: $_csrf},
done: function (res) {
if(res.code == 0){
$("input[name='icon']").val(res.data.image_id);
$("#icon1").attr('src', res.data.image_src);
}
},
error: function (res) {
}
});
uploader.render({
elem: "#upload2",
url: '/admin/image/upload',
data: {_csrf: $_csrf,image_type:2},
done: function (res) {
if(res.code == 0){
$("input[name='banner']").val(res.data.image_id);
$("#icon2").attr('src', res.data.image_src);
}
},
error: function (res) {
}
});
//form render
var form = layui.form;
form.render();
</script>
...@@ -46,9 +46,21 @@ ...@@ -46,9 +46,21 @@
</div> </div>
</div> </div>
<div class="layui-form-item"> <div class="layui-form-item">
<label class="layui-form-label">应用名称</label> <label class="layui-form-label">中文名</label>
<div class="layui-input-block"> <div class="layui-input-block">
<input class="layui-input" name="name" value="" lay-verify="required"> <input class="layui-input" name="name[]" value="" lay-verify="required">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">英文名</label>
<div class="layui-input-block">
<input class="layui-input" name="name[]" value="" lay-verify="required">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">日文名</label>
<div class="layui-input-block">
<input class="layui-input" name="name[]" value="" lay-verify="required">
</div> </div>
</div> </div>
<div class="layui-form-item"> <div class="layui-form-item">
......
...@@ -48,9 +48,21 @@ ...@@ -48,9 +48,21 @@
</div> </div>
</div> </div>
<div class="layui-form-item"> <div class="layui-form-item">
<label class="layui-form-label">应用名称</label> <label class="layui-form-label">中文名</label>
<div class="layui-input-block"> <div class="layui-input-block">
<input class="layui-input" name="name" value="<?= $item['name'] ?>" lay-verify="required"> <input class="layui-input" name="name[]" value="<?= $item['name_zh'] ?>" lay-verify="required">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">英文名</label>
<div class="layui-input-block">
<input class="layui-input" name="name[]" value="<?= $item['name_en'] ?>" lay-verify="required">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">日文名</label>
<div class="layui-input-block">
<input class="layui-input" name="name[]" value="<?= $item['name_ja'] ?>" lay-verify="required">
</div> </div>
</div> </div>
<div class="layui-form-item"> <div class="layui-form-item">
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
width: 100px; width: 100px;
} }
</style> </style>
<h4>所属分类---<?= $parent_category->name ?></h4> <h4>所属分类---<?= $parent_category->name["zh-CN"] ?></h4>
<div class="layui-row" style="padding: 5px;"> <div class="layui-row" style="padding: 5px;">
<div class="layui-col-md1"> <div class="layui-col-md1">
<a href="/admin/application/add?category_id=<?= $parent_category->id ?>"> <a href="/admin/application/add?category_id=<?= $parent_category->id ?>">
...@@ -58,13 +58,15 @@ ...@@ -58,13 +58,15 @@
<a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a> <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-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-normal layui-btn-xs" lay-event="add_category">添加所属分类</a>
<a class="layui-btn layui-btn-primary layui-btn-xs" href="/admin/application/image-index?id={{d.id}}" >详情图管理</a> <a class="layui-btn layui-btn-primary layui-btn-xs" href="/admin/application/image-index?id={{d.id}}">详情图管理</a>
</script> </script>
<script type="text/html" id="recommendTpl"> <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>
<script type="text/html" id="enableTpl"> <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' : '' }}> <input type="checkbox" name="isenable" value="{{d.id}}" lay-skin="switch" lay-text="启用|禁用" lay-filter="enableDemo"
{{ d.enable== 1 ? 'checked' : '' }}>
</script> </script>
<script type="text/javascript"> <script type="text/javascript">
var form = layui.form; var form = layui.form;
...@@ -75,7 +77,7 @@ ...@@ -75,7 +77,7 @@
elem: '#table1', elem: '#table1',
page: true, page: true,
limit: 10, limit: 10,
url: '/admin/application/list?id='+category_id, url: '/admin/application/list?id=' + category_id,
cols: [[ cols: [[
{ {
field: 'id', field: 'id',
...@@ -84,6 +86,11 @@ ...@@ -84,6 +86,11 @@
{ {
field: 'name', field: 'name',
title: '名称', title: '名称',
templet: function (data) {
var name = JSON.parse(data.name);
console.log(typeof (data.name), name.zh);
return name.zh
}
}, },
{ {
...@@ -99,10 +106,10 @@ ...@@ -99,10 +106,10 @@
{ {
field: 'has_h5', field: 'has_h5',
title: 'h5', title: 'h5',
templet: function(d){ templet: function (d) {
if(d.has_h5){ if (d.has_h5) {
return "有"; return "有";
}else{ } else {
return "无"; return "无";
} }
} }
...@@ -110,10 +117,10 @@ ...@@ -110,10 +117,10 @@
{ {
field: 'has_android', field: 'has_android',
title: '安卓', title: '安卓',
templet: function(d){ templet: function (d) {
if(d.has_android){ if (d.has_android) {
return "有"; return "有";
}else{ } else {
return "无"; return "无";
} }
} }
...@@ -121,14 +128,14 @@ ...@@ -121,14 +128,14 @@
{ {
field: 'has_ios', field: 'has_ios',
title: 'ios', title: 'ios',
templet: function(d){ templet: function (d) {
if(d.has_ios === 3){ if (d.has_ios === 3) {
return "企业版/商店版"; return "企业版/商店版";
}else if(d.has_ios === 2){ } else if (d.has_ios === 2) {
return "商店版"; return "商店版";
}else if(d.has_ios === 1){ } else if (d.has_ios === 1) {
return "企业版"; return "企业版";
}else{ } else {
return "无"; return "无";
} }
} }
...@@ -153,15 +160,15 @@ ...@@ -153,15 +160,15 @@
]], ]],
}); });
table.on('tool(table1)', function(obj) { table.on('tool(table1)', function (obj) {
var data = obj.data; var data = obj.data;
var event = obj.event; var event = obj.event;
if (event === 'edit') { if (event === 'edit') {
$.get('/admin/application/edit', {id: data.id,category_id:category_id}, function (str) { $.get('/admin/application/edit', {id: data.id, category_id: category_id}, function (str) {
var editIndex = layer.open({ var editIndex = layer.open({
type: 1, type: 1,
title: '编辑: ' + data.name, title: '编辑: ' + data.name,
area: ['625px','800px'], area: ['625px', '800px'],
content: str, content: str,
btn: ['保存', '取消'], btn: ['保存', '取消'],
btn1: function () { btn1: function () {
...@@ -182,31 +189,31 @@ ...@@ -182,31 +189,31 @@
}); });
} else if ('del' === event) { } else if ('del' === event) {
var index = layer.confirm("确认删除?", {icon: 3, title: '删除'}, function () { var index = layer.confirm("确认删除?", {icon: 3, title: '删除'}, function () {
$.get('/admin/application/delete', {id: data.id,category_id:category_id}, function (rev) { $.get('/admin/application/delete', {id: data.id, category_id: category_id}, function (rev) {
layer.msg(rev.msg); layer.msg(rev.msg);
if (0==rev.code) { if (0 == rev.code) {
table.reload('table1',{ table.reload('table1', {
page:{curr:1} page: {curr: 1}
}); });
} }
}); });
}); });
}else if ('add_category' === event) { } else if ('add_category' === event) {
$("#app_id").val(data.id); $("#app_id").val(data.id);
var index = layer.open({ var index = layer.open({
title: '添加应用分类', title: '添加应用分类',
area: ['500px','400px'], area: ['500px', '400px'],
type: 1, type: 1,
content: $("#_form"), content: $("#_form"),
btn: ['保存', '取消'], btn: ['保存', '取消'],
success: function() { success: function () {
form.val("form1", { form.val("form1", {
cate_id: 0, cate_id: 0,
sort: '', sort: '',
}); });
}, },
btn1: function() { btn1: function () {
$.post('/admin/application/add-category', $("#form1").serialize(), function(rev) { $.post('/admin/application/add-category', $("#form1").serialize(), function (rev) {
layer.msg(rev.msg); layer.msg(rev.msg);
if (0 == rev.code) { if (0 == rev.code) {
layer.close(index); layer.close(index);
...@@ -214,63 +221,63 @@ ...@@ -214,63 +221,63 @@
} }
}); });
}, },
btn2: function() { btn2: function () {
layer.close(index); layer.close(index);
$("#_form").css('display', 'none'); $("#_form").css('display', 'none');
}, },
cancel: function() { cancel: function () {
layer.close(index); layer.close(index);
$("#_form").css('display', 'none'); $("#_form").css('display', 'none');
} }
}); });
} }
}); });
form.on('switch(recommendDemo)', function(obj){ form.on('switch(recommendDemo)', function (obj) {
//layer.tips(this.value + ' ' + this.name + ':'+ obj.elem.checked, obj.othis);return; //layer.tips(this.value + ' ' + this.name + ':'+ obj.elem.checked, obj.othis);return;
if(obj.elem.checked){ if (obj.elem.checked) {
$.get('/admin/applicate-recommend/add', {id:this.value,type:2}, function(rev) { $.get('/admin/applicate-recommend/add', {id: this.value, type: 2}, function (rev) {
layer.msg(rev.msg); layer.msg(rev.msg);
if (0 == rev.code) { if (0 == rev.code) {
}else{ } else {
} }
}); });
}else{ } else {
$.get('/admin/applicate-recommend/delete', {id:this.value,type:2}, function(rev) { $.get('/admin/applicate-recommend/delete', {id: this.value, type: 2}, function (rev) {
layer.msg(rev.msg); layer.msg(rev.msg);
if (0 == rev.code) { if (0 == rev.code) {
}else{ } else {
} }
}); });
} }
}); });
form.on('switch(enableDemo)', function(obj){ form.on('switch(enableDemo)', function (obj) {
var enable = 1; var enable = 1;
if(obj.elem.checked){ if (obj.elem.checked) {
enable = 1 enable = 1
}else{ } else {
enable = 0; enable = 0;
} }
$.get('/admin/application/set-enable', {id:this.value,enable:enable}, function(rev) { $.get('/admin/application/set-enable', {id: this.value, enable: enable}, function (rev) {
layer.msg(rev.msg); layer.msg(rev.msg);
if (0 == rev.code) { if (0 == rev.code) {
}else{ } else {
} }
}); });
}); });
//监听单元格编辑 //监听单元格编辑
table.on('edit(table1)', function(obj){ table.on('edit(table1)', function (obj) {
var value = obj.value; //得到修改后的值 var value = obj.value; //得到修改后的值
var data = obj.data; //得到所在行所有键值 var data = obj.data; //得到所在行所有键值
$.get('/admin/application/set-sort', {id:data.id,category_id:category_id,sort:value}, function(rev) { $.get('/admin/application/set-sort', {id: data.id, category_id: category_id, sort: value}, function (rev) {
layer.msg(rev.msg); layer.msg(rev.msg);
if (0 == rev.code) { if (0 == rev.code) {
table.reload('table1',{}); table.reload('table1', {});
}else{ } else {
} }
}); });
......
/**
* @author rlgyzhcn@qq.com
*/
var table = layui.table;
var form = layui.form;
var layer = layui.layer;
form.render();
var tableIns = table.render({
elem: "#table1",
url: '/admin/application-category/index',
limit: 10,
page: 1,
loading: true,
cols: [[
{
field: 'coin_name', title: '名称', templet: function (data) {
var name = JSON.parse(data.name);
console.log(typeof (data.name), name.zh);
return name.zh
}
},
{field: 'icon_url', title: '图标', templet: '#iconTpl'},
{field: 'isrecommend', title: '首页推荐', templet: '#recommendTpl', width: 100},
{field: 'enable', title: '状态', templet: '#enableTpl', width: 100},
{field: 'id', title: '操作', templet: '#operationTpl'}
]],
});
form.on('submit(form1)', function (data) {
table.reload("table1", {
where: data.field,
page: {curr: 1},
});
return false;
});
//监听单元格事件
table.on('tool(table1)', function (obj) {
var data = obj.data;
if ('del' === obj.event) {
var index = layer.confirm("确认删除?", {icon: 3, title: '删除'}, function () {
$.get('/admin/application-category/delete', {id: data.id}, function (rev) {
layer.msg(rev.msg);
if (0 == rev.code) {
table.reload('table1', {
page: {curr: 1}
});
}
});
});
} else if (obj.event == 'edit') {
$.get('/admin/application-category/edit', {id: data.id}, function (str) {
var editIndex = layer.open({
type: 1,
title: '编辑: ' + data.name,
area: '625px',
content: str,
btn: ['保存', '取消'],
btn1: function () {
// console.log();
$.post('/admin/application-category/edit', $("#application-category-edit").serialize(), function (rev) {
layer.msg(rev.msg);
if (rev.code == 0) {
table.reload("table1", {
where: data.field,
});
layer.close(editIndex);
}
});
}
});
});
}
});
form.on('switch(recommendDemo)', function (obj) {
//layer.tips(this.value + ' ' + this.name + ':'+ obj.elem.checked, obj.othis);return;
if (obj.elem.checked) {
$.get('/admin/applicate-recommend/add', {id: this.value, type: 1}, function (rev) {
layer.msg(rev.msg);
if (0 == rev.code) {
} else {
}
});
} else {
$.get('/admin/applicate-recommend/delete', {id: this.value, type: 1}, function (rev) {
layer.msg(rev.msg);
if (0 == rev.code) {
} else {
}
});
}
});
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 {
}
});
});
\ No newline at end of file
...@@ -92,6 +92,11 @@ class CoinApplicationCategory extends BaseActiveRecord ...@@ -92,6 +92,11 @@ class CoinApplicationCategory extends BaseActiveRecord
return self::find()->where(['id' => $id])->one(); return self::find()->where(['id' => $id])->one();
} }
public static function getAppCategory($id)
{
return self::find()->where(['id' => $id])->asArray()->one();
}
public static function getCateItemsArray($condition = []) public static function getCateItemsArray($condition = [])
{ {
return self::find()->where($condition)->asArray()->all(); return self::find()->where($condition)->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