Authored by hf

code review by fei.hong: do format common.php codes

@@ -85,4 +85,5 @@ @@ -85,4 +85,5 @@
85 {{/ newArrivls}} 85 {{/ newArrivls}}
86 {{/ boys}} 86 {{/ boys}}
87 </div> 87 </div>
  88 +<script>__custom = {"yopid":"index"};</script>
88 {{> layout/footer}} 89 {{> layout/footer}}
@@ -2,6 +2,7 @@ @@ -2,6 +2,7 @@
2 <noscript><iframe src="//www.googletagmanager.com/ns.html?id=GTM-W958MG" height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript> 2 <noscript><iframe src="//www.googletagmanager.com/ns.html?id=GTM-W958MG" height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
3 <script> 3 <script>
4 var _hmt = _hmt || []; 4 var _hmt = _hmt || [];
  5 +var _gaq = _gaq || [];
5 (function() { 6 (function() {
6 function async_load(){ 7 function async_load(){
7 (function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start': 8 (function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
@@ -10,6 +11,14 @@ var _hmt = _hmt || []; @@ -10,6 +11,14 @@ var _hmt = _hmt || [];
10 '//www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f); 11 '//www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
11 })(window,document,'script','dataLayer','GTM-W958MG'); 12 })(window,document,'script','dataLayer','GTM-W958MG');
12 (function() { 13 (function() {
  14 + _gaq.push(['_setAccount', 'UA-48997038-32']);
  15 + _gaq.push(['_trackPageview']);
  16 + var ga = document.createElement('script');
  17 + ga.type = 'text/javascript'; ga.async = true;
  18 + ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
  19 + var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  20 + })();
  21 + (function() {
13 var hm = document.createElement("script"); 22 var hm = document.createElement("script");
14 hm.src = "//hm.baidu.com/hm.js?c6ee7218b8321cb65fb2e98f284d8311"; 23 hm.src = "//hm.baidu.com/hm.js?c6ee7218b8321cb65fb2e98f284d8311";
15 hm.async = 1; 24 hm.async = 1;
@@ -30,6 +39,17 @@ var _hmt = _hmt || []; @@ -30,6 +39,17 @@ var _hmt = _hmt || [];
30 var s = document.getElementsByTagName("script")[0]; 39 var s = document.getElementsByTagName("script")[0];
31 s.parentNode.insertBefore(hm, s); 40 s.parentNode.insertBefore(hm, s);
32 })(); 41 })();
  42 + (function() {
  43 + var hm = document.createElement("script");
  44 + hm.src = "http://static.criteo.net/js/ld/ld.js";
  45 + hm.async = 1;
  46 + var s = document.getElementsByTagName("script")[0];
  47 + s.parentNode.insertBefore(hm, s);
  48 + var u = _ozuid || "";
  49 + u = (u == 0) ? "" : u;
  50 + window.criteo_q = window.criteo_q || [];
  51 + window.criteo_q.push({event: "setAccount", account: 16184 },{event: "setCustomerId", id: u},{event: "setSiteType", type: "d" },{event: "viewHome" });
  52 + })();
33 } 53 }
34 if (window.addEventListener) { 54 if (window.addEventListener) {
35 window.addEventListener('load', async_load, false); 55 window.addEventListener('load', async_load, false);
@@ -10,6 +10,8 @@ @@ -10,6 +10,8 @@
10 <title>{{title}}</title> 10 <title>{{title}}</title>
11 <link rel="dns-prefetch" href="//cdn.yoho.cn"> 11 <link rel="dns-prefetch" href="//cdn.yoho.cn">
12 <link rel="dns-prefetch" href="//static.yohobuy.com"> 12 <link rel="dns-prefetch" href="//static.yohobuy.com">
  13 + <link rel="dns-prefetch" href="//img10.static.yhbimg.com">
  14 + <link rel="dns-prefetch" href="//img11.static.yhbimg.com">
13 <link rel="dns-prefetch" href="//img12.static.yhbimg.com"> 15 <link rel="dns-prefetch" href="//img12.static.yhbimg.com">
14 <link rel="dns-prefetch" href="//img13.static.yhbimg.com"> 16 <link rel="dns-prefetch" href="//img13.static.yhbimg.com">
15 {{#if rlsEnv}} 17 {{#if rlsEnv}}
@@ -3,43 +3,39 @@ @@ -3,43 +3,39 @@
3 </script> 3 </script>
4 {{!-- 正常头部 --}} 4 {{!-- 正常头部 --}}
5 {{#headerdata}} 5 {{#headerdata}}
6 - <script> 6 +<script>
7 seajs.use('js/header'); 7 seajs.use('js/header');
8 - </script> 8 +</script>
9 {{/headerdata}} 9 {{/headerdata}}
10 {{!-- 简单头部 --}} 10 {{!-- 简单头部 --}}
11 {{#simpleHeader}} 11 {{#simpleHeader}}
12 - <script> 12 +<script>
13 seajs.use('js/simple-header'); 13 seajs.use('js/simple-header');
14 - </script> 14 +</script>
15 {{/simpleHeader}} 15 {{/simpleHeader}}
16 {{!-- 首页 --}} 16 {{!-- 首页 --}}
17 {{#if boysHomePage}} 17 {{#if boysHomePage}}
18 - <script> 18 +<script>
19 seajs.use('js/home/home'); 19 seajs.use('js/home/home');
20 - </script> 20 +</script>
21 {{/if}} 21 {{/if}}
22 -  
23 {{!-- 搜索 --}} 22 {{!-- 搜索 --}}
24 {{#if searchListPage}} 23 {{#if searchListPage}}
25 - <script> 24 +<script>
26 seajs.use('js/product/brand'); 25 seajs.use('js/product/brand');
27 seajs.use(['js/product/list', 'js/product/product'], function (list, product) { 26 seajs.use(['js/product/list', 'js/product/product'], function (list, product) {
28 -  
29 product.init(5); 27 product.init(5);
30 window.onresize = function () { 28 window.onresize = function () {
31 setTimeout(function () { 29 setTimeout(function () {
32 product.init(5); 30 product.init(5);
33 }, 300); 31 }, 300);
34 }; 32 };
35 -  
36 }); 33 });
37 - </script> 34 +</script>
38 {{/if}} 35 {{/if}}
39 -  
40 {{!-- 列表 --}} 36 {{!-- 列表 --}}
41 {{#if productListPage}} 37 {{#if productListPage}}
42 - <script> 38 +<script>
43 seajs.use(['js/product/list', 'js/product/product'], function (list, product) { 39 seajs.use(['js/product/list', 'js/product/product'], function (list, product) {
44 40
45 product.init(4); 41 product.init(4);
@@ -50,98 +46,84 @@ @@ -50,98 +46,84 @@
50 }; 46 };
51 47
52 }); 48 });
53 - </script> 49 +</script>
54 {{/if}} 50 {{/if}}
55 -  
56 {{!-- 商品详情页 --}} 51 {{!-- 商品详情页 --}}
57 {{#if productDetailPage}} 52 {{#if productDetailPage}}
58 - <script> 53 +<script>
59 seajs.use('js/product/item'); 54 seajs.use('js/product/item');
60 - </script> 55 +</script>
61 {{/if}} 56 {{/if}}
62 -  
63 {{!-- 逛 --}} 57 {{!-- 逛 --}}
64 {{#if guangIndexPage}} 58 {{#if guangIndexPage}}
65 - <script> 59 +<script>
66 seajs.use('js/guang/index'); 60 seajs.use('js/guang/index');
67 - </script> 61 +</script>
68 {{/if}} 62 {{/if}}
69 -  
70 {{!-- 逛详情页 --}} 63 {{!-- 逛详情页 --}}
71 {{#if guangDetailPage}} 64 {{#if guangDetailPage}}
72 - <script> 65 +<script>
73 seajs.use('js/guang/detail'); 66 seajs.use('js/guang/detail');
74 - </script> 67 +</script>
75 {{/if}} 68 {{/if}}
76 -  
77 {{!-- 逛列表页 --}} 69 {{!-- 逛列表页 --}}
78 {{#if guangListPage}} 70 {{#if guangListPage}}
79 - <script> 71 +<script>
80 seajs.use('js/guang/list'); 72 seajs.use('js/guang/list');
81 - </script> 73 +</script>
82 {{/if}} 74 {{/if}}
83 -  
84 {{!-- SALE --}} 75 {{!-- SALE --}}
85 {{#if saleIndexPage}} 76 {{#if saleIndexPage}}
86 - <script> 77 +<script>
87 seajs.use('js/sale/index'); 78 seajs.use('js/sale/index');
88 - </script> 79 +</script>
89 {{/if}} 80 {{/if}}
90 -  
91 {{!-- sale列表 --}} 81 {{!-- sale列表 --}}
92 {{#if saleListPage}} 82 {{#if saleListPage}}
93 <script> 83 <script>
94 seajs.use(['js/product/list', 'js/product/product', 'js/sale/banner'], function (list, product) { 84 seajs.use(['js/product/list', 'js/product/product', 'js/sale/banner'], function (list, product) {
95 -  
96 product.init(4); 85 product.init(4);
97 window.onresize = function () { 86 window.onresize = function () {
98 setTimeout(function () { 87 setTimeout(function () {
99 product.init(4); 88 product.init(4);
100 }, 300); 89 }, 300);
101 }; 90 };
102 -  
103 }); 91 });
104 </script> 92 </script>
105 {{/if}} 93 {{/if}}
106 -  
107 {{!-- sale 分类列表 --}} 94 {{!-- sale 分类列表 --}}
108 {{#if saleCatPage}} 95 {{#if saleCatPage}}
109 <script> 96 <script>
110 seajs.use(['js/product/list', 'js/product/product', 'js/sale/banner'], function (list, product) { 97 seajs.use(['js/product/list', 'js/product/product', 'js/sale/banner'], function (list, product) {
111 -  
112 product.init(4); 98 product.init(4);
113 window.onresize = function () { 99 window.onresize = function () {
114 setTimeout(function () { 100 setTimeout(function () {
115 product.init(4); 101 product.init(4);
116 }, 300); 102 }, 300);
117 }; 103 };
118 -  
119 }); 104 });
120 </script> 105 </script>
121 {{/if}} 106 {{/if}}
122 -  
123 {{!-- 登录注册找回密码--}} 107 {{!-- 登录注册找回密码--}}
124 {{#if loginPage}} 108 {{#if loginPage}}
125 - <script> 109 +<script>
126 seajs.use('js/passport/login'); 110 seajs.use('js/passport/login');
127 - </script> 111 +</script>
128 {{/if}} 112 {{/if}}
129 {{!-- 第三方绑定--}} 113 {{!-- 第三方绑定--}}
130 {{#if thirdLogin}} 114 {{#if thirdLogin}}
131 - <script> 115 +<script>
132 seajs.use('js/passport/thirdlogin'); 116 seajs.use('js/passport/thirdlogin');
133 - </script> 117 +</script>
134 {{/if}} 118 {{/if}}
135 -  
136 {{!-- 注册页--}} 119 {{!-- 注册页--}}
137 {{#if registerPage}} 120 {{#if registerPage}}
138 - <script> 121 +<script>
139 seajs.use('js/passport/reg', function (reg) { 122 seajs.use('js/passport/reg', function (reg) {
140 reg.init('reg'); 123 reg.init('reg');
141 }); 124 });
142 - </script> 125 +</script>
143 {{/if}} 126 {{/if}}
144 -  
145 {{!-- 第三方登录完善信息页--}} 127 {{!-- 第三方登录完善信息页--}}
146 {{#if thirdPage}} 128 {{#if thirdPage}}
147 <script> 129 <script>
@@ -150,43 +132,39 @@ @@ -150,43 +132,39 @@
150 }); 132 });
151 </script> 133 </script>
152 {{/if}} 134 {{/if}}
153 -  
154 {{!-- 找回密码--}} 135 {{!-- 找回密码--}}
155 {{#if backPage}} 136 {{#if backPage}}
156 - <script> 137 +<script>
157 seajs.use('js/passport/back'); 138 seajs.use('js/passport/back');
158 - </script> 139 +</script>
159 {{/if}} 140 {{/if}}
160 -  
161 {{!-- 重置密码--}} 141 {{!-- 重置密码--}}
162 {{#if resetPage}} 142 {{#if resetPage}}
163 - <script> 143 +<script>
164 seajs.use('js/passport/reset'); 144 seajs.use('js/passport/reset');
165 - </script> 145 +</script>
166 {{/if}} 146 {{/if}}
167 -  
168 {{!-- 验证手机 --}} 147 {{!-- 验证手机 --}}
169 {{#if vertificationPage}} 148 {{#if vertificationPage}}
170 - <script> 149 +<script>
171 seajs.use('js/passport/vertification'); 150 seajs.use('js/passport/vertification');
172 - </script> 151 +</script>
173 {{/if}} 152 {{/if}}
174 -  
175 {{!-- 热销排行--}} 153 {{!-- 热销排行--}}
176 {{#if hotrankPage}} 154 {{#if hotrankPage}}
177 - <script> 155 +<script>
178 seajs.use('js/product/hotrank'); 156 seajs.use('js/product/hotrank');
179 - </script> 157 +</script>
180 {{/if}} 158 {{/if}}
181 {{!-- 品牌页 --}} 159 {{!-- 品牌页 --}}
182 {{#if brandsHomePage}} 160 {{#if brandsHomePage}}
183 - <script> 161 +<script>
184 seajs.use('js/brand/index'); 162 seajs.use('js/brand/index');
185 - </script> 163 +</script>
186 {{/if}} 164 {{/if}}
187 {{!-- 订单保存--}} 165 {{!-- 订单保存--}}
188 {{#if orderSavePage}} 166 {{#if orderSavePage}}
189 - <script> 167 +<script>
190 seajs.use('js/order/save'); 168 seajs.use('js/order/save');
191 - </script> 169 +</script>
192 {{/if}} 170 {{/if}}
1 <?php 1 <?php
  2 +
2 use Action\WebAction; 3 use Action\WebAction;
3 use Index\HomeModel; 4 use Index\HomeModel;
4 use Configs\WebCacheConfig; 5 use Configs\WebCacheConfig;
@@ -31,8 +32,8 @@ class CommonController extends WebAction @@ -31,8 +32,8 @@ class CommonController extends WebAction
31 $key = WebCacheConfig::KEY_WEB_INDEX_BRANDS_LIST_DATA . '_' . $type; 32 $key = WebCacheConfig::KEY_WEB_INDEX_BRANDS_LIST_DATA . '_' . $type;
32 // array('logoBrand'=>'','moreBrand'=>'') 33 // array('logoBrand'=>'','moreBrand'=>'')
33 $data = Cache::get($key); 34 $data = Cache::get($key);
34 - }  
35 - while (false); 35 +
  36 + } while (false);
36 37
37 $this->echoJson($data); 38 $this->echoJson($data);
38 } 39 }
@@ -49,7 +50,7 @@ class CommonController extends WebAction @@ -49,7 +50,7 @@ class CommonController extends WebAction
49 $result = array(); 50 $result = array();
50 do { 51 do {
51 /* 判断是不是AJAX请求 */ 52 /* 判断是不是AJAX请求 */
52 - if (! $this->isAjax()) { 53 + if (!$this->isAjax()) {
53 break; 54 break;
54 } 55 }
55 $channels = array( 56 $channels = array(
@@ -61,7 +62,7 @@ class CommonController extends WebAction @@ -61,7 +62,7 @@ class CommonController extends WebAction
61 $channel = $this->post('type', ''); 62 $channel = $this->post('type', '');
62 $pageIndex = (int) $this->post('pageIndex', 0); 63 $pageIndex = (int) $this->post('pageIndex', 0);
63 $pageCount = (int) $this->post('pageCount', 8); 64 $pageCount = (int) $this->post('pageCount', 8);
64 - if (! in_array($channel, $channels)) { 65 + if (!in_array($channel, $channels)) {
65 break; 66 break;
66 } 67 }
67 68
@@ -98,43 +99,34 @@ class CommonController extends WebAction @@ -98,43 +99,34 @@ class CommonController extends WebAction
98 */ 99 */
99 public function getbannerAction() 100 public function getbannerAction()
100 { 101 {
101 - $url = 'http://service.api.yohobuy.com/operations/api/v4/resource/get?';  
102 - $content_code = $this->get('content_code', '');  
103 - $client_type = $this->get('client_type', 'web'); 102 + $contentCode = $this->get('content_code', '');
104 $callback = $this->get('callback', ''); 103 $callback = $this->get('callback', '');
105 $width = $this->get('width', ''); 104 $width = $this->get('width', '');
106 $height = $this->get('height', ''); 105 $height = $this->get('height', '');
107 - $params = array(  
108 - 'content_code' => $content_code,  
109 - 'client_type' => $client_type  
110 - );  
111 - $data = IndexData::getResourceData($content_code);//Yohobuy::get($url.http_build_query($params));  
112 - if(empty($data['data']))  
113 - { 106 +
  107 + $data = IndexData::getResourceData($contentCode);
  108 + if (empty($data['data'])) {
114 return $this->helpJsonCallbackResult($callback, 200, '没有数据', ''); 109 return $this->helpJsonCallbackResult($callback, 200, '没有数据', '');
115 - }  
116 - else  
117 - { 110 + } else {
118 $banner = ''; 111 $banner = '';
119 - if(isset($data['data'][0]['data']))  
120 - {  
121 - if($data['data'][0]['template_name'] == 'single_image') { 112 + if (isset($data['data'][0]['data'])) {
  113 + if ($data['data'][0]['template_name'] == 'single_image') {
122 $banner = current($data['data'][0]['data']); 114 $banner = current($data['data'][0]['data']);
123 - } else if($data['data'][0]['template_name'] == 'single_name_image') { 115 + } else if ($data['data'][0]['template_name'] == 'single_name_image') {
124 $banner = $data['data'][0]['data']; 116 $banner = $data['data'][0]['data'];
125 } 117 }
126 - if(!empty($banner)) {  
127 - if(empty($width) || empty($height) ) {  
128 - $width = 2600;//通栏广告 118 + if (!empty($banner)) {
  119 + if (empty($width) || empty($height)) {
  120 + $width = 2600; //通栏广告
129 $height = 60; 121 $height = 60;
130 } 122 }
131 - $banner['src'] = Images::getImageUrl($banner['src'], $width, $height ,2); 123 + $banner['src'] = Images::getImageUrl($banner['src'], $width, $height, 2);
132 //str_replace('?imageView/{mode}/w/{width}/h/{height}', '', $banner['src']); 124 //str_replace('?imageView/{mode}/w/{width}/h/{height}', '', $banner['src']);
133 } 125 }
134 } 126 }
135 - }  
136 return $this->helpJsonCallbackResult($callback, $data['code'], $data['message'], $banner); 127 return $this->helpJsonCallbackResult($callback, $data['code'], $data['message'], $banner);
137 } 128 }
  129 + }
138 130
139 /** 131 /**
140 * 获取邮件订阅 132 * 获取邮件订阅
@@ -148,7 +140,7 @@ class CommonController extends WebAction @@ -148,7 +140,7 @@ class CommonController extends WebAction
148 $uid = intval($this->get('uid', '0')); 140 $uid = intval($this->get('uid', '0'));
149 $data = array(); 141 $data = array();
150 //验证邮件 142 //验证邮件
151 - if(Helpers::verifyEmail($email)) { 143 + if (Helpers::verifyEmail($email)) {
152 $data = IndexData::emailSubscriber($email, $uid); 144 $data = IndexData::emailSubscriber($email, $uid);
153 return $this->helpJsonCallbackResult($callback, $data['code'], $data['message'], $data['data']); 145 return $this->helpJsonCallbackResult($callback, $data['code'], $data['message'], $data['data']);
154 } else { 146 } else {
@@ -168,7 +160,7 @@ class CommonController extends WebAction @@ -168,7 +160,7 @@ class CommonController extends WebAction
168 $question_id = intval($this->get('question_id', 0)); 160 $question_id = intval($this->get('question_id', 0));
169 $answer = trim($this->get('answer')); 161 $answer = trim($this->get('answer'));
170 $solution = intval($this->get('solution', 0)); 162 $solution = intval($this->get('solution', 0));
171 - if(!empty($feedback_id) || !empty($question_id) || !empty($answer) || !empty($solution)) { 163 + if (!empty($feedback_id) || !empty($question_id) || !empty($answer) || !empty($solution)) {
172 $data = IndexData::suggestFeedback($feedback_id, $question_id, $answer, $solution); 164 $data = IndexData::suggestFeedback($feedback_id, $question_id, $answer, $solution);
173 return $this->helpJsonCallbackResult($callback, $data['code'], $data['message'], $data['data']); 165 return $this->helpJsonCallbackResult($callback, $data['code'], $data['message'], $data['data']);
174 } else { 166 } else {
@@ -179,7 +171,6 @@ class CommonController extends WebAction @@ -179,7 +171,6 @@ class CommonController extends WebAction
179 /* 171 /*
180 * 简单头部 172 * 简单头部
181 */ 173 */
182 -  
183 public function getSimpleHeaderAction() 174 public function getSimpleHeaderAction()
184 { 175 {
185 $result = array(); 176 $result = array();
@@ -190,12 +181,11 @@ class CommonController extends WebAction @@ -190,12 +181,11 @@ class CommonController extends WebAction
190 } 181 }
191 182
192 //获取用户 183 //获取用户
193 - $uid = $this->getUid(true); 184 + $uid = $this->getUid(false);
194 if (!$uid) { 185 if (!$uid) {
195 $isLogin = false; 186 $isLogin = false;
196 $username = ''; 187 $username = '';
197 - }  
198 - else { 188 + } else {
199 $isLogin = true; 189 $isLogin = true;
200 $username = $this->_uname; 190 $username = $this->_uname;
201 } 191 }
@@ -212,8 +202,7 @@ class CommonController extends WebAction @@ -212,8 +202,7 @@ class CommonController extends WebAction
212 'userCenter' => Helpers::url('/home?t=' . time()), //用户中心链接 202 'userCenter' => Helpers::url('/home?t=' . time()), //用户中心链接
213 'logout' => Helpers::url('/logout.html?t=' . time()), //退出 203 'logout' => Helpers::url('/logout.html?t=' . time()), //退出
214 ); 204 );
215 - }  
216 - else { 205 + } else {
217 $tool+=array( 206 $tool+=array(
218 'login' => Helpers::url('/signin.html'), //登录链接,已登录不传 207 'login' => Helpers::url('/signin.html'), //登录链接,已登录不传
219 'register' => Helpers::url('/reg.html'), //注册链接,已登录不传 208 'register' => Helpers::url('/reg.html'), //注册链接,已登录不传
@@ -233,8 +222,7 @@ class CommonController extends WebAction @@ -233,8 +222,7 @@ class CommonController extends WebAction
233 'code' => 200, 222 'code' => 200,
234 'data' => $simpleHeader 223 'data' => $simpleHeader
235 ); 224 );
236 - }  
237 - while (false); 225 + } while (false);
238 226
239 $this->echoJson($result); 227 $this->echoJson($result);
240 } 228 }