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
881be1ed
Commit
881be1ed
authored
Oct 17, 2018
by
ZhuChunYang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
bedbcfb8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
232 additions
and
7 deletions
+232
-7
ApplicateRecommendController.php
backend/controllers/ApplicateRecommendController.php
+58
-3
ApplicationCategoryController.php
backend/controllers/ApplicationCategoryController.php
+0
-1
index.php
backend/views/applicate-recommend/index.php
+80
-0
index.php
backend/views/application-category/index.php
+29
-1
list.php
backend/views/application/list.php
+9
-1
CoinApplicateRecommend.php
common/models/psources/CoinApplicateRecommend.php
+48
-0
CoinApplication.php
common/models/psources/CoinApplication.php
+4
-1
CoinApplicationCategory.php
common/models/psources/CoinApplicationCategory.php
+4
-0
No files found.
backend/controllers/ApplicateRecommendController.php
View file @
881be1ed
...
...
@@ -8,10 +8,10 @@
namespace
backend\controllers
;
use
backend\models\coin\CoinApplicationCategoryForm
;
use
common\models\psources\CoinApplicateRecommend
;
use
common\models\psources\CoinApplication
;
use
common\models\psources\CoinApplicationCategory
;
use
Yii
;
use
yii\web\UploadedFile
;
class
ApplicateRecommendController
extends
BaseController
...
...
@@ -24,11 +24,65 @@ class ApplicateRecommendController extends BaseController
$id
=
$request
->
get
(
'id'
,
''
);
$type
=
$request
->
get
(
'type'
,
''
);
if
(
$id
&&
$type
){
$recommend
=
CoinApplicateRecommend
::
getRecommend
(
$id
,
$type
);
if
(
$recommend
){
return
[
'code'
=>
1
,
'msg'
=>
'分类/应用已经添加为首页推荐,不能再添加'
];
}
$count
=
CoinApplicateRecommend
::
getRecommendCount
();
if
(
$count
>=
8
){
return
[
'code'
=>
1
,
'msg'
=>
'首页推荐分类/应用数量已经8个,无法再添加'
];
}
if
(
$type
==
1
){
//分类
$applicate_category
=
CoinApplicationCategory
::
getCategoryById
(
$id
);
$name
=
$applicate_category
->
name
;
}
else
{
//应用
$applicate
=
CoinApplication
::
getApplicate
(
$id
);
$name
=
$applicate
->
name
;
}
$recommend
=
new
CoinApplicateRecommend
();
$recommend
->
relate_id
=
$id
;
$recommend
->
type
=
$type
;
$recommend
->
name
=
$name
;
$recommend
->
save
();
return
[
'code'
=>
0
,
'msg'
=>
'首页推荐添加成功'
];
}
else
{
return
[
'code'
=>
1
,
'msg'
=>
'首页推荐添加失败'
];
}
}
}
public
function
actionDelete
()
{
if
(
Yii
::
$app
->
request
->
isAjax
)
{
Yii
::
$app
->
response
->
format
=
'json'
;
$request
=
Yii
::
$app
->
request
;
$id
=
$request
->
get
(
'id'
,
''
);
$type
=
$request
->
get
(
'type'
,
''
);
if
(
$id
&&
$type
){
$recommend
=
CoinApplicateRecommend
::
getRecommend
(
$id
,
$type
);
if
(
!
$recommend
){
return
[
'code'
=>
1
,
'msg'
=>
'首页推荐不存在,不能删除'
];
}
$recommend
->
delete
();
return
[
'code'
=>
0
,
'msg'
=>
'首页推荐删除成功'
];
}
else
{
return
[
'code'
=>
1
,
'msg'
=>
'首页推荐失败'
];
return
[
'code'
=>
1
,
'msg'
=>
'首页推荐
删除
失败'
];
}
}
}
/**
* 应用/分类推荐列表
*/
public
function
actionIndex
()
{
if
(
Yii
::
$app
->
request
->
isAjax
){
Yii
::
$app
->
response
->
format
=
'json'
;
$data
=
CoinApplicateRecommend
::
find
()
->
asArray
()
->
all
();
return
[
'data'
=>
$data
,
'code'
=>
0
];
}
return
$this
->
render
(
'index'
);
}
}
\ No newline at end of file
backend/controllers/ApplicationCategoryController.php
View file @
881be1ed
...
...
@@ -11,7 +11,6 @@ namespace backend\controllers;
use
backend\models\coin\CoinApplicationCategoryForm
;
use
common\models\psources\CoinApplicationCategory
;
use
Yii
;
use
yii\web\UploadedFile
;
class
ApplicationCategoryController
extends
BaseController
...
...
backend/views/applicate-recommend/index.php
0 → 100644
View file @
881be1ed
<?php
/**
* Created by PhpStorm.
* User: ZCY
* Date: 2018/10/17
* Time: 10:55
*/
?>
<h4>
首页推荐列表
</h4>
<div
class=
"layui-col-md9"
>
<table
class=
"layui-table"
id=
"table1"
lay-filter=
"table1"
></table>
</div>
<script
type=
"text/html"
id=
"typeTpl"
>
{{
#
if
(
d
.
type
==
1
){
}}
应用分类
{{
#
}
else
{
}}
应用
{{
#
}
}}
</script>
<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/applicate-recommend/index'
,
cols
:
[[
{
field
:
'relate_id'
,
title
:
'应用/分类ID'
},
{
field
:
'name'
,
title
:
'名称'
,
},
{
field
:
'type'
,
title
:
'类型'
,
templet
:
'#typeTpl'
},
{
field
:
'sort'
,
title
:
'排序'
},
{
title
:
'操作'
,
templet
:
'#operationTpl'
}
]],
});
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/applicate-recommend/delete'
,
{
id
:
data
.
relate_id
,
type
:
data
.
type
},
function
(
rev
)
{
layer
.
msg
(
rev
.
msg
);
if
(
0
==
rev
.
code
)
{
table
.
reload
(
'table1'
,{
page
:{
curr
:
1
}
});
}
});
});
}
});
</script>
\ No newline at end of file
backend/views/application-category/index.php
View file @
881be1ed
...
...
@@ -26,7 +26,7 @@
</form>
</div>
</div>
<div
class=
"layui-col-md
9
"
>
<div
class=
"layui-col-md
10
"
>
<table
class=
"layui-table"
id=
"table1"
lay-filter=
"table1"
></table>
</div>
...
...
@@ -108,6 +108,9 @@
<
a
class
=
"layui-btn layui-btn-danger layui-btn-xs"
lay
-
event
=
"del"
>
删除
<
/a>
<
a
class
=
"layui-btn layui-btn-primary layui-btn-xs"
href
=
"/admin/application/list?id={{d.id}}"
>
应用列表
<
/a>
</script>
<script
type=
"text/html"
id=
"recommendTpl"
>
<
input
type
=
"checkbox"
name
=
"isrecommend"
value
=
"{{d.id}}"
lay
-
skin
=
"switch"
lay
-
text
=
"是|否"
lay
-
filter
=
"recommendDemo"
{{
d
.
isrecommend
==
1
?
'checked'
:
''
}}
>
</script>
<script
type=
"text/javascript"
>
var
table
=
layui
.
table
;
...
...
@@ -149,6 +152,11 @@
templet
:
'#operationTpl'
},
{
title
:
'首页推荐'
,
field
:
'isrecommend'
,
templet
:
'#recommendTpl'
,
},
{
field
:
'icon'
,
title
:
'图标'
,
hide
:
true
,
...
...
@@ -321,6 +329,25 @@
$
(
"#icon1"
).
attr
(
'src'
,
''
);
$
(
"#icon2"
).
attr
(
'src'
,
''
);
}
form
.
on
(
'switch(recommendDemo)'
,
function
(
obj
){
//layer.tips(this.value + ' ' + this.name + ':'+ obj.elem.checked, obj.othis);return;
if
(
obj
.
elem
.
checked
){
$
.
get
(
'/admin/applicate-recommend/add'
,
{
id
:
this
.
value
,
type
:
1
},
function
(
rev
)
{
layer
.
msg
(
rev
.
msg
);
if
(
0
==
rev
.
code
)
{
}
else
{
}
});
}
else
{
$
.
get
(
'/admin/applicate-recommend/delete'
,
{
id
:
this
.
value
,
type
:
1
},
function
(
rev
)
{
layer
.
msg
(
rev
.
msg
);
if
(
0
==
rev
.
code
)
{
}
else
{
}
});
}
});
</script>
\ No newline at end of file
backend/views/application/list.php
View file @
881be1ed
...
...
@@ -213,7 +213,15 @@
layer
.
msg
(
rev
.
msg
);
if
(
0
==
rev
.
code
)
{
}
else
{
obj
.
elem
.
checked
=
false
;
}
});
}
else
{
$
.
get
(
'/admin/applicate-recommend/delete'
,
{
id
:
this
.
value
,
type
:
2
},
function
(
rev
)
{
layer
.
msg
(
rev
.
msg
);
if
(
0
==
rev
.
code
)
{
}
else
{
}
});
}
...
...
common/models/psources/CoinApplicateRecommend.php
0 → 100644
View file @
881be1ed
<?php
/**
* Created by PhpStorm.
* User: ZCY
* Date: 2018/10/17
* Time: 9:36
*/
namespace
common\models\psources
;
use
common\core\BaseActiveRecord
;
use
Yii
;
class
CoinApplicateRecommend
extends
BaseActiveRecord
{
public
static
function
getDb
()
{
return
Yii
::
$app
->
get
(
'p_sources'
);
}
public
static
function
tableName
()
{
return
'{{%coin_applicate_recommend}}'
;
}
public
static
function
getRecommend
(
$relate_id
,
$type
)
{
return
self
::
find
()
->
where
([
'relate_id'
=>
$relate_id
,
'type'
=>
$type
])
->
one
();
}
public
static
function
getRecommendCount
()
{
return
self
::
find
()
->
count
();
}
/**
* @param $type
* 1 分类 2 应用
*/
public
static
function
getRecommendItemsByType
(
$type
)
{
$data
=
self
::
find
()
->
where
([
'type'
=>
$type
])
->
asArray
()
->
all
();
return
array_column
(
$data
,
null
,
'relate_id'
);
}
}
\ No newline at end of file
common/models/psources/CoinApplication.php
View file @
881be1ed
...
...
@@ -47,6 +47,7 @@ class CoinApplication extends BaseActiveRecord
$data
=
$data
->
asArray
()
->
all
();
$icon_Items
=
array_column
(
$data
,
'icon'
);
$icon_Infos
=
CoinImage
::
getItemsByIds
(
$icon_Items
);
$recommendItems
=
CoinApplicateRecommend
::
getRecommendItemsByType
(
2
);
foreach
(
$data
as
$key
=>
&
$value
){
if
(
$value
[
'icon'
]){
$value
[
'icon_url'
]
=
$icon_Infos
[
$value
[
'icon'
]][
'base_url'
]
.
$icon_Infos
[
$value
[
'icon'
]][
'file_url'
];
...
...
@@ -74,7 +75,9 @@ class CoinApplication extends BaseActiveRecord
}
else
{
$value
[
'has_ios'
]
=
0
;
}
$value
[
'isrecommend'
]
=
1
;
if
(
isset
(
$recommendItems
[
$value
[
'id'
]])){
$value
[
'isrecommend'
]
=
1
;
}
}
return
[
'count'
=>
$count
,
'data'
=>
$data
,
'code'
=>
0
];
}
...
...
common/models/psources/CoinApplicationCategory.php
View file @
881be1ed
...
...
@@ -60,6 +60,7 @@ class CoinApplicationCategory extends BaseActiveRecord
$icon_Infos
=
CoinImage
::
getItemsByIds
(
$image_Items
);
//获取分类应用数量
$cate_app_items
=
CoinAppCate
::
getAppCountByCateIds
(
$id_Items
);
$recommendItems
=
CoinApplicateRecommend
::
getRecommendItemsByType
(
1
);
foreach
(
$data
as
$key
=>
&
$value
){
if
(
$value
[
'icon'
]){
$value
[
'icon_url'
]
=
$icon_Infos
[
$value
[
'icon'
]][
'base_url'
]
.
$icon_Infos
[
$value
[
'icon'
]][
'file_url'
];
...
...
@@ -76,6 +77,9 @@ class CoinApplicationCategory extends BaseActiveRecord
}
else
{
$value
[
'app_count'
]
=
0
;
}
if
(
isset
(
$recommendItems
[
$value
[
'id'
]])){
$value
[
'isrecommend'
]
=
1
;
}
}
return
[
'count'
=>
$count
,
'data'
=>
$data
,
'code'
=>
0
];
}
...
...
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