Toggle navigation
Toggle navigation
This project
Loading...
Sign in
fe
/
YOHOBUYPC
·
Commits
Go to a project
GitLab
Go to group
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
0
Merge Requests
2
Members
Labels
Wiki
Forks
Network
Create a new issue
Download as
Email Patches
Plain Diff
Browse Files
Authored by
uedxwg
9 years ago
Commit
558d99b076ab98eade455b82a4604fe57e307a75
1 parent
8f9db511
历史错误修改
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
95 additions
and
6 deletions
static/js/category/brand.js
static/js/index/search.js
static/sass/category/_brand.scss
static/sass/index/_search.scss
template/m.yohobuy.com/actions/category/brand/search.phtml
template/m.yohobuy.com/actions/index/search/index.phtml
static/js/category/brand.js
View file @
558d99b
...
...
@@ -11,11 +11,19 @@ var $ = require('jquery'),
var
swiper
,
$fixTitleBar
,
$brandText
,
$brandHref
,
$brandList
=
$
(
'.brand-list'
);
var
searchH
=
$
(
'.newbrand-search'
).
outerHeight
(),
headerH
=
$
(
'.yoho-header'
).
outerHeight
(),
brandSwipe
=
parseInt
(
searchH
)
+
parseInt
(
headerH
)
-
1
,
minBrandListTop
,
searchArray
=
[],
clearTextHammer
,
removeHistory
,
searchList
,
yohoHistory
,
minBrandListTop
;
var
brandsData
,
...
...
@@ -109,6 +117,21 @@ function searchResult() {
// 插入 dom,绑定事件
$
(
'.search-result'
).
html
(
html
);
$
(
'.search-result .brand-list p'
).
each
(
function
(
index
)
{
searchList
=
new
Hammer
(
$
(
'.search-result .brand-list p'
).
eq
(
index
)[
0
]);
searchList
.
on
(
'tap'
,
function
()
{
$brandText
=
$
(
'.search-result .brand-list p'
).
eq
(
index
).
find
(
'a'
).
html
();
$brandHref
=
$
(
'.search-result .brand-list p'
).
eq
(
index
).
find
(
'a'
).
attr
(
'href'
);
if
(
localStorage
.
getItem
(
'yohoHistory'
))
{
yohoHistory
=
localStorage
.
getItem
(
'yohoHistory'
);
searchArray
.
push
(
yohoHistory
);
}
if
(
searchArray
.
toString
().
split
(
$brandText
).
length
<
2
)
{
searchArray
.
push
(
'{"searchName":"'
+
$brandText
+
'","searchHref":"'
+
$brandText
+
'"}'
);
}
localStorage
.
setItem
(
'yohoHistory'
,
searchArray
);
});
});
}
if
(
$
(
'.brand-search-page'
).
length
)
{
...
...
@@ -116,6 +139,7 @@ if ($('.brand-search-page').length) {
$keyword
=
$
(
'#keyword'
);
$keyword
.
on
(
'input'
,
function
()
{
$
(
'.history'
).
css
(
'display'
,
'none'
);
if
(
$keyword
.
val
().
length
)
{
searchResult
();
$
(
this
).
closest
(
'.search-box'
).
css
(
'width'
,
'11.25rem'
);
...
...
@@ -137,4 +161,20 @@ if ($('.brand-search-page').length) {
$
(
'form.search-box'
).
on
(
'submit'
,
function
()
{
return
false
;
});
if
(
localStorage
&&
localStorage
.
getItem
(
'yohoHistory'
))
{
yohoHistory
=
$
.
parseJSON
(
'['
+
localStorage
.
getItem
(
'yohoHistory'
)
+
']'
);
if
(
yohoHistory
)
{
$
.
each
(
yohoHistory
,
function
(
index
,
content
)
{
$
(
'<a href="'
+
content
.
searchHref
+
'">'
+
content
.
searchName
+
'</a>'
).
appendTo
(
'.historyList'
);
});
}
}
else
{
$
(
'.history'
).
css
(
'display'
,
'none'
);
}
removeHistory
=
new
Hammer
(
$
(
'.removeHistory'
)[
0
]);
removeHistory
.
on
(
'tap'
,
function
(
e
)
{
$
(
'.historyList'
).
html
(
' '
);
localStorage
.
clear
();
});
}
...
...
static/js/index/search.js
View file @
558d99b
...
...
@@ -37,7 +37,6 @@ $input.on('input', function() {
$clear
.
removeClass
(
'hide'
);
}
});
cHammer
=
new
Hammer
(
$clear
[
0
]);
cHammer
.
on
(
'tap'
,
function
()
{
$input
.
val
(
''
).
trigger
(
'input'
);
...
...
static/sass/category/_brand.scss
View file @
558d99b
...
...
@@ -194,6 +194,51 @@
.search-result
{
padding-top
:
176rem
/
$pxConvertRem
;
}
}
.history
{
width
:
100%
;
height
:
auto
;
overflow
:
hidden
;
position
:
absolute
;
left
:
0
;
top
:
176rem
/
$pxConvertRem
;
>
h6
{
width
:
100%
;
height
:
88rem
/
$pxConvertRem
;
line-height
:
88rem
/
$pxConvertRem
;
color
:
#999
;
text-indent
:
.6rem
;
font-size
:
36em
/
$pxConvertRem
;
}
.historyList
{
width
:
100%
;
height
:
auto
;
overflow
:
hidden
;
display
:
block
;
>
a
{
width
:
auto
;
height
:
58rem
/
$pxConvertRem
;
overflow
:
hidden
;
line-height
:
58rem
/
$pxConvertRem
;
margin
:
0
0
20rem
/
$pxConvertRem
.6rem
;
padding
:
0
20rem
/
$pxConvertRem
;
float
:
left
;
background-color
:
#f8f8f8
;
color
:
#444
;
}
}
>
span
{
width
:
auto
;
height
:
68rem
/
$pxConvertRem
;
overflow
:
hidden
;
display
:
inline-block
;
line-height
:
68rem
/
$pxConvertRem
;
border
:
1px
solid
#e6e6e6
;
padding
:
0
28rem
/
$pxConvertRem
;
font-size
:
48em
/
$pxConvertRem
;
margin-left
:
.6rem
;
color
:
#000
;
}
}
}
...
...
static/sass/index/_search.scss
View file @
558d99b
...
...
@@ -27,20 +27,20 @@
.clear-input
{
position
:
absolute
;
top
:
24rem
/
$pxConvertRem
;
right
:
1
00
rem
/
$pxConvertRem
;
right
:
1
45
rem
/
$pxConvertRem
;
font-size
:
32rem
/
$pxConvertRem
;
color
:
#b2b2b2
;
}
.search
{
position
:
absolute
;
top
:
1
6
rem
/
$pxConvertRem
;
top
:
1
8
rem
/
$pxConvertRem
;
left
:
515rem
/
$pxConvertRem
;
border
:
none
;
background
:
transparent
;
color
:
#000
;
font-size
:
32rem
/
$pxConvertRem
;
line-height
:
64
rem
/
$pxConvertRem
;
line-height
:
56
rem
/
$pxConvertRem
;
}
}
...
...
template/m.yohobuy.com/actions/category/brand/search.phtml
View file @
558d99b
...
...
@@ -10,6 +10,11 @@
</div>
</form>
</div>
<div
class=
"history"
>
<h
6
>历史纪录</h
6
>
<div
class=
"historyList"
></div>
<span
class='removeHistory'>清空搜索历史</span>
</div>
<div
class=
"search-result"
>
</div>
</div>
...
...
template/m.yohobuy.com/actions/index/search/index.phtml
View file @
558d99b
...
...
@@ -6,7 +6,7 @@
<i
class=
"search-icon iconfont"
>
60
f;</i>
<input
type=
"text"
placeholder=
"搜索商品"
name=
"query"
>
<i
class=
"clear-input iconfont hide"
>
626
;</i>
<
span
id=
"search"
class=
"search"
type=
"submit"
>搜索</spa
n>
<
button
id=
"search"
class=
"search"
type=
"submit"
>搜索</butto
n>
</form>
</div>
<div
class=
"search-items"
>
...
...
Please
register
or
login
to post a comment