Toggle navigation
Toggle navigation
This project
Loading...
Sign in
fe
/
YOHOBUYWAP
·
Commits
Go to a project
GitLab
Go to group
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
0
Merge Requests
0
Members
Labels
Wiki
Forks
Network
Create a new issue
Download as
Email Patches
Plain Diff
Browse Files
Authored by
whb
9 years ago
Commit
8bb433ed8069f45f9ffeefb7dae9d4782533c9e1
1 parent
58d4d312
index,js.css
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
306 additions
and
302 deletions
web-static/dist/yohobuy/0.0.1/index-debug.js
web-static/dist/yohobuy/0.0.1/index.css
web-static/dist/yohobuy/0.0.1/index.js
web-static/dist/yohobuy/assets/img/passport/third-s81c3ccb2fa.png
web-static/dist/yohobuy/0.0.1/index-debug.js
View file @
8bb433e
...
...
@@ -1483,305 +1483,309 @@ require("js/product/sort-pager");
require
(
"js/product/product"
);
});
define
(
"js/product/filter"
,
[
"jquery"
],
function
(
require
,
exports
,
module
){
/**
* 商品筛选逻辑
* @author: xuqi<qi.xu@yoho.cn>
* @date: 2015/12/4
*/
var
$
=
require
(
"jquery"
);
var
checkUnicode
=
{
unchecked
:
''
,
checked
:
''
},
moreUnicode
=
{
up
:
''
,
down
:
''
};
//品牌相关变量
var
$brandDefault
=
$
(
'.brand .default'
),
$brandPanel
=
$
(
'.brand .brand-panel'
),
$brandAttrs
=
$
(
'.brand .attr'
),
$brandMore
=
$
(
'#brand-more'
),
$brandMulti
=
$
(
'#brand-multi'
);
var
$brandMoreTxt
,
$brandMoreIcon
;
//价格相关变量
var
$udPrice
=
$
(
'.ud-price-range'
),
interReg
=
/^
\d
+$/
,
$limit
,
$min
,
$max
,
$btn
;
//分类相关变量
var
$sortSub
=
$
(
'.sort-sub-wrap'
);
//高级选项相关变量
var
$seniorSubWrap
=
$
(
'.senior-sub-wrap'
),
$seniorAttrWrap
=
$
(
'.senior-attr-wrap'
);
var
seniorHoverTime
,
hoveredIndex
;
//清除checkbox选中状态
function
clearChecked
(
$checkbox
)
{
$checkbox
.
removeClass
(
'checked'
).
html
(
checkUnicode
.
unchecked
);
}
//显示更多品牌面板
function
brandShowMore
()
{
$brandDefault
.
addClass
(
'hide'
);
$brandPanel
.
removeClass
(
'hide'
);
}
//隐藏更多品牌面板
function
brandHideMore
()
{
$brandPanel
.
addClass
(
'hide'
);
$brandDefault
.
removeClass
(
'hide'
);
}
//url构造&跳转
function
uriLoc
(
attr
,
val
)
{
var
href
=
decodeURIComponent
(
window
.
location
.
search
),
query
=
attr
+
'='
+
val
,
newHref
;
if
(
href
===
''
)
{
newHref
=
'?'
+
query
;
}
else
{
newHref
=
href
+
'&'
+
query
;
}
window
.
location
.
href
=
newHref
;
}
//隐藏高级选项面板
function
hideSeniorPanel
(
index
)
{
$seniorSubWrap
.
children
(
'.senior-sub:eq('
+
hoveredIndex
+
')'
).
addClass
(
'hide'
);
$seniorAttrWrap
.
children
(
'.attr:eq('
+
hoveredIndex
+
')'
).
removeClass
(
'hover'
);
hoveredIndex
=
-
1
;
}
//屏蔽筛选项双击文字选中
$
(
'.filter-box'
).
on
(
'selectstart'
,
'.attr, .brands-index span'
,
function
()
{
return
false
;
});
//【分类】
$
(
'.sort-pre'
).
on
(
'click'
,
'li'
,
function
()
{
var
$this
=
$
(
this
),
index
=
$this
.
index
();
$this
.
siblings
(
'.active'
).
removeClass
(
'active'
);
$this
.
addClass
(
'active'
);
$sortSub
.
children
(
':not(.hide)'
).
addClass
(
'hide'
);
$sortSub
.
children
(
':eq('
+
index
+
')'
).
removeClass
(
'hide'
);
});
//【品牌】
if
(
$brandMore
.
length
>
0
)
{
$brandMoreTxt
=
$brandMore
.
children
(
'em'
);
$brandMoreIcon
=
$brandMore
.
children
(
'.iconfont'
);
}
//【品牌】多选
$brandMulti
.
click
(
function
()
{
if
(
$brandPanel
.
css
(
'display'
)
===
'none'
)
{
//显示品牌面板
brandShowMore
();
}
$brandPanel
.
addClass
(
'multi'
);
//显示出checkbox
$
(
this
).
addClass
(
'hide'
);
});
//【品牌】更多
$brandMore
.
click
(
function
()
{
var
$this
=
$
(
this
);
if
(
$this
.
hasClass
(
'more'
))
{
brandHideMore
();
$brandMoreTxt
.
text
(
'更多'
);
$brandMoreIcon
.
html
(
moreUnicode
.
down
);
}
else
{
brandShowMore
();
$brandMoreTxt
.
text
(
'收起'
);
$brandMoreIcon
.
html
(
moreUnicode
.
up
);
}
$
(
this
).
toggleClass
(
'more'
);
});
//【品牌】索引
$
(
'.brands-index'
).
on
(
'click'
,
'span'
,
function
()
{
var
$this
=
$
(
this
),
index
=
$this
.
data
(
'index'
);
if
(
$this
.
index
()
===
0
)
{
//全部
$brandAttrs
.
removeClass
(
'hide'
);
}
else
{
$brandAttrs
.
addClass
(
'hide'
).
filter
(
'[data-index='
+
index
+
']'
).
removeClass
(
'hide'
);
}
});
//【品牌】搜索
$
(
'#brand-search-input'
).
keyup
(
function
()
{
var
val
=
$
(
this
).
val
().
toLowerCase
();
if
(
val
===
''
)
{
$brandAttrs
.
removeClass
(
'hide'
);
}
else
{
$brandAttrs
.
addClass
(
'hide'
).
filter
(
'[data-key*='
+
val
+
']'
).
removeClass
(
'hide'
);
}
});
//【品牌】多选确定
$
(
'#brand-multi-ok'
).
click
(
function
()
{
var
val
=
''
;
if
(
$
(
this
).
hasClass
(
'dis'
))
{
return
;
}
$brandPanel
.
find
(
'.checked'
).
each
(
function
()
{
var
id
=
$
(
this
).
data
(
'id'
);
val
+=
(
val
===
''
)
?
id
:
(
','
+
id
);
});
uriLoc
(
'brand'
,
val
);
});
//【品牌/高级选项】多选取消
$
(
'.multi-select-cancel'
).
click
(
function
()
{
var
$panel
=
$
(
this
).
closest
(
'.multi'
);
if
(
$panel
.
hasClass
(
'brand-panel'
))
{
brandHideMore
();
$brandMulti
.
removeClass
(
'hide'
);
//显示多选按钮
}
$panel
.
removeClass
(
'multi'
);
clearChecked
(
$panel
.
find
(
'.checkbox.checked'
));
//清除选中状态
});
//【品牌/高级选项】checkbox
$
(
'.check-container'
).
on
(
'click'
,
'.attr'
,
function
()
{
var
$this
=
$
(
this
),
$check
=
$this
.
find
(
'.checkbox'
),
$btnOk
=
$this
.
parent
(
'.check-container'
).
next
(
'.btns'
).
find
(
'.multi-select-ok'
);
$check
.
toggleClass
(
'checked'
);
if
(
$check
.
hasClass
(
'checked'
))
{
$check
.
html
(
checkUnicode
.
checked
);
}
else
{
$check
.
html
(
checkUnicode
.
unchecked
);
}
//更新按钮状态
if
(
$check
.
hasClass
(
'checked'
)
||
$this
.
siblings
(
'.attr'
).
find
(
'.checked'
).
length
>
0
)
{
$btnOk
.
removeClass
(
'dis'
);
}
else
{
$btnOk
.
addClass
(
'dis'
);
}
});
//【品牌/高级选项】当多选时阻止链接默认跳转
$
(
'.brand, .senior'
).
on
(
'click'
,
'.attr > a'
,
function
(
e
)
{
if
(
$
(
this
).
closest
(
'.multi'
).
length
>
0
)
{
e
.
preventDefault
();
}
});
//【价格】用户定义价格处理
if
(
$udPrice
.
length
>
0
)
{
$limit
=
$udPrice
.
find
(
'.limit'
);
$min
=
$limit
.
filter
(
'.min'
);
$max
=
$limit
.
filter
(
'.max'
);
$btn
=
$udPrice
.
find
(
'.price-sure'
);
//【价格】输入
$limit
.
keyup
(
function
()
{
var
min
=
$
.
trim
(
$min
.
val
()),
max
=
$
.
trim
(
$max
.
val
()),
isMinInt
=
interReg
.
test
(
min
),
isMaxInt
=
interReg
.
test
(
max
);
if
(
isMaxInt
&&
(
min
===
''
||
isMinInt
)
||
isMinInt
&&
(
max
===
''
||
isMaxInt
)
)
{
$btn
.
removeClass
(
'hide'
);
}
else
{
$btn
.
addClass
(
'hide'
);
}
});
//【价格】多项查询
$btn
.
click
(
function
()
{
var
min
=
$
.
trim
(
$min
.
val
()),
max
=
$
.
trim
(
$max
.
val
()),
tmp
;
//对于min大于max的情况,交换位置
if
(
min
!==
''
&&
max
!==
''
&&
+
min
>
+
max
)
{
tmp
=
max
;
max
=
min
;
min
=
tmp
;
}
uriLoc
(
'price'
,
min
+
','
+
max
);
});
}
//【高级选项】鼠标移入显示子项
$seniorAttrWrap
.
on
(
'mouseenter'
,
'.attr'
,
function
()
{
var
index
=
$
(
this
).
addClass
(
'hover'
).
index
();
$seniorSubWrap
.
children
(
'.senior-sub:eq('
+
index
+
')'
).
removeClass
(
'hide'
);
}).
on
(
'mouseleave'
,
'.attr'
,
function
()
{
var
$this
=
$
(
this
),
index
=
$this
.
index
();
hoveredIndex
=
index
;
seniorHoverTime
=
setTimeout
(
function
()
{
hideSeniorPanel
();
},
100
);
});
//【高级选项】多选
$
(
'.senior-sub'
).
on
(
'click'
,
'.multi-select'
,
function
()
{
$
(
this
).
closest
(
'.senior-sub'
).
addClass
(
'multi'
);
}).
on
(
'click'
,
'.multi-select-ok'
,
function
()
{
var
$btn
=
$
(
this
),
$sub
=
$btn
.
closest
(
'.senior-sub'
),
val
=
''
;
if
(
$btn
.
hasClass
(
'dis'
))
{
return
;
}
$sub
.
find
(
'.checked'
).
each
(
function
()
{
var
id
=
$
(
this
).
data
(
'id'
);
val
+=
(
val
===
''
)
?
id
:
(
','
+
id
);
});
uriLoc
(
$sub
.
data
(
'attr'
),
val
);
}).
on
(
'mouseenter'
,
function
()
{
clearTimeout
(
seniorHoverTime
);
}).
on
(
'mouseleave'
,
function
()
{
hideSeniorPanel
();
/**
* 商品筛选逻辑
* @author: xuqi<qi.xu@yoho.cn>
* @date: 2015/12/4
*/
var
$
=
require
(
"jquery"
);
var
checkUnicode
=
{
unchecked
:
''
,
checked
:
''
},
moreUnicode
=
{
up
:
''
,
down
:
''
};
//品牌相关变量
var
$brandDefault
=
$
(
'.brand .default'
),
$brandPanel
=
$
(
'.brand .brand-panel'
),
$brandAttrs
=
$
(
'.brand .attr'
),
$brandMore
=
$
(
'#brand-more'
),
$brandMulti
=
$
(
'#brand-multi'
);
var
$brandMoreTxt
,
$brandMoreIcon
;
//价格相关变量
var
$udPrice
=
$
(
'.ud-price-range'
),
interReg
=
/^
\d
+$/
,
$limit
,
$min
,
$max
,
$btn
;
//分类相关变量
var
$sortSub
=
$
(
'.sort-sub-wrap'
);
//高级选项相关变量
var
$seniorSubWrap
=
$
(
'.senior-sub-wrap'
),
$seniorAttrWrap
=
$
(
'.senior-attr-wrap'
);
var
seniorHoverTime
,
hoveredIndex
;
//清除checkbox选中状态
function
clearChecked
(
$checkbox
)
{
$checkbox
.
removeClass
(
'checked'
).
html
(
checkUnicode
.
unchecked
);
}
//显示更多品牌面板
function
brandShowMore
()
{
$brandDefault
.
addClass
(
'hide'
);
$brandPanel
.
removeClass
(
'hide'
);
}
//隐藏更多品牌面板
function
brandHideMore
()
{
$brandPanel
.
addClass
(
'hide'
);
$brandDefault
.
removeClass
(
'hide'
);
}
//url构造&跳转
function
uriLoc
(
attr
,
val
)
{
var
href
=
decodeURIComponent
(
window
.
location
.
search
),
query
=
attr
+
'='
+
val
,
newHref
;
if
(
href
===
''
)
{
newHref
=
'?'
+
query
;
}
else
{
newHref
=
href
+
'&'
+
query
;
}
window
.
location
.
href
=
newHref
;
}
//隐藏高级选项面板
function
hideSeniorPanel
(
index
)
{
$seniorSubWrap
.
children
(
'.senior-sub:eq('
+
hoveredIndex
+
')'
).
addClass
(
'hide'
);
$seniorAttrWrap
.
children
(
'.attr:eq('
+
hoveredIndex
+
')'
).
removeClass
(
'hover'
);
hoveredIndex
=
-
1
;
}
//屏蔽筛选项双击文字选中
$
(
'.filter-box'
).
on
(
'selectstart'
,
'.attr, .brands-index span'
,
function
()
{
return
false
;
});
//【分类】
$
(
'.sort-pre'
).
on
(
'click'
,
'li'
,
function
()
{
var
$this
=
$
(
this
),
index
=
$this
.
index
();
$this
.
siblings
(
'.active'
).
removeClass
(
'active'
);
$this
.
addClass
(
'active'
);
$sortSub
.
children
(
':not(.hide)'
).
addClass
(
'hide'
);
$sortSub
.
children
(
':eq('
+
index
+
')'
).
removeClass
(
'hide'
);
});
//【品牌】
if
(
$brandMore
.
length
>
0
)
{
$brandMoreTxt
=
$brandMore
.
children
(
'em'
);
$brandMoreIcon
=
$brandMore
.
children
(
'.iconfont'
);
}
//【品牌】多选
$brandMulti
.
click
(
function
()
{
if
(
$brandPanel
.
css
(
'display'
)
===
'none'
)
{
//显示品牌面板
brandShowMore
();
}
$brandPanel
.
addClass
(
'multi'
);
//显示出checkbox
$
(
this
).
addClass
(
'hide'
);
});
//【品牌】更多
$brandMore
.
click
(
function
()
{
var
$this
=
$
(
this
);
if
(
$this
.
hasClass
(
'more'
))
{
brandHideMore
();
$brandMoreTxt
.
text
(
'更多'
);
$brandMoreIcon
.
html
(
moreUnicode
.
down
);
}
else
{
brandShowMore
();
$brandMoreTxt
.
text
(
'收起'
);
$brandMoreIcon
.
html
(
moreUnicode
.
up
);
}
$
(
this
).
toggleClass
(
'more'
);
});
//【品牌】索引
$
(
'.brands-index'
).
on
(
'click'
,
'span'
,
function
()
{
var
$this
=
$
(
this
),
index
=
$this
.
data
(
'index'
);
if
(
$this
.
index
()
===
0
)
{
//全部
$brandAttrs
.
removeClass
(
'hide'
);
}
else
{
$brandAttrs
.
addClass
(
'hide'
).
filter
(
'[data-index='
+
index
+
']'
).
removeClass
(
'hide'
);
}
});
//【品牌】搜索
$
(
'#brand-search-input'
).
keyup
(
function
()
{
var
val
=
$
(
this
).
val
().
toLowerCase
();
if
(
val
===
''
)
{
$brandAttrs
.
removeClass
(
'hide'
);
}
else
{
$brandAttrs
.
addClass
(
'hide'
).
filter
(
'[data-key*='
+
val
+
']'
).
removeClass
(
'hide'
);
}
});
//【品牌】多选确定
$
(
'#brand-multi-ok'
).
click
(
function
()
{
var
val
=
''
;
if
(
$
(
this
).
hasClass
(
'dis'
))
{
return
;
}
$brandPanel
.
find
(
'.checked'
).
each
(
function
()
{
var
id
=
$
(
this
).
data
(
'id'
);
val
+=
(
val
===
''
)
?
id
:
(
','
+
id
);
});
uriLoc
(
'brand'
,
val
);
});
//【品牌/高级选项】多选取消
$
(
'.multi-select-cancel'
).
click
(
function
()
{
var
$panel
=
$
(
this
).
closest
(
'.multi'
);
if
(
$panel
.
hasClass
(
'brand-panel'
))
{
brandHideMore
();
$brandMulti
.
removeClass
(
'hide'
);
//显示多选按钮
}
$panel
.
removeClass
(
'multi'
);
clearChecked
(
$panel
.
find
(
'.checkbox.checked'
));
//清除选中状态
});
//【品牌/高级选项】checkbox
$
(
'.check-container'
).
on
(
'click'
,
'.attr'
,
function
()
{
var
$this
=
$
(
this
),
$check
=
$this
.
find
(
'.checkbox'
),
$btnOk
=
$this
.
parent
(
'.check-container'
).
next
(
'.btns'
).
find
(
'.multi-select-ok'
);
$check
.
toggleClass
(
'checked'
);
if
(
$check
.
hasClass
(
'checked'
))
{
$check
.
html
(
checkUnicode
.
checked
);
}
else
{
$check
.
html
(
checkUnicode
.
unchecked
);
}
//更新按钮状态
if
(
$check
.
hasClass
(
'checked'
)
||
$this
.
siblings
(
'.attr'
).
find
(
'.checked'
).
length
>
0
)
{
$btnOk
.
removeClass
(
'dis'
);
}
else
{
$btnOk
.
addClass
(
'dis'
);
}
});
//【品牌/高级选项】当多选时阻止链接默认跳转
$
(
'.brand, .senior'
).
on
(
'click'
,
'.attr > a'
,
function
(
e
)
{
if
(
$
(
this
).
closest
(
'.multi'
).
length
>
0
)
{
e
.
preventDefault
();
}
});
//【价格】用户定义价格处理
if
(
$udPrice
.
length
>
0
)
{
$limit
=
$udPrice
.
find
(
'.limit'
);
$min
=
$limit
.
filter
(
'.min'
);
$max
=
$limit
.
filter
(
'.max'
);
$btn
=
$udPrice
.
find
(
'.price-sure'
);
//【价格】输入
$limit
.
keyup
(
function
()
{
var
min
=
$
.
trim
(
$min
.
val
()),
max
=
$
.
trim
(
$max
.
val
()),
isMinInt
=
interReg
.
test
(
min
),
isMaxInt
=
interReg
.
test
(
max
);
if
(
isMaxInt
&&
(
min
===
''
||
isMinInt
)
||
isMinInt
&&
(
max
===
''
||
isMaxInt
)
)
{
$btn
.
removeClass
(
'hide'
);
}
else
{
$btn
.
addClass
(
'hide'
);
}
});
//【价格】多项查询
$btn
.
click
(
function
()
{
var
min
=
$
.
trim
(
$min
.
val
()),
max
=
$
.
trim
(
$max
.
val
()),
tmp
;
//对于min大于max的情况,交换位置
if
(
min
!==
''
&&
max
!==
''
&&
+
min
>
+
max
)
{
tmp
=
max
;
max
=
min
;
min
=
tmp
;
}
uriLoc
(
'price'
,
min
+
','
+
max
);
});
}
//【高级选项】鼠标移入显示子项
$seniorAttrWrap
.
on
(
'mouseenter'
,
'.attr'
,
function
()
{
var
$this
=
$
(
this
);
var
index
=
$this
.
index
();
$this
.
addClass
(
'hover'
).
siblings
().
removeClass
(
'hover'
);
$seniorSubWrap
.
children
(
'.senior-sub:eq('
+
index
+
')'
).
removeClass
(
'hide'
).
siblings
().
addClass
(
'hide'
);
}).
on
(
'mouseleave'
,
'.attr'
,
function
()
{
var
$this
=
$
(
this
),
index
=
$this
.
index
();
hoveredIndex
=
index
;
seniorHoverTime
=
setTimeout
(
function
()
{
hideSeniorPanel
();
},
100
);
});
//【高级选项】多选
$
(
'.senior-sub'
).
on
(
'click'
,
'.multi-select'
,
function
()
{
$
(
this
).
closest
(
'.senior-sub'
).
addClass
(
'multi'
);
}).
on
(
'click'
,
'.multi-select-ok'
,
function
()
{
var
$btn
=
$
(
this
),
$sub
=
$btn
.
closest
(
'.senior-sub'
),
val
=
''
;
if
(
$btn
.
hasClass
(
'dis'
))
{
return
;
}
$sub
.
find
(
'.checked'
).
each
(
function
()
{
var
id
=
$
(
this
).
data
(
'id'
);
val
+=
(
val
===
''
)
?
id
:
(
','
+
id
);
});
uriLoc
(
$sub
.
data
(
'attr'
),
val
);
}).
on
(
'mouseenter'
,
function
()
{
clearTimeout
(
seniorHoverTime
);
}).
on
(
'mouseleave'
,
function
()
{
hideSeniorPanel
();
});
});
define
(
"js/product/sort-pager"
,
[
"jquery"
],
function
(
require
,
exports
,
module
){
/**
...
...
@@ -3962,7 +3966,7 @@ function picCaptchaAjaxFn(page, callback) {
type
:
'POST'
,
url
:
url
,
data
:
{
c
ode
:
$ca
.
val
()
verifyC
ode
:
$ca
.
val
()
//mobile: $pn.val(),
//area: $region.text().split('+')[1]
...
...
@@ -3995,7 +3999,7 @@ function msgCaptchaAjaxFn(page, callback) {
type
:
'POST'
,
url
:
url
,
data
:
{
c
ode
:
$ca
.
val
(),
verifyC
ode
:
$ca
.
val
(),
mobile
:
$pn
.
val
(),
area
:
$region
.
text
().
split
(
'+'
)[
1
]
}
...
...
@@ -4291,7 +4295,7 @@ exports.init = function(page) {
$regionSelect
.
change
(
function
()
{
$region
.
text
(
'+'
+
$
(
'#region'
).
val
());
$region
.
text
(
$
(
'#region'
).
val
());
validateRule
(
page
,
$pn
,
showErrTip
);
//验证
});
...
...
@@ -4319,7 +4323,7 @@ exports.init = function(page) {
data
:
{
area
:
$region
.
text
().
split
(
'+'
)[
1
],
mobile
:
$pn
.
val
(),
c
ode
:
$ca
.
val
()
verifyC
ode
:
$ca
.
val
()
}
}).
then
(
function
(
data
)
{
if
(
data
.
code
===
200
)
{
...
...
web-static/dist/yohobuy/0.0.1/index.css
View file @
8bb433e
This diff could not be displayed because it is too large.
web-static/dist/yohobuy/0.0.1/index.js
View file @
8bb433e
This diff could not be displayed because it is too large.
web-static/dist/yohobuy/assets/img/passport/third-s81c3ccb2fa.png
deleted
100644 → 0
View file @
58d4d31
3.76 KB
Please
register
or
login
to post a comment