Commit 437d3cc1 authored by shajiaiming's avatar shajiaiming

应用查询

parent e6cb4f80
...@@ -12,6 +12,7 @@ use backend\models\coin\CoinApplicationCategoryForm; ...@@ -12,6 +12,7 @@ use backend\models\coin\CoinApplicationCategoryForm;
use common\models\psources\CoinApplicationCategory; use common\models\psources\CoinApplicationCategory;
use common\models\psources\CoinBanner; use common\models\psources\CoinBanner;
use common\models\psources\CoinImage; use common\models\psources\CoinImage;
use common\models\psources\CoinPlatform;
use Yii; use Yii;
...@@ -24,7 +25,7 @@ class ApplicationCategoryController extends BaseController ...@@ -24,7 +25,7 @@ class ApplicationCategoryController extends BaseController
public function actionIndex() public function actionIndex()
{ {
$user_platform_id = Yii::$app->user->identity->platform_id; $user_platform_id = Yii::$app->user->identity->platform_id;
$platforms = CoinPlatform::find()->select('id, name')->asArray()->all();
if (Yii::$app->request->isAjax) { if (Yii::$app->request->isAjax) {
Yii::$app->response->format = 'json'; Yii::$app->response->format = 'json';
$request = Yii::$app->request; $request = Yii::$app->request;
...@@ -34,7 +35,13 @@ class ApplicationCategoryController extends BaseController ...@@ -34,7 +35,13 @@ class ApplicationCategoryController extends BaseController
$where = []; $where = [];
if (1 !== $user_platform_id) { if (1 !== $user_platform_id) {
$where[] = ['platform_id' => $user_platform_id]; $where[] = ['platform_id' => $user_platform_id];
} else {
$platform_id = Yii::$app->request->get('platform', '');
if(!empty($platform_id)) {
$where[] = ['platform_id' => $platform_id];
}
} }
if ($name) { if ($name) {
$where[] = ['name' => $name]; $where[] = ['name' => $name];
} }
...@@ -42,14 +49,12 @@ class ApplicationCategoryController extends BaseController ...@@ -42,14 +49,12 @@ class ApplicationCategoryController extends BaseController
foreach ($data['data'] as &$val) { foreach ($data['data'] as &$val) {
$val['name'] = str_replace('en-US', 'en', $val['name']); $val['name'] = str_replace('en-US', 'en', $val['name']);
$val['name'] = str_replace('zh-CN', 'zh', $val['name']); $val['name'] = str_replace('zh-CN', 'zh', $val['name']);
}
foreach ($data['data'] as $key => &$val) {
$val['coin_name'] = isset($val['platform']['name']) ? $val['platform']['name'] : ''; $val['coin_name'] = isset($val['platform']['name']) ? $val['platform']['name'] : '';
} }
return $data; return $data;
} }
return $this->render('index'); return $this->render('index', ['platforms' => $platforms, 'user_platform_id' => $user_platform_id]);
} }
/** /**
......
...@@ -23,6 +23,26 @@ IndexAsset::register($this); ...@@ -23,6 +23,26 @@ IndexAsset::register($this);
<button class="layui-btn layui-btn-default" id="add">添加应用分类</button> <button class="layui-btn layui-btn-default" id="add">添加应用分类</button>
</a> </a>
</div> </div>
<?php
if (1 == $user_platform_id) {
?>
<form class="layui-form" method="get" action="">
<div class="layui-inline">
<label class="layui-form-label" style="margin-bottom: 0; width: 100px;">钱包</label>
<div class="layui-input-inline">
<select name="platform" id = "platform">
<?php foreach ($platforms as $key => $platform): ?>
<option value="<?= $platform['id'] ?>"><?= $platform['name'] ?></option>
<?php endforeach; ?>
</select>
</div>
</div>
<div class="layui-inline">
<button class="layui-btn" lay-submit lay-filter="form1">搜索</button>
</div>
</form>
<?php
} ?>
</div> </div>
<div class="layui-row"> <div class="layui-row">
<table class="layui-table" id="table1" lay-filter="table1"></table> <table class="layui-table" id="table1" lay-filter="table1"></table>
...@@ -44,13 +64,15 @@ IndexAsset::register($this); ...@@ -44,13 +64,15 @@ IndexAsset::register($this);
<script type="text/html" id="operationTpl"> <script type="text/html" id="operationTpl">
<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-primary layui-btn-xs" href="/admin/application/list?id={{d.id}}" >应用列表</a> <a class="layui-btn layui-btn-primary layui-btn-xs" href="/admin/application/list?id={{d.id}}">应用列表</a>
<a class="layui-btn layui-btn-normal layui-btn-xs" href="/admin/application-category/banner-index?id={{d.id}}" >banner图管理</a> <a class="layui-btn layui-btn-normal layui-btn-xs" href="/admin/application-category/banner-index?id={{d.id}}">banner图管理</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>
...@@ -13,12 +13,13 @@ var tableIns = table.render({ ...@@ -13,12 +13,13 @@ var tableIns = table.render({
loading: true, loading: true,
cols: [[ cols: [[
{ {
field: 'coin_name', title: '名称', templet: function (data) { field: 'name', title: '名称', templet: function (data) {
var name = JSON.parse(data.name); var name = JSON.parse(data.name);
console.log(typeof (data.name), name.zh); console.log(typeof (data.name), name.zh);
return name.zh return name.zh
} }
}, },
{field: 'coin_name',title: '钱包'},
{field: 'icon_url', title: '图标', templet: '#iconTpl'}, {field: 'icon_url', title: '图标', templet: '#iconTpl'},
{field: 'isrecommend', title: '首页推荐', templet: '#recommendTpl', width: 100}, {field: 'isrecommend', title: '首页推荐', templet: '#recommendTpl', width: 100},
{field: 'enable', title: '状态', templet: '#enableTpl', width: 100}, {field: 'enable', title: '状态', templet: '#enableTpl', width: 100},
......
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