Commit f60145ce authored by ZhuChunYang's avatar ZhuChunYang

update

parent 53a0c840
......@@ -425,4 +425,38 @@ class CoinController extends BaseController
return ['code' => -1, 'msg' => '没有权限删除'];
}
}
public function actionPlatformCoin()
{
if (Yii::$app->request->isAjax) {
Yii::$app->response->format = 'json';
$request = Yii::$app->request;
$data = Coin::getPlatformList();
foreach ($data as $item){
if($item){
$platformInfo['platform'] = $item;
$icon = Yii::$app->redis_app->hget('platform_image_info',$item);
$platformInfo['icon'] = $icon ?? '';
$platformItems[] = $platformInfo;
}
}
return ['data' => $platformItems, 'code' => 0];
}
return $this->render('platform_coin');
}
public function actionAddPlatformCoin()
{
if(Yii::$app->request->isPost){
Yii::$app->response->format = 'json';
$platform = Yii::$app->request->post('platform');
$image = Yii::$app->request->post('image');
if($platform && $image){
Yii::$app->redis_app->hset('platform_image_info',$platform,$image);
return ['code' => 0, 'msg' => '图片添加成功'];
}
return ['code' => 0, 'msg' => '图片添加失败'];
}
}
}
......@@ -21,7 +21,8 @@ class UploadForm extends BaseForm
3 => "/application/", //存放应用详情图片,
4 => "/h5_icon/", //存放h5_logo ,
5 => "/h5_banner/", //存放h5_banner,
6 => "/h5_application/" //存放h5_application
6 => "/h5_application/", //存放h5_application
7 => "/platform_icon/" , //平台logo
];
......
<?php
/**
* Created by PhpStorm.
* User: ZCY
* Date: 2018/11/16
* Time: 10:53
*/
?>
<h4>平台币种图片管理</h4>
<div class="layui-row layui-col-md6" >
<table id="table1" class="layui-table" lay-filter="table1"></table>
</div>
<div class="layui-row add" style="display: none;padding: 5px;" id="_form">
<div class="layui-col-xs6 layui-col-sm6 layui-col-md11">
<form class="layui-form" action="javascript:void(0)" id="form1" method="post" lay-filter="form1">
<input type="hidden" name="_csrf" value="<?= Yii::$app->request->getCsrfToken() ?>">
<input type="hidden" name="platform" value="">
<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="image1">
</div>
<input type="hidden" name="image" 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>
</form>
</div>
</div>
<script>
var table = layui.table;
table.render({
elem: "#table1",
cols: [[
{field: 'platform', title: '平台'},
{field: 'icon', title: '图标', templet: "#iconTpl"},
{field: 'id', title: '操作', templet: "#operatorTpl"}
]],
url: '/admin/coin/platform-coin'
});
//图片上传
var uploader = layui.upload;
$_csrf = $("input[name='_csrf']").val();
uploader.render({
elem: "#upload1",
url: '/admin/image/upload',
data:{_csrf:$_csrf,image_type:7},
done: function (res) {
if(res.code == 0){
$("input[name='image']").val(res.data.image_src);
$("#image1").attr('src', res.data.image_src);
}
},
error: function (res) {
}
});
var form = layui.form;
form.render();
table.on('tool(table1)', function(obj) {
var event = obj.event;
var data = obj.data;
if (event === 'edit') {
var index = layer.open({
title: '编辑应用分类',
area: '500px',
type: 1,
content: $("#_form"),
btn: ['保存', '取消'],
success: function() {
form.val("form1", {
platform: data.platform,
image: data.icon
});
$("#image1").attr('src', data.icon);
},
btn1: function() {
$.post('/admin/coin/add-platform-coin', $("#form1").serialize(), function(rev) {
layer.msg(rev.msg);
if (0 == rev.code) {
layer.close(index);
$("#_form").css('display', 'none');
table.reload('table1');
}
clearForm();
});
},
btn2: function() {
layer.close(index);
$("#_form").css('display', 'none');
clearForm();
},
cancel: function() {
layer.close(index);
$("#_form").css('display', 'none');
clearForm();
}
});
}
});
function clearForm(){
form.val("form1", {
image: '',
platform: ''
});
$("#image1").attr('src', '');
}
</script>
<script type="text/html" id="operatorTpl">
<button class="layui-btn layui-btn-xs" lay-event="edit">编辑币种图片</button>
</script>
<script type="text/html" id="iconTpl">
<a href="{{d.icon}}" target="_blank"><img src="{{d.icon}}" style="max-width: 32px; max-height: 32px;"/></a>
</script>
\ No newline at end of file
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