Merge branch 'develop' of http://git.dev.yoho.cn/web/yohobuy into develop
Showing
4 changed files
with
109 additions
and
6 deletions
@@ -7,6 +7,7 @@ use LibModels\Web\Product\BrandData; | @@ -7,6 +7,7 @@ use LibModels\Web\Product\BrandData; | ||
7 | use LibModels\Web\Product\SearchData; | 7 | use LibModels\Web\Product\SearchData; |
8 | use Api\Yohobuy; | 8 | use Api\Yohobuy; |
9 | use Api\Sign; | 9 | use Api\Sign; |
10 | +use Index\HomeModel; | ||
10 | /** | 11 | /** |
11 | * 搜索辅助类 | 12 | * 搜索辅助类 |
12 | */ | 13 | */ |
@@ -31,7 +32,7 @@ class HelperSearch | @@ -31,7 +32,7 @@ class HelperSearch | ||
31 | private static function setListNav() | 32 | private static function setListNav() |
32 | { | 33 | { |
33 | $options = self::$options; | 34 | $options = self::$options; |
34 | - $cookieChannel = isset($_COOKIE['_Channel']) ? $_COOKIE['_Channel'] : 'boys'; | 35 | + $channel = HomeModel::getSwitchChannel(); |
35 | if (isset($options['brandName']) && !empty($options['brandName'])) { | 36 | if (isset($options['brandName']) && !empty($options['brandName'])) { |
36 | $initNav = $options['brandNameEn'] . $options['brandNameCn']; | 37 | $initNav = $options['brandNameEn'] . $options['brandNameCn']; |
37 | }else{ | 38 | }else{ |
@@ -39,7 +40,7 @@ class HelperSearch | @@ -39,7 +40,7 @@ class HelperSearch | ||
39 | } | 40 | } |
40 | self::$listNav[0] = array( | 41 | self::$listNav[0] = array( |
41 | 'href' => '', | 42 | 'href' => '', |
42 | - 'name' => strtoupper($cookieChannel).'首页' | 43 | + 'name' => strtoupper($channel).'首页' |
43 | ); | 44 | ); |
44 | self::$listNav[1] = array( | 45 | self::$listNav[1] = array( |
45 | 'href' => '', | 46 | 'href' => '', |
@@ -799,7 +799,12 @@ class Helpers | @@ -799,7 +799,12 @@ class Helpers | ||
799 | */ | 799 | */ |
800 | public static function syncUserSession($uid, $refer = '', $callback = 'call') | 800 | public static function syncUserSession($uid, $refer = '', $callback = 'call') |
801 | { | 801 | { |
802 | - return 'http://mapi.yohobuy.com/Passport/session/index?callback=' . $callback | 802 | + if(APPLICATION_ENV == 'production') { |
803 | + $domain = 'http://mapi.yohobuy.com'; | ||
804 | + } else { | ||
805 | + $domain = 'http://m1.yohobuy.com'; | ||
806 | + } | ||
807 | + return $domain.'/Passport/session/index?callback=' . $callback | ||
803 | . '&sign=' . md5(md5($uid . 'Js8Yn0!EwPM45-ws')) . '&uid=' . $uid . '&go=' . $refer; | 808 | . '&sign=' . md5(md5($uid . 'Js8Yn0!EwPM45-ws')) . '&uid=' . $uid . '&go=' . $refer; |
804 | } | 809 | } |
805 | 810 | ||
@@ -815,7 +820,12 @@ class Helpers | @@ -815,7 +820,12 @@ class Helpers | ||
815 | */ | 820 | */ |
816 | public static function logoutSession($token, $refer = '', $callback = 'call') | 821 | public static function logoutSession($token, $refer = '', $callback = 'call') |
817 | { | 822 | { |
818 | - return 'http://mapi.yohobuy.com/Passport/session/logout?callback=' . $callback | 823 | + if(APPLICATION_ENV == 'production') { |
824 | + $domain = 'http://mapi.yohobuy.com'; | ||
825 | + } else { | ||
826 | + $domain = 'http://m1.yohobuy.com'; | ||
827 | + } | ||
828 | + return $domain.'/Passport/session/logout?callback=' . $callback | ||
819 | . '&sign=' . md5(md5('Js8Yn0!EwPM45-ws')) . '&token=' . $token . '&go=' . $refer; | 829 | . '&sign=' . md5(md5('Js8Yn0!EwPM45-ws')) . '&token=' . $token . '&go=' . $refer; |
820 | } | 830 | } |
821 | 831 |
@@ -68,7 +68,7 @@ function closeMask() { | @@ -68,7 +68,7 @@ function closeMask() { | ||
68 | if ($target.hasClass('mask') || $target.hasClass('backdrop')) { | 68 | if ($target.hasClass('mask') || $target.hasClass('backdrop')) { |
69 | $('#alreayregist').hide(); | 69 | $('#alreayregist').hide(); |
70 | } | 70 | } |
71 | - }) | 71 | + }); |
72 | } | 72 | } |
73 | 73 | ||
74 | function nextStep() { | 74 | function nextStep() { |
@@ -6,4 +6,96 @@ if ($('.simple-header').size() > 0) { | @@ -6,4 +6,96 @@ if ($('.simple-header').size() > 0) { | ||
6 | }).on('mouseleave', function() { | 6 | }).on('mouseleave', function() { |
7 | $(this).find('.tool-select').fadeOut(); | 7 | $(this).find('.tool-select').fadeOut(); |
8 | }); | 8 | }); |
9 | -} | ||
9 | +} | ||
10 | + | ||
11 | +/** | ||
12 | + * 格式化用户名 | ||
13 | + * @return {[type]} [description] | ||
14 | + */ | ||
15 | +function formatUsernName(userName) { | ||
16 | + var name, | ||
17 | + char, | ||
18 | + _num = 0, | ||
19 | + _length = 0, | ||
20 | + t; | ||
21 | + | ||
22 | + for (t = 0; t < userName.length; t++) { | ||
23 | + char = userName.substr(t, 1); | ||
24 | + if (/.*[\u4e00-\u9fa5]+.*$/.test(char)) { | ||
25 | + _length += 2; | ||
26 | + } else { | ||
27 | + _length += 1; | ||
28 | + } | ||
29 | + } | ||
30 | + if (_length <= 10) { | ||
31 | + name = userName; | ||
32 | + } else { | ||
33 | + _num = 0; | ||
34 | + name = ''; | ||
35 | + for (t = 0; t < userName.length; t++) { | ||
36 | + if (_num < 10) { | ||
37 | + char = userName.substr(t, 1); | ||
38 | + if (char !== '*') { | ||
39 | + if (/.*[\u4e00-\u9fa5]+.*$/.test(char)) { | ||
40 | + _num += 2; | ||
41 | + } else { | ||
42 | + _num += 1; | ||
43 | + } | ||
44 | + } | ||
45 | + name += char; | ||
46 | + } | ||
47 | + } | ||
48 | + if (name.length < userName.length) { | ||
49 | + name += '...'; | ||
50 | + } | ||
51 | + } | ||
52 | + return name; | ||
53 | +} | ||
54 | + | ||
55 | +/** | ||
56 | + * 设置简单头部登陆状态 | ||
57 | + * @return {[type]} [description] | ||
58 | + */ | ||
59 | +function setLoginStatus(_data) { | ||
60 | + var loginHtml, | ||
61 | + name; | ||
62 | + | ||
63 | + if (_data && _data.href && _data.href.user) { | ||
64 | + name = formatUsernName(_data.href.user); | ||
65 | + loginHtml = '<span>Hi~</span><a href="">' + | ||
66 | + name + '</a> <a href="' + _data.href.logout + '">[退出]</a>'; | ||
67 | + } else { | ||
68 | + name = formatUsernName(_data.user); | ||
69 | + loginHtml = '<span>Hi~</span><a href="">' + | ||
70 | + name + '</a> <a href="http://www.yohobuy.com/signin.html">[请登录]</a>' + | ||
71 | + '<a href="http://www.yohobuy.com/reg.html">[免费注册]</a>'; | ||
72 | + } | ||
73 | + $('.header-tool li').eq(0).html(loginHtml); | ||
74 | +} | ||
75 | + | ||
76 | +/** | ||
77 | + * 获取登录信息 | ||
78 | + * @return {[type]} [description] | ||
79 | + */ | ||
80 | +function actionLoginInfo() { | ||
81 | + $.ajax({ | ||
82 | + type: 'GET', | ||
83 | + url: '/common/getSimpleHeader', | ||
84 | + data: {}, | ||
85 | + success: function(data) { | ||
86 | + if (data.code === 200) { | ||
87 | + setLoginStatus(data.data); | ||
88 | + } | ||
89 | + } | ||
90 | + }); | ||
91 | +} | ||
92 | + | ||
93 | +/** | ||
94 | + * 初始化函数 | ||
95 | + * @return {[type]} [description] | ||
96 | + */ | ||
97 | +function init() { | ||
98 | + actionLoginInfo(); //获取登录信息 | ||
99 | +} | ||
100 | + | ||
101 | +init(); |
-
Please register or login to post a comment