Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
token
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wallet
token
Commits
dc454a86
Commit
dc454a86
authored
Dec 19, 2018
by
ZhuChunYang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
ee630520
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
273 additions
and
0 deletions
+273
-0
CoinBannerController.php
backend/controllers/CoinBannerController.php
+73
-0
index.php
backend/views/coin-banner/index.php
+165
-0
CoinBannerItem.php
common/models/psources/CoinBannerItem.php
+35
-0
No files found.
backend/controllers/CoinBannerController.php
0 → 100644
View file @
dc454a86
<?php
/**
* Created by PhpStorm.
* User: ZCY
* Date: 2018/12/18
* Time: 16:24
*/
namespace
backend\controllers
;
use
common\models\psources\CoinApplicateRecommend
;
use
common\models\psources\CoinApplication
;
use
common\models\psources\CoinApplicationCategory
;
use
common\models\psources\CoinBannerItem
;
use
common\models\psources\CoinImage
;
use
Yii
;
class
CoinBannerController
extends
BaseController
{
public
function
actionAdd
()
{
if
(
Yii
::
$app
->
request
->
isAjax
)
{
Yii
::
$app
->
response
->
format
=
'json'
;
$request
=
Yii
::
$app
->
request
;
$image_url
=
$request
->
post
(
'image_url'
,
''
);
$banner_url
=
$request
->
post
(
'banner_url'
,
''
);
if
(
$image_url
&&
$banner_url
){
$banner_item
=
new
CoinBannerItem
();
$banner_item
->
banner_url
=
$banner_url
;
$banner_item
->
image_url
=
$image_url
;
$banner_item
->
save
();
return
[
'code'
=>
0
,
'msg'
=>
'banner添加成功'
];
}
else
{
return
[
'code'
=>
1
,
'msg'
=>
'banner添加加失败'
];
}
}
}
public
function
actionDelete
()
{
if
(
Yii
::
$app
->
request
->
isAjax
)
{
Yii
::
$app
->
response
->
format
=
'json'
;
$request
=
Yii
::
$app
->
request
;
$id
=
$request
->
get
(
'id'
,
''
);
if
(
$id
){
$banner
=
CoinBannerItem
::
getBanner
(
$id
);
if
(
!
$banner
){
return
[
'code'
=>
1
,
'msg'
=>
'banner不存在,不能删除'
];
}
$banner
->
delete
();
return
[
'code'
=>
0
,
'msg'
=>
'banner删除成功'
];
}
else
{
return
[
'code'
=>
1
,
'msg'
=>
'banner删除失败'
];
}
}
}
/**
* banner列表
*/
public
function
actionIndex
()
{
if
(
Yii
::
$app
->
request
->
isAjax
){
Yii
::
$app
->
response
->
format
=
'json'
;
$data
=
CoinBannerItem
::
getItems
();
return
[
'data'
=>
$data
,
'code'
=>
0
];
}
return
$this
->
render
(
'index'
);
}
}
\ No newline at end of file
backend/views/coin-banner/index.php
0 → 100644
View file @
dc454a86
<?php
/**
* Created by PhpStorm.
* User: ZCY
* Date: 2018/10/17
* Time: 10:55
*/
?>
<style>
.layui-form-label
{
width
:
100px
;
}
</style>
<h4>
banner管理列表
</h4>
<div
class=
"layui-row"
>
<div
class=
"layui-col-md1"
>
<button
class=
"layui-btn layui-btn-default"
id=
"add"
>
添加banner图
</button>
</div>
</div>
<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-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
()
?>
"
>
<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=
"image_url"
value=
""
>
</div>
<div
class=
"layui-inline"
style=
"margin-left: 50px;"
>
<button
type=
"button"
class=
"layui-btn"
id=
"upload1"
style=
""
>
<i
class=
"layui-icon"
>

</i>
上传新图片
</button>
</div>
</div>
<div
class=
"layui-form-item"
>
<label
class=
"layui-form-label"
>
跳转地址
</label>
<div
class=
"layui-input-block"
>
<input
type=
"text"
class=
"layui-input"
name=
"banner_url"
value=
""
>
</div>
</div>
</form>
</div>
</div>
<script
type=
"text/html"
id=
"operationTpl"
>
<
a
class
=
"layui-btn layui-btn-danger layui-btn-xs"
lay
-
event
=
"del"
>
删除
<
/a>
</script>
<script
type=
"text/javascript"
>
var
table
=
layui
.
table
;
table
.
render
({
elem
:
'#table1'
,
url
:
'/admin/coin-banner/index'
,
cols
:
[[
{
field
:
'id'
,
title
:
'编号'
},
{
field
:
'banner_url'
,
title
:
'banner跳转地址'
,
templet
:
function
(
d
){
return
"<a href='"
+
d
.
banner_url
+
"' target='_blank'>"
+
d
.
banner_url
+
"</a>"
;
}
},
{
field
:
'image_url'
,
title
:
'图片跳转地址'
,
templet
:
function
(
d
){
return
"<a href='"
+
d
.
image_url
+
"' target='_blank'>"
+
d
.
image_url
+
"</a>"
;
},
width
:
600
},
{
title
:
'操作'
,
templet
:
'#operationTpl'
,
width
:
200
}
]],
});
var
form
=
layui
.
form
;
form
.
render
();
table
.
on
(
'tool(table1)'
,
function
(
obj
)
{
var
event
=
obj
.
event
;
var
data
=
obj
.
data
;
if
(
event
===
'del'
)
{
var
index
=
layer
.
confirm
(
"确认删除?"
,
{
icon
:
3
,
title
:
'删除'
},
function
()
{
$
.
get
(
'/admin/coin-banner/delete'
,
{
id
:
data
.
id
},
function
(
rev
)
{
layer
.
msg
(
rev
.
msg
);
if
(
0
==
rev
.
code
)
{
table
.
reload
(
'table1'
);
}
});
});
}
});
$
(
'#add'
).
click
(
function
()
{
var
index
=
layer
.
open
({
title
:
'添加banner'
,
area
:
'800px'
,
type
:
1
,
content
:
$
(
"#_form"
),
btn
:
[
'保存'
,
'取消'
],
success
:
function
()
{
clearForm
();
},
btn1
:
function
()
{
$
.
post
(
'/admin/coin-banner/add'
,
$
(
"#form1"
).
serialize
(),
function
(
rev
)
{
layer
.
msg
(
rev
.
msg
);
if
(
0
==
rev
.
code
)
{
layer
.
close
(
index
);
$
(
"#_form"
).
css
(
'display'
,
'none'
);
clearForm
();
table
.
reload
(
'table1'
);
}
});
},
btn2
:
function
()
{
layer
.
close
(
index
);
$
(
"#_form"
).
css
(
'display'
,
'none'
);
},
cancel
:
function
()
{
layer
.
close
(
index
);
$
(
"#_form"
).
css
(
'display'
,
'none'
);
}
});
})
function
clearForm
(){
form
.
val
(
"form1"
,
{
image_url
:
''
,
banner_url
:
''
});
$
(
"#icon1"
).
attr
(
'src'
,
''
);
}
//图片上传
var
uploader
=
layui
.
upload
;
$_csrf
=
$
(
"input[name='_csrf']"
).
val
();
uploader
.
render
({
elem
:
"#upload1"
,
url
:
'/admin/image/upload'
,
data
:
{
_csrf
:
$_csrf
,
image_type
:
2
},
done
:
function
(
res
)
{
if
(
res
.
code
==
0
){
$
(
"input[name='image_url']"
).
val
(
res
.
data
.
image_src
);
$
(
"#icon1"
).
attr
(
'src'
,
res
.
data
.
image_src
);
}
},
error
:
function
(
res
)
{
}
});
</script>
\ No newline at end of file
common/models/psources/CoinBannerItem.php
0 → 100644
View file @
dc454a86
<?php
/**
* Created by PhpStorm.
* User: ZCY
* Date: 2018/12/18
* Time: 16:56
*/
namespace
common\models\psources
;
use
common\core\BaseActiveRecord
;
use
Yii
;
class
CoinBannerItem
extends
BaseActiveRecord
{
public
static
function
getDb
()
{
return
Yii
::
$app
->
get
(
'p_sources'
);
}
public
static
function
tableName
()
{
return
'{{coin_banner_item}}'
;
}
public
static
function
getItems
()
{
return
self
::
find
()
->
asArray
()
->
all
();
}
public
static
function
getBanner
(
$id
)
{
return
self
::
find
()
->
where
([
'id'
=>
$id
])
->
one
();
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment