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
Plain Diff
Browse Files
Authored by
梁志锋
9 years ago
Commit
d24ef77a42496f34ea5bc04a55bba7b702dd4dbe
2 parents
7c4b49f1
c5a4ecd6
Merge branch 'develop' of
http://git.dev.yoho.cn/web/yohobuy
into develop
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
667 additions
and
552 deletions
library/Action/AbstractAction.php
library/Action/WebAction.php
library/Plugin/DataProcess/FloorProcess.php
library/Plugin/Helpers.php
library/Plugin/Partner/alipay/class/AlipayNotify.class.php
static/js/category/brand.js
static/sass/category/_brand.scss
template/m.yohobuy.com/actions/category/brand/index.phtml
template/www.yohobuy.com/partials/layout/simple-header.phtml
web-static/dist/yohobuy/0.0.1/index-debug.js
web-static/dist/yohobuy/0.0.1/index.js
yohobuy/m.yohobuy.com/application/models/Index/User.php
library/Action/AbstractAction.php
View file @
d24ef77
...
...
@@ -68,7 +68,7 @@ class AbstractAction extends Controller_Abstract
case
'develop'
:
// 开发
default
:
$this
->
_view
->
assign
(
'devEnv'
,
true
);
$this
->
_useSession
=
fals
e
;
$this
->
_useSession
=
tru
e
;
break
;
}
}
...
...
@@ -317,7 +317,7 @@ class AbstractAction extends Controller_Abstract
}
}
/**
/**
* 获取当前登录的用户ID
*
* @param bool $useSession (true:从服务端session中检查, false:从客户端cookie中检查)
...
...
@@ -329,10 +329,11 @@ class AbstractAction extends Controller_Abstract
if
(
!
$this
->
_useSession
)
{
$useSession
=
false
;
}
$useSession
=
false
;
//
$useSession = false;
if
(
!
$this
->
_uid
)
{
$cookie
=
$this
->
getCookie
(
'_UID'
);
// 兼容老的
if
(
!
empty
(
$cookie
))
{
$cookieList
=
explode
(
'::'
,
$cookie
);
if
(
isset
(
$cookieList
[
1
])
&&
is_numeric
(
$cookieList
[
1
]))
{
...
...
@@ -351,11 +352,18 @@ class AbstractAction extends Controller_Abstract
$this
->
_usession
=
$cookieList
[
3
];
$this
->
_vip
=
$cookieList
[
2
];
}
}
// 新的, 如果老站没有同步成功,再尝试从SESSION获取
elseif
(
$useSession
)
{
$uid
=
$this
->
getSession
(
'_LOGIN_UID'
);
if
(
!
empty
(
$uid
))
{
$this
->
_uid
=
$uid
;
}
}
}
return
$this
->
_uid
;
}
/**
* 获取客户端唯一标识
*
...
...
library/Action/WebAction.php
View file @
d24ef77
...
...
@@ -67,7 +67,7 @@ class WebAction extends Controller_Abstract
case
'develop'
:
// 开发
default
:
$this
->
_view
->
assign
(
'devEnv'
,
true
);
$this
->
_useSession
=
fals
e
;
$this
->
_useSession
=
tru
e
;
break
;
}
}
...
...
@@ -333,9 +333,11 @@ class WebAction extends Controller_Abstract
if
(
!
$this
->
_useSession
)
{
$useSession
=
false
;
}
//$useSession = false;
if
(
!
$this
->
_uid
)
{
$cookie
=
$this
->
getCookie
(
'_UID'
);
// 兼容老的
if
(
!
empty
(
$cookie
))
{
$cookieList
=
explode
(
'::'
,
$cookie
);
if
(
isset
(
$cookieList
[
1
])
&&
is_numeric
(
$cookieList
[
1
]))
{
...
...
@@ -354,6 +356,13 @@ class WebAction extends Controller_Abstract
$this
->
_usession
=
$cookieList
[
3
];
$this
->
_vip
=
$cookieList
[
2
];
}
}
// 新的, 如果老站没有同步成功,再尝试从SESSION获取
elseif
(
$useSession
)
{
$uid
=
$this
->
getSession
(
'_LOGIN_UID'
);
if
(
!
empty
(
$uid
))
{
$this
->
_uid
=
$uid
;
}
}
}
return
$this
->
_uid
;
...
...
library/Plugin/DataProcess/FloorProcess.php
View file @
d24ef77
...
...
@@ -208,7 +208,7 @@ class FloorProcess
foreach
(
$data
[
'list'
]
as
&
$one
)
{
if
(
isset
(
$one
[
'url'
]))
{
$one
[
'url'
]
=
Helpers
::
getFilterUrl
(
$one
[
'url'
]);
//
isset(self::$channel[$type]) && $one['url'] .= '?gender=' . self::$channel[$type];
isset
(
self
::
$channel
[
$type
])
&&
$one
[
'url'
]
.=
'?gender='
.
self
::
$channel
[
$type
];
}
$one
[
'img'
]
=
Helpers
::
getImageUrl
(
$one
[
'src'
],
158
,
174
);
unset
(
$one
[
'src'
]);
...
...
library/Plugin/Helpers.php
View file @
d24ef77
...
...
@@ -189,8 +189,8 @@ class Helpers
* @return float|string 转换之后的价格
*/
public
static
function
transPrice
(
$price
)
{
return
!
empty
(
$price
)
?
number_format
(
$price
,
2
,
'.'
,
''
)
:
0
;
{
return
!
empty
(
$price
)
?
number_format
(
$price
,
2
,
'.'
,
''
)
:
0
;
}
/**
...
...
@@ -566,8 +566,8 @@ class Helpers
$arr
[
$key
][
'appearDate'
]
=
$vo
[
'expect_arrival_time'
];
}
// 商品链接
if
(
$haveLink
&&
isset
(
$vo
[
'product_id'
]))
{
$arr
[
$key
][
'link'
]
=
self
::
url
(
'/product/pro_'
.
$vo
[
'product_id'
]
.
'_'
.
$vo
[
'goods_id'
]
.
'/'
.
$vo
[
'cn_alphabet'
]
.
'.html'
);
if
(
$haveLink
&&
isset
(
$vo
[
'product_skn'
]))
{
$arr
[
$key
][
'link'
]
=
self
::
url
(
'/product/show_'
.
$vo
[
'product_skn'
]
.
'.html'
);
}
// 累计购买数
$count
+=
intval
(
$vo
[
'buy_number'
]);
...
...
@@ -576,52 +576,70 @@ class Helpers
return
$arr
;
}
/**
/**
* 格式化购物车商品
*
* @param array $cartGoods 购物车商品列表
* @param boolean $isValid 是否是可用商品(非失效商品),默认是
* @param bool $isAdvanceCart 是否是预售购物车(和上市期有关)
* @return array 处理之后的购物车商品数据
*/
public
static
function
formatCartGoods
(
$cartGoods
)
public
static
function
formatCartGoods
(
$cartGoods
,
$isAdvanceCart
,
$isValid
=
true
)
{
$arr
=
array
();
$oneGoods
=
array
();
foreach
(
$cartGoods
as
$key
=>
$value
)
{
$oneGoods
[
'id'
]
=
$value
[
'product_sku'
];
$oneGoods
[
'skn'
]
=
$value
[
'product_skn'
];
$oneGoods
[
'name'
]
=
$value
[
'product_name'
];
$oneGoods
[
'thumb'
]
=
!
empty
(
$value
[
'goods_images'
])
?
Images
::
getImageUrl
(
$value
[
'goods_images'
],
120
,
120
)
:
''
;
$oneGoods
[
'color'
]
=
$value
[
'color_name'
];
$oneGoods
[
'size'
]
=
$value
[
'size_name'
];
$oneGoods
[
'price'
]
=
self
::
transPrice
(
$value
[
'sales_price'
]);
$oneGoods
[
'count'
]
=
$value
[
'buy_number'
];
$oneGoods
[
'lowStocks'
]
=
(
$value
[
'buy_number'
]
<
$value
[
'storage_number'
]);
//gift=>是否赠品,advanceBuy=>是否加价购,soldOut=>失效商品;
if
(
!
isset
(
$value
[
'goods_type'
]))
{
$oneGoods
[
'isSoldOut'
]
=
true
;
}
elseif
(
$value
[
'goods_type'
]
==
'gift'
&&
!
isset
(
$value
[
'isAdvanceBuy'
]))
{
$oneGoods
[
'isGift'
]
=
true
;
}
elseif
(
$value
[
'goods_type'
]
==
'price_gift'
)
{
$oneGoods
[
'isAdvanceBuy'
]
=
true
;
}
// 上市期
if
(
!
empty
(
$value
[
'expect_arrival_time'
]))
{
$oneGoods
[
'appearDate'
]
=
$value
[
'expect_arrival_time'
];
}
// 商品链接
if
(
isset
(
$value
[
'cn_alphabet'
])
)
{
$oneGoods
[
'url'
]
=
self
::
url
(
'/product/pro_'
.
$value
[
'product_id'
]
.
'_'
.
$value
[
'goods_id'
]
.
'/'
.
$value
[
'cn_alphabet'
]
.
'.html'
);
}
$arr
[
$key
]
=
$oneGoods
;
}
$oneGoods
=
array
();
foreach
(
$cartGoods
as
$key
=>
$value
)
{
$oneGoods
=
array
();
$oneGoods
[
'id'
]
=
$value
[
'product_sku'
];
$oneGoods
[
'skn'
]
=
$value
[
'product_skn'
];
$oneGoods
[
'name'
]
=
$value
[
'product_name'
];
$oneGoods
[
'thumb'
]
=
!
empty
(
$value
[
'goods_images'
])
?
Images
::
getImageUrl
(
$value
[
'goods_images'
],
120
,
160
)
:
''
;
$oneGoods
[
'color'
]
=
$value
[
'color_name'
];
$oneGoods
[
'size'
]
=
$value
[
'size_name'
];
$oneGoods
[
'checked'
]
=
$value
[
'selected'
]
===
'Y'
;
$oneGoods
[
'price'
]
=
self
::
transPrice
(
$value
[
'last_vip_price'
]);
$oneGoods
[
'isVipPrice'
]
=
$value
[
'sales_price'
]
!==
$value
[
'last_vip_price'
];
$oneGoods
[
'count'
]
=
$value
[
'buy_number'
];
if
(
$isValid
)
{
// 库存不足
$oneGoods
[
'lowStocks'
]
=
(
$value
[
'buy_number'
]
>
$value
[
'storage_number'
]);
}
else
{
// 失效商品
$oneGoods
[
'inValid'
]
=
true
;
}
//gift=>是否赠品,advanceBuy=>是否加价购,soldOut=>失效商品;
if
(
!
isset
(
$value
[
'goods_type'
]))
{
$oneGoods
[
'inValid'
]
=
true
;
}
elseif
(
$value
[
'goods_type'
]
==
'gift'
&&
!
isset
(
$value
[
'isAdvanceBuy'
]))
{
$oneGoods
[
'isGift'
]
=
true
;
$oneGoods
[
'salesPrice'
]
=
self
::
transPrice
(
$value
[
'sales_price'
]);
$oneGoods
[
'price'
]
=
self
::
transPrice
(
$value
[
'last_price'
]);
}
elseif
(
$value
[
'goods_type'
]
==
'price_gift'
)
{
$oneGoods
[
'showCheckbox'
]
=
true
;
$oneGoods
[
'isAdvanceBuy'
]
=
true
;
$oneGoods
[
'salesPrice'
]
=
self
::
transPrice
(
$value
[
'sales_price'
]);
$oneGoods
[
'price'
]
=
self
::
transPrice
(
$value
[
'last_price'
]);
}
else
{
$oneGoods
[
'showCheckbox'
]
=
true
;
}
// 上市期
if
(
$isAdvanceCart
&&
!
empty
(
$value
[
'expect_arrival_time'
]))
{
$oneGoods
[
'appearDate'
]
=
$value
[
'expect_arrival_time'
];
}
// 商品链接
$oneGoods
[
'link'
]
=
self
::
url
(
'/product/show_'
.
$value
[
'product_skn'
]
.
'.html'
);
$arr
[
$key
]
=
$oneGoods
;
}
return
$arr
;
}
/**
* 格式化加价购商品
* 格式化加价购
和赠品
商品
*
* @param array $advanceGoods 加价购商品列表
* @param int $count 计商品件数
...
...
@@ -631,33 +649,38 @@ class Helpers
{
$arr
=
array
();
$gift
=
array
();
$oneGoods
=
array
();
foreach
(
$advanceGoods
as
$value
)
{
$gift
=
array
();
$gift
[
'promotionTitle'
]
=
$value
[
'promotion_title'
];
foreach
(
$value
[
'goods_list'
]
as
$single
)
{
$oneGoods
[
'id'
]
=
$single
[
'product_skn'
];
$oneGoods
[
'name'
]
=
$single
[
'product_name'
];
$oneGoods
[
'thumb'
]
=
!
empty
(
$single
[
'goods_images'
])
?
Images
::
getImageUrl
(
$single
[
'goods_images'
],
120
,
120
)
:
''
;
$oneGoods
[
'appearDate'
]
=
'12月'
;
// 目前app接口没有返回该数据
$oneGoods
[
'price'
]
=
$single
[
'last_price'
];
$oneGoods
[
'marketPrice'
]
=
$single
[
'market_price'
];
$oneGoods
[
'count'
]
=
$single
[
'storage_number'
];
$gift
[
'goods'
][]
=
$oneGoods
;
}
$gift
=
array
();
$oneGoods
=
array
();
$number
=
0
;
foreach
(
$advanceGoods
as
$value
)
{
$gift
=
array
();
$gift
[
'promotionId'
]
=
$value
[
'promotion_id'
];
$gift
[
'promotionTitle'
]
=
$value
[
'promotion_title'
];
$number
=
0
;
foreach
(
$value
[
'goods_list'
]
as
$single
)
{
$oneGoods
=
array
();
$oneGoods
[
'id'
]
=
$single
[
'product_skn'
];
$oneGoods
[
'name'
]
=
$single
[
'product_name'
];
$oneGoods
[
'thumb'
]
=
!
empty
(
$single
[
'goods_images'
])
?
Images
::
getImageUrl
(
$single
[
'goods_images'
],
120
,
160
)
:
''
;
$oneGoods
[
'price'
]
=
self
::
transPrice
(
$single
[
'last_price'
]);
$oneGoods
[
'marketPrice'
]
=
self
::
transPrice
(
$single
[
'market_price'
]);
$oneGoods
[
'count'
]
=
$single
[
'storage_number'
];
$gift
[
'goods'
][]
=
$oneGoods
;
$number
++
;
}
$arr
[]
=
$gift
;
$arr
[]
=
$gift
;
// 计算加价购商品数目
$count
+=
count
(
$value
[
'goods_list'
]);
}
// 计算加价购商品数目
//$count += count($value['goods_list']);
$count
+=
$number
;
}
return
$arr
;
}
/**
* 订单状态,按订单支付类型和订单状态
* @var array
...
...
library/Plugin/Partner/alipay/class/AlipayNotify.class.php
View file @
d24ef77
...
...
@@ -38,35 +38,36 @@ class AlipayNotify {
* @return 验证结果
*/
function
verifyNotify
(){
if
(
empty
(
$_POST
))
{
//判断POST来的数组是否为空
return
false
;
}
else
{
//生成签名结果
$isSign
=
$this
->
getSignVeryfy
(
$_POST
,
$_POST
[
"sign"
]);
//获取支付宝远程服务器ATN结果(验证是否是支付宝发来的消息)
$responseTxt
=
'true'
;
if
(
!
empty
(
$_POST
[
"notify_id"
]))
{
$responseTxt
=
$this
->
getResponse
(
$_POST
[
"notify_id"
]);}
//写日志记录
//if ($isSign) {
// $isSignStr = 'true';
//}
//else {
// $isSignStr = 'false';
//}
//$log_text = "responseTxt=".$responseTxt."\n notify_url_log:isSign=".$isSignStr.",";
//$log_text = $log_text.createLinkString($_POST);
//logResult($log_text);
//验证
//$responsetTxt的结果不是true,与服务器设置问题、合作身份者ID、notify_id一分钟失效有关
//isSign的结果不是true,与安全校验码、请求时的参数格式(如:带自定义参数等)、编码格式有关
if
(
preg_match
(
"/true$/i"
,
$responseTxt
)
&&
$isSign
)
{
return
true
;
}
else
{
return
false
;
}
}
if
(
empty
(
$_POST
))
{
//判断POST来的数组是否为空
return
false
;
}
else
{
//生成签名结果
$isSign
=
$this
->
getSignVeryfy
(
$_POST
,
$_POST
[
"sign"
]);
//获取支付宝远程服务器ATN结果(验证是否是支付宝发来的消息)
$responseTxt
=
'true'
;
if
(
!
empty
(
$_POST
[
"notify_id"
]))
{
$responseTxt
=
$this
->
getResponse
(
$_POST
[
"notify_id"
]);
}
//写日志记录
//if ($isSign) {
// $isSignStr = 'true';
//}
//else {
// $isSignStr = 'false';
//}
//$log_text = "responseTxt=".$responseTxt."\n notify_url_log:isSign=".$isSignStr.",";
//$log_text = $log_text.createLinkString($_POST);
//logResult($log_text);
//验证
//$responsetTxt的结果不是true,与服务器设置问题、合作身份者ID、notify_id一分钟失效有关
//isSign的结果不是true,与安全校验码、请求时的参数格式(如:带自定义参数等)、编码格式有关
if
(
preg_match
(
"/true$/i"
,
$responseTxt
)
&&
$isSign
)
{
return
true
;
}
else
{
return
false
;
}
}
}
/**
...
...
@@ -74,36 +75,36 @@ class AlipayNotify {
* @return 验证结果
*/
function
verifyReturn
(){
if
(
empty
(
$_GET
))
{
//判断POST来的数组是否为空
return
false
;
}
else
{
//生成签名结果
$isSign
=
$this
->
getSignVeryfy
(
$_GET
,
$_GET
[
"sign"
]);
//获取支付宝远程服务器ATN结果(验证是否是支付宝发来的消息)
$responseTxt
=
'true'
;
if
(
!
empty
(
$_GET
[
"notify_id"
]))
{
$responseTxt
=
$this
->
getResponse
(
$_GET
[
"notify_id"
]);}
//写日志记录
//if ($isSign) {
// $isSignStr = 'true';
//}
//else {
// $isSignStr = 'false';
//}
//$log_text = "responseTxt=".$responseTxt."\n return_url_log:isSign=".$isSignStr.",";
//$log_text = $log_text.createLinkString($_GET);
//logResult($log_text);
//验证
//$responsetTxt的结果不是true,与服务器设置问题、合作身份者ID、notify_id一分钟失效有关
//isSign的结果不是true,与安全校验码、请求时的参数格式(如:带自定义参数等)、编码格式有关
if
(
preg_match
(
"/true$/i"
,
$responseTxt
)
&&
$isSign
)
{
return
true
;
}
else
{
return
false
;
}
}
if
(
empty
(
$_GET
))
{
//判断POST来的数组是否为空
return
false
;
}
else
{
//生成签名结果
$isSign
=
$this
->
getSignVeryfy
(
$_GET
,
$_GET
[
"sign"
]);
//获取支付宝远程服务器ATN结果(验证是否是支付宝发来的消息)
$responseTxt
=
'true'
;
if
(
!
empty
(
$_GET
[
"notify_id"
]))
{
$responseTxt
=
$this
->
getResponse
(
$_GET
[
"notify_id"
]);
}
//写日志记录
//if ($isSign) {
// $isSignStr = 'true';
//}
//else {
// $isSignStr = 'false';
//}
//$log_text = "responseTxt=".$responseTxt."\n return_url_log:isSign=".$isSignStr.",";
//$log_text = $log_text.createLinkString($_GET);
//logResult($log_text);
//验证
//$responsetTxt的结果不是true,与服务器设置问题、合作身份者ID、notify_id一分钟失效有关
//isSign的结果不是true,与安全校验码、请求时的参数格式(如:带自定义参数等)、编码格式有关
if
(
preg_match
(
"/true$/i"
,
$responseTxt
)
&&
$isSign
)
{
return
true
;
}
else
{
return
false
;
}
}
}
/**
...
...
static/js/category/brand.js
View file @
d24ef77
...
...
@@ -7,7 +7,6 @@
var
$
=
require
(
'jquery'
),
Hammer
=
require
(
'yoho.hammer'
),
Swiper
=
require
(
'yoho.iswiper'
),
loading
=
require
(
'../plugin/loading'
),
lazyLoad
=
require
(
'yoho.lazyload'
);
var
swiper
,
...
...
@@ -26,8 +25,6 @@ var brandsData,
$keyword
,
clearTextHammer
;
loading
.
showLoadingMask
();
//热门品牌滑动
hotBrandsSwiper
=
new
Swiper
(
'.brands-swiper'
,
{
grabCursor
:
true
,
...
...
@@ -50,14 +47,9 @@ $('.yoho-header').css({
top
:
0
});
(
function
()
{
if
(
$
(
'.banner-top'
).
length
>
0
)
{
$
(
'.hot-brands'
).
css
(
'padding-top'
,
'0'
);
}
$
(
'.hide-when-loading'
).
show
();
loading
.
hideLoadingMask
();
})();
if
(
$
(
'.banner-top'
).
length
>
0
)
{
$
(
'.hot-brands'
).
css
(
'padding-top'
,
'0'
);
}
$fixTitleBar
=
$
(
'<div class="title-bar fixed-title-bar"><h2></h2></div>'
);
$fixTitleBar
.
css
({
...
...
@@ -189,16 +181,8 @@ if ($('.brand-search-page').length) {
if
(
$genderItem
.
length
>
0
)
{
$genderItem
.
on
(
'touchstart'
,
function
()
{
var
index
=
$
(
this
).
data
(
'id'
)
+
1
;
$
(
'.genderNav ul .active'
).
removeClass
(
'active'
);
$
(
this
).
addClass
(
'active'
);
$
(
'.hide-when-loading'
).
hide
();
loading
.
showLoadingMask
();
function
reload
()
{
window
.
location
.
search
=
'channel='
+
index
;
}
setTimeout
(
reload
.
bind
(
this
),
100
);
window
.
location
.
search
=
'channel='
+
(
$
(
this
).
data
(
'id'
)
+
1
);
});
}
...
...
static/sass/category/_brand.scss
View file @
d24ef77
...
...
@@ -2,9 +2,6 @@
.re-pos-search
{
top
:
170rem
/
$pxConvertRem
!
important
;
}
.hide-when-loading
{
display
:
none
;
}
.genderNav
{
display
:
block
;
width
:
100%
;
...
...
template/m.yohobuy.com/actions/category/brand/index.phtml
View file @
d24ef77
...
...
@@ -21,40 +21,38 @@
</a>
</div>
</div>
<div
class=
"hide-when-loading"
>
{
{#
topData
}
}
{
{!
头部banner
}
}
{
{#
bannerTop
}
}
{
{>
home/banner_top
}
}
{
{/
bannerTop
}
}
{
{!
热门品牌可滑动
}
}
{
{#
hotBrandsScroll
}
}
{
{>
home/hot_brands_swipe
}
}
{
{/
hotBrandsScroll
}
}
{
{/
topData
}
}
{
{#
topData
}
}
{
{!
头部banner
}
}
{
{#
bannerTop
}
}
{
{>
home/banner_top
}
}
{
{/
bannerTop
}
}
{
{#
brandList
}
}
<div
class=
"brand-list bar-{{@index}}"
>
<div
class=
"title-bar"
>
<h
2
style=
"position: static;"
>
{
{title
}
}</h
2
>
</div>
{
{#
list
}
}
<p>
<a
href=
"{{url}}"
>
{
{name
}
}
{
{#
isHot
}
}
<i
class=
"icon-hot"
>HOT</i>
{
{/
isHot
}
}
{
{#
isNew
}
}
<i
class=
"icon-new"
>NEW</i>
{
{/
isNew
}
}
</a>
</p>
{
{/
list
}
}
{
{!
热门品牌可滑动
}
}
{
{#
hotBrandsScroll
}
}
{
{>
home/hot_brands_swipe
}
}
{
{/
hotBrandsScroll
}
}
{
{/
topData
}
}
{
{#
brandList
}
}
<div
class=
"brand-list bar-{{@index}}"
>
<div
class=
"title-bar"
>
<h
2
style=
"position: static;"
>
{
{title
}
}</h
2
>
</div>
{
{/
brandList
}
}
{
{#
list
}
}
<p>
<a
href=
"{{url}}"
>
{
{name
}
}
{
{#
isHot
}
}
<i
class=
"icon-hot"
>HOT</i>
{
{/
isHot
}
}
{
{#
isNew
}
}
<i
class=
"icon-new"
>NEW</i>
{
{/
isNew
}
}
</a>
</p>
{
{/
list
}
}
</div>
{
{/
brandList
}
}
{
{/channel
}
}
{
{>
layout/footer
}
}
...
...
template/www.yohobuy.com/partials/layout/simple-header.phtml
View file @
d24ef77
...
...
@@ -12,7 +12,18 @@
<!-- [if (gte IE 6)&(lte IE 8)>
<script src="http://cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
<link
rel=
"stylesheet"
href=
"http://webstatic.dev.yohobuy.com/css/index.css"
>
{{#if rlsEnv}}
<link
rel=
"stylesheet"
href=
"http://cdn.yoho.cn/yohobuy/{{version}}/index.css"
>
{{/if}}
{{#if preEnv}}
<link
rel=
"stylesheet"
href=
"http://cdn.yoho.cn/yohobuy/{{version}}/index.css"
>
{{/if}}
{{#if testEnv}}
<link
rel=
"stylesheet"
href=
"http://static.buy.test.yoho.cn/dist/yohobuy/{{version}}/index.css"
>
{{/if}}
{{#if devEnv}}
<link
rel=
"stylesheet"
href=
"http://webstatic.dev.yohobuy.com/css/index.css"
>
{{/if}}
</head>
<body>
{{# simpleHeader}}
...
...
web-static/dist/yohobuy/0.0.1/index-debug.js
View file @
d24ef77
...
...
@@ -3990,14 +3990,30 @@ validateResult = [
];
//手机号ajax校验
function
phoneAjaxFn
(
callback
)
{
$
.
ajax
({
url
:
'/passport/register/checkmobile'
,
type
:
'POST'
,
data
:
{
function
phoneAjaxFn
(
page
,
callback
)
{
var
url
,
data
;
if
(
page
===
'reg'
)
{
url
=
'/passport/register/checkmobile'
;
data
=
{
mobile
:
$pn
.
val
(),
area
:
$region
.
text
().
split
(
'+'
)[
1
]
}
};
}
else
if
(
page
===
'third'
)
{
url
=
'/passport/autouserinfo/bindCheck'
;
data
=
{
mobile
:
$pn
.
val
(),
area
:
$region
.
text
().
split
(
'+'
)[
1
],
openId
:
1
,
sourceType
:
'QQ'
};
}
$
.
ajax
({
url
:
url
,
type
:
'POST'
,
data
:
data
}).
then
(
function
(
data
)
{
switch
(
data
.
code
)
{
case
200
:
...
...
@@ -4015,10 +4031,17 @@ function phoneAjaxFn(callback) {
}
//图形验证码ajax校验
function
picCaptchaAjaxFn
(
callback
)
{
function
picCaptchaAjaxFn
(
page
,
callback
)
{
var
url
;
if
(
page
===
'reg'
)
{
url
=
'/passport/register/piccaptcha'
;
}
else
if
(
page
===
'third'
)
{
url
=
'/passport/autouserinfo/checkPicCode'
;
}
$
.
ajax
({
type
:
'POST'
,
url
:
'/passport/register/piccaptcha'
,
url
:
url
,
data
:
{
code
:
$ca
.
val
(),
mobile
:
$pn
.
val
(),
...
...
@@ -4030,7 +4053,7 @@ function picCaptchaAjaxFn(callback) {
validateResult
[
1
].
message
=
''
;
validateResult
[
1
].
status
=
true
;
break
;
case
40
4
:
case
40
0
:
validateResult
[
1
].
message
=
'图形验证码错误'
;
validateResult
[
1
].
status
=
false
;
break
;
...
...
@@ -4040,10 +4063,17 @@ function picCaptchaAjaxFn(callback) {
}
//短信验证码ajax校验
function
msgCaptchaAjaxFn
(
callback
)
{
function
msgCaptchaAjaxFn
(
page
,
callback
)
{
var
url
;
if
(
page
===
'reg'
)
{
url
=
'/passport/register/msgcaptcha'
;
}
else
if
(
page
===
'third'
)
{
url
=
'/passport/autouserinfo/checkBindMsg'
;
}
$
.
ajax
({
type
:
'POST'
,
url
:
'/passport/register/msgcaptcha'
,
url
:
url
,
data
:
{
code
:
$ca
.
val
(),
mobile
:
$pn
.
val
(),
...
...
@@ -4055,7 +4085,7 @@ function msgCaptchaAjaxFn(callback) {
validateResult
[
2
].
message
=
''
;
validateResult
[
2
].
status
=
true
;
break
;
case
40
4
:
case
40
0
:
validateResult
[
2
].
message
=
'短信验证码错误'
;
validateResult
[
2
].
status
=
false
;
break
;
...
...
@@ -4066,7 +4096,7 @@ function msgCaptchaAjaxFn(callback) {
}
// 验证
function
validateRule
(
$element
,
callback
)
{
function
validateRule
(
page
,
$element
,
callback
)
{
var
val
=
$
.
trim
(
$element
.
val
()),
regionCode
;
...
...
@@ -4088,7 +4118,7 @@ function validateRule($element, callback) {
callback
();
}
else
{
phoneAjaxFn
(
callback
);
phoneAjaxFn
(
page
,
callback
);
}
//图形验证码校验
...
...
@@ -4107,7 +4137,7 @@ function validateRule($element, callback) {
// 并且手机号正确
if
(
validateResult
[
0
].
status
)
{
picCaptchaAjaxFn
(
callback
);
picCaptchaAjaxFn
(
page
,
callback
);
}
else
{
validateResult
[
1
].
message
=
'图形验证码错误'
;
validateResult
[
1
].
status
=
false
;
...
...
@@ -4133,7 +4163,7 @@ function validateRule($element, callback) {
// 并且图形验证码正确
if
(
validateResult
[
1
].
status
)
{
msgCaptchaAjaxFn
(
callback
);
msgCaptchaAjaxFn
(
page
,
callback
);
}
else
{
validateResult
[
2
].
message
=
'短信验证码错误'
;
validateResult
[
2
].
status
=
false
;
...
...
@@ -4286,143 +4316,172 @@ function pwdFn($obj) {
// 失去焦点时开始校验
// Tips: 不可以在获得焦点的时候验证,获得焦点和失去焦点的间隔太小,如果中间存在ajax校验的话会出现问题
$registerPage
.
find
(
'.va'
).
keyup
(
function
()
{
// ( ▼-▼ )注册页和信息完善页面接口不同
exports
.
init
=
function
(
page
)
{
$registerPage
.
find
(
'.va'
).
keyup
(
function
()
{
var
j
,
statusLen
=
0
,
vLen
=
validateResult
.
length
,
$that
=
$
(
this
);
var
j
,
statusLen
=
0
,
vLen
=
validateResult
.
length
,
$that
=
$
(
this
);
validateRule
(
$
(
this
),
function
()
{
showErrTip
();
// 显示错误提示
showBorder
();
// 显示红色边框
validateRule
(
page
,
$
(
this
),
function
()
{
showErrTip
();
// 显示错误提示
showBorder
();
// 显示红色边框
// 如果validateResult中有4个status为true表示验证通过
for
(
j
=
0
;
j
<
vLen
;
j
++
)
{
// 如果validateResult中有4个status为true表示验证通过
for
(
j
=
0
;
j
<
vLen
;
j
++
)
{
if
(
validateResult
[
j
].
status
)
{
if
(
validateResult
[
j
].
status
)
{
statusLen
++
;
}
}
if
(
statusLen
===
4
&&
$
(
'#agree-terms'
).
is
(
':checked'
))
{
$registerBtn
.
removeClass
(
'disable'
).
removeAttr
(
'disabled'
);
}
else
{
$registerBtn
.
addClass
(
'disable'
).
attr
(
'disabled'
,
'true'
);
}
statusLen
++
;
}
// 图形验证通过时,发送短信按钮可点击
if
(
validateResult
[
1
].
status
)
{
$sendCaptcha
.
removeClass
(
'disable'
);
}
else
{
$sendCaptcha
.
addClass
(
'disable'
);
}
}
//图形验证通过时,发送短信按钮可点击 end
if
(
statusLen
===
4
&&
$
(
'#agree-terms'
).
is
(
':checked'
))
{
$registerBtn
.
removeClass
(
'disable'
).
removeAttr
(
'disabled'
);
}
else
{
$registerBtn
.
addClass
(
'disable'
).
attr
(
'disabled'
,
'true'
);
}
});
// 图形验证通过时,发送短信按钮可点击
if
(
validateResult
[
1
].
status
)
{
$sendCaptcha
.
removeClass
(
'disable'
);
}
else
{
$sendCaptcha
.
addClass
(
'disable'
);
}
// 如果是密码则校验强度
if
((
$that
).
hasClass
(
'pwd'
))
{
pwdFn
(
$that
);
}
//图形验证通过时,发送短信按钮可点击 end
}).
blur
(
function
()
{
});
/*validateRule($(this), function() {
showErrTip();
showBorder(); // 显示红色边框
});*/
});
// 如果是密码则校验强度
if
((
$that
).
hasClass
(
'pwd'
))
{
pwdFn
(
$that
);
}
$regionSelect
.
change
(
function
()
{
}).
blur
(
function
()
{
$region
.
text
(
'+'
+
$
(
'#region'
).
val
());
/*validateRule($(this), function() {
showErrTip();
showBorder(); // 显示红色边框
});*/
});
validateRule
(
$pn
,
showErrTip
);
//验证
});
$regionSelect
.
change
(
function
()
{
// 点击发送验证码
$sendCaptcha
.
click
(
function
()
{
var
timeResidue
=
10
,
t
;
$region
.
text
(
'+'
+
$
(
'#region'
).
val
());
if
(
$
(
this
).
hasClass
(
'disable'
))
{
return
;
}
validateRule
(
page
,
$pn
,
showErrTip
);
//验证
});
//todo ajax
// 点击发送验证码
$sendCaptcha
.
click
(
function
()
{
var
timeResidue
=
20
,
t
,
url
;
t
=
setInterval
(
function
()
{
if
(
timeResidue
<=
0
)
{
$sendCaptcha
.
removeClass
(
'disable'
).
val
(
'获取短信验证码'
);
clearInterval
(
t
);
if
(
$
(
this
).
hasClass
(
'disable'
))
{
return
;
}
$sendCaptcha
.
addClass
(
'disable'
).
val
(
timeResidue
--
+
'秒可重新发送'
);
},
1000
);
});
//form表单提交
$registerBtn
.
click
(
function
()
{
if
(
$
(
this
).
hasClass
(
'disable'
))
{
return
;
}
else
{
if
(
page
===
'reg'
)
{
url
=
'/passport/register/sendBindMsg'
;
}
else
if
(
page
===
'third'
)
{
url
=
'/passport/autouserinfo/sendBindMsg'
;
}
//
ajax提交
//
todo ajax 发送验证码
$
.
ajax
({
type
:
'POST'
,
url
:
'/passport/register/mobileregister'
,
url
:
url
,
data
:
{
area
:
$region
.
text
().
split
(
'+'
)[
1
],
mobile
:
$pn
.
val
(),
captcha
:
$ca
.
val
(),
code
:
$mc
.
val
(),
password
:
$pwd
.
val
()
code
:
$ca
.
val
()
}
}).
then
(
function
(
data
)
{
if
(
data
.
code
===
200
)
{
t
=
setInterval
(
function
()
{
if
(
timeResidue
<=
0
)
{
$sendCaptcha
.
removeClass
(
'disable'
).
val
(
'获取短信验证码'
);
clearInterval
(
t
);
return
;
}
$sendCaptcha
.
addClass
(
'disable'
).
val
(
timeResidue
--
+
'秒可重新发送'
);
},
1000
);
}
});
});
//ajax表单提交
$registerBtn
.
click
(
function
()
{
var
time
=
0
,
t
,
refer
=
data
.
href
;
var
url
;
t
=
setTimeout
(
function
()
{
time
++
;
},
1000
);
if
(
page
===
'reg'
)
{
url
=
'/passport/register/mobileregister'
;
}
else
if
(
page
===
'third'
)
{
url
=
'/passport/autouserinfo/bindMobile'
;
}
if
(
$
(
this
).
hasClass
(
'disable'
))
{
return
;
}
else
{
//ajax提交
$
.
ajax
({
type
:
'POST'
,
url
:
'/passport/register/mobileregister'
,
url
:
url
,
data
:
{
session
:
data
.
session
area
:
$region
.
text
().
split
(
'+'
)[
1
],
mobile
:
$pn
.
val
(),
captcha
:
$ca
.
val
(),
code
:
$mc
.
val
(),
password
:
$pwd
.
val
()
}
}).
then
(
function
(
data
)
{
if
(
data
.
code
===
200
&&
t
<
3
)
{
var
time
=
0
,
t
,
refer
=
data
.
href
;
t
=
setTimeout
(
function
()
{
time
++
;
},
1000
);
$
.
ajax
({
type
:
'POST'
,
url
:
'/passport/register/mobileregister'
,
data
:
{
session
:
data
.
session
}
}).
then
(
function
(
data
)
{
if
(
data
.
code
===
200
&&
t
<
3
)
{
clearInterval
(
t
);
location
.
href
=
refer
;
}
});
if
(
t
>=
3
)
{
clearInterval
(
t
);
location
.
href
=
refer
;
}
});
if
(
t
>=
3
)
{
clearInterval
(
t
);
location
.
href
=
refer
;
}
});
}
});
});
}
});
$
(
'.change-captcha'
).
click
(
function
()
{
var
time
=
new
Date
(),
$captchaImg
=
$
(
'.captcha-img'
),
captchaImgSrc
=
$captchaImg
.
attr
(
'src'
).
split
(
'?'
)[
0
];
$
(
'.change-captcha'
).
click
(
function
()
{
var
time
=
new
Date
(),
$captchaImg
=
$
(
'.captcha-img'
),
captchaImgSrc
=
$captchaImg
.
attr
(
'src'
).
split
(
'?'
)[
0
];
$captchaImg
.
attr
(
'src'
,
captchaImgSrc
+
'?t='
+
time
.
getTime
());
});
$captchaImg
.
attr
(
'src'
,
captchaImgSrc
+
'?t='
+
time
.
getTime
());
});
};
});
define
(
"js/passport/mail-phone-regx"
,
[],
function
(
require
,
exports
,
module
){
/**
...
...
@@ -4795,265 +4854,290 @@ $('#find-btn').click(function(e) {
});
});
define
(
"js/passport/login"
,
[
"jquery"
,
"jquery.placeholder"
],
function
(
require
,
exports
,
module
){
/**
* 登录
* @author: xuqi<qi.xu@yoho.cn>
* @date: 2015/12/11
*/
var
$
=
require
(
"jquery"
);
var
mailPostfix
=
{
num
:
[
'qq.com'
,
'163.com'
,
'126.com'
,
'sina.com'
,
'gmail.com'
,
'sohu.com'
,
'hotmail.com'
,
'139.com'
,
'189.com'
],
other
:
[
'gmail.com'
,
'qq.com'
,
'163.com'
,
'126.com'
,
'sina.com'
,
'sohu.com'
,
'hotmail.com'
,
'139.com'
,
'189.com'
]
};
var
$account
=
$
(
'#account'
),
$password
=
$
(
'#password'
);
var
$accountTip
=
$account
.
siblings
(
'.err-tip'
),
$passwordTip
=
$password
.
siblings
(
'.err-tip'
),
$capsLock
=
$
(
'#caps-lock'
);
var
$countryCodeHide
=
$
(
'#country-code-hide'
),
$countryCodeEm
=
$
(
'#country-code > em'
),
$countryList
=
$
(
'#country-list'
);
var
$emailAutoComplete
=
$
(
'#email-autocomplete'
);
var
mailPhoneRegx
=
require
(
"js/passport/mail-phone-regx"
);
//checkbox status unicode
var
checkbox
=
{
checked
:
''
,
unchecked
:
''
};
var
emailAcTime
;
require
(
"jquery.placeholder"
);
//验证账户名
function
validateAccount
()
{
var
pass
=
false
,
account
=
$
.
trim
(
$account
.
val
()),
err
;
if
(
account
!==
''
)
{
if
(
/^
[
0-9
]
+$/
.
test
(
account
))
{
//如果是纯数字,则作为手机号码处理
if
(
mailPhoneRegx
.
phoneRegx
[
'+'
+
$countryCodeHide
.
val
()].
test
(
account
))
{
pass
=
true
;
}
else
{
pass
=
false
;
err
=
'手机号码不正确,请重新输入'
;
}
}
else
{
if
(
mailPhoneRegx
.
emailRegx
.
test
(
account
))
{
pass
=
true
;
}
else
{
pass
=
false
;
err
=
'邮箱格式不正确,请重新输入'
;
}
}
}
else
{
err
=
'请输入账户名'
;
}
if
(
pass
)
{
$accountTip
.
addClass
(
'hide'
);
$account
.
removeClass
(
'error'
);
}
else
{
$accountTip
.
removeClass
(
'hide'
).
children
(
'em'
).
text
(
err
);
$account
.
addClass
(
'error'
);
}
return
pass
;
}
//验证密码
function
validatePassword
()
{
var
pass
=
false
,
password
=
$
.
trim
(
$password
.
val
()),
err
;
if
(
password
!==
''
)
{
if
(
password
.
length
<
6
)
{
err
=
'请输入长度为6-20字符的密码'
;
}
else
{
pass
=
true
;
}
}
else
{
err
=
'请输入密码'
;
}
if
(
pass
)
{
$passwordTip
.
addClass
(
'hide'
);
$password
.
removeClass
(
'error'
);
}
else
{
$passwordTip
.
removeClass
(
'hide'
).
children
(
'em'
).
text
(
err
);
$password
.
addClass
(
'error'
);
}
}
//验证
function
validate
()
{
var
pass
=
true
,
account
=
$
.
trim
(
$account
.
val
()),
password
=
$
.
trim
(
$password
.
val
());
if
(
account
!==
''
)
{
pass
=
validateAccount
()
&&
validatePassword
();
}
else
{
pass
=
false
;
$account
.
addClass
(
'error'
);
if
(
password
===
''
)
{
//账户名和密码都为空的情况下点击登陆,只在账户输入框后显示错误提示
$accountTip
.
addClass
(
'both-error'
).
removeClass
(
'hide'
).
children
(
'em'
).
text
(
'请输入账户名和密码'
);
$passwordTip
.
addClass
(
'hide'
);
$password
.
addClass
(
'error'
);
}
else
{
$accountTip
.
removeClass
(
'hide'
).
children
(
'em'
).
text
(
'请输入账户名'
);
}
}
return
pass
;
}
$
(
'[placeholder]'
).
placeholder
();
//展开地区列表
$
(
'#country-code'
).
on
(
'click'
,
function
()
{
if
(
$countryList
.
css
(
'display'
)
===
'none'
)
{
$countryList
.
slideDown
();
}
});
//选中地区列表项
$countryList
.
on
(
'click'
,
'li'
,
function
()
{
var
$this
=
$
(
this
),
cc
=
$this
.
data
(
'cc'
);
$countryCodeEm
.
html
(
$this
.
html
());
$countryCodeHide
.
val
(
cc
);
$countryList
.
slideUp
();
});
//点击其他区域,收起区域列表
$
(
document
).
on
(
'click'
,
function
(
e
)
{
if
(
$
(
e
.
target
).
closest
(
'#country-code'
).
length
>
0
)
{
return
;
}
if
(
$countryList
.
css
(
'display'
)
===
'block'
)
{
$countryList
.
slideUp
();
}
});
//邮箱
$account
.
on
(
'keyup'
,
function
()
{
var
account
=
$
.
trim
(
$
(
this
).
val
()),
html
=
''
,
accountMatch
,
matchStr
,
postfix
,
i
;
//输入@时自动补全邮箱后缀
//此处>0非错误,用于避免输入的第一个字符为@被识别为邮箱
if
(
account
.
indexOf
(
'@'
)
>
0
)
{
accountMatch
=
account
.
match
(
/^
[
0-9
]
+@
(
.*
)
/
);
if
(
accountMatch
)
{
//数字邮箱补全
postfix
=
mailPostfix
.
num
;
}
else
{
postfix
=
mailPostfix
.
other
;
}
matchStr
=
accountMatch
[
1
];
for
(
i
=
0
;
i
<
postfix
.
length
;
i
++
)
{
if
(
postfix
[
i
].
indexOf
(
matchStr
)
>
-
1
)
{
html
+=
'<li>'
+
account
.
slice
(
0
,
account
.
indexOf
(
'@'
))
+
'@'
+
postfix
[
i
]
+
'</li>'
;
}
}
if
(
html
!==
''
)
{
$emailAutoComplete
.
html
(
html
).
removeClass
(
'hide'
);
}
else
{
//隐藏autocomplete
$emailAutoComplete
.
html
(
''
).
addClass
(
'hide'
);
}
}
}).
on
(
'blur'
,
function
()
{
emailAcTime
=
setTimeout
(
function
()
{
$emailAutoComplete
.
addClass
(
'hide'
);
//验证
validateAccount
();
},
200
);
});
//密码
$password
.
on
(
'blur'
,
function
()
{
validatePassword
();
}).
on
(
'keypress'
,
function
(
e
)
{
var
code
=
e
.
which
,
isShift
=
e
.
shiftKey
||
(
code
===
16
)
||
false
;
//CapsLock检测
if
((
!
isShift
&&
(
code
>=
65
&&
code
<=
90
))
||
(
isShift
&&
(
code
>=
97
&&
code
<=
122
)))
{
$capsLock
.
removeClass
(
'hide'
);
return
;
}
$capsLock
.
addClass
(
'hide'
);
});
//邮箱自动完成列表项点击
$emailAutoComplete
.
on
(
'click'
,
'li'
,
function
()
{
clearTimeout
(
emailAcTime
);
//清空默认关闭
$account
.
val
(
$
(
this
).
text
()).
focus
();
$emailAutoComplete
.
addClass
(
'hide'
);
});
//记住登录状态
$
(
'.remeber-me'
).
on
(
'click'
,
function
()
{
var
$this
=
$
(
this
);
$this
.
toggleClass
(
'checked'
);
if
(
$this
.
hasClass
(
'checked'
))
{
$this
.
children
(
'i'
).
html
(
checkbox
.
checked
);
}
else
{
$this
.
children
(
'i'
).
html
(
checkbox
.
unchecked
);
}
});
//focus到输入框则隐藏错误提示和样式
$
(
'.va'
).
on
(
'focus'
,
function
()
{
var
$this
=
$
(
this
);
$this
.
removeClass
(
'error'
);
$this
.
siblings
(
'.err-tip'
).
addClass
(
'hide'
);
});
//登录
$
(
'#login-btn'
).
on
(
'click'
,
function
()
{
var
pass
=
validate
();
if
(
pass
)
{
$
(
'#login-form'
).
submit
();
}
/**
* 登录
* @author: xuqi<qi.xu@yoho.cn>
* @date: 2015/12/11
*/
var
$
=
require
(
"jquery"
);
var
mailPostfix
=
{
num
:
[
'qq.com'
,
'163.com'
,
'126.com'
,
'sina.com'
,
'gmail.com'
,
'sohu.com'
,
'hotmail.com'
,
'139.com'
,
'189.com'
],
other
:
[
'gmail.com'
,
'qq.com'
,
'163.com'
,
'126.com'
,
'sina.com'
,
'sohu.com'
,
'hotmail.com'
,
'139.com'
,
'189.com'
]
};
var
$account
=
$
(
'#account'
),
$password
=
$
(
'#password'
);
var
$accountTip
=
$account
.
siblings
(
'.err-tip'
),
$passwordTip
=
$password
.
siblings
(
'.err-tip'
),
$capsLock
=
$
(
'#caps-lock'
);
var
$countryCodeHide
=
$
(
'#country-code-hide'
),
$countryCodeEm
=
$
(
'#country-code > em'
),
$countryList
=
$
(
'#country-list'
);
var
$emailAutoComplete
=
$
(
'#email-autocomplete'
);
var
mailPhoneRegx
=
require
(
"js/passport/mail-phone-regx"
);
//checkbox status unicode
var
checkbox
=
{
checked
:
''
,
unchecked
:
''
};
var
authing
=
false
;
var
emailAcTime
;
require
(
"jquery.placeholder"
);
//验证账户名
function
validateAccount
()
{
var
pass
=
false
,
account
=
$
.
trim
(
$account
.
val
()),
err
;
if
(
account
!==
''
)
{
if
(
/^
[
0-9
]
+$/
.
test
(
account
))
{
//如果是纯数字,则作为手机号码处理
if
(
mailPhoneRegx
.
phoneRegx
[
$countryCodeHide
.
val
()].
test
(
account
))
{
pass
=
true
;
}
else
{
pass
=
false
;
err
=
'手机号码不正确,请重新输入'
;
}
}
else
{
if
(
mailPhoneRegx
.
emailRegx
.
test
(
account
))
{
pass
=
true
;
}
else
{
pass
=
false
;
err
=
'邮箱格式不正确,请重新输入'
;
}
}
}
else
{
err
=
'请输入账户名'
;
}
if
(
pass
)
{
$accountTip
.
addClass
(
'hide'
);
$account
.
removeClass
(
'error'
);
}
else
{
$accountTip
.
removeClass
(
'hide'
).
children
(
'em'
).
text
(
err
);
$account
.
addClass
(
'error'
);
}
return
pass
;
}
//验证密码
function
validatePassword
()
{
var
pass
=
false
,
password
=
$
.
trim
(
$password
.
val
()),
err
;
if
(
password
!==
''
)
{
if
(
password
.
length
<
6
)
{
err
=
'请输入长度为6-20字符的密码'
;
}
else
{
pass
=
true
;
}
}
else
{
err
=
'请输入密码'
;
}
if
(
pass
)
{
$passwordTip
.
addClass
(
'hide'
);
$password
.
removeClass
(
'error'
);
}
else
{
$passwordTip
.
removeClass
(
'hide'
).
children
(
'em'
).
text
(
err
);
$password
.
addClass
(
'error'
);
}
return
pass
;
}
//验证
function
validate
()
{
var
pass
=
true
,
account
=
$
.
trim
(
$account
.
val
()),
password
=
$
.
trim
(
$password
.
val
());
if
(
account
!==
''
)
{
pass
=
validateAccount
()
&&
validatePassword
();
}
else
{
pass
=
false
;
$account
.
addClass
(
'error'
);
if
(
password
===
''
)
{
//账户名和密码都为空的情况下点击登陆,只在账户输入框后显示错误提示
$accountTip
.
addClass
(
'both-error'
).
removeClass
(
'hide'
).
children
(
'em'
).
text
(
'请输入账户名和密码'
);
$passwordTip
.
addClass
(
'hide'
);
$password
.
addClass
(
'error'
);
}
else
{
$accountTip
.
removeClass
(
'hide'
).
children
(
'em'
).
text
(
'请输入账户名'
);
}
}
return
pass
;
}
$
(
'[placeholder]'
).
placeholder
();
//展开地区列表
$
(
'#country-code'
).
on
(
'click'
,
function
()
{
if
(
$countryList
.
css
(
'display'
)
===
'none'
)
{
$countryList
.
slideDown
();
}
});
//选中地区列表项
$countryList
.
on
(
'click'
,
'li'
,
function
()
{
var
$this
=
$
(
this
),
cc
=
$this
.
data
(
'cc'
);
$countryCodeEm
.
html
(
$this
.
html
());
$countryCodeHide
.
val
(
cc
);
$countryList
.
slideUp
();
});
//点击其他区域,收起区域列表
$
(
document
).
on
(
'click'
,
function
(
e
)
{
if
(
$
(
e
.
target
).
closest
(
'#country-code'
).
length
>
0
)
{
return
;
}
if
(
$countryList
.
css
(
'display'
)
===
'block'
)
{
$countryList
.
slideUp
();
}
});
//邮箱
$account
.
on
(
'keyup'
,
function
()
{
var
account
=
$
.
trim
(
$
(
this
).
val
()),
html
=
''
,
accountMatch
,
matchStr
,
postfix
,
i
;
//输入@时自动补全邮箱后缀
//此处>0非错误,用于避免输入的第一个字符为@被识别为邮箱
if
(
account
.
indexOf
(
'@'
)
>
0
)
{
accountMatch
=
account
.
match
(
/^
[
0-9
]
+@
(
.*
)
/
);
if
(
accountMatch
)
{
//数字邮箱补全
postfix
=
mailPostfix
.
num
;
}
else
{
postfix
=
mailPostfix
.
other
;
}
matchStr
=
accountMatch
[
1
];
for
(
i
=
0
;
i
<
postfix
.
length
;
i
++
)
{
if
(
postfix
[
i
].
indexOf
(
matchStr
)
>
-
1
)
{
html
+=
'<li>'
+
account
.
slice
(
0
,
account
.
indexOf
(
'@'
))
+
'@'
+
postfix
[
i
]
+
'</li>'
;
}
}
if
(
html
!==
''
)
{
$emailAutoComplete
.
html
(
html
).
removeClass
(
'hide'
);
}
else
{
//隐藏autocomplete
$emailAutoComplete
.
html
(
''
).
addClass
(
'hide'
);
}
}
}).
on
(
'blur'
,
function
()
{
emailAcTime
=
setTimeout
(
function
()
{
$emailAutoComplete
.
addClass
(
'hide'
);
//验证
validateAccount
();
},
200
);
});
//密码
$password
.
on
(
'blur'
,
function
()
{
validatePassword
();
}).
on
(
'keypress'
,
function
(
e
)
{
var
code
=
e
.
which
,
isShift
=
e
.
shiftKey
||
(
code
===
16
)
||
false
;
//CapsLock检测
if
((
!
isShift
&&
(
code
>=
65
&&
code
<=
90
))
||
(
isShift
&&
(
code
>=
97
&&
code
<=
122
)))
{
$capsLock
.
removeClass
(
'hide'
);
return
;
}
$capsLock
.
addClass
(
'hide'
);
});
//邮箱自动完成列表项点击
$emailAutoComplete
.
on
(
'click'
,
'li'
,
function
()
{
clearTimeout
(
emailAcTime
);
//清空默认关闭
$account
.
val
(
$
(
this
).
text
()).
focus
();
$emailAutoComplete
.
addClass
(
'hide'
);
});
//记住登录状态
$
(
'.remeber-me'
).
on
(
'click'
,
function
()
{
var
$this
=
$
(
this
);
$this
.
toggleClass
(
'checked'
);
if
(
$this
.
hasClass
(
'checked'
))
{
$this
.
children
(
'i'
).
html
(
checkbox
.
checked
);
}
else
{
$this
.
children
(
'i'
).
html
(
checkbox
.
unchecked
);
}
});
//focus到输入框则隐藏错误提示和样式
$
(
'.va'
).
on
(
'focus'
,
function
()
{
var
$this
=
$
(
this
);
$this
.
removeClass
(
'error'
);
$this
.
siblings
(
'.err-tip'
).
addClass
(
'hide'
);
});
//登录
$
(
'#login-btn'
).
on
(
'click'
,
function
()
{
var
pass
=
validate
();
if
(
pass
&&
authing
===
false
)
{
authing
=
true
;
$
.
ajax
({
url
:
'/passport/login/auth'
,
type
:
'POST'
,
data
:
{
areaCode
:
$countryCodeHide
.
val
().
replace
(
'+'
,
''
),
account
:
$
.
trim
(
$account
.
val
()),
password
:
$
.
trim
(
$password
.
val
())
},
success
:
function
(
data
)
{
if
(
data
.
code
===
400
)
{
$passwordTip
.
removeClass
(
'hide'
).
children
(
'em'
).
text
(
data
.
message
);
$password
.
addClass
(
'error'
);
return
;
}
else
{
location
.
href
=
data
.
data
.
href
;
}
},
complete
:
function
()
{
authing
=
false
;
}
});
}
});
});
define
(
"js/passport/reset"
,
[
"jquery"
,
"jquery.placeholder"
],
function
(
require
,
exports
,
module
){
...
...
web-static/dist/yohobuy/0.0.1/index.js
View file @
d24ef77
This diff could not be displayed because it is too large.
yohobuy/m.yohobuy.com/application/models/Index/User.php
View file @
d24ef77
...
...
@@ -202,9 +202,9 @@ class UserModel
$product
[
'imgUrl'
]
=
!
empty
(
$val
[
'image'
])
?
Helpers
::
getImageUrl
(
$val
[
'image'
],
447
,
596
)
:
''
;
;
$product
[
'title'
]
=
$val
[
'product_name'
];
$product
[
'price'
]
=
'¥'
.
Helpers
::
transPrice
(
floatval
(
$val
[
'market_price'
]));
$product
[
'discountPrice'
]
=
(
$val
[
'market_price'
]
-
$val
[
'sales_price'
]
>
0
)
?
'¥'
.
Helpers
::
transPrice
(
floatval
(
$val
[
'sales_price'
]))
:
false
;
$product
[
'savePrice'
]
=
(
$val
[
'price_down'
]
>
0
)
?
'¥'
.
Helpers
::
transPrice
(
floatval
(
$val
[
'price_down'
]))
:
false
;
$product
[
'price'
]
=
!
empty
(
$val
[
'market_price'
])
?
'¥'
.
$val
[
'market_price'
]
.
'.00'
:
0
;
$product
[
'discountPrice'
]
=
(
$val
[
'market_price'
]
-
$val
[
'sales_price'
]
>
0
)
?
'¥'
.
$val
[
'sales_price'
]
.
'.00'
:
false
;
$product
[
'savePrice'
]
=
(
$val
[
'price_down'
]
>
0
)
?
'¥'
.
$val
[
'price_down'
]
.
'.00'
:
false
;
$product
[
'sellOut'
]
=
(
$val
[
'storage'
]
<=
0
);
$datas
[]
=
$product
;
...
...
@@ -256,8 +256,8 @@ class UserModel
$product
=
array
();
$product
[
'link'
]
=
isset
(
$one
[
'goods'
][
0
],
$one
[
'cnAlphabet'
])
?
Helpers
::
url
(
'/product/pro_'
.
$one
[
'product_id'
]
.
'_'
.
$one
[
'goods'
][
0
][
'id'
]
.
'/'
.
$one
[
'cnAlphabet'
]
.
'.html'
)
:
''
;
$product
[
'imgUrl'
]
=
(
isset
(
$one
[
'default_images'
])
&&
!
empty
(
$one
[
'default_images'
]))
?
Images
::
getImageUrl
(
$one
[
'default_images'
],
235
,
314
)
:
''
;
$product
[
'price'
]
=
'¥'
.
Helpers
::
transPrice
(
floatval
(
$one
[
'market_price'
]));
$product
[
'discount'
]
=
(
$one
[
'market_price'
]
>
$one
[
'sales_price'
])
?
'¥'
.
Helpers
::
transPrice
(
floatval
(
$one
[
'sales_price'
]))
:
false
;
$product
[
'price'
]
=
!
empty
(
$one
[
'market_price'
])
?
'¥'
.
$one
[
'market_price'
]
:
0
;
$product
[
'discount'
]
=
(
$one
[
'market_price'
]
>
$one
[
'sales_price'
])
?
'¥'
.
$one
[
'sales_price'
]
:
false
;
$brand
[
'productList'
][]
=
$product
;
}
...
...
@@ -321,7 +321,7 @@ class UserModel
$val
[
'link'
]
=
Helpers
::
url
(
'/product/show_'
.
$val
[
'product_skn'
]
.
'.html'
);
$val
[
'image'
]
=
!
empty
(
$val
[
'image'
])
?
Helpers
::
getImageUrl
(
$val
[
'image'
],
447
,
596
)
:
''
;
$val
[
'sales_price'
]
=
Helpers
::
transPrice
(
$val
[
'sales_price'
]);
$val
[
'market_price'
]
=
(
$val
[
'market_price'
]
-
$val
[
'sales_price'
]
>
0
)
?
'¥'
.
Helpers
::
transPrice
(
floatval
(
$val
[
'market_price'
]))
:
false
;
$val
[
'market_price'
]
=
(
$val
[
'market_price'
]
-
$val
[
'sales_price'
]
>
0
)
?
$val
[
'market_price'
]
.
'.00'
:
false
;
}
!
empty
(
$data
)
&&
$result
[
'browseRecord'
]
=
$data
;
}
...
...
Please
register
or
login
to post a comment