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
d475df3b75926e503cb9492c0d3e730b48886cd9
1 parent
b2402e6a
index.js
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
659 additions
and
536 deletions
web-static/dist/yohobuy/0.0.1/index-debug.js
web-static/dist/yohobuy/0.0.1/index.js
web-static/dist/yohobuy/0.0.1/index-debug.js
View file @
d475df3
...
...
@@ -320,6 +320,98 @@ if ($('.simple-header').size() > 0) {
$
(
this
).
find
(
'.tool-select'
).
fadeOut
();
});
}
/**
* 格式化用户名
* @return {[type]} [description]
*/
function
formatUsernName
(
userName
)
{
var
name
,
char
,
_num
=
0
,
_length
=
0
,
t
;
for
(
t
=
0
;
t
<
userName
.
length
;
t
++
)
{
char
=
userName
.
substr
(
t
,
1
);
if
(
/.*
[\u
4e00-
\u
9fa5
]
+.*$/
.
test
(
char
))
{
_length
+=
2
;
}
else
{
_length
+=
1
;
}
}
if
(
_length
<=
10
)
{
name
=
userName
;
}
else
{
_num
=
0
;
name
=
''
;
for
(
t
=
0
;
t
<
userName
.
length
;
t
++
)
{
if
(
_num
<
10
)
{
char
=
userName
.
substr
(
t
,
1
);
if
(
char
!==
'*'
)
{
if
(
/.*
[\u
4e00-
\u
9fa5
]
+.*$/
.
test
(
char
))
{
_num
+=
2
;
}
else
{
_num
+=
1
;
}
}
name
+=
char
;
}
}
if
(
name
.
length
<
userName
.
length
)
{
name
+=
'...'
;
}
}
return
name
;
}
/**
* 设置简单头部登陆状态
* @return {[type]} [description]
*/
function
setLoginStatus
(
_data
)
{
var
loginHtml
,
name
;
if
(
_data
&&
_data
.
href
&&
_data
.
href
.
user
)
{
name
=
formatUsernName
(
_data
.
href
.
user
);
loginHtml
=
'<span>Hi~</span><a href="">'
+
name
+
'</a> <a href="'
+
_data
.
href
.
logout
+
'">[退出]</a>'
;
}
else
{
name
=
formatUsernName
(
_data
.
user
);
loginHtml
=
'<span>Hi~</span><a href="">'
+
name
+
'</a> <a href="http://www.yohobuy.com/signin.html">[请登录]</a>'
+
'<a href="http://www.yohobuy.com/reg.html">[免费注册]</a>'
;
}
$
(
'.header-tool li'
).
eq
(
0
).
html
(
loginHtml
);
}
/**
* 获取登录信息
* @return {[type]} [description]
*/
function
actionLoginInfo
()
{
$
.
ajax
({
type
:
'GET'
,
url
:
'/common/getSimpleHeader'
,
data
:
{},
success
:
function
(
data
)
{
if
(
data
.
code
===
200
)
{
setLoginStatus
(
data
.
data
);
}
}
});
}
/**
* 初始化函数
* @return {[type]} [description]
*/
function
init
()
{
actionLoginInfo
();
//获取登录信息
}
init
();
});
define
(
"js/header"
,
[
"jquery"
,
"handlebars"
,
"source-map"
,
"index"
],
function
(
require
,
exports
,
module
){
/**
...
...
@@ -643,10 +735,26 @@ function JsonPCallBack(data) {
if
(
+
data
.
code
===
200
)
{
if
(
typeof
data
.
data
===
'object'
)
{
topbanner
=
'<a target="_blank" href="'
+
data
.
data
.
url
+
'" class="page-top-banner"'
+
'style="height:50px;border:none;background-image:url('
+
window
.
unescape
(
data
.
data
.
src
)
+
');'
+
'background-position: center;display:block;background-color:#ff5409;"> </a>'
;
$
(
'body'
).
prepend
(
topbanner
);
if
(
data
.
data
.
url
!==
''
){
topbanner
=
'<a target="_blank" href="'
+
data
.
data
.
url
+
'" class="page-top-banner"'
+
'style="height:36px;border:none;background-image:url('
+
window
.
unescape
(
data
.
data
.
src
)
+
');'
+
'background-position: center;display:block;background-size:contain"> </a>'
;
}
else
{
topbanner
=
'<div class="noticewrapper">'
+
'<div class="noticecontainer">'
+
'<h1 class="noticetitle">关于系统升级的公告</h1>'
+
'<div class="noticecontent">'
+
'<p class="tips">尊敬的顾客:</p>'
+
'<p class="detail">您好!为了向您提供更优质的服务,目前系统正在升级,请耐心等待。</p>'
+
'<p class="detail">'
+
'系统升级期间,部分地区用户体验会有暂时中断,如遇紧急事宜,欢迎垂询客服热线:400-889-9646 09:00-22:30(周一至周日)。稍后系统将恢复正常'
+
'</p>'
+
'<p class="detail">使用,欢迎您继续光顾YOHO!BUY有货!带来不便之处深表歉意,请您谅解!</p>'
+
'</div>'
+
'</div>'
+
'</div>'
;
}
$
(
'body'
).
prepend
(
topbanner
);
}
}
}
...
...
@@ -1872,362 +1980,364 @@ require("js/product/latest-walk");
require
(
"js/product/product"
);
});
define
(
"js/product/filter"
,
[
"jquery"
,
"handlebars"
,
"source-map"
],
function
(
require
,
exports
,
module
){
/**
* 商品筛选逻辑
* @author: xuqi<qi.xu@yoho.cn>
* @date: 2015/12/4
*/
var
$
=
require
(
"jquery"
),
Handlebars
=
require
(
"handlebars"
);
var
checkUnicode
=
{
unchecked
:
''
,
checked
:
''
},
moreUnicode
=
{
up
:
''
,
down
:
''
};
//品牌相关变量
var
$brandDefault
=
$
(
'.brand .default'
),
$brandPanel
=
$
(
'.brand .brand-panel'
),
$brandAttrs
=
$brandPanel
.
find
(
'.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
;
// 尺寸 handlebars 模板
var
sizeTmpl
=
'{{# size}}<a class="attr {{#if checked}}checked{{/if}}" href="{{href}}">{{name}}</a>{{/ size}}'
,
sizeCache
=
{},
// 缓存一下尺寸信息
$sizeWrap
=
$
(
'.filter-box .size'
);
sizeTmpl
=
Handlebars
.
compile
(
sizeTmpl
);
//清除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
(),
id
=
$this
.
data
(
'id'
);
if
(
$this
.
hasClass
(
'active'
))
{
// 选中时,再次点击取消选中
$this
.
removeClass
(
'active'
);
$sortSub
.
children
(
':eq('
+
index
+
')'
).
addClass
(
'hide'
);
$sizeWrap
.
addClass
(
'hide'
);
return
;
}
$this
.
siblings
(
'.active'
).
removeClass
(
'active'
);
$this
.
addClass
(
'active'
);
$sortSub
.
children
(
':not(.hide)'
).
addClass
(
'hide'
);
$sortSub
.
children
(
':eq('
+
index
+
')'
).
removeClass
(
'hide'
);
if
(
sizeCache
[
id
])
{
$sizeWrap
.
find
(
'.attr-content'
).
html
(
sizeCache
[
id
]);
$sizeWrap
.
removeClass
(
'hide'
);
}
else
{
$
.
ajax
({
url
:
'/product/search/sortSize'
,
data
:
{
msort
:
id
}
}).
then
(
function
(
res
)
{
if
(
$
.
type
(
res
)
===
'array'
&&
res
.
length
)
{
sizeCache
[
id
]
=
sizeTmpl
({
size
:
res
});
$sizeWrap
.
find
(
'.attr-content'
).
html
(
sizeCache
[
id
]);
$sizeWrap
.
removeClass
(
'hide'
);
}
else
{
$sizeWrap
.
addClass
(
'hide'
);
}
});
}
});
//【品牌】
if
(
$brandMore
.
length
>
0
)
{
$brandMoreTxt
=
$brandMore
.
children
(
'em'
);
$brandMoreIcon
=
$brandMore
.
children
(
'.iconfont'
);
}
//【品牌】多选
$brandMulti
.
click
(
function
()
{
if
(
$brandPanel
.
css
(
'display'
)
===
'none'
)
{
//显示品牌面板
$brandMore
.
trigger
(
'click'
);
}
$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
(
'mouseenter'
,
'span'
,
function
()
{
var
$this
=
$
(
this
),
index
=
$this
.
data
(
'index'
);
if
(
$this
.
hasClass
(
'hover'
))
{
return
;
}
$this
.
siblings
(
'span.hover'
).
removeClass
(
'hover'
);
$this
.
addClass
(
'hover'
);
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'
))
{
$brandMulti
.
removeClass
(
'hide'
);
//显示多选按钮
$brandMore
.
trigger
(
'click'
);
}
$panel
.
removeClass
(
'multi'
);
clearChecked
(
$panel
.
find
(
'.checkbox.checked'
));
//清除选中状态
});
//【品牌/高级选项】checkbox
$
(
'.check-container'
).
on
(
'click'
,
'.attr'
,
function
()
{
var
$this
=
$
(
this
),
$check
=
$this
.
find
(
'.checkbox'
),
$btnOk
=
$this
.
closest
(
'.brand-panel, .senior-sub'
).
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
();
if
(
$this
.
hasClass
(
'no-sub'
))
{
return
;
}
$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
();
if
(
$this
.
hasClass
(
'no-sub'
))
{
return
;
}
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"
),
Handlebars
=
require
(
"handlebars"
);
var
checkUnicode
=
{
unchecked
:
''
,
checked
:
''
},
moreUnicode
=
{
up
:
''
,
down
:
''
};
//品牌相关变量
var
$brandDefault
=
$
(
'.brand .default'
),
$brandPanel
=
$
(
'.brand .brand-panel'
),
$brandAttrs
=
$brandPanel
.
find
(
'.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
;
// 尺寸 handlebars 模板
var
sizeTmpl
=
'{{# size}}<a class="attr {{#if checked}}checked{{/if}}" href="{{href}}">{{name}}</a>{{/ size}}'
,
sizeCache
=
{},
// 缓存一下尺寸信息
$sizeWrap
=
$
(
'.filter-box .size'
);
sizeTmpl
=
Handlebars
.
compile
(
sizeTmpl
);
//清除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
(),
id
=
$this
.
data
(
'id'
);
if
(
$this
.
hasClass
(
'active'
))
{
// 选中时,再次点击取消选中
$this
.
removeClass
(
'active'
);
$sortSub
.
children
(
':eq('
+
index
+
')'
).
addClass
(
'hide'
);
$sizeWrap
.
addClass
(
'hide'
);
return
;
}
$this
.
siblings
(
'.active'
).
removeClass
(
'active'
);
$this
.
addClass
(
'active'
);
$sortSub
.
children
(
':not(.hide)'
).
addClass
(
'hide'
);
$sortSub
.
children
(
':eq('
+
index
+
')'
).
removeClass
(
'hide'
);
if
(
!
$sizeWrap
.
data
(
'load'
))
{
if
(
sizeCache
[
id
])
{
$sizeWrap
.
find
(
'.attr-content'
).
html
(
sizeCache
[
id
]);
$sizeWrap
.
removeClass
(
'hide'
);
}
else
{
$
.
ajax
({
url
:
'/product/search/sortSize'
,
data
:
{
msort
:
id
}
}).
then
(
function
(
res
)
{
if
(
$
.
type
(
res
)
===
'array'
&&
res
.
length
)
{
sizeCache
[
id
]
=
sizeTmpl
({
size
:
res
});
$sizeWrap
.
find
(
'.attr-content'
).
html
(
sizeCache
[
id
]);
$sizeWrap
.
removeClass
(
'hide'
);
}
else
{
$sizeWrap
.
addClass
(
'hide'
);
}
});
}
}
});
//【品牌】
if
(
$brandMore
.
length
>
0
)
{
$brandMoreTxt
=
$brandMore
.
children
(
'em'
);
$brandMoreIcon
=
$brandMore
.
children
(
'.iconfont'
);
}
//【品牌】多选
$brandMulti
.
click
(
function
()
{
if
(
$brandPanel
.
css
(
'display'
)
===
'none'
)
{
//显示品牌面板
$brandMore
.
trigger
(
'click'
);
}
$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
(
'mouseenter'
,
'span'
,
function
()
{
var
$this
=
$
(
this
),
index
=
$this
.
data
(
'index'
);
if
(
$this
.
hasClass
(
'hover'
))
{
return
;
}
$this
.
siblings
(
'span.hover'
).
removeClass
(
'hover'
);
$this
.
addClass
(
'hover'
);
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'
))
{
$brandMulti
.
removeClass
(
'hide'
);
//显示多选按钮
$brandMore
.
trigger
(
'click'
);
}
$panel
.
removeClass
(
'multi'
);
clearChecked
(
$panel
.
find
(
'.checkbox.checked'
));
//清除选中状态
});
//【品牌/高级选项】checkbox
$
(
'.check-container'
).
on
(
'click'
,
'.attr'
,
function
()
{
var
$this
=
$
(
this
),
$check
=
$this
.
find
(
'.checkbox'
),
$btnOk
=
$this
.
closest
(
'.brand-panel, .senior-sub'
).
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
();
if
(
$this
.
hasClass
(
'no-sub'
))
{
return
;
}
$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
();
if
(
$this
.
hasClass
(
'no-sub'
))
{
return
;
}
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
){
...
...
@@ -2396,6 +2506,14 @@ exports.init = function(num) {
};
}
function
removeHtmlFn
()
{
$goodInfoMain
.
html
(
''
);
$goodSelectColor
.
html
(
''
);
$goodItemWrapper
.
css
({
display
:
'none'
});
}
productList
.
addHandler
(
'MouseEnter'
,
function
(
event
)
{
var
itemMr
=
10
,
//list的右边距
itemMb
=
35
,
//list的下边距
...
...
@@ -2409,6 +2527,11 @@ exports.init = function(num) {
wrapperPt
,
//鼠标移入时弹层的上内边距
containerPt
;
//商品列表容器的上内边距
// 获取图片之前,先把获取上一张图片的ajax请求取消。 网络差的时候会出现错误
// if (getProductAjax && getProductAjax.readyState!= 4) {
// getProductAjax.abort();
// }
$
.
ajax
({
type
:
'POST'
,
url
:
'/product/list/getProductPic'
,
...
...
@@ -2418,11 +2541,8 @@ exports.init = function(num) {
}
}).
then
(
function
(
data
)
{
//setTimeout(function () {
removeHtmlFn
();
ulStr
=
createColorList
(
data
.
pics
).
colorListStr
;
//ajax请求的颜色列表
ulNum
=
createColorList
(
data
.
pics
).
ulNum
;
//ajax请求的颜色的数量
...
...
@@ -2465,23 +2585,14 @@ exports.init = function(num) {
if
(
data
.
pics
[
0
]
&&
data
.
pics
[
0
].
src
)
{
$goodInfoMain
.
find
(
'.good-thumb img'
).
attr
(
'src'
,
data
.
pics
[
0
].
src
);
}
//}, 1000);
});
});
$goodItemWrapper
.
mouseleave
(
function
()
{
//
removeHtmlFn();
removeHtmlFn
();
});
function
removeHtmlFn
()
{
$goodInfoMain
.
html
(
''
);
$goodSelectColor
.
html
(
''
);
$goodItemWrapper
.
css
({
display
:
'none'
});
}
};
//鼠标放在颜色列表上效果
...
...
@@ -2495,6 +2606,11 @@ $(document).on('hover', '.good-select-color li', function() {
$goodInfoMain
.
on
(
'click'
,
'.col-btn'
,
function
()
{
var
$this
=
$
(
this
);
if
(
!
window
.
getUid
())
{
location
.
href
=
'/signin.html?refer='
+
encodeURIComponent
(
location
.
href
);
return
;
}
$
.
ajax
({
type
:
'POST'
,
url
:
'/product/list/changeFavorite'
,
...
...
@@ -2636,40 +2752,40 @@ module.exports = function($o, rowWidth) {
};
});
define
(
"js/product/brand"
,
[
"jquery"
],
function
(
require
,
exports
,
module
){
/**
* 品牌页面
* @auhtor: bikai<kai.bi@yoho.cn>
* @date: 2016/1/21
*/
var
$
=
require
(
"jquery"
);
$
(
'#brand-favor'
).
on
(
'click'
,
function
()
{
var
$this
=
$
(
this
),
uid
=
window
.
getUid
();
if
(
!
uid
)
{
location
.
href
=
'/signin.html?refer='
+
location
.
href
;
return
;
}
$
.
ajax
({
type
:
'post'
,
url
:
'/product/index/favoriteBrand'
,
data
:
{
uid
:
uid
,
brandId
:
$this
.
data
(
'id'
)
}
}).
then
(
function
(
res
)
{
if
(
res
.
code
===
200
)
{
if
(
res
.
message
===
'add'
)
{
$this
.
find
(
'i'
).
addClass
(
'coled'
);
}
else
{
$this
.
find
(
'i'
).
removeClass
(
'coled'
);
}
}
});
});
/**
* 品牌页面
* @auhtor: bikai<kai.bi@yoho.cn>
* @date: 2016/1/21
*/
var
$
=
require
(
"jquery"
);
$
(
'#brand-favor'
).
on
(
'click'
,
function
()
{
var
$this
=
$
(
this
),
uid
=
window
.
getUid
();
if
(
!
uid
)
{
location
.
href
=
'/signin.html?refer='
+
encodeURIComponent
(
location
.
href
);
return
;
}
$
.
ajax
({
type
:
'post'
,
url
:
'/product/index/favoriteBrand'
,
data
:
{
uid
:
uid
,
brandId
:
$this
.
data
(
'id'
)
}
}).
then
(
function
(
res
)
{
if
(
res
.
code
===
200
)
{
if
(
res
.
message
===
'add'
)
{
$this
.
find
(
'i'
).
addClass
(
'coled'
);
}
else
{
$this
.
find
(
'i'
).
removeClass
(
'coled'
);
}
}
});
});
});
define
(
"js/product/hotrank"
,
[
"jquery"
,
"handlebars"
,
"source-map"
,
"lazyload"
],
function
(
require
,
exports
,
module
){
...
...
@@ -3134,6 +3250,10 @@ var $ = require("jquery"),
var
brandTpl
,
brandHtml
;
if
(
!
data
||
data
.
length
===
0
)
{
return
;
}
that
.
_createHelper
();
brandHtml
=
'\{{#brandList logoBrand}}'
+
'<a href="\{{href}}" target="_blank"><img class="lazy" data-original="\{{img}}" alt=""></a>'
+
...
...
@@ -5827,10 +5947,13 @@ function pwdKeyupEvt() {
}
else
{
if
(
pwd
.
length
<
6
||
pwd
.
length
>
20
)
{
hasNoErrPw
=
false
;
$pwdTip1
.
removeClass
(
'default yes'
).
addClass
(
'no red'
);
$pwdTip1
.
text
(
'密码只支持6-20位字符'
).
removeClass
(
'default yes'
).
addClass
(
'no red'
);
}
else
if
(
!
/
[
0-9a-zA-Z
]{6,20}
$/
.
test
(
pwd
))
{
hasNoErrPw
=
false
;
$pwdTip1
.
text
(
'不能包含特殊字符'
).
removeClass
(
'default yes'
).
addClass
(
'no red'
);
}
else
{
hasNoErrPw
=
true
;
$pwdTip1
.
removeClass
(
'default no red'
).
addClass
(
'yes'
);
$pwdTip1
.
text
(
'密码只支持6-20位字符'
).
removeClass
(
'default no red'
).
addClass
(
'yes'
);
}
//提示2不做验证
...
...
@@ -6042,132 +6165,132 @@ $('#captcha').keyup(function() {
});
});
define
(
"js/passport/thirdlogin"
,
[
"jquery"
],
function
(
require
,
exports
,
module
){
/**
* 登录
* @author: wq
* @date: 2016/1/21
*/
var
$
=
require
(
"jquery"
);
function
chooseProtocol
()
{
$
(
'.choosetag'
).
on
(
'change'
,
function
()
{
if
(
$
(
this
).
attr
(
'checked'
))
{
$
(
'.choosewrapper'
).
css
({
'background-image'
:
'url("http://webstatic.dev.yohobuy.com/img/passport/choosed.png")'
});
}
else
{
$
(
'.choosewrapper'
).
css
({
'background-image'
:
'none'
});
}
});
}
function
chooseAreaToogle
()
{
$
(
'.optionshow'
).
on
(
'click'
,
function
()
{
$
(
'.optionslist'
).
toggleClass
(
'hide'
);
});
}
function
cancelChooseArea
()
{
$
(
document
).
on
(
'click'
,
'body'
,
function
(
e
)
{
var
$target
=
$
(
e
.
target
);
if
(
$target
.
hasClass
(
'yohoselectarea'
)
||
$target
.
hasClass
(
'yohoselectarea'
)
||
$target
.
hasClass
(
'areaname'
)
||
$target
.
hasClass
(
'righttag'
)
||
$target
.
hasClass
(
'optionslist'
)
||
$target
.
hasClass
(
'optionitem'
))
{
return
;
}
else
{
$
(
'.optionslist'
).
addClass
(
'hide'
);
}
});
}
function
chooseArea
()
{
$
(
'.optionitem'
).
on
(
'click'
,
function
()
{
var
$option
=
$
(
this
);
var
areanum
=
$option
.
attr
(
'areanum'
);
var
areaname
=
$option
.
text
();
$
(
'#areaname'
).
text
(
areaname
);
$
(
'#areanum'
).
text
(
areanum
);
$
(
'#areacode'
).
val
(
areanum
);
$
(
'.optionslist'
).
addClass
(
'hide'
);
});
}
function
isagree
()
{
return
$
(
'.choosetag'
).
attr
(
'checked'
);
}
function
closeMask
()
{
var
$target
;
$
(
document
).
on
(
'click'
,
'#alreayregist'
,
function
(
e
)
{
$target
=
$
(
e
.
target
);
if
(
$target
.
hasClass
(
'mask'
)
||
$target
.
hasClass
(
'backdrop'
))
{
$
(
'#alreayregist'
).
hide
();
}
})
}
function
nextStep
()
{
var
openId
=
''
;
var
sourceType
=
''
;
var
mobile
=
''
;
var
areaCode
=
''
;
$
(
'#bindfirststep'
).
on
(
'click'
,
function
(
e
)
{
e
.
preventDefault
();
mobile
=
$
(
'.phonenum'
).
val
();
areaCode
=
$
(
'.areanum'
).
text
();
if
(
mobile
===
''
)
{
alert
(
'手机号码不能为空'
);
return
;
}
if
(
!
isagree
())
{
alert
(
'请先同意我们的协议'
);
return
;
}
openId
=
$
(
'#openId'
).
val
()
||
'29803EC6D4AAC3AAB8ABDB6AE829D579'
;
sourceType
=
$
(
'#sourceType'
).
val
()
||
'qq'
;
$
.
ajax
({
type
:
'post'
,
url
:
'/passport/autouserinfo/bindCheck'
,
data
:
{
mobile
:
mobile
,
area
:
areaCode
,
openId
:
openId
,
sourceType
:
sourceType
},
dataType
:
'json'
,
success
:
function
(
data
)
{
if
(
data
.
code
===
200
)
{
if
(
data
.
data
.
isReg
===
0
)
{
$
(
'#bindmobileform'
).
attr
(
'action'
,
'/passport/thirdlogin/noregist'
);
$
(
'#bindmobileform'
).
submit
();
}
else
{
$
(
'#alreayregist'
).
show
();
}
}
else
{
alert
(
data
.
message
);
}
}
});
});
}
function
init
()
{
chooseProtocol
();
chooseArea
();
chooseAreaToogle
();
cancelChooseArea
();
nextStep
();
closeMask
();
}
/**
* 登录
* @author: wq
* @date: 2016/1/21
*/
var
$
=
require
(
"jquery"
);
function
chooseProtocol
()
{
$
(
'.choosetag'
).
on
(
'change'
,
function
()
{
if
(
$
(
this
).
attr
(
'checked'
))
{
$
(
'.choosewrapper'
).
css
({
'background-image'
:
'url("http://webstatic.dev.yohobuy.com/img/passport/choosed.png")'
});
}
else
{
$
(
'.choosewrapper'
).
css
({
'background-image'
:
'none'
});
}
});
}
function
chooseAreaToogle
()
{
$
(
'.optionshow'
).
on
(
'click'
,
function
()
{
$
(
'.optionslist'
).
toggleClass
(
'hide'
);
});
}
function
cancelChooseArea
()
{
$
(
document
).
on
(
'click'
,
'body'
,
function
(
e
)
{
var
$target
=
$
(
e
.
target
);
if
(
$target
.
hasClass
(
'yohoselectarea'
)
||
$target
.
hasClass
(
'yohoselectarea'
)
||
$target
.
hasClass
(
'areaname'
)
||
$target
.
hasClass
(
'righttag'
)
||
$target
.
hasClass
(
'optionslist'
)
||
$target
.
hasClass
(
'optionitem'
))
{
return
;
}
else
{
$
(
'.optionslist'
).
addClass
(
'hide'
);
}
});
}
function
chooseArea
()
{
$
(
'.optionitem'
).
on
(
'click'
,
function
()
{
var
$option
=
$
(
this
);
var
areanum
=
$option
.
attr
(
'areanum'
);
var
areaname
=
$option
.
text
();
$
(
'#areaname'
).
text
(
areaname
);
$
(
'#areanum'
).
text
(
areanum
);
$
(
'#areacode'
).
val
(
areanum
);
$
(
'.optionslist'
).
addClass
(
'hide'
);
});
}
function
isagree
()
{
return
$
(
'.choosetag'
).
attr
(
'checked'
);
}
function
closeMask
()
{
var
$target
;
$
(
document
).
on
(
'click'
,
'#alreayregist'
,
function
(
e
)
{
$target
=
$
(
e
.
target
);
if
(
$target
.
hasClass
(
'mask'
)
||
$target
.
hasClass
(
'backdrop'
))
{
$
(
'#alreayregist'
).
hide
();
}
});
}
function
nextStep
()
{
var
openId
=
''
;
var
sourceType
=
''
;
var
mobile
=
''
;
var
areaCode
=
''
;
$
(
'#bindfirststep'
).
on
(
'click'
,
function
(
e
)
{
e
.
preventDefault
();
mobile
=
$
(
'.phonenum'
).
val
();
areaCode
=
$
(
'.areanum'
).
text
();
if
(
mobile
===
''
)
{
alert
(
'手机号码不能为空'
);
return
;
}
if
(
!
isagree
())
{
alert
(
'请先同意我们的协议'
);
return
;
}
openId
=
$
(
'#openId'
).
val
()
||
'29803EC6D4AAC3AAB8ABDB6AE829D579'
;
sourceType
=
$
(
'#sourceType'
).
val
()
||
'qq'
;
$
.
ajax
({
type
:
'post'
,
url
:
'/passport/autouserinfo/bindCheck'
,
data
:
{
mobile
:
mobile
,
area
:
areaCode
,
openId
:
openId
,
sourceType
:
sourceType
},
dataType
:
'json'
,
success
:
function
(
data
)
{
if
(
data
.
code
===
200
)
{
if
(
data
.
data
.
isReg
===
0
)
{
$
(
'#bindmobileform'
).
attr
(
'action'
,
'/passport/thirdlogin/noregist'
);
$
(
'#bindmobileform'
).
submit
();
}
else
{
$
(
'#alreayregist'
).
show
();
}
}
else
{
alert
(
data
.
message
);
}
}
});
});
}
function
init
()
{
chooseProtocol
();
chooseArea
();
chooseAreaToogle
();
cancelChooseArea
();
nextStep
();
closeMask
();
}
init
();
});
...
...
web-static/dist/yohobuy/0.0.1/index.js
View file @
d475df3
This diff could not be displayed because it is too large.
Please
register
or
login
to post a comment