Commit 761b431b authored by shajiaiming's avatar shajiaiming

多语言信息

parent df7d1dd5
......@@ -30,6 +30,10 @@ class ApplicationController extends BaseController
$page = $request->get('page', 1);
$limit = $request->get('limit', 10);
$data = CoinApplication::getListByCategory($page, $limit, $id);
foreach ($data['data'] as &$val){
$val['name'] = str_replace('en-US', 'en', $val['name']);
$val['name'] = str_replace('zh-CN', 'zh', $val['name']);
}
return $data;
} else {
$id = Yii::$app->request->get('id');
......
<?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 @@
width: 100px;
}
</style>
<h4>所属分类---<?= $applicate_category->name ?></h4>
<h4>所属分类---<?= $applicate_category->name["zh-CN"] ?></h4>
<div class="layui-row" style="padding: 5px;">
<div class="layui-tab layui-tab-card">
<ul class="layui-tab-title">
......
......@@ -14,33 +14,33 @@
</style>
<div class="layui-row" style="padding: 5px;">
<div class="layui-col-md12">
<form class="layui-form" method="post" action="" id="coinEdit">
<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 ?>">
<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_json[]" value="<?= $model->name_json['zh-CN'] ?>">
<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_json[]" value="<?= $model->name_json['en-US'] ?>">
<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_json[]" value="<?= $model->name_json['ja'] ?>">
<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">
<div class="layui-input-block" style="width: 250px">
<input type="text" name="sort" required lay-verify="required" placeholder=""
autocomplete="off"
autocomplete="off" value="<?= $model['sort'] ?>"
class="layui-input">
</div>
</div>
......@@ -48,10 +48,10 @@
<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"
<img src="<?= $model['icon_url'] ?>" style="margin-top: 11px; max-width: 32px; max-height: 32px"
id="icon1">
</div>
<input type="hidden" name="icon" value="">
<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="">
......@@ -63,9 +63,9 @@
<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">
<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="">
<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="">
......@@ -77,7 +77,7 @@
<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 ?>">
autocomplete="off" class="layui-input" value="<?= $model['banner_url'] ?>">
</div>
</div>
</form>
......@@ -93,12 +93,28 @@
$_csrf = $("input[name='_csrf']").val();
uploader.render({
elem: "#upload1",
url: '/admin/coin/upload',
url: '/admin/image/upload',
data: {_csrf: $_csrf},
done: function (res) {
console.log(res.data.src);
$("input[name='icon']").val(res.data.src);
$("#icon1").attr('src', res.data.src);
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) {
......
<?php
/**
* Created by PhpStorm.
* User: rlgyzhcn
* Date: 18-5-31
* Time: 上午9:59
*/
use backend\assets\applicationCategory\IndexAsset;
IndexAsset::register($this);
?>
<style>
.layui-table-tips-c {
padding: 0px;
}
</style>
<h4>应用分类列表</h4>
<div class="layui-row">
<div class="layui-col-md1">
<a href="/admin/coin/add">
<button class="layui-btn layui-btn-default" id="add">添加应用分类</button>
</a>
</div>
<div class="layui-col-md8">
<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">
<input class="layui-input" name="name">
</div>
</div>
<div class="layui-inline">
<button class="layui-btn" lay-submit lay-filter="form1">搜索</button>
</div>
</form>
</div>
</div>
<div class="layui-row">
<table class="layui-table" id="table1" lay-filter="table1"></table>
</div>
<script type="text/html" id="iconTpl">
<img src="{{d.icon_url}}" style="max-width: 32px; max-height: 32px;"/>
</script>
<!--<script type="text/html" id="operationTpl">-->
<!-- <a lay-event="edit">-->
<!-- <button class="layui-btn layui-btn-sm"><i class="layui-icon">&#xe642;</i></button>-->
<!-- </a>-->
<!-- <a lay-event="delete">-->
<!-- <button class="layui-btn layui-btn-sm layui-btn-danger"><i class="layui-icon">&#xe640;</i></button>-->
<!-- </a>-->
<!--</script>-->
<script type="text/html" id="operationTpl">
<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-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>
</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' : '' }}>
</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>
......@@ -11,7 +11,7 @@
width: 100px;
}
</style>
<h4>所属分类---<?= $parent_category->name ?></h4>
<h4>所属分类---<?= $parent_category->name["zh-CN"] ?></h4>
<div class="layui-row" style="padding: 5px;">
<div class="layui-col-md1">
<a href="/admin/application/add?category_id=<?= $parent_category->id ?>">
......@@ -87,12 +87,9 @@
field: 'name',
title: '名称',
templet: function (data) {
//var name = JSON.parse(data.name);
//var name = eval("(" + data.name + ")")
// var obj = eval("(" + data.name + ')');
// console.log(obj);
// console.log(data.name);
return data.name;
var name = JSON.parse(data.name);
console.log(typeof (data.name), name.zh);
return name.zh
}
},
......
......@@ -12,11 +12,16 @@ var tableIns = table.render({
page: 1,
loading: true,
cols: [[
{field: 'name', title: '名称'},
{field: 'coin_name', title: '名称'},
{
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: 'isrecommend', title: '首页推荐', templet: '#recommendTpl', width: 100},
{field: 'enable', title: '状态', templet: '#enableTpl', width: 100},
{field: 'id', title: '操作', templet: '#operationTpl'}
]],
});
......@@ -30,25 +35,15 @@ form.on('submit(form1)', function (data) {
//监听单元格事件
table.on('tool(table1)', function (obj) {
var data = obj.data;
if (obj.event === 'getExchange') {
var load = layer.load(1);
$.get('/admin/coin/get-exchange-list-by-id?id=' + obj.data.id, {}, function (str) {
layer.close(load);
layer.open({
type: 1,
title: '上架交易所列表',
content: str,
});
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 == 'delete') {
layer.confirm('真的要删除' + data.name + '吗?', {icon: 3, title: '删除'}, function (index) {
layer.close(index);
//向服务端发送删除指令
$.get('/admin/coin/delete?id=' + obj.data.id, function (data, status) {
if (data.code == 0) {
obj.del(); //删除对应行(tr)的DOM结构
}
layer.msg(data.msg);
});
});
} else if (obj.event == 'edit') {
......@@ -61,7 +56,7 @@ table.on('tool(table1)', function (obj) {
btn: ['保存', '取消'],
btn1: function () {
// console.log();
$.post('/admin/coin/edit', $("#coinEdit").serialize(), function (rev) {
$.post('/admin/application-category/edit', $("#application-category-edit").serialize(), function (rev) {
layer.msg(rev.msg);
if (rev.code == 0) {
table.reload("table1", {
......@@ -75,38 +70,38 @@ table.on('tool(table1)', function (obj) {
});
}
});
form.on('switch(recommendDemo)', function(obj){
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) {
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 {
}
});
}else{
$.get('/admin/applicate-recommend/delete', {id:this.value,type:1}, function(rev) {
} else {
$.get('/admin/applicate-recommend/delete', {id: this.value, type: 1}, function (rev) {
layer.msg(rev.msg);
if (0 == rev.code) {
}else{
} else {
}
});
}
});
form.on('switch(enableDemo)', function(obj){
form.on('switch(enableDemo)', function (obj) {
var enable = 1;
if(obj.elem.checked){
if (obj.elem.checked) {
enable = 1
}else{
} else {
enable = 0;
}
$.get('/admin/application-category/set-enable', {id:this.value,enable:enable}, function(rev) {
$.get('/admin/application-category/set-enable', {id: this.value, enable: enable}, function (rev) {
layer.msg(rev.msg);
if (0 == rev.code) {
}else{
} else {
}
});
......
......@@ -92,6 +92,11 @@ class CoinApplicationCategory extends BaseActiveRecord
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 = [])
{
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