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
86cf011b
Commit
86cf011b
authored
6 years ago
by
ZhuChunYang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加热门搜索
parent
286be60e
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
166 additions
and
19 deletions
+166
-19
ApplicateRankController.php
backend/controllers/ApplicateRankController.php
+64
-0
index.php
backend/views/applicate-rank/index.php
+34
-3
index.js
backend/web/js/applicate-rank/index.js
+68
-16
No files found.
backend/controllers/ApplicateRankController.php
View file @
86cf011b
...
...
@@ -101,5 +101,68 @@ class ApplicateRankController extends BaseController
}
}
public
function
actionAddSearch
()
{
if
(
Yii
::
$app
->
request
->
isAjax
)
{
Yii
::
$app
->
response
->
format
=
'json'
;
$request
=
Yii
::
$app
->
request
->
post
();
$serach_name
=
$request
[
'name'
];
if
(
$serach_name
){
Yii
::
$app
->
redis_app
->
zadd
(
'application_hot_search'
,
1
,
$serach_name
);
return
[
'code'
=>
0
,
'msg'
=>
'添加成功'
];
}
else
{
return
[
'code'
=>
1
,
'msg'
=>
'添加失败'
];
}
}
}
public
function
actionSearchIndex
()
{
if
(
Yii
::
$app
->
request
->
isAjax
)
{
Yii
::
$app
->
response
->
format
=
'json'
;
$redis
=
Yii
::
$app
->
redis_app
;
$data
=
$redis
->
zrange
(
'application_hot_search'
,
0
,
-
1
);
$search_data
=
[];
foreach
(
$data
as
$value
){
$item
[
'name'
]
=
$value
;
$item
[
'sort'
]
=
$redis
->
zscore
(
'application_hot_search'
,
$value
);
$search_data
[]
=
$item
;
}
return
[
'data'
=>
$search_data
,
'code'
=>
0
];
}
}
public
function
actionSearchDelete
()
{
if
(
Yii
::
$app
->
request
->
isAjax
)
{
Yii
::
$app
->
response
->
format
=
'json'
;
$request
=
Yii
::
$app
->
request
;
$name
=
$request
->
get
(
'name'
,
''
);
if
(
$name
)
{
Yii
::
$app
->
redis_app
->
zrem
(
'application_hot_search'
,
$name
);
return
[
'code'
=>
0
,
'msg'
=>
'热门搜索删除成功'
];
}
else
{
return
[
'code'
=>
1
,
'msg'
=>
'热门搜索删除失败'
];
}
}
}
public
function
actionSetSearchSort
()
{
if
(
Yii
::
$app
->
request
->
isAjax
)
{
Yii
::
$app
->
response
->
format
=
'json'
;
$request
=
Yii
::
$app
->
request
;
$name
=
$request
->
get
(
'name'
,
''
);
$sort
=
$request
->
get
(
'sort'
,
1
);
if
(
$name
)
{
Yii
::
$app
->
redis_app
->
zadd
(
'application_hot_search'
,
$sort
,
$name
);
return
[
'code'
=>
0
,
'msg'
=>
'排序设置成功'
];
}
else
{
return
[
'code'
=>
1
,
'msg'
=>
'排序设置失败'
];
}
}
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
backend/views/applicate-rank/index.php
View file @
86cf011b
...
...
@@ -15,21 +15,26 @@ IndexAsset::register($this);
<ul
class=
"layui-tab-title"
>
<li
class=
"layui-this"
>
热度榜
</li>
<li>
新品榜
</li>
<li>
热门搜索
</li>
</ul>
<div
class=
"layui-tab-content"
>
<div
class=
"layui-tab-item layui-show"
>
<button
class=
"layui-btn layui-btn-default"
id=
"add1"
>
添加热度应用
</button>
<table
class=
"layui-table"
id=
"table1"
lay-filter=
"table
1
"
></table>
<table
class=
"layui-table"
id=
"table1"
lay-filter=
"table"
></table>
</div>
<div
class=
"layui-tab-item"
>
<button
class=
"layui-btn layui-btn-default"
id=
"add2"
>
添加新品应用
</button>
<table
class=
"layui-table"
id=
"table2"
lay-filter=
"table2"
></table>
<table
class=
"layui-table"
id=
"table2"
lay-filter=
"table"
></table>
</div>
<div
class=
"layui-tab-item"
>
<button
class=
"layui-btn layui-btn-default"
id=
"add3"
>
添加热门搜索
</button>
<table
class=
"layui-table"
id=
"table3"
lay-filter=
"table"
></table>
</div>
</div>
</div>
</div>
<!-- 添加页面 -->
<!-- 添加
应用
页面 -->
<div
class=
"layui-row add"
style=
"display: none;padding: 5px;"
>
<div
class=
"layui-col-xs6 layui-col-sm6 layui-col-md11"
>
<form
class=
"layui-form form_add"
action=
"javascript:void(0)"
method=
"post"
lay-filter=
"form1"
>
...
...
@@ -54,6 +59,31 @@ IndexAsset::register($this);
</div>
</div>
<!-- 添加热门搜索页面 -->
<div
class=
"layui-row add_search"
style=
"display: none;padding: 5px;"
>
<div
class=
"layui-col-xs6 layui-col-sm6 layui-col-md11"
>
<form
class=
"layui-form form_add"
action=
"javascript:void(0)"
method=
"post"
lay-filter=
"form1"
>
<input
type=
"hidden"
name=
"_csrf"
value=
"
<?=
Yii
::
$app
->
request
->
getCsrfToken
()
?>
"
>
<div
class=
"layui-form-item"
>
<label
class=
"layui-form-label"
>
名称
</label>
<div
class=
"layui-input-block"
>
<input
type=
"text"
name=
"name"
required
lay-verify=
"required"
placeholder=
""
autocomplete=
"off"
class=
"layui-input"
>
</div>
</div>
<div
class=
"layui-form-item"
>
<div
class=
"layui-input-block"
>
<button
class=
"layui-btn btn_add_submit"
lay-submit
lay-filter=
"formSearch"
>
立即提交
</button>
</div>
</div>
</form>
</div>
</div>
<script
type=
"text/html"
id=
"operTpl"
>
<
a
class
=
"btn_delete"
lay
-
event
=
"delete"
><
i
class
=
"layui-icon"
style
=
"color: #4b67ff"
>&
#
xe640
;
<
/i></
a
>
</script>
<script
type=
"text/html"
id=
"operSearchTpl"
>
<
a
class
=
"btn_delete"
lay
-
event
=
"delete_search"
><
i
class
=
"layui-icon"
style
=
"color: #4b67ff"
>&
#
xe640
;
<
/i></
a
>
</script>
\ No newline at end of file
This diff is collapsed.
Click to expand it.
backend/web/js/applicate-rank/index.js
View file @
86cf011b
var
table1
=
layui
.
table
;
var
table2
=
layui
.
table
;
var
table3
=
layui
.
table
;
var
form
=
layui
.
form
;
var
layer_add
;
...
...
@@ -25,6 +26,16 @@ table2.render({
{
title
:
'操作'
,
templet
:
'#operTpl'
},
]]
});
table3
.
render
({
elem
:
'#table3'
,
url
:
'/admin/applicate-rank/search-index'
,
cols
:
[[
{
field
:
'name'
,
title
:
'热门搜索名称'
},
{
field
:
'sort'
,
title
:
'排序'
,
edit
:
'text'
},
{
title
:
'操作'
,
templet
:
'#operSearchTpl'
},
]]
});
form
.
render
();
layui
.
table
.
on
(
'tool(table)'
,
function
(
obj
)
{
...
...
@@ -43,6 +54,19 @@ layui.table.on('tool(table)', function (obj) {
}
});
});
}
else
if
(
event
==
'delete_search'
){
var
ldelete
=
layer
.
confirm
(
'确定要删除?'
,
{
icon
:
3
,
title
:
'删除'
},
function
(
index
)
{
$
.
get
(
'/admin/applicate-rank/search-delete'
,
{
name
:
data
.
name
},
function
(
rev
)
{
layer
.
msg
(
rev
.
msg
);
if
(
rev
.
code
==
0
)
{
obj
.
del
();
layer
.
close
(
ldelete
);
}
});
});
}
});
//添加图层
...
...
@@ -77,6 +101,21 @@ $("#add2").click(function () {
}
});
});
$
(
"#add3"
).
click
(
function
()
{
layer_add
=
layer
.
open
({
type
:
1
,
title
:
'版本信息'
,
content
:
$
(
'.add_search'
),
//这里content是一个普通的String
scrollbar
:
false
,
area
:
[
'700px'
,
'200px'
],
cancel
:
function
(
index
,
layero
)
{
$
(
'.add_search'
).
attr
(
'style'
,
'display:none;padding: 5px;'
);
$
(
'input[name="name"]'
).
val
(
''
);
form
.
render
();
},
});
});
form
.
on
(
'submit(formDemo)'
,
function
(
data
)
{
$
.
post
(
'/admin/applicate-rank/add'
,
data
.
field
,
function
(
rev
)
{
layer
.
msg
(
rev
.
msg
);
...
...
@@ -88,41 +127,54 @@ form.on('submit(formDemo)', function (data) {
return
false
;
});
form
.
on
(
'submit(formSearch)'
,
function
(
data
)
{
$
.
post
(
'/admin/applicate-rank/add-search'
,
data
.
field
,
function
(
rev
)
{
layer
.
msg
(
rev
.
msg
);
if
(
rev
.
code
==
0
)
{
layer
.
close
(
layer_add
);
$
(
'.add_search'
).
attr
(
'style'
,
'display:none;padding: 5px;'
);
$
(
'input[name="name"]'
).
val
(
''
);
table3
.
reload
(
'table3'
,
{});
form
.
render
();
}
});
return
false
;
});
function
after_close_add
(
reflush
=
true
)
{
if
(
reflush
)
{
table1
.
reload
(
'table1'
,
{});
table2
.
reload
(
'table2'
,
{});
}
$
(
'.add'
).
attr
(
'style'
,
'display:none'
);
$
(
'.add'
).
attr
(
'style'
,
'display:none
;padding: 5px;
'
);
$
(
'input[name="id"]'
).
val
(
''
);
$
(
'select[name="applicate_id"]'
).
val
(
0
);
form
.
render
();
}
//监听单元格编辑
layui
.
table
.
on
(
'edit(table
1
)'
,
function
(
obj
){
layui
.
table
.
on
(
'edit(table)'
,
function
(
obj
){
var
value
=
obj
.
value
;
//得到修改后的值
var
data
=
obj
.
data
;
//得到所在行所有键值
$
.
get
(
'/admin/applicate-rank/set-sort'
,
{
id
:
data
.
id
,
type
:
data
.
type
,
sort
:
value
},
function
(
rev
)
{
if
(
data
.
type
){
var
params
=
{
id
:
data
.
id
,
type
:
data
.
type
,
sort
:
value
};
var
url
=
'/admin/applicate-rank/set-sort'
;
}
else
{
var
params
=
{
name
:
data
.
name
,
sort
:
value
};
var
url
=
'/admin/applicate-rank/set-search-sort'
;
}
$
.
get
(
url
,
params
,
function
(
rev
)
{
layer
.
msg
(
rev
.
msg
);
if
(
0
==
rev
.
code
)
{
table1
.
reload
(
'table1'
,{});
if
(
data
.
type
){
layui
.
table
.
reload
(
'table'
+
data
.
type
,{});
}
else
{
layui
.
table
.
reload
(
'table3'
,{});
}
}
else
{
}
});
});
//监听单元格编辑
layui
.
table
.
on
(
'edit(table2)'
,
function
(
obj
){
var
value
=
obj
.
value
;
//得到修改后的值
var
data
=
obj
.
data
;
//得到所在行所有键值
$
.
get
(
'/admin/applicate-rank/set-sort'
,
{
id
:
data
.
id
,
type
:
data
.
type
,
sort
:
value
},
function
(
rev
)
{
layer
.
msg
(
rev
.
msg
);
if
(
0
==
rev
.
code
)
{
table2
.
reload
(
'table2'
,{});
}
else
{
}
});
});
This diff is collapsed.
Click to expand it.
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