Commit e71c922b authored by shajiaiming's avatar shajiaiming

Merge branch 'feature/optimize' into 'master'

SFT 海报增加 类型 See merge request !101
parents 9845b193 7de66c6c
......@@ -13,14 +13,15 @@ class CoinPlatformBannerController extends BaseController
$code = 0;
$msg = 'success';
$platform_id = Yii::$app->request->get('platform_id', '');
if(empty($platform_id)){
$msg = '参数不能为空';
$type = Yii::$app->request->get('type', '');
if (empty($platform_id) || empty($type)) {
$msg = '参数错误';
$code = -1;
$data = null;
goto doEnd;
}
$data = CoinPlatformBanner::find()->where(['platform_id' => $platform_id])->asArray()->all();
$data = CoinPlatformBanner::find()->where(['platform_id' => $platform_id, 'type' => $type])->asArray()->all();
doEnd :
return ['code' => $code, 'data' => $data, 'msg' => $msg];
......
......@@ -14,14 +14,16 @@ class CoinPlatformBannerController extends BaseController
Yii::$app->response->format = 'json';
$request = Yii::$app->request;
$image_url = $request->post('image_url', '');
if($image_url){
$type = $request->post('banner_type', 1);
if ($image_url) {
$banner_item = new CoinPlatformBanner();
$banner_item->image_url = $image_url;
$banner_item->platform_id = $user_platform_id;
$banner_item->type = $type;
$banner_item->save();
return ['code' => 0,'msg' => 'banner添加成功'];
}else{
return ['code' => 1,'msg' => 'banner添加加失败'];
return ['code' => 0, 'msg' => 'banner添加成功'];
} else {
return ['code' => 1, 'msg' => 'banner添加加失败'];
}
}
}
......@@ -36,15 +38,15 @@ class CoinPlatformBannerController extends BaseController
Yii::$app->response->format = 'json';
$request = Yii::$app->request;
$id = $request->get('id', '');
if($id){
if ($id) {
$banner = CoinPlatformBanner::getBanner($id);
if(!$banner){
return ['code' => 1,'msg' =>'banner不存在,不能删除'];
if (!$banner) {
return ['code' => 1, 'msg' => 'banner不存在,不能删除'];
}
$banner->delete();
return ['code' => 0,'msg' => 'banner删除成功'];
}else{
return ['code' => 1 ,'msg' => 'banner删除失败'];
return ['code' => 0, 'msg' => 'banner删除成功'];
} else {
return ['code' => 1, 'msg' => 'banner删除失败'];
}
}
}
......@@ -55,17 +57,17 @@ class CoinPlatformBannerController extends BaseController
public function actionIndex()
{
$user_platform_id = Yii::$app->user->identity->platform_id;
if(Yii::$app->request->isAjax){
if (Yii::$app->request->isAjax) {
Yii::$app->response->format = 'json';
$condition = [];
if(1 !== $user_platform_id){
if (1 !== $user_platform_id) {
$condition = ['platform_id' => $user_platform_id];
}
$data = CoinPlatformBanner::getItems($condition);
foreach ($data as $key => &$val){
foreach ($data as $key => &$val) {
$val['coin_name'] = isset($val['platform']['name']) ? $val['platform']['name'] : '';
}
return [ 'data' =>$data, 'code' => 0];
return ['data' => $data, 'code' => 0];
}
return $this->render('index');
}
......
......@@ -12,7 +12,7 @@
<div class="layui-col-md9">
<table class="layui-table" id="table1" lay-filter="table1"></table>
</div>
<div class="layui-row add" style="display: none;padding: 5px;" id="_form">
<div class="layui-row add" style="display: none;padding: 50px;" 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() ?>">
......@@ -31,6 +31,15 @@
</button>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">图片类型</label>
<div class="layui-input-block">
<select name="banner_type">
<option value="1">banner</option>
<option value="2">海报</option>
</select>
</div>
</div>
</form>
</div>
</div>
......@@ -54,7 +63,7 @@
},
{
field: 'image_url',
title: '图片跳转地址',
title: '图片地址',
width: 600
},
{
......@@ -87,7 +96,7 @@
$('#add').click(function () {
var index = layer.open({
title: '添加banner',
area: '800px',
area: '750px',
type: 1,
content: $("#_form"),
btn: ['保存', '取消'],
......
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