Authored by Rock Zhang

修改newsale数据处理逻辑

@@ -63,10 +63,10 @@ @@ -63,10 +63,10 @@
63 <div id="retrive-pwd-mask" class="mask"></div> 63 <div id="retrive-pwd-mask" class="mask"></div>
64 <ul id="retrive-pwd-ways" class="retrive-pwd-ways"> 64 <ul id="retrive-pwd-ways" class="retrive-pwd-ways">
65 <li> 65 <li>
66 - <a href=/phoneback.html>通过手机找回密码</a> 66 + <a href=/passport/back/mobile>通过手机找回密码</a>
67 </li> 67 </li>
68 <li> 68 <li>
69 - <a href=/emailback.html>通过邮箱找回密码</a> 69 + <a href=/passport/back/email>通过邮箱找回密码</a>
70 </li> 70 </li>
71 <li id="cancel-retrive"> 71 <li id="cancel-retrive">
72 取消 72 取消
@@ -62,7 +62,8 @@ class BackData @@ -62,7 +62,8 @@ class BackData
62 $param['re-input'] = $pwd; 62 $param['re-input'] = $pwd;
63 $param['code'] = $code; 63 $param['code'] = $code;
64 64
65 - return Yohobuy::post(Yohobuy::YOHOBUY_URL.'passport/back/update', $param); 65 + // 默认返回的不是json类型数据,是html
  66 + return Yohobuy::post(Yohobuy::YOHOBUY_URL.'passport/back/update', $param, true);
66 } 67 }
67 68
68 69
@@ -18,26 +18,59 @@ class NewSaleProcess @@ -18,26 +18,59 @@ class NewSaleProcess
18 public static function newSaleData($focus, $products) 18 public static function newSaleData($focus, $products)
19 { 19 {
20 $result = array( 20 $result = array(
21 - 'headerBanner' => self::bannerData($focus) 21 + 'headerBanner' => self::bannerData($focus),
  22 + 'goodsContainer' => array()
22 ); 23 );
23 24
24 - $list = array('list'=>array());  
25 foreach($products as $single) 25 foreach($products as $single)
26 { 26 {
  27 + // 处理Tabs
27 $noTab = true; 28 $noTab = true;
28 if(isset($single['tabs']) && $noTab) 29 if(isset($single['tabs']) && $noTab)
29 { 30 {
30 - $list['tabs'] = array();  
31 - foreach ($single['tabs'] as $one) 31 + $result['tabs'] = array();
  32 + foreach ($single['tabs'] as $key => $one)
32 { 33 {
33 - $list['tabs'][] = $one; 34 + $tabItem = array();
  35 + $tabItem['title'] = $one;
  36 + if($key === 1)
  37 + {
  38 + $tabItem['focus'] = true;
  39 + }
  40 + $result['tabs'][] = $tabItem;
34 } 41 }
35 $noTab = false; 42 $noTab = false;
36 } 43 }
37 44
38 - $list['list'][] = $single['product_list']; 45 + // 处理商品
  46 + $productsLi = array('goods'=>array());
  47 + if(isset($single['product_list']))
  48 + {
  49 + foreach ($single['product_list'] as $value)
  50 + {
  51 + $oneProduct = array();
  52 + $oneProduct['id'] = $value['product_skn'];
  53 + $oneProduct['thumb'] = Helpers::getImageUrl($value['default_images'], 290, 388, 1);
  54 + $oneProduct['name'] = $value['product_name'];
  55 + $oneProduct['price'] = $value['market_price'];
  56 + $oneProduct['salePrice'] = $value['sales_price'];
  57 + $oneProduct['isSale'] = ($value['is_discount'] === 'N' ? false : true);
  58 + $oneProduct['isFew'] = ($value['is_soon_sold_out'] === 'N' ? false : true);
  59 + $oneProduct['isNew'] = ($value['is_new'] === 'N' ? false : true);
  60 + $oneProduct['url'] = $value['product_skn'];
  61 +
  62 + $productsLi['goods'][] = $oneProduct;
  63 + }
  64 + }
  65 +
  66 + // 对于第一个productsLi添加show字段
  67 + if(count($result['goodsContainer']) === 0)
  68 + {
  69 + $productsLi['show'] = true;
  70 + }
  71 +
  72 + $result['goodsContainer'][] = $productsLi;
39 } 73 }
40 - $result['listNav'] = $list;  
41 74
42 return $result; 75 return $result;
43 } 76 }
@@ -50,7 +50,7 @@ $btnNext.on('touchstart', function() { @@ -50,7 +50,7 @@ $btnNext.on('touchstart', function() {
50 }, 50 },
51 success: function(data) { 51 success: function(data) {
52 if (data.code === 200) { 52 if (data.code === 200) {
53 - location.href = '/passport/back/code'; 53 + location.href = data.data;
54 } else { 54 } else {
55 showErrTip(data.message); 55 showErrTip(data.message);
56 } 56 }
@@ -62,8 +62,8 @@ class BackController extends AbstractAction @@ -62,8 +62,8 @@ class BackController extends AbstractAction
62 { 62 {
63 $email = $this->get('email', ''); 63 $email = $this->get('email', '');
64 // 获取到邮箱域名 64 // 获取到邮箱域名
65 - $pattern = "/^([0-9A-Za-z\\-_\\.]+)@([0-9a-z]+\\.[a-z]{2,3}(\\.[a-z]{2})?)$/i";  
66 - $domain_name = 'http://mail.'.preg_replace( $pattern ,"$2", $email ); 65 + list($name, $domain) = explode('@', $email);
  66 + $domain_name = 'http://' . (($domain == 'gmail.com') ? 'mail.google.com' : 'mail.' . $domain);
67 67
68 $data = array( 68 $data = array(
69 'backUrl' => '/passport/back/email', 69 'backUrl' => '/passport/back/email',
@@ -92,7 +92,14 @@ class BackController extends AbstractAction @@ -92,7 +92,14 @@ class BackController extends AbstractAction
92 92
93 $data = BackData::modifyPasswordByEmail($pwd, $code); 93 $data = BackData::modifyPasswordByEmail($pwd, $code);
94 94
95 - $this->echoJson($data);// 前端不需要判断结果 95 + $result = array('code'=>200);
  96 + if(strpos($data, 'history.back') !== false)
  97 + {
  98 + $result['code'] = 400;
  99 + $result['message'] = '修改失败';
  100 + }
  101 +
  102 + $this->echoJson($result);// 前端不需要判断结果
96 } 103 }
97 } 104 }
98 105
@@ -131,7 +138,7 @@ class BackController extends AbstractAction @@ -131,7 +138,7 @@ class BackController extends AbstractAction
131 'isPassportPage' => true, 138 'isPassportPage' => true,
132 'backMobile' => true, 139 'backMobile' => true,
133 'countrys' => $areas, 140 'countrys' => $areas,
134 - 'countryCode' => '+86' 141 + 'areaCode' => '+86'
135 ); 142 );
136 143
137 $this->_view->assign('title', 'YOHO!有货'); 144 $this->_view->assign('title', 'YOHO!有货');
@@ -29,8 +29,8 @@ class LoginController extends AbstractAction @@ -29,8 +29,8 @@ class LoginController extends AbstractAction
29 'weiboLoginUrl' => '/passport/login/sina', // 注册的URL链接 29 'weiboLoginUrl' => '/passport/login/sina', // 注册的URL链接
30 'qqLoginUrl' => '/passport/login/qq', // 注册的URL链接 30 'qqLoginUrl' => '/passport/login/qq', // 注册的URL链接
31 'interationalUrl' => '/login.html', // 国际号登录的URL链接 31 'interationalUrl' => '/login.html', // 国际号登录的URL链接
32 - 'phoneRetriveUrl' => '/phoneback.html', // 通过手机号找回密码的URL链接  
33 - 'emailRetriveUrl' => '/emailback.html', // 通过邮箱找回密码的URL链接 32 + 'phoneRetriveUrl' => '/passport/back/mobile', // 通过手机号找回密码的URL链接
  33 + 'emailRetriveUrl' => '/passport/back/email', // 通过邮箱找回密码的URL链接
34 ); 34 );
35 35
36 // 生成HTML(signin.html) 36 // 生成HTML(signin.html)
@@ -2,7 +2,7 @@ @@ -2,7 +2,7 @@
2 2
3 use Action\AbstractAction; 3 use Action\AbstractAction;
4 use LibModels\wap\Product\NewsaleData as Newsale; 4 use LibModels\wap\Product\NewsaleData as Newsale;
5 -use Plugin\Helpers; 5 +use Plugin\DataProcess\NewSaleProcess;
6 /** 6 /**
7 * 新品到着 7 * 新品到着
8 */ 8 */
@@ -10,7 +10,13 @@ class NewsaleController extends AbstractAction @@ -10,7 +10,13 @@ class NewsaleController extends AbstractAction
10 { 10 {
11 public function indexAction() 11 public function indexAction()
12 { 12 {
13 - /*$this->_view->assign('title', '新品到着'); 13 +
  14 + $data = array(
  15 + 'newArrival' => true,
  16 + 'header' => array(
  17 + 'title' => '新品到着'
  18 + )
  19 + );
14 20
15 // 新品到着顶部焦点图 21 // 新品到着顶部焦点图
16 $focusData = Newsale::getNewsaleFocus('a7989369aa86681c678bc40f171b8f1d'); 22 $focusData = Newsale::getNewsaleFocus('a7989369aa86681c678bc40f171b8f1d');
@@ -18,22 +24,18 @@ class NewsaleController extends AbstractAction @@ -18,22 +24,18 @@ class NewsaleController extends AbstractAction
18 $focus = array(); 24 $focus = array();
19 if($focusData['code'] == 200) 25 if($focusData['code'] == 200)
20 { 26 {
21 - foreach ($focusData['data'] as $single)  
22 - {  
23 - foreach ($single['data'] as $val) {  
24 - $val['src'] = Helpers::getImageUrl($val['src'], 375, 667, 1);  
25 - $focus[] = $val;  
26 - }  
27 - } 27 + $focus = $focusData['data'];
28 } 28 }
29 29
30 // 批量获取新品到着商品数据 30 // 批量获取新品到着商品数据
31 $products = Newsale::getNewProducts('1,3', 1, 60); 31 $products = Newsale::getNewProducts('1,3', 1, 60);
32 - var_dump($focus); 32 + // 添加商品数据
  33 + $data += NewSaleProcess::newSaleData($focus, $products);
33 34
34 - $this->_view->display('new', compact('focus', 'products'));*/ 35 + /*echo '<pre>';
  36 + print_r($data);exit;*/
35 37
36 - $data = array( 38 + /*$data = array(
37 'headerBanner' => array( 39 'headerBanner' => array(
38 'list' => array( 40 'list' => array(
39 array( 41 array(
@@ -220,7 +222,7 @@ class NewsaleController extends AbstractAction @@ -220,7 +222,7 @@ class NewsaleController extends AbstractAction
220 ) 222 )
221 223
222 ) 224 )
223 - ); 225 + );*/
224 226
225 $this->_view->assign('title', '新品到着'); 227 $this->_view->assign('title', '新品到着');
226 $this->_view->display('new', $data); 228 $this->_view->display('new', $data);
@@ -254,11 +256,13 @@ class NewsaleController extends AbstractAction @@ -254,11 +256,13 @@ class NewsaleController extends AbstractAction
254 } 256 }
255 } 257 }
256 258
257 - 259 + /**
  260 + * 折扣专区
  261 + */
258 public function discountAction() 262 public function discountAction()
259 { 263 {
260 264
261 - $data = array( 265 + /*$data = array(
262 'header' => array( 266 'header' => array(
263 'title' => 'SALE' 267 'title' => 'SALE'
264 ), 268 ),
@@ -315,9 +319,14 @@ class NewsaleController extends AbstractAction @@ -315,9 +319,14 @@ class NewsaleController extends AbstractAction
315 ) 319 )
316 ) 320 )
317 ) 321 )
318 - ); 322 + );*/
319 323
320 - /*$this->_view->assign('title', '折扣专区'); 324 + $data = array(
  325 + 'discount' => true,
  326 + 'header' => array(
  327 + 'title' => 'SALE'
  328 + )
  329 + );
321 330
322 // 折扣专区顶部焦点图 331 // 折扣专区顶部焦点图
323 $focusData = Newsale::getNewsaleFocus('e9c9be32d72e2906d404a72ee24cb523'); 332 $focusData = Newsale::getNewsaleFocus('e9c9be32d72e2906d404a72ee24cb523');
@@ -325,20 +334,28 @@ class NewsaleController extends AbstractAction @@ -325,20 +334,28 @@ class NewsaleController extends AbstractAction
325 $focus = array(); 334 $focus = array();
326 if($focusData['code'] == 200) 335 if($focusData['code'] == 200)
327 { 336 {
328 - foreach ($focusData['data'] as $single)  
329 - {  
330 - foreach ($single['data'] as $val) {  
331 - $val['src'] = Helpers::getImageUrl($val['src'], 375, 667, 1);  
332 - $focus[] = $val;  
333 - }  
334 - } 337 + $focus = $focusData['data'];
335 } 338 }
336 339
337 // 折扣专区商品数据 340 // 折扣专区商品数据
338 - $products = Newsale::getNewProducts('1,3', 1, 60);  
339 - var_dump($products); 341 + $products = Newsale::getSaleProducts('1,3', 1);
  342 + // 更新tabs
  343 + $tabs = array();
  344 + foreach (array_keys($products) as $key => $value) {
  345 + $tabItem = array();
  346 + $tabItem['title'] = $value;
  347 + if($key === 0)
  348 + {
  349 + $tabItem['focus'] = true;
  350 + }
  351 + $tabs[] = $tabItem;
  352 + }
  353 + $data += array('tabs' => $tabs);
  354 + // 添加商品数据
  355 + $data += NewSaleProcess::newSaleData($focus, $products);
340 356
341 - $this->_view->display('new', compact('focus', 'products'));*/ 357 + echo '<pre>';
  358 + print_r($data);exit;
342 359
343 $this->_view->assign('title', '折扣专区'); 360 $this->_view->assign('title', '折扣专区');
344 $this->_view->display('sale', $data); 361 $this->_view->display('sale', $data);