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
fadf8d25
Commit
fadf8d25
authored
Aug 23, 2019
by
shajiaiming
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feature/optimize' into 'master'
sft banner See merge request
!96
parents
ab5d40db
812e5343
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
275 additions
and
0 deletions
+275
-0
CoinPlatformBannerController.php
api/controllers/CoinPlatformBannerController.php
+21
-0
CoinPlatformBannerController.php
backend/controllers/CoinPlatformBannerController.php
+74
-0
index.php
backend/views/coin-platform-banner/index.php
+145
-0
CoinPlatformBanner.php
common/models/psources/CoinPlatformBanner.php
+35
-0
No files found.
api/controllers/CoinPlatformBannerController.php
0 → 100644
View file @
fadf8d25
<?php
namespace
api\controllers
;
use
Yii
;
use
api\base\BaseController
;
use
common\models\psources\CoinPlatformBanner
;
class
CoinPlatformBannerController
extends
BaseController
{
public
function
actionIndex
()
{
$code
=
0
;
$msg
=
'success'
;
$platform_id
=
Yii
::
$app
->
request
->
get
(
'platform_id'
,
13
);
$data
=
CoinPlatformBanner
::
find
()
->
where
([
'platform_id'
=>
$platform_id
])
->
asArray
()
->
all
();
return
[
'code'
=>
$code
,
'data'
=>
$data
,
'msg'
=>
$msg
];
}
}
\ No newline at end of file
backend/controllers/CoinPlatformBannerController.php
0 → 100644
View file @
fadf8d25
<?php
namespace
backend\controllers
;
use
Yii
;
use
common\models\psources\CoinPlatformBanner
;
class
CoinPlatformBannerController
extends
BaseController
{
public
function
actionAdd
()
{
$user_platform_id
=
Yii
::
$app
->
user
->
identity
->
platform_id
;
if
(
Yii
::
$app
->
request
->
isAjax
)
{
Yii
::
$app
->
response
->
format
=
'json'
;
$request
=
Yii
::
$app
->
request
;
$image_url
=
$request
->
post
(
'image_url'
,
''
);
if
(
$image_url
){
$banner_item
=
new
CoinPlatformBanner
();
$banner_item
->
image_url
=
$image_url
;
$banner_item
->
platform_id
=
$user_platform_id
;
$banner_item
->
save
();
return
[
'code'
=>
0
,
'msg'
=>
'banner添加成功'
];
}
else
{
return
[
'code'
=>
1
,
'msg'
=>
'banner添加加失败'
];
}
}
}
/**
* @return array
* 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
=
CoinPlatformBanner
::
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
()
{
$user_platform_id
=
Yii
::
$app
->
user
->
identity
->
platform_id
;
if
(
Yii
::
$app
->
request
->
isAjax
){
Yii
::
$app
->
response
->
format
=
'json'
;
$condition
=
[];
if
(
1
!==
$user_platform_id
){
$condition
=
[
'platform_id'
=>
$user_platform_id
];
}
$data
=
CoinPlatformBanner
::
getItems
(
$condition
);
foreach
(
$data
as
$key
=>
&
$val
){
$val
[
'coin_name'
]
=
isset
(
$val
[
'platform'
][
'name'
])
?
$val
[
'platform'
][
'name'
]
:
''
;
}
return
[
'data'
=>
$data
,
'code'
=>
0
];
}
return
$this
->
render
(
'index'
);
}
}
\ No newline at end of file
backend/views/coin-platform-banner/index.php
0 → 100644
View file @
fadf8d25
<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>
</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-platform-banner/index'
,
cols
:
[[
{
field
:
'id'
,
title
:
'编号'
},
{
field
:
'coin_name'
,
title
:
'钱包'
,
},
{
field
:
'image_url'
,
title
:
'图片跳转地址'
,
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-platform-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-platform-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/CoinPlatformBanner.php
0 → 100644
View file @
fadf8d25
<?php
namespace
common\models\psources
;
use
Yii
;
use
common\core\BaseActiveRecord
;
class
CoinPlatformBanner
extends
BaseActiveRecord
{
public
static
function
getDb
()
{
return
Yii
::
$app
->
get
(
'p_sources'
);
}
public
static
function
tableName
()
{
return
'{{coin_platform_banner}}'
;
}
public
static
function
getBanner
(
$id
)
{
return
self
::
find
()
->
where
([
'id'
=>
$id
])
->
one
();
}
public
static
function
getItems
(
$condition
=
[])
{
return
self
::
find
()
->
joinWith
(
'platform'
)
->
where
(
$condition
)
->
asArray
()
->
all
();
}
public
function
getPlatform
()
{
return
$this
->
hasOne
(
CoinPlatform
::
className
(),
[
'id'
=>
'platform_id'
]);
}
}
\ 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