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
c7f5bb74
Commit
c7f5bb74
authored
Oct 19, 2018
by
ZhuChunYang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
首页推荐添加icon
parent
5026da06
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
122 additions
and
11 deletions
+122
-11
ApplicateRecommendController.php
backend/controllers/ApplicateRecommendController.php
+32
-3
CoinApplicationCategoryForm.php
backend/models/coin/CoinApplicationCategoryForm.php
+1
-1
CoinApplicationForm.php
backend/models/coin/CoinApplicationForm.php
+1
-1
index.php
backend/views/applicate-recommend/index.php
+82
-4
CoinApplicateRecommend.php
common/models/psources/CoinApplicateRecommend.php
+6
-2
No files found.
backend/controllers/ApplicateRecommendController.php
View file @
c7f5bb74
...
...
@@ -11,6 +11,7 @@ namespace backend\controllers;
use
common\models\psources\CoinApplicateRecommend
;
use
common\models\psources\CoinApplication
;
use
common\models\psources\CoinApplicationCategory
;
use
common\models\psources\CoinImage
;
use
Yii
;
...
...
@@ -35,17 +36,14 @@ class ApplicateRecommendController extends BaseController
if
(
$type
==
1
){
//分类
$applicate_category
=
CoinApplicationCategory
::
getCategoryById
(
$id
);
$name
=
$applicate_category
->
name
;
$icon
=
$applicate_category
->
icon
;
}
else
{
//应用
$applicate
=
CoinApplication
::
getApplicate
(
$id
);
$name
=
$applicate
->
name
;
$icon
=
$applicate
->
icon
;
}
$recommend
=
new
CoinApplicateRecommend
();
$recommend
->
relate_id
=
$id
;
$recommend
->
type
=
$type
;
$recommend
->
name
=
$name
;
$recommend
->
icon
=
$icon
;
$recommend
->
save
();
return
[
'code'
=>
0
,
'msg'
=>
'首页推荐添加成功'
];
}
else
{
...
...
@@ -82,6 +80,15 @@ class ApplicateRecommendController extends BaseController
if
(
Yii
::
$app
->
request
->
isAjax
){
Yii
::
$app
->
response
->
format
=
'json'
;
$data
=
CoinApplicateRecommend
::
find
()
->
orderBy
(
'sort asc'
)
->
asArray
()
->
all
();
$icon_Items
=
array_column
(
$data
,
'icon'
);
$icon_Infos
=
CoinImage
::
getItemsByIds
(
$icon_Items
);
foreach
(
$data
as
&
$value
){
if
(
$value
[
'icon'
]){
$value
[
'icon_url'
]
=
$icon_Infos
[
$value
[
'icon'
]][
'base_url'
]
.
$icon_Infos
[
$value
[
'icon'
]][
'file_url'
];
}
else
{
$value
[
'icon_url'
]
=
''
;
}
}
return
[
'data'
=>
$data
,
'code'
=>
0
];
}
return
$this
->
render
(
'index'
);
...
...
@@ -109,5 +116,26 @@ class ApplicateRecommendController extends BaseController
}
}
public
function
actionSetIcon
()
{
if
(
Yii
::
$app
->
request
->
isPost
){
Yii
::
$app
->
response
->
format
=
'json'
;
$id
=
Yii
::
$app
->
request
->
post
(
'id'
,
0
);
$icon
=
Yii
::
$app
->
request
->
post
(
'icon'
,
0
);
if
(
$id
&&
$icon
){
$recommend
=
CoinApplicateRecommend
::
getRecommendById
(
$id
);
if
(
$recommend
){
$recommend
->
icon
=
$icon
;
$recommend
->
save
();
return
[
'code'
=>
0
,
'msg'
=>
'图片添加成功'
];
}
else
{
return
[
'code'
=>
1
,
'msg'
=>
'首页推荐不存在'
];
}
}
else
{
return
[
'code'
=>
1
,
'msg'
=>
'图片添加失败'
];
}
}
}
}
\ No newline at end of file
backend/models/coin/CoinApplicationCategoryForm.php
View file @
c7f5bb74
...
...
@@ -102,7 +102,7 @@ class CoinApplicationCategoryForm extends BaseForm
if
(
$coin_applicate_category
){
$coin_applicate_category
->
setAttributes
(
$this
->
attributes
,
false
);
$coin_applicate_category
->
save
();
CoinApplicateRecommend
::
updateName
AndIcon
(
$this
->
id
,
1
,
$this
->
name
,
$this
->
icon
);
CoinApplicateRecommend
::
updateName
(
$this
->
id
,
1
,
$this
->
name
);
return
[
'code'
=>
0
,
'msg'
=>
'应用分类修改成功!'
];
}
else
{
return
[
'code'
=>
1
,
'msg'
=>
'应用分类不存在'
];
...
...
backend/models/coin/CoinApplicationForm.php
View file @
c7f5bb74
...
...
@@ -132,7 +132,7 @@ class CoinApplicationForm extends BaseForm
if
(
$coin_applicate
){
$coin_applicate
->
setAttributes
(
$this
->
attributes
,
false
);
$coin_applicate
->
save
();
CoinApplicateRecommend
::
updateName
AndIcon
(
$this
->
id
,
2
,
$this
->
name
,
$this
->
icon
);
//更新首页推荐name
CoinApplicateRecommend
::
updateName
(
$this
->
id
,
2
,
$this
->
name
);
//更新首页推荐name
return
[
'code'
=>
0
,
'msg'
=>
'应用修改成功!'
];
}
else
{
return
[
'code'
=>
1
,
'msg'
=>
'应用不存在'
];
...
...
backend/views/applicate-recommend/index.php
View file @
c7f5bb74
...
...
@@ -12,7 +12,29 @@
<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
()
?>
"
>
<input
type=
"hidden"
name=
"id"
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=
"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"
>

</i>
上传新图片
</button>
</div>
</div>
</form>
</div>
</div>
<script
type=
"text/html"
id=
"typeTpl"
>
{{
#
if
(
d
.
type
==
1
){
}}
应用分类
...
...
@@ -20,7 +42,11 @@
应用
{{
#
}
}}
</script>
<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
class
=
"layui-btn layui-btn-normal layui-btn-xs"
lay
-
event
=
"edit"
>
编辑图片
<
/a>
<
a
class
=
"layui-btn layui-btn-danger layui-btn-xs"
lay
-
event
=
"del"
>
删除
<
/a>
</script>
<script
type=
"text/javascript"
>
...
...
@@ -28,8 +54,6 @@
table
.
render
({
elem
:
'#table1'
,
url
:
'/admin/applicate-recommend/index'
,
skin
:
'row'
,
size
:
'sm'
,
cols
:
[[
{
field
:
'relate_id'
,
...
...
@@ -49,7 +73,11 @@
title
:
'排序'
,
edit
:
'text'
},
{
field
:
'icon_url'
,
title
:
'图标'
,
templet
:
'#iconTpl'
},
{
title
:
'操作'
,
templet
:
'#operationTpl'
...
...
@@ -72,6 +100,39 @@
}
});
});
}
else
if
(
event
===
'edit'
){
var
index
=
layer
.
open
({
title
:
'编辑图片'
,
area
:
'800px'
,
type
:
1
,
content
:
$
(
"#_form"
),
btn
:
[
'保存'
,
'取消'
],
success
:
function
()
{
form
.
val
(
"form1"
,
{
id
:
data
.
id
,
icon
:
data
.
icon
,
});
$
(
"#icon1"
).
attr
(
'src'
,
data
.
icon_url
);
},
btn1
:
function
()
{
$
.
post
(
'/admin/applicate-recommend/set-icon'
,
$
(
"#form1"
).
serialize
(),
function
(
rev
)
{
layer
.
msg
(
rev
.
msg
);
if
(
0
==
rev
.
code
)
{
layer
.
close
(
index
);
$
(
"#_form"
).
css
(
'display'
,
'none'
);
table
.
reload
(
'table1'
);
}
});
},
btn2
:
function
()
{
layer
.
close
(
index
);
$
(
"#_form"
).
css
(
'display'
,
'none'
);
},
cancel
:
function
()
{
layer
.
close
(
index
);
$
(
"#_form"
).
css
(
'display'
,
'none'
);
}
});
}
});
//监听单元格编辑
...
...
@@ -87,6 +148,22 @@
}
});
});
//图片上传
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
)
{
}
});
</script>
\ No newline at end of file
common/models/psources/CoinApplicateRecommend.php
View file @
c7f5bb74
...
...
@@ -43,12 +43,11 @@ class CoinApplicateRecommend extends BaseActiveRecord
return
array_column
(
$data
,
null
,
'relate_id'
);
}
public
static
function
updateName
AndIcon
(
$id
,
$type
,
$name
,
$icon
)
public
static
function
updateName
(
$id
,
$type
,
$name
)
{
$recommend
=
self
::
find
()
->
where
([
'relate_id'
=>
$id
,
'type'
=>
$type
])
->
one
();
if
(
$recommend
){
$recommend
->
name
=
$name
;
$recommend
->
icon
=
$icon
;
$recommend
->
save
();
}
}
...
...
@@ -66,6 +65,11 @@ class CoinApplicateRecommend extends BaseActiveRecord
return
self
::
find
()
->
select
(
'relate_id as app_cate_id,name,type,icon'
)
->
asArray
()
->
orderBy
(
'sort asc'
)
->
all
();
}
public
static
function
getRecommendById
(
$id
)
{
return
self
::
find
()
->
where
([
'id'
=>
$id
])
->
one
();
}
...
...
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