Authored by 周少峰

Merge branch 'develop' of git.dev.yoho.cn:web/yohobuy into feature/web-list

@@ -465,14 +465,14 @@ class WebAction extends Controller_Abstract @@ -465,14 +465,14 @@ class WebAction extends Controller_Abstract
465 */ 465 */
466 protected function setWebNavHeader($channel = '') 466 protected function setWebNavHeader($channel = '')
467 { 467 {
468 - if(empty($channel)) {  
469 - $channel = \Index\HomeModel::getSwitchChannel();  
470 - }  
471 - else {//设置频道  
472 - \Index\HomeModel::setSwitchToCookie($channel);  
473 - } 468 +// if(empty($channel)) {
  469 +// $channel = \Index\HomeModel::getSwitchChannel();
  470 +// }
  471 +// else {//设置频道
  472 +// \Index\HomeModel::setSwitchToCookie($channel);
  473 +// }
474 $header = array( 474 $header = array(
475 - 'navbars'=>\Index\HomeModel::getNavBars($channel), 475 + 'navbars'=> \Index\HomeModel::getNavBars($channel),
476 'gobytype'=> 'gobuy'.$channel, 476 'gobytype'=> 'gobuy'.$channel,
477 'searchcate'=>'searchcate'.$channel, 477 'searchcate'=>'searchcate'.$channel,
478 'myyoho' => array( 478 'myyoho' => array(
@@ -59,5 +59,9 @@ class CacheConfig @@ -59,5 +59,9 @@ class CacheConfig
59 const KEY_INDEX_BRANDS_LIST_DATA = 'key_index_brands_list_data';//频道brands数据 59 const KEY_INDEX_BRANDS_LIST_DATA = 'key_index_brands_list_data';//频道brands数据
60 60
61 const KEY_CODE_YOHOCOIN_BANNER = 'key_code_yohocoin_banner';// 有货币banner数据 61 const KEY_CODE_YOHOCOIN_BANNER = 'key_code_yohocoin_banner';// 有货币banner数据
  62 +
  63 + const KEY_WEB_HOME_NAVBAR_DATA = 'key_web_home_navbar_data';//web的导航数据
  64 + const KEY_WEB_HOME_CHANNEL_DATA = 'key_web_home_channel_data';//web首页频道数据[boys, girls, kids, lifestyle]
  65 + const KEY_WEB_HOME_CHANNEL_NEWARRIVAL_DATA = 'key_web_home_newarrival_data';//web频道最新上架数据[boys, girls, kids, lifestyle]
62 66
63 } 67 }
@@ -22,7 +22,7 @@ class IndexData @@ -22,7 +22,7 @@ class IndexData
22 $params = array('parent_id'=>'','platform'=>'web', 22 $params = array('parent_id'=>'','platform'=>'web',
23 'status'=> $status,'fields'=> $fields 23 'status'=> $status,'fields'=> $fields
24 ); 24 );
25 - return Yohobuy::yarClient(Yohobuy::SERVICE_URL . self::URL_OPERATIONS_CATEGORY,'getCategory', $params, false); 25 + return Yohobuy::yarClient(Yohobuy::SERVICE_URL . self::URL_OPERATIONS_CATEGORY,'getCategory', $params, true);
26 } 26 }
27 27
28 /** 28 /**
  1 +<?php
  2 +namespace LibModels\Web\Product;
  3 +
  4 +use Api\Yohobuy;
  5 +use Api\Sign;
  6 +
  7 +
  8 +/**
  9 + * 热销排行
  10 + *
  11 + * */
  12 +class HotrankData extends \LibModels\Wap\Product\SearchData
  13 +{
  14 + const URI_HOTRANK_RES = '/operations/service/v4/resource';
  15 + const URI_HOTRANK_TAG = '/operations/api/v5/resource/get';
  16 +
  17 +
  18 + /**
  19 + 获取热销排行
  20 + * 分类标签
  21 + */
  22 + public static function getHotranktag($client_type = 'web',$channel = 0, $is_concurrent = true, $callback = '')
  23 + {
  24 + // 构建必传参数
  25 + $params = Yohobuy::param();
  26 + $params['client_type'] = 'web';
  27 + $params['channel'] =$channel ;
  28 + $params['is_concurrent'] = true;
  29 + $params['callback'] = $callback;
  30 + $params['client_secret'] = Sign::getSign($params);
  31 + return Yohobuy::get(Yohobuy::SERVICE_URL . self::URI_HOTRANK_TAG, $params);
  32 + }
  33 +
  34 +}
@@ -263,7 +263,8 @@ class Process @@ -263,7 +263,8 @@ class Process
263 'mergeNewReportData', 263 'mergeNewReportData',
264 'mergeSinglehotData2', 264 'mergeSinglehotData2',
265 'mergeHotCategoryData', 265 'mergeHotCategoryData',
266 - 'mergeGirlkidsData' 266 + 'mergeGirlkidsData',
  267 + 'mergeHotBrandsData'
267 ); 268 );
268 foreach ($data as $key => $val) { 269 foreach ($data as $key => $val) {
269 foreach ($mergeProcessList as $merge) { 270 foreach ($mergeProcessList as $merge) {
@@ -807,7 +808,7 @@ class Process @@ -807,7 +808,7 @@ class Process
807 // 排序 808 // 排序
808 uksort($result, function ($a, $b) use($skns) { 809 uksort($result, function ($a, $b) use($skns) {
809 $skn_arr = explode(' ', $skns); 810 $skn_arr = explode(' ', $skns);
810 - return array_search($a, $skn_arr) > array_search($b, $skn_arr); 811 + return array_search($a, $skn_arr) > array_search($b, $skn_arr);
811 }); 812 });
812 $pos = 1; 813 $pos = 1;
813 //添加TOP标示 814 //添加TOP标示
@@ -819,8 +820,61 @@ class Process @@ -819,8 +820,61 @@ class Process
819 break; 820 break;
820 } 821 }
821 $pos ++; 822 $pos ++;
822 - }  
823 - return $result;  
824 - }  
825 - 823 + }
  824 + return $result;
  825 + }
  826 +
  827 + /**
  828 + * 热门品牌数据处理
  829 + *
  830 + * @param array $data
  831 + * @param string $type
  832 + */
  833 + public static function mergeHotBrandsData($key,array &$data,$type)
  834 + {
  835 + $result = array();
  836 + $temp = array();
  837 + if ($data[$key]['template_name'] == 'custom_brands')
  838 + {
  839 + // print_r($data[$key]);
  840 + $result = array(
  841 + 'hotBrands' => array(
  842 + 'name' => '',
  843 + 'brandUrl' => ''
  844 + )
  845 + );
  846 + // text模版
  847 + $result['hotBrands']['name'] = '热门品牌';
  848 + //floor模板
  849 + $floor = array(
  850 + 'logoBrand' => '',
  851 + 'moreBrand' => ''
  852 + );
  853 +
  854 + $brands = $data[$key]['data']['list'];
  855 + foreach ($brands as $val)
  856 + {
  857 + $width = 185;
  858 + $height = 86;
  859 + $type = 'lifestyle';
  860 + $val['src'] = Images::getImageUrl($val['src'], $width, $height, 2);
  861 + $val['url'] = Helpers::transUrl($val['url'], $type);
  862 + $floor['logoBrand'][] = array(
  863 + 'href' => $val['url'],
  864 + 'img' => $val['src']
  865 + );
  866 + }
  867 + $floor['moreBrand'] = 'http://yohobuy.com/brands';
  868 + //$floor['moreBrand'] = 'http://yohobuy.com/brands?gender=1,3&openby:yohobuy={"action":"go.list","params":{"actiontype":0,"gender":"1,3"}}';
  869 + //print_r($floor);
  870 + $type_key = sprintf("%s_%s", $type, $key);
  871 + $cacheKey = sprintf("%s_%s", CacheConfig::KEY_INDEX_BRANDS_LIST_DATA, $type_key);
  872 + //print_r($cacheKey);
  873 + Cache::set($cacheKey, $floor, 7200);
  874 + $result['hotBrands']['brandUrl'] = '/common/getIndexResourceBrand?type=' . $type_key;
  875 + //print_r($result['hotBrands']['brandUrl']);
  876 + }
  877 + return $result;
  878 + }
  879 +
826 } 880 }
@@ -240,9 +240,8 @@ class HelperSearch @@ -240,9 +240,8 @@ class HelperSearch
240 240
241 public static function groupSort($sort) 241 public static function groupSort($sort)
242 { 242 {
243 -  
244 $options = self::$options; 243 $options = self::$options;
245 - if (isset($options['controller']) && $options['controller'] != 'Search') { 244 + if (isset($options['controller']) && $options['controller'] == 'Search') {
246 return array(); 245 return array();
247 } 246 }
248 //设置导航 247 //设置导航
@@ -286,7 +285,6 @@ class HelperSearch @@ -286,7 +285,6 @@ class HelperSearch
286 } 285 }
287 } 286 }
288 $result['list'] = $sortList; 287 $result['list'] = $sortList;
289 -// print_r($result); exit;  
290 return $result; 288 return $result;
291 } 289 }
292 290
@@ -294,7 +292,7 @@ class HelperSearch @@ -294,7 +292,7 @@ class HelperSearch
294 { 292 {
295 $result = array(); 293 $result = array();
296 $options = self::$options; 294 $options = self::$options;
297 - if (!isset($options['controller']) || $options['controller'] != 'Search') { 295 + if (!isset($options['controller']) || $options['controller'] == 'Search') {
298 return $result; 296 return $result;
299 } 297 }
300 $params = self::$params; 298 $params = self::$params;
@@ -88,7 +88,6 @@ $invoice.on('touchend', '.checkbox', function() { @@ -88,7 +88,6 @@ $invoice.on('touchend', '.checkbox', function() {
88 if ($this.hasClass('icon-checkbox')) { 88 if ($this.hasClass('icon-checkbox')) {
89 $invoice.removeClass('focus'); 89 $invoice.removeClass('focus');
90 } 90 }
91 - return false;  
92 }); 91 });
93 92
94 function orderCompute() { 93 function orderCompute() {
@@ -243,10 +242,10 @@ $('.coin').on('touchend', function() { @@ -243,10 +242,10 @@ $('.coin').on('touchend', function() {
243 orderCompute(); 242 orderCompute();
244 }); 243 });
245 244
246 -$invoice.on('touchend', function(e) { 245 +$invoice.on('touchend', '.checkbox', function(e) {
247 var $this = $(this); 246 var $this = $(this);
248 247
249 - orderInfo('invoice', $this.find('.checkbox').hasClass('icon-cb-checked')); 248 + orderInfo('invoice', $this.hasClass('icon-cb-checked'));
250 e.preventDefault(); 249 e.preventDefault();
251 e.stopPropagation(); 250 e.stopPropagation();
252 }); 251 });
@@ -34,6 +34,20 @@ @@ -34,6 +34,20 @@
34 </div> 34 </div>
35 {{/if}} 35 {{/if}}
36 36
  37 + {{#if gender}}
  38 + <div class="channel section">
  39 + <span class="title">性别:</span>
  40 +
  41 + <div class="attr-content clearfix">
  42 + {{#each channel}}
  43 + <a class="attr {{#if checked}}checked{{/if}}" href="{{href}}">
  44 + {{name}}
  45 + </a>
  46 + {{/each}}
  47 + </div>
  48 + </div>
  49 + {{/if}}
  50 +
37 {{#if sort}} 51 {{#if sort}}
38 <div class="sort section"> 52 <div class="sort section">
39 <span class="title">分类:</span> 53 <span class="title">分类:</span>
@@ -135,7 +135,6 @@ exports.init = function(num) { @@ -135,7 +135,6 @@ exports.init = function(num) {
135 135
136 // 鼠标悬浮获取到商品信息后显示第一张图片 136 // 鼠标悬浮获取到商品信息后显示第一张图片
137 if (data[0] && data[0].src) { 137 if (data[0] && data[0].src) {
138 - $(event.target).find('.good-thumb img').attr('src', data[0].src);  
139 $goodInfoMain.find('.good-thumb img').attr('src', data[0].src); 138 $goodInfoMain.find('.good-thumb img').attr('src', data[0].src);
140 } 139 }
141 140
@@ -82,6 +82,7 @@ @@ -82,6 +82,7 @@
82 width: 14px; 82 width: 14px;
83 border: 1px solid #fff; 83 border: 1px solid #fff;
84 margin-bottom: -3px; 84 margin-bottom: -3px;
  85 + background-size: 100% !important;
85 } 86 }
86 87
87 .clear-checked { 88 .clear-checked {
@@ -283,6 +284,7 @@ @@ -283,6 +284,7 @@
283 border: 1px solid #ccc; 284 border: 1px solid #ccc;
284 margin-bottom: -6px; 285 margin-bottom: -6px;
285 margin-right: 5px; 286 margin-right: 5px;
  287 + background-size: 100% !important;
286 } 288 }
287 289
288 .senior { 290 .senior {
@@ -125,9 +125,20 @@ @@ -125,9 +125,20 @@
125 } 125 }
126 } 126 }
127 127
  128 + @keyframes slideRight {
  129 + from {
  130 + max-width: 0;
  131 + }
  132 + to {
  133 + max-width: 150px;
  134 + }
  135 + }
  136 +
128 .good-select-color { 137 .good-select-color {
129 float: left; 138 float: left;
130 margin-top: 22px; 139 margin-top: 22px;
  140 + overflow: hidden;
  141 + animation: slideRight 600ms 1;
131 142
132 ul { 143 ul {
133 display: block; 144 display: block;
@@ -175,4 +186,4 @@ @@ -175,4 +186,4 @@
175 } 186 }
176 187
177 188
178 -}  
  189 +}
@@ -167,15 +167,15 @@ class DetailModel @@ -167,15 +167,15 @@ class DetailModel
167 $colorGroup = array(); 167 $colorGroup = array();
168 $sizeGroup = array(); 168 $sizeGroup = array();
169 $goodsGroup = array(); 169 $goodsGroup = array();
  170 + $colorList = array();
170 $sizeList = array(); 171 $sizeList = array();
  172 + $allSizeList = array(); // 所有尺码列表
171 $thumbImageList = array(); 173 $thumbImageList = array();
172 $colorStorageGroup = array(); // 颜色分组的库存总数集合, 多个之间用/分隔 174 $colorStorageGroup = array(); // 颜色分组的库存总数集合, 多个之间用/分隔
173 - $sizeStorageStr = ''; // 尺码库存总数集合, 多个之间用/分隔  
174 $colorStorageNum = 0; 175 $colorStorageNum = 0;
175 $totalStorageNum = 0; // 总库存数 176 $totalStorageNum = 0; // 总库存数
176 foreach ($baseInfo['goodsList'] as $value) { 177 foreach ($baseInfo['goodsList'] as $value) {
177 $colorStorageNum = 0; 178 $colorStorageNum = 0;
178 - $sizeStorageStr = '';  
179 179
180 // 商品分组 180 // 商品分组
181 if (isset($value['goodsImagesList'])) { 181 if (isset($value['goodsImagesList'])) {
@@ -188,10 +188,10 @@ class DetailModel @@ -188,10 +188,10 @@ class DetailModel
188 } 188 }
189 189
190 // 商品的尺码列表 190 // 商品的尺码列表
191 - $colorStorageGroup[$value['productSkc']] = array(); 191 + $colorStorageGroup[ $value['productSkc'] ] = array();
192 if (isset($value['goodsSizeBoList'])) { 192 if (isset($value['goodsSizeBoList'])) {
193 foreach ($value['goodsSizeBoList'] as $size) { 193 foreach ($value['goodsSizeBoList'] as $size) {
194 - $sizeList[$value['productSkc']][] = array( 194 + $sizeList[ $value['productSkc'] ][] = array(
195 'id' => $size['id'], 195 'id' => $size['id'],
196 'skuId' => $size['goodsSizeSkuId'], 196 'skuId' => $size['goodsSizeSkuId'],
197 'goodsId' => $size['goodsId'], 197 'goodsId' => $size['goodsId'],
@@ -199,19 +199,21 @@ class DetailModel @@ -199,19 +199,21 @@ class DetailModel
199 'name' => $size['sizeName'], 199 'name' => $size['sizeName'],
200 'sizeNum' => $size['goodsSizeStorageNum'], 200 'sizeNum' => $size['goodsSizeStorageNum'],
201 ); 201 );
  202 +
  203 + // 所有尺码列表,赋值用于前端展示默认尺码的时候 判断出没有库存则显示灰色
  204 + $allSizeList[ $size['sizeName'] ] = empty($allSizeList[ $size['sizeName'] ]) ? $size['goodsSizeStorageNum'] : $allSizeList[ $size['sizeName'] ];
  205 +
202 $colorStorageNum += intval($size['goodsSizeStorageNum']); 206 $colorStorageNum += intval($size['goodsSizeStorageNum']);
203 - $sizeStorageStr .= $size['goodsSizeStorageNum'] . '/';  
204 $colorStorageGroup[$value['productSkc']][$size['sizeName']] = $size['goodsSizeStorageNum']; 207 $colorStorageGroup[$value['productSkc']][$size['sizeName']] = $size['goodsSizeStorageNum'];
205 } 208 }
206 209
207 // 颜色分组 210 // 颜色分组
208 - $colorGroup[] = array( 211 + $colorList[] = array(
209 'id' => $value['colorId'], 212 'id' => $value['colorId'],
210 'skcId' => $value['productSkc'], 213 'skcId' => $value['productSkc'],
211 'name' => $value['colorName'], 214 'name' => $value['colorName'],
212 'goodsName' => $value['goodsName'], 215 'goodsName' => $value['goodsName'],
213 'colorNum' => $colorStorageNum, 216 'colorNum' => $colorStorageNum,
214 - 'sizeNumStr' => rtrim($sizeStorageStr, '/'),  
215 ); 217 );
216 } 218 }
217 219
@@ -221,25 +223,30 @@ class DetailModel @@ -221,25 +223,30 @@ class DetailModel
221 // 商品库存总数 223 // 商品库存总数
222 $totalStorageNum += $colorStorageNum; 224 $totalStorageNum += $colorStorageNum;
223 } 225 }
  226 +
  227 + // 遍历所有尺码,构建颜色显示数据
  228 + $i = 1;
  229 + foreach ($allSizeList as $sizeName => $value) {
  230 + // 默认尺码
  231 + $sizeGroup[0]['size'][] = array(
  232 + 'name' => $sizeName, // 尺码名称
  233 + 'sizeNum' => empty($value) ? false : true, // 是否有库存 (false:表示没有库存,true:表示有库存)
  234 + );
224 235
225 - // 遍历所有尺码,统计出该尺码的每个颜色的库存量,没有时添0,不能空着,因为JS中需要判断  
226 - foreach ($sizeList as $skc => $sizeArr) {  
227 - foreach ($sizeArr as $key => $value) {  
228 - $sizeStorageStr = '';  
229 - foreach ($colorStorageGroup as $colorArr) {  
230 - if (isset($colorArr[$value['name']])) {  
231 - $sizeStorageStr .= $colorArr[$value['name']] . '/';  
232 - } else {  
233 - $sizeStorageStr .= '0/';  
234 - }  
235 - }  
236 - $sizeList[$skc][$key]['colorNumStr'] = rtrim($sizeStorageStr, '/'); 236 + // 各个颜色的尺码, 每行显示一个尺码对应的颜色
  237 + foreach ($colorList as $colorArr) {
  238 + $colorArr['colorNum'] = isset($colorStorageGroup[ $colorArr['skcId'] ][$sizeName]) ? $colorStorageGroup[ $colorArr['skcId'] ][$sizeName] : 0;
  239 + $colorGroup[$i]['color'][] = $colorArr;
237 } 240 }
  241 +
  242 + ++ $i;
238 } 243 }
239 -  
240 - // 格式化尺码对应的各个颜色分组  
241 - foreach ($colorGroup as $value) {  
242 - $sizeGroup[]['size'] = $sizeList[$value['skcId']]; 244 + // 遍历所有颜色, 构建尺码显示数据
  245 + foreach ($colorList as $value) {
  246 + // 各个尺码的颜色,每行显示一个颜色的对应尺码
  247 + $sizeGroup[]['size'] = $sizeList[ $value['skcId'] ];
  248 + // 默认颜色
  249 + $colorGroup[0]['color'][] = $value;
243 } 250 }
244 251
245 // 商品图: 多个 252 // 商品图: 多个
@@ -563,9 +570,8 @@ class DetailModel @@ -563,9 +570,8 @@ class DetailModel
563 if (is_numeric($productId) && is_numeric($pageNum) && is_numeric($pageSize)) { 570 if (is_numeric($productId) && is_numeric($pageNum) && is_numeric($pageSize)) {
564 $consultList = DetailData::consultList($uid, $productId, $pageNum, $pageSize); 571 $consultList = DetailData::consultList($uid, $productId, $pageNum, $pageSize);
565 if (isset($consultList['code']) && $consultList['code'] === 200) { 572 if (isset($consultList['code']) && $consultList['code'] === 200) {
566 - $consultList = $consultList['data']['list'];  
567 $build = array(); 573 $build = array();
568 - foreach ($consultList as $value) { 574 + foreach ($consultList['data']['list'] as $value) {
569 $build['question'] = $value['ask']; 575 $build['question'] = $value['ask'];
570 $build['time'] = $value['ask_time']; 576 $build['time'] = $value['ask_time'];
571 $build['answer'] = $value['answer']; 577 $build['answer'] = $value['answer'];
@@ -615,21 +621,20 @@ class DetailModel @@ -615,21 +621,20 @@ class DetailModel
615 $result = array('code' => 400, 'message' => '出错啦~'); 621 $result = array('code' => 400, 'message' => '出错啦~');
616 622
617 do { 623 do {
618 - $record = DetailData::upvoteConsult($uid, $id);  
619 -  
620 if (empty($uid)) { 624 if (empty($uid)) {
621 $result['code'] = 401; 625 $result['code'] = 401;
622 $result['message'] = '用户id为空'; 626 $result['message'] = '用户id为空';
623 $result['data'] = Helpers::url('/signin.html', array('refer' => Helpers::url('/product/detail/consults', array('product_id' => $productId, 'total' => $total)))); 627 $result['data'] = Helpers::url('/signin.html', array('refer' => Helpers::url('/product/detail/consults', array('product_id' => $productId, 'total' => $total))));
624 break; 628 break;
625 } 629 }
626 - 630 +
627 // 处理数据 631 // 处理数据
628 - if ($record && isset($record['code'])) { 632 + $record = DetailData::upvoteConsult($uid, $id);
  633 + if (!empty($record['code'])) {
629 $result['code'] = $record['code']; 634 $result['code'] = $record['code'];
630 $result['message'] = $record['message']; 635 $result['message'] = $record['message'];
631 } 636 }
632 - }while(false); 637 + } while (false);
633 638
634 return $result; 639 return $result;
635 } 640 }
@@ -648,21 +653,20 @@ class DetailModel @@ -648,21 +653,20 @@ class DetailModel
648 $result = array('code' => 400, 'message' => '出错啦~'); 653 $result = array('code' => 400, 'message' => '出错啦~');
649 654
650 do { 655 do {
651 - $record = DetailData::usefulConsult($uid, $id);  
652 -  
653 if (empty($uid)) { 656 if (empty($uid)) {
654 $result['code'] = 401; 657 $result['code'] = 401;
655 $result['message'] = '用户id为空'; 658 $result['message'] = '用户id为空';
656 $result['data'] = Helpers::url('/signin.html', array('refer' => Helpers::url('/product/detail/consults', array('product_id' => $productId, 'total' => $total)))); 659 $result['data'] = Helpers::url('/signin.html', array('refer' => Helpers::url('/product/detail/consults', array('product_id' => $productId, 'total' => $total))));
657 break; 660 break;
658 } 661 }
659 - 662 +
660 // 处理数据 663 // 处理数据
661 - if ($record && isset($record['code'])) { 664 + $record = DetailData::usefulConsult($uid, $id);
  665 + if (!empty($record['code'])) {
662 $result['code'] = $record['code']; 666 $result['code'] = $record['code'];
663 $result['message'] = $record['message']; 667 $result['message'] = $record['message'];
664 } 668 }
665 - }while(false); 669 + } while (false);
666 670
667 return $result; 671 return $result;
668 } 672 }
1 <?php 1 <?php
  2 +
  3 +use Action\WebAction;
  4 +
2 /** 5 /**
3 * 默认控制器 6 * 默认控制器
4 */ 7 */
5 -use Action\WebAction;  
6 -  
7 class IndexController extends WebAction 8 class IndexController extends WebAction
8 { 9 {
9 10
@@ -63,59 +63,64 @@ class HomeModel @@ -63,59 +63,64 @@ class HomeModel
63 return array(); 63 return array();
64 } 64 }
65 $menu = array(); 65 $menu = array();
66 - $item = array();  
67 - foreach ($data['data'] as $val) {  
68 - $item = array(  
69 - 'name_cn' => $val['sort_name'], // 父级  
70 - 'name_en' => $val['sort_name_en'],  
71 - 'link' => $val['sort_url'],  
72 - 'icon' => $val['sort_ico'],  
73 - 'classname' => str_replace(' ', '', strtolower($val['sort_name_en'])) == $channel ? $channel : '',  
74 - 'index_main' => 0,  
75 - 'is_hot' => $val['is_hot'] == 'Y' ? true : false,  
76 - 'is_new' => $val['is_new'] == 'Y' ? true : false,  
77 - // 'subnav' => array()  
78 - );  
79 - foreach ($val['sub'] as $sub) { // 二级  
80 - $index_sub = 0;  
81 - $subnav = array(  
82 - 'name' => $sub['sort_name'],  
83 - 'name_en' => $sub['sort_name_en'],  
84 - 'link' => $sub['sort_url'],  
85 - 'is_hot' => $sub['is_hot'] == 'Y' ? true : false,  
86 - 'is_new' => $sub['is_new'] == 'Y' ? true : false,  
87 - // 'thirdnav' => array(),  
88 - 'index_sub' => $index_sub ++  
89 - );  
90 - if (isset($sub['sub'])) {  
91 - foreach ($sub['sub'] as $thirdsub) { // 三级  
92 - $thirdnav = array(  
93 - 'title' => $thirdsub['sort_name'],  
94 - 'name_en' => $thirdsub['sort_name_en'],  
95 - 'link' => $thirdsub['sort_url'],  
96 - // 'branditems' => array()  
97 - );  
98 - if (isset($thirdsub['sub'])) {  
99 - foreach ($thirdsub['sub'] as $fourthnav) { // 四级  
100 - $thirdnav['branditems'][] = array(  
101 - 'brandname' => $fourthnav['sort_name'],  
102 - 'link' => $fourthnav['sort_url'],  
103 - 'hot' => $fourthnav['is_hot'] == 'Y' ? 'hot' : ''  
104 - );  
105 - }  
106 - }  
107 - $subnav['thirdnav'][] = $thirdnav;  
108 - }  
109 - }  
110 -  
111 - $item['subnav'][] = $subnav;  
112 - }  
113 - $menu[] = $item; 66 + $key = sprintf('%s_%s_%s',CacheConfig::KEY_WEB_HOME_NAVBAR_DATA, md5(serialize($data)), $channel);
  67 + $menu = Cache::get($key);
  68 + if(empty($menu)) {
  69 + $item = array();
  70 + foreach ($data['data'] as $val) {
  71 + $item = array(
  72 + 'name_cn' => $val['sort_name'], // 父级
  73 + 'name_en' => $val['sort_name_en'],
  74 + 'link' => $val['sort_url'],
  75 + 'icon' => $val['sort_ico'],
  76 + 'classname' => str_replace(' ', '', strtolower($val['sort_name_en'])) == $channel ? $channel : '',
  77 + 'index_main' => 0,
  78 + 'is_hot' => $val['is_hot'] == 'Y' ? true : false,
  79 + 'is_new' => $val['is_new'] == 'Y' ? true : false,
  80 + // 'subnav' => array()
  81 + );
  82 + foreach ($val['sub'] as $sub) { // 二级
  83 + $index_sub = 0;
  84 + $subnav = array(
  85 + 'name' => $sub['sort_name'],
  86 + 'name_en' => $sub['sort_name_en'],
  87 + 'link' => $sub['sort_url'],
  88 + 'is_hot' => $sub['is_hot'] == 'Y' ? true : false,
  89 + 'is_new' => $sub['is_new'] == 'Y' ? true : false,
  90 + // 'thirdnav' => array(),
  91 + 'index_sub' => $index_sub ++
  92 + );
  93 + if (isset($sub['sub'])) {
  94 + foreach ($sub['sub'] as $thirdsub) { // 三级
  95 + $thirdnav = array(
  96 + 'title' => $thirdsub['sort_name'],
  97 + 'name_en' => $thirdsub['sort_name_en'],
  98 + 'link' => $thirdsub['sort_url'],
  99 + // 'branditems' => array()
  100 + );
  101 + if (isset($thirdsub['sub'])) {
  102 + foreach ($thirdsub['sub'] as $fourthnav) { // 四级
  103 + $thirdnav['branditems'][] = array(
  104 + 'brandname' => $fourthnav['sort_name'],
  105 + 'link' => $fourthnav['sort_url'],
  106 + 'hot' => $fourthnav['is_hot'] == 'Y' ? 'hot' : ''
  107 + );
  108 + }
  109 + }
  110 + $subnav['thirdnav'][] = $thirdnav;
  111 + }
  112 + }
  113 +
  114 + $item['subnav'][] = $subnav;
  115 + }
  116 + $menu[] = $item;
  117 + }
  118 + Cache::set($key, $menu, 3600);
114 } 119 }
115 return $menu; 120 return $menu;
116 } 121 }
117 122
118 - /** 123 + /**
119 * 选择频道 124 * 选择频道
120 * 125 *
121 * @return void 126 * @return void
@@ -165,9 +170,14 @@ class HomeModel @@ -165,9 +170,14 @@ class HomeModel
165 */ 170 */
166 public static function getChannelResource($channel, $content_code) 171 public static function getChannelResource($channel, $content_code)
167 { 172 {
168 - $resource = IndexData::getResourceData($content_code);  
169 - // 格式化数据  
170 - $data = ChannelProcess::getFormat($channel, $resource['data']); 173 + $key = sprintf(CacheConfig::KEY_WEB_HOME_CHANNEL_DATA.'_'.$channel);
  174 + $data = Cache::get($key);
  175 + if(empty($data)) {
  176 + $resource = IndexData::getResourceData($content_code);
  177 + // 格式化数据
  178 + $data = ChannelProcess::getFormat($channel, $resource['data']);
  179 + Cache::set($key, $data, 3600);
  180 + }
171 return $data; 181 return $data;
172 } 182 }
173 183
@@ -213,45 +223,51 @@ class HomeModel @@ -213,45 +223,51 @@ class HomeModel
213 public static function getNewArrival($channel) 223 public static function getNewArrival($channel)
214 { 224 {
215 $result = array(); 225 $result = array();
216 - $params = array(  
217 - 'order' => 's_t_desc',  
218 - 'shelve_time' => strtotime("-60 days") . ',' . time()  
219 - );  
220 - //男首频道最新上架参数是gender=1,3  
221 - if($channel == self::COOKIE_NAME_BOYS) {  
222 - $params['gender'] = '1,3';  
223 - }  
224 - //女首频道最新上架参数是gender=2,3  
225 - else if($channel == self::COOKIE_NAME_GIRLS) {  
226 - $params['gender'] = '2,3';  
227 - }  
228 - // 最新上架分类  
229 - if (isset(ChannelConfig::$newArrivalSortList[$channel])) {  
230 - $sortList = ChannelConfig::$newArrivalSortList[$channel];  
231 - // 获取分类列表获取商品信息  
232 - $goodsList = SearchData::getSearchDataBySort($params, $sortList);  
233 - $pos = 1;  
234 - foreach ($goodsList as $goods) {  
235 - // 格式化数据  
236 - $val = Helpers::formatProduct($goods, true, true, true, 280, 373);  
237 - if ($val['price'] == false) {  
238 - $val['price'] = $val['salePrice'];  
239 - }  
240 - $val['url'] = sprintf('%s?channel=%s&from=%s-n_%s', $val['url'], $channel , $channel, $pos++);  
241 - //TODO 字段要调整  
242 - $val['isFew'] = $val['is_soon_sold_out'];  
243 - $val['tags']['isLimit'] = $val['tags']['is_limited'];  
244 - $val['tags']['isSale'] = false;//$val['tags']['is_discount'];暂时不显示  
245 - $val['tags']['isNew'] = false;//$val['tags']['is_new'];暂时不显示  
246 - $val['tags']['isYearMidPromotion'] = $val['tags']['midYear'];  
247 - $val['tags']['isYearEndPromotion'] = $val['tags']['yearEnd'];  
248 - $val['tags']['isReNew'] = false;//$val['tags']['is_advance'];暂时不显示  
249 - unset($val['tags']['is_advance'], $val['tags']['is_discount'], $val['tags']['is_limited'], $val['tags']['is_new'],  
250 - $val['tags']['is_yohood'], $val['tags']['midYear'], $val['tags']['yearEnd']);  
251 - if (! empty($val)) {  
252 - $result[] = $val;  
253 - }  
254 - } 226 + $key = sprintf(CacheConfig::KEY_WEB_HOME_CHANNEL_NEWARRIVAL_DATA.'_'.$channel);
  227 + //缓存数据
  228 + $result = Cache::get($key);
  229 + if(empty($result)) {
  230 + $params = array(
  231 + 'order' => 's_t_desc',
  232 + 'shelve_time' => strtotime("-60 days") . ',' . time()
  233 + );
  234 + //男首频道最新上架参数是gender=1,3
  235 + if($channel == self::COOKIE_NAME_BOYS) {
  236 + $params['gender'] = '1,3';
  237 + }
  238 + //女首频道最新上架参数是gender=2,3
  239 + else if($channel == self::COOKIE_NAME_GIRLS) {
  240 + $params['gender'] = '2,3';
  241 + }
  242 + // 最新上架分类
  243 + if (isset(ChannelConfig::$newArrivalSortList[$channel])) {
  244 + $sortList = ChannelConfig::$newArrivalSortList[$channel];
  245 + // 获取分类列表获取商品信息
  246 + $goodsList = SearchData::getSearchDataBySort($params, $sortList);
  247 + $pos = 1;
  248 + foreach ($goodsList as $goods) {
  249 + // 格式化数据
  250 + $val = Helpers::formatProduct($goods, true, true, true, 280, 373);
  251 + if ($val['price'] == false) {
  252 + $val['price'] = $val['salePrice'];
  253 + }
  254 + $val['url'] = sprintf('%s?channel=%s&from=%s-n_%s', $val['url'], $channel , $channel, $pos++);
  255 + //TODO 字段要调整
  256 + $val['isFew'] = $val['is_soon_sold_out'];
  257 + $val['tags']['isLimit'] = $val['tags']['is_limited'];
  258 + $val['tags']['isSale'] = false;//$val['tags']['is_discount'];暂时不显示
  259 + $val['tags']['isNew'] = false;//$val['tags']['is_new'];暂时不显示
  260 + $val['tags']['isYearMidPromotion'] = $val['tags']['midYear'];
  261 + $val['tags']['isYearEndPromotion'] = $val['tags']['yearEnd'];
  262 + $val['tags']['isReNew'] = false;//$val['tags']['is_advance'];暂时不显示
  263 + unset($val['tags']['is_advance'], $val['tags']['is_discount'], $val['tags']['is_limited'], $val['tags']['is_new'],
  264 + $val['tags']['is_yohood'], $val['tags']['midYear'], $val['tags']['yearEnd']);
  265 + if (! empty($val)) {
  266 + $result[] = $val;
  267 + }
  268 + }
  269 + }
  270 + Cache::set($key, $result, 3600);
255 } 271 }
256 return $result; 272 return $result;
257 } 273 }
  1 +<?php
  2 +namespace product;
  3 +
  4 +use Plugin\Images;
  5 +use Plugin\Helpers;
  6 +use Plugin\Cache;
  7 +use Configs\CacheConfig;
  8 +use LibModels\Web\Home\IndexData;
  9 +use \LibModels\Web\Product\HotrankData;
  10 +use \LibModels\Web\Product\SearchData;
  11 +
  12 +class HotrankModel {
  13 +
  14 + /**
  15 + * 人气单品 一周热卖
  16 + */
  17 + static public function getSearchData($condition, $options)
  18 + {
  19 + // 调用接口查询商品数据
  20 + $result = SearchData::searchElasticByCondition($condition);
  21 + //print_r($result);
  22 +
  23 + if(!empty($result)){
  24 + $res = self::getProductList($result);
  25 + if(!empty($res['popular'])){
  26 + $data['popular'] = $res['popular'];
  27 + }
  28 + if(!empty($res['hotWeek'])){
  29 + $data['hotWeek'] = $res['hotWeek'];
  30 + }
  31 + }
  32 + return $data;
  33 + }
  34 +
  35 +
  36 +
  37 + /**
  38 + * 获取分类标签
  39 + */
  40 + static public function getHotranktag($classes)
  41 + {
  42 + $list = SearchData::getClassesData($classes);
  43 + //print_r($list);
  44 + $nav = array();
  45 + if(!empty($list['data']['sort'])){
  46 + foreach($list['data']['sort'] as $li=>$lt){
  47 + $nav[$li]['sid'] = $lt['sort_id'];
  48 + $nav[$li]['textCn'] = $lt['sort_name'];
  49 + }
  50 + }
  51 + //print_r($nav);
  52 + return $nav;
  53 + }
  54 +
  55 +
  56 + /**
  57 + * 人气单品 一周热卖 数据处理
  58 + */
  59 + static public function getProductList($result)
  60 + {
  61 + /*----product start---------*/
  62 + if(empty($result) || empty($result['data']) || empty($result['data']['product_list'])){
  63 + return;
  64 + }
  65 + $data = $result['data']['product_list'];
  66 +
  67 + $popular = array();
  68 + $hotWeek = array();
  69 + foreach($data as $key=>$val){
  70 + if(empty($val['goods_list'])){
  71 + continue;
  72 + }
  73 + $defaultGoodsId = 0;
  74 + foreach ($val['goods_list'] as $v){
  75 + if($v['is_default'] == 'Y'){
  76 + $defaultGoodsId = $v['goods_id'];
  77 + }
  78 + }
  79 + if(empty($defaultGoodsId)){
  80 + $defaultGoodsId = $val['goods_list'][0]['goods_id'];
  81 + }
  82 +
  83 + $product_id = empty($val['product_id']) ? '' : $val['product_id'];
  84 + $re['url'] = 'http://item.yohobuy.com/product/pro_'.$product_id.'_'.$defaultGoodsId.'.html';
  85 +
  86 + $re['marketPrice'] = (int)$val['market_price'] == (int)$val['sales_price'] ? '' : '¥'.$val['market_price'];
  87 + $re['salePrice'] = empty($val['sales_price']) ? '' : '¥'.$val['sales_price'];
  88 + $re['name'] = $val['product_name'];
  89 + if($key <= 9){
  90 + $re['rank'] = $key + 1;
  91 + if($key <= 5){
  92 + $re['img'] = empty($val['default_images']) ? '' : Images::getImageUrl($val['default_images'], 378, 504, 2);
  93 + $popular['list'][] = $re;
  94 + }else{
  95 + $re['img'] = empty($val['default_images']) ? '' : Images::getImageUrl($val['default_images'], 280, 373, 2);
  96 + $popular['list'][] = $re;
  97 + }
  98 + }else{
  99 + $re['rank'] = '';
  100 + $re['thumb'] = empty($val['default_images']) ? '' : Images::getImageUrl($val['default_images'], 280, 373, 2);
  101 + $hot[] = $re;
  102 + }
  103 + }
  104 + $popular['name'] = '人气单品';
  105 +
  106 + $hotWeek = array(
  107 + 'name'=>'一周热卖',
  108 + 'list'=>$hot,
  109 + );
  110 +
  111 + return array('popular'=>$popular,'hotWeek'=>$hotWeek);
  112 + }
  113 +}
1 -<?php  
2 -use Action\WebAction;  
3 -use LibModels\Web\Passport\RegData;  
4 -use Passport\PassportModel;  
5 -use Plugin\Helpers;  
6 -use LibModels\Wap\Passport\BackData;  
7 -use Plugin\AuthCode;  
8 -class BackController extends WebAction {  
9 -  
10 - /**  
11 - * 找回密码  
12 - */  
13 - public function indexAction() {  
14 - $banner = PassportModel::getLeftBanner(PassportModel::BACK_LFFT_BANNER_CODE);  
15 - $data = array (  
16 - 'simpleHeader' => PassportModel::getSimpleHeader(false),  
17 - 'backPage' => true,  
18 - 'back' => array (  
19 - 'coverHref' => $banner ['url'],  
20 - 'coverImg' => $banner ['img'],  
21 - 'countryCode' => '86',  
22 - 'countryName' => '中国',  
23 - 'captchaUrl' => '/passport/images?t=1449799445',  
24 - 'countryList' => RegData::getAreasData()  
25 - )  
26 - );  
27 - $this->_view->display ( 'index', $data );  
28 - }  
29 -  
30 - /**  
31 - * 校验验证码  
32 - */  
33 - public function authcodeAction() {  
34 - $phoneNum = $this->post ('phoneNum', '');  
35 - $area = intval ($this->post( 'area', '86' ));  
36 - $verifyCode = $this->post ('verifyCode', '');  
37 - $data = array('code' => 400, 'message' =>'验证失败');  
38 - if ((Helpers::verifyEmail($phoneNum) || Helpers::verifyMobile($phoneNum))  
39 - && PassportModel::verifyCode($verifyCode)) {  
40 - $data['code'] = 200;  
41 - $data['message'] = '验证成功';  
42 - }  
43 - echo $this->echoJson($data);  
44 - }  
45 -  
46 - /**  
47 - * 邮箱  
48 - */  
49 - public function emailAction() {  
50 - $phoneNum = $this->post ('phoneNum', '');  
51 - $area = intval ($this->post('area', '86'));  
52 - $verifyCode = $this->post('verifyCode', '');  
53 - if (Helpers::verifyEmail($phoneNum)) { // 验证邮箱  
54 - $email = $phoneNum;  
55 - $data = BackData::sendCodeToEmail($email);  
56 -  
57 - if ($data ['code'] == 200) {  
58 - $this->setSession('email', $email);  
59 - $this->redirect ('sendemail');  
60 - } else {  
61 - $this->redirect ('index');  
62 - }  
63 -  
64 - } else if (Helpers::verifyMobile($phoneNum)) { // 验证手机号  
65 - $mobile = $phoneNum;  
66 - $data = BackData::sendCodeToMobile($mobile, $area);  
67 - if ($data ['code'] == 200) {  
68 - $this->setSession ('mobile', $mobile );  
69 - $this->setSession ('area', $area );  
70 - $this->setSession ('verifyCode', $verifyCode );  
71 - $this->redirect ('verification');  
72 - } else {  
73 - $this->redirect ('index');  
74 - }  
75 - }  
76 - }  
77 -  
78 - /**  
79 - * 发送邮件页面  
80 - */  
81 - public function sendemailAction() {  
82 - $email = $this->getSession ('email');  
83 - if (empty ( $email )) {  
84 - $this->redirect ('index');  
85 - }  
86 - $banner = PassportModel::getLeftBanner(PassportModel::BACK_LFFT_BANNER_CODE);  
87 - $data = array (  
88 - 'simpleHeader' => PassportModel::getSimpleHeader(false),  
89 - 'sendEmail' => array (  
90 - 'coverHref' => $banner ['url'],  
91 - 'coverImg' => $banner ['img'],  
92 - 'countrys' => array ()  
93 - )  
94 - );  
95 - $this->_view->display('send-email', $data);  
96 - }  
97 -  
98 - /**  
99 - * 重置密码页面  
100 - */  
101 - public function backcodeAction() {  
102 - $code = $this->get('code');  
103 - $info = $this->checkCode($code);  
104 - if (empty ( $info )) {  
105 - $this->redirect ('index');  
106 - }  
107 - $banner = PassportModel::getLeftBanner(PassportModel::BACK_LFFT_BANNER_CODE);  
108 - $data = array (  
109 - 'simpleHeader' => PassportModel::getSimpleHeader(false),  
110 - 'resetPage' => true,  
111 - 'resetPwd' => array (  
112 - 'coverHref' => $banner ['url'],  
113 - 'coverImg' => $banner ['img'],  
114 - 'countrys' => array(),  
115 - 'code' => $code  
116 - )  
117 - );  
118 - $this->_view->display('reset-pwd', $data);  
119 - }  
120 -  
121 - /**  
122 - * 更新密码接口  
123 - */  
124 - public function updateAction() {  
125 - $code = $this->post('code');  
126 - $password = $this->post('pwd');  
127 - $info = $this->checkCode($code);  
128 - if (Helpers::verifyPassword ($password) && ! empty ($info)) {  
129 - // 修改密码  
130 - if (isset ( $info ['mobile'] )) { // 手机号修改密码  
131 - $mobile = $info ['mobile'];  
132 - $token = $info ['token'];  
133 - $area = $info ['area'];  
134 - $data = BackData::modifyPasswordByMobile($mobile, $token, $password, $area);  
135 - if ($data ['code'] == 200) {  
136 - $this->redirect ( 'resetSuccess' );  
137 - }  
138 - } else if (isset ($info ['uid'])) { // 其他方式修改密码  
139 - $uid = $info ['uid'];  
140 - $this->redirect ( 'resetSuccess' );  
141 - }  
142 - }  
143 - // 跳转错误页面  
144 - // $this->redirect('/error/index');  
145 - }  
146 -  
147 - /**  
148 - * 重置密码成功  
149 - */  
150 - public function resetSuccessAction() {  
151 - $banner = PassportModel::getLeftBanner ( PassportModel::BACK_LFFT_BANNER_CODE );  
152 - $data = array (  
153 - 'simpleHeader' => PassportModel::getSimpleHeader ( false ),  
154 - 'resetSuccess' => array (  
155 - 'coverHref' => $banner ['url'],  
156 - 'coverImg' => $banner ['img'],  
157 - 'countrys' => array ()  
158 - )  
159 - );  
160 - $this->_view->display ( 'reset-success', $data );  
161 - }  
162 -  
163 - /**  
164 - * 手机验证页面  
165 - */  
166 - public function verificationAction() {  
167 - $mobile = $this->getSession ('mobile');  
168 - $area = $this->getSession ('area');  
169 - $verifyCode = $this->getSession ('verifyCode');  
170 - if (empty ($mobile)) {  
171 - $this->redirect ('index');  
172 - }  
173 - $banner = PassportModel::getLeftBanner (PassportModel::BACK_LFFT_BANNER_CODE);  
174 - $data = array (  
175 - 'simpleHeader' => PassportModel::getSimpleHeader ( false ),  
176 - 'vertificationPage' => true,  
177 - 'verification' => array (  
178 - 'coverHref' => $banner ['url'],  
179 - 'coverImg' => $banner ['img'],  
180 - 'mobile' => $mobile,  
181 - 'area' => $area,  
182 - 'verifyCode' => $verifyCode,  
183 - 'countrys' => array ()  
184 - )  
185 - );  
186 - $this->_view->display ('verification', $data);  
187 - }  
188 -  
189 - /**  
190 - * 手机找回密码验证  
191 - */  
192 - public function backmobileAction() {  
193 - $mobile = $this->post ( 'mobile' );  
194 - $area = $this->post ( 'area' );  
195 - $verifyCode = $this->post ( 'verifyCode' );  
196 - $code = $this->post ( 'code' ); // code  
197 - if ($this->getSession ( 'mobile' ) == $mobile && $this->getSession ( 'area' ) == $area) {  
198 - $result = BackData::validateMobileCode ( $mobile, $code, $area );  
199 - if ($result ['code'] == 200) {  
200 - $str = json_encode ( array (  
201 - 'mobile' => $mobile,  
202 - 'area' => $area,  
203 - 'token' => $result ['data'] ['token'],  
204 - 'create_time' => time ()  
205 - ) );  
206 - $code = AuthCode::encode ( $str, PassportModel::BACK_FIND_SECRET_KEY );  
207 - $url = '/passport/back/backcode?code=' . base64_encode ( $code );  
208 - $this->redirect ( SITE_MAIN . $url );  
209 - }  
210 - }  
211 - }  
212 -  
213 - /**  
214 - * 检查code  
215 - *  
216 - * @param string $code  
217 - * @return boolean  
218 - */  
219 - private function checkCode($code) {  
220 - $code = base64_decode ( $code );  
221 - $info = json_decode ( AuthCode::decode ( $code, PassportModel::BACK_FIND_SECRET_KEY ), true );  
222 - if ($info ['create_time'] < 1 || (time () - $info ['create_time']) > 86400) {  
223 - return array ();  
224 - }  
225 - return $info;  
226 - } 1 +<?php
  2 +use Action\WebAction;
  3 +use LibModels\Web\Passport\RegData;
  4 +use Passport\PassportModel;
  5 +use Plugin\Helpers;
  6 +use LibModels\Wap\Passport\BackData;
  7 +use Plugin\AuthCode;
  8 +class BackController extends WebAction {
  9 +
  10 + /**
  11 + * 找回密码
  12 + */
  13 + public function indexAction() {
  14 + $banner = PassportModel::getLeftBanner(PassportModel::BACK_LFFT_BANNER_CODE);
  15 + $data = array (
  16 + 'simpleHeader' => PassportModel::getSimpleHeader(false),
  17 + 'backPage' => true,
  18 + 'back' => array (
  19 + 'coverHref' => $banner ['url'],
  20 + 'coverImg' => $banner ['img'],
  21 + 'countryCode' => '86',
  22 + 'countryName' => '中国',
  23 + 'captchaUrl' => '/passport/images?t=1449799445',
  24 + 'countryList' => RegData::getAreasData()
  25 + )
  26 + );
  27 + $this->_view->display ( 'index', $data );
  28 + }
  29 +
  30 + /**
  31 + * 校验验证码
  32 + */
  33 + public function authcodeAction() {
  34 + $phoneNum = $this->post ('phoneNum', '');
  35 + $area = intval ($this->post( 'area', '86' ));
  36 + $verifyCode = $this->post ('verifyCode', '');
  37 + $data = array('code' => 400, 'message' =>'验证失败');
  38 + if ((Helpers::verifyEmail($phoneNum) || Helpers::verifyMobile($phoneNum))
  39 + && PassportModel::verifyCode($verifyCode)) {
  40 + $data['code'] = 200;
  41 + $data['message'] = '验证成功';
  42 + }
  43 + echo $this->echoJson($data);
  44 + }
  45 +
  46 + /**
  47 + * 邮箱
  48 + */
  49 + public function emailAction() {
  50 + $phoneNum = $this->post ('phoneNum', '');
  51 + $area = intval ($this->post('area', '86'));
  52 + $verifyCode = $this->post('verifyCode', '');
  53 + if (Helpers::verifyEmail($phoneNum)) { // 验证邮箱
  54 + $email = $phoneNum;
  55 + $data = BackData::sendCodeToEmail($email);
  56 + if ($data ['code'] == 200) {
  57 + $this->setSession('email', $email);
  58 + $this->redirect ('sendemail');
  59 + } else {
  60 + $this->redirect ('index');
  61 + }
  62 +
  63 + } else if (Helpers::verifyMobile($phoneNum)) { // 验证手机号
  64 + $mobile = $phoneNum;
  65 + $data = BackData::sendCodeToMobile($mobile, $area);
  66 +
  67 + if ($data['code'] == 200) {
  68 + $this->setSession ('mobile', $mobile );
  69 + $this->setSession ('area', $area );
  70 + $this->setSession ('verifyCode', $verifyCode );
  71 + $this->redirect ('verification');
  72 + } else {
  73 + $this->redirect ('index');
  74 + }
  75 + }
  76 + }
  77 +
  78 + /**
  79 + * 发送邮件页面
  80 + */
  81 + public function sendemailAction() {
  82 + $email = $this->getSession ('email');
  83 + if (empty ( $email )) {
  84 + $this->redirect ('index');
  85 + }
  86 + $banner = PassportModel::getLeftBanner(PassportModel::BACK_LFFT_BANNER_CODE);
  87 + $data = array (
  88 + 'simpleHeader' => PassportModel::getSimpleHeader(false),
  89 + 'sendEmail' => array (
  90 + 'coverHref' => $banner ['url'],
  91 + 'coverImg' => $banner ['img'],
  92 + 'countrys' => array ()
  93 + )
  94 + );
  95 + $this->_view->display('send-email', $data);
  96 + }
  97 +
  98 + /**
  99 + * 重置密码页面
  100 + */
  101 + public function backcodeAction() {
  102 + $code = $this->get('code');
  103 + $info = $this->checkCode($code);
  104 + if (empty ( $info )) {
  105 + $this->redirect ('index');
  106 + }
  107 + $banner = PassportModel::getLeftBanner(PassportModel::BACK_LFFT_BANNER_CODE);
  108 + $data = array (
  109 + 'simpleHeader' => PassportModel::getSimpleHeader(false),
  110 + 'resetPage' => true,
  111 + 'resetPwd' => array (
  112 + 'coverHref' => $banner ['url'],
  113 + 'coverImg' => $banner ['img'],
  114 + 'countrys' => array(),
  115 + 'code' => $code
  116 + )
  117 + );
  118 + $this->_view->display('reset-pwd', $data);
  119 + }
  120 +
  121 + /**
  122 + * 更新密码接口
  123 + */
  124 + public function updateAction() {
  125 + $code = $this->post('code');
  126 + $password = $this->post('pwd');
  127 + $info = $this->checkCode($code);
  128 + if (Helpers::verifyPassword ($password) && ! empty ($info)) {
  129 + // 修改密码
  130 + if (isset ( $info ['mobile'] )) { // 手机号修改密码
  131 + $mobile = $info ['mobile'];
  132 + $token = $info ['token'];
  133 + $area = $info ['area'];
  134 + $data = BackData::modifyPasswordByMobile($mobile, $token, $password, $area);
  135 + if ($data ['code'] == 200) {
  136 + $this->redirect ( 'resetSuccess' );
  137 + }
  138 + } else if (isset ($info ['uid'])) { // 其他方式修改密码
  139 + $uid = $info ['uid'];
  140 + $this->redirect ( 'resetSuccess' );
  141 + }
  142 + }
  143 + // 跳转错误页面
  144 + // $this->redirect('/error/index');
  145 + }
  146 +
  147 + /**
  148 + * 重置密码成功
  149 + */
  150 + public function resetSuccessAction() {
  151 + $banner = PassportModel::getLeftBanner ( PassportModel::BACK_LFFT_BANNER_CODE );
  152 + $data = array (
  153 + 'simpleHeader' => PassportModel::getSimpleHeader ( false ),
  154 + 'resetSuccess' => array (
  155 + 'coverHref' => $banner ['url'],
  156 + 'coverImg' => $banner ['img'],
  157 + 'countrys' => array ()
  158 + )
  159 + );
  160 + $this->_view->display ( 'reset-success', $data );
  161 + }
  162 +
  163 + /**
  164 + * 手机验证页面
  165 + */
  166 + public function verificationAction() {
  167 + $mobile = $this->getSession ('mobile');
  168 + $area = $this->getSession ('area');
  169 + $verifyCode = $this->getSession ('verifyCode');
  170 + if (empty ($mobile)) {
  171 + $this->redirect ('index');
  172 + }
  173 + $banner = PassportModel::getLeftBanner (PassportModel::BACK_LFFT_BANNER_CODE);
  174 + $data = array (
  175 + 'simpleHeader' => PassportModel::getSimpleHeader ( false ),
  176 + 'vertificationPage' => true,
  177 + 'verification' => array (
  178 + 'coverHref' => $banner ['url'],
  179 + 'coverImg' => $banner ['img'],
  180 + 'mobile' => $mobile,
  181 + 'area' => $area,
  182 + 'verifyCode' => $verifyCode,
  183 + 'countrys' => array ()
  184 + )
  185 + );
  186 + $this->_view->display ('verification', $data);
  187 + }
  188 +
  189 + /**
  190 + * 手机找回密码验证
  191 + */
  192 + public function backmobileAction() {
  193 + $mobile = $this->post ( 'mobile' );
  194 + $area = $this->post ( 'area' );
  195 + $verifyCode = $this->post ( 'verifyCode' );
  196 + $code = $this->post ( 'code' ); // code
  197 + if ($this->getSession ( 'mobile' ) == $mobile && $this->getSession ( 'area' ) == $area) {
  198 + $result = BackData::validateMobileCode ( $mobile, $code, $area );
  199 + if ($result ['code'] == 200) {
  200 + $str = json_encode ( array (
  201 + 'mobile' => $mobile,
  202 + 'area' => $area,
  203 + 'token' => $result ['data'] ['token'],
  204 + 'create_time' => time ()
  205 + ) );
  206 + $code = AuthCode::encode ( $str, PassportModel::BACK_FIND_SECRET_KEY );
  207 + $url = '/passport/back/backcode?code=' . base64_encode ( $code );
  208 + $this->redirect ( SITE_MAIN . $url );
  209 + }
  210 + }
  211 + //出错直接跳到找回密码页
  212 + $this->redirect ('/passport/back/index');
  213 + }
  214 +
  215 + /**
  216 + * 检查code
  217 + *
  218 + * @param string $code
  219 + * @return boolean
  220 + */
  221 + private function checkCode($code) {
  222 + $code = base64_decode ( $code );
  223 + $info = json_decode ( AuthCode::decode ( $code, PassportModel::BACK_FIND_SECRET_KEY ), true );
  224 + if ($info ['create_time'] < 1 || (time () - $info ['create_time']) > 86400) {
  225 + return array ();
  226 + }
  227 + return $info;
  228 + }
  229 +
227 } 230 }
@@ -2,6 +2,10 @@ @@ -2,6 +2,10 @@
2 use Action\WebAction; 2 use Action\WebAction;
3 use LibModels\Web\Product\BrandData; 3 use LibModels\Web\Product\BrandData;
4 4
  5 +use LibModels\Web\Product\HotrankData;
  6 +use product\HotrankModel;
  7 +use LibModels\Web\Home\IndexData;
  8 +
5 class IndexController extends WebAction 9 class IndexController extends WebAction
6 { 10 {
7 /** 11 /**
@@ -47,5 +51,240 @@ class IndexController extends WebAction @@ -47,5 +51,240 @@ class IndexController extends WebAction
47 //渲染模板 51 //渲染模板
48 $this->_view->display('list',$data); 52 $this->_view->display('list',$data);
49 } 53 }
  54 +
  55 + public function hotrankAction() {
  56 + $this->setWebNavHeader(\Index\HomeModel::COOKIE_NAME_LIFESTYLE);
  57 + $data = array(
  58 + 'hotrankPage' => true,
  59 + 'hotrank' => array(
  60 + array(
  61 + 'slide' => array(
  62 + 'list' => array(
  63 + array(
  64 + 'href' => '/?gender=1,3',
  65 + 'img' => 'http://img10.static.yhbimg.com/taobaocms/2015/11/26/12/01c3b99f554ad50d9e5a9900719715c94c.jpg'
  66 + ),
  67 + array(
  68 + 'href' => '/?gender=1,3',
  69 + 'img' => 'http://img12.static.yhbimg.com/taobaocms/2015/11/27/09/02a4f1c10e1e81574520e5c0239741a076.jpg'
  70 + ),
  71 + array(
  72 + 'href' => '/?gender=1,3',
  73 + 'img' => 'http://img10.static.yhbimg.com/taobaocms/2015/11/26/12/01c3b99f554ad50d9e5a9900719715c94c.jpg'
  74 + ),
  75 + array(
  76 + 'href' => '/?gender=1,3',
  77 + 'img' => 'http://img12.static.yhbimg.com/taobaocms/2015/11/27/09/02a4f1c10e1e81574520e5c0239741a076.jpg'
  78 + ),
  79 + array(
  80 + 'href' => '/?gender=1,3',
  81 + 'img' => 'http://img10.static.yhbimg.com/taobaocms/2015/11/26/12/01c3b99f554ad50d9e5a9900719715c94c.jpg'
  82 + ),
  83 + array(
  84 + 'href' => '/?gender=1,3',
  85 + 'img' => 'http://img12.static.yhbimg.com/taobaocms/2015/11/27/09/02a4f1c10e1e81574520e5c0239741a076.jpg'
  86 + ),
  87 + array(
  88 + 'href' => '/?gender=1,3',
  89 + 'img' => 'http://img10.static.yhbimg.com/taobaocms/2015/11/26/12/01c3b99f554ad50d9e5a9900719715c94c.jpg'
  90 + ),
  91 + array(
  92 + 'href' => '/?gender=1,3',
  93 + 'img' => 'http://img12.static.yhbimg.com/taobaocms/2015/11/27/09/02a4f1c10e1e81574520e5c0239741a076.jpg'
  94 + )
  95 + )
  96 + )
  97 + ),
  98 + array(
  99 + 'popular' => array(
  100 + 'name' => '人气单品',
  101 + 'list' => array(
  102 + array(
  103 + 'href' => '',
  104 + 'img' => 'http://img13.static.yhbimg.com/goodsimg/2014/09/16/07/027e03e45e3e88db0adbf6255671546a0b.jpg?imageMogr2/thumbnail/378x504/extent/378x504/background/d2hpdGU=/position/center/quality/90',
  105 + 'title' => 'YYYOHOOD 黄伟文Wyman X yohood联名商品 圆领卫衣',
  106 + 'price' => '399',
  107 + 'sPrice' => '199',
  108 + 'rank' => '1'
  109 + ),
  110 + array(
  111 + 'href' => '',
  112 + 'img' => 'http://img13.static.yhbimg.com/goodsimg/2014/09/16/07/027e03e45e3e88db0adbf6255671546a0b.jpg?imageMogr2/thumbnail/378x504/extent/378x504/background/d2hpdGU=/position/center/quality/90',
  113 + 'title' => 'YYYOHOOD 黄伟文Wyman X yohood联名商品 圆领卫衣',
  114 + 'price' => '399',
  115 + 'sPrice' => '199',
  116 + 'rank' => '2'
  117 + ),
  118 + array(
  119 + 'href' => '',
  120 + 'img' => 'http://img13.static.yhbimg.com/goodsimg/2014/09/16/07/027e03e45e3e88db0adbf6255671546a0b.jpg?imageMogr2/thumbnail/378x504/extent/378x504/background/d2hpdGU=/position/center/quality/90',
  121 + 'title' => 'YYYOHOOD 黄伟文Wyman X yohood联名商品 圆领卫衣',
  122 + 'price' => '399',
  123 + 'sPrice' => '199',
  124 + 'rank' => '3'
  125 + ),
  126 + array(
  127 + 'href' => '',
  128 + 'img' => 'http://img13.static.yhbimg.com/goodsimg/2014/09/16/07/027e03e45e3e88db0adbf6255671546a0b.jpg?imageMogr2/thumbnail/378x504/extent/378x504/background/d2hpdGU=/position/center/quality/90',
  129 + 'title' => 'YYYOHOOD 黄伟文Wyman X yohood联名商品 圆领卫衣',
  130 + 'price' => '399',
  131 + 'sPrice' => '199',
  132 + 'rank' => '4'
  133 + ),
  134 + array(
  135 + 'href' => '',
  136 + 'img' => 'http://img13.static.yhbimg.com/goodsimg/2014/09/16/07/027e03e45e3e88db0adbf6255671546a0b.jpg?imageMogr2/thumbnail/378x504/extent/378x504/background/d2hpdGU=/position/center/quality/90',
  137 + 'title' => 'YYYOHOOD 黄伟文Wyman X yohood联名商品 圆领卫衣',
  138 + 'price' => '399',
  139 + 'sPrice' => '199',
  140 + 'rank' => '5'
  141 + ),
  142 + array(
  143 + 'href' => '',
  144 + 'img' => 'http://img13.static.yhbimg.com/goodsimg/2014/09/16/07/027e03e45e3e88db0adbf6255671546a0b.jpg?imageMogr2/thumbnail/378x504/extent/378x504/background/d2hpdGU=/position/center/quality/90',
  145 + 'title' => 'YYYOHOOD 黄伟文Wyman X yohood联名商品 圆领卫衣',
  146 + 'price' => '399',
  147 + 'sPrice' => '199',
  148 + 'rank' => '6'
  149 + ),
  150 + array(
  151 + 'href' => '',
  152 + 'img' => 'http://img13.static.yhbimg.com/goodsimg/2014/09/16/07/027e03e45e3e88db0adbf6255671546a0b.jpg?imageMogr2/thumbnail/378x504/extent/378x504/background/d2hpdGU=/position/center/quality/90',
  153 + 'title' => 'YYYOHOOD 黄伟文Wyman X yohood联名商品 圆领卫衣',
  154 + 'price' => '399',
  155 + 'sPrice' => '199',
  156 + 'rank' => '7'
  157 + ),
  158 + array(
  159 + 'href' => '',
  160 + 'img' => 'http://img13.static.yhbimg.com/goodsimg/2014/09/16/07/027e03e45e3e88db0adbf6255671546a0b.jpg?imageMogr2/thumbnail/378x504/extent/378x504/background/d2hpdGU=/position/center/quality/90',
  161 + 'title' => 'YYYOHOOD 黄伟文Wyman X yohood联名商品 圆领卫衣',
  162 + 'price' => '399',
  163 + 'sPrice' => '199',
  164 + 'rank' => '8'
  165 + ),
  166 + array(
  167 + 'href' => '',
  168 + 'img' => 'http://img13.static.yhbimg.com/goodsimg/2014/09/16/07/027e03e45e3e88db0adbf6255671546a0b.jpg?imageMogr2/thumbnail/378x504/extent/378x504/background/d2hpdGU=/position/center/quality/90',
  169 + 'title' => 'YYYOHOOD 黄伟文Wyman X yohood联名商品 圆领卫衣',
  170 + 'price' => '399',
  171 + 'sPrice' => '199',
  172 + 'rank' => '9'
  173 + ),
  174 + array(
  175 + 'href' => '',
  176 + 'img' => 'http://img13.static.yhbimg.com/goodsimg/2014/09/16/07/027e03e45e3e88db0adbf6255671546a0b.jpg?imageMogr2/thumbnail/378x504/extent/378x504/background/d2hpdGU=/position/center/quality/90',
  177 + 'title' => 'YYYOHOOD 黄伟文Wyman X yohood联名商品 圆领卫衣',
  178 + 'price' => '399',
  179 + 'sPrice' => '199',
  180 + 'rank' => '10'
  181 + )
  182 + )
  183 +
  184 + )
  185 + ),
  186 + array(
  187 + 'hotBrands' => array(
  188 + 'name' => '热门品牌',
  189 + )
  190 + ),
  191 + array(
  192 + 'hotWeek' => array(
  193 + 'name' => '一周热卖',
  194 + 'nav' => array(
  195 + array(
  196 + 'textCn' => 'TOP100',
  197 + 'url' => '',
  198 + 'sid' => 1
  199 + ),
  200 + array(
  201 + 'textCn' => '上装',
  202 + 'url' => '',
  203 + 'sid' => 2
  204 + ),
  205 + array(
  206 + 'textCn' => '男生测试',
  207 + 'url' => '',
  208 + 'sid' => 3
  209 + ),
  210 + array(
  211 + 'textCn' => '配饰',
  212 + 'url' => '',
  213 + 'sid' => 4
  214 + )
  215 + ),
  216 + 'list' => array(
  217 + array(
  218 + 'thumb' => 'http://img13.static.yhbimg.com/goodsimg/2015/11/24/10/020dce58a189f3fbfc071b3d5dc7ccc4e9.jpg?imageMogr2/thumbnail/280x373/extent/280x373/background/d2hpdGU=/position/center/quality/90',
  219 + 'url' => 'http://item.yohobuy.com/product/pro_294497_377385.html',
  220 + 'name' => 'MARtube马克图布 暖手宝移动电源萌兔',
  221 + 'marketPrice' => '109',
  222 + 'salePrice' => '129'
  223 + ),
  224 + array(
  225 + 'thumb' => 'http://img13.static.yhbimg.com/goodsimg/2015/11/24/10/020dce58a189f3fbfc071b3d5dc7ccc4e9.jpg?imageMogr2/thumbnail/280x373/extent/280x373/background/d2hpdGU=/position/center/quality/90',
  226 + 'url' => 'http://item.yohobuy.com/product/pro_294497_377385.html',
  227 + 'name' => 'MARtube马克图布 暖手宝移动电源萌兔',
  228 + 'marketPrice' => '109',
  229 + 'salePrice' => '129'
  230 + ),
  231 + array(
  232 + 'thumb' => 'http://img13.static.yhbimg.com/goodsimg/2015/11/24/10/020dce58a189f3fbfc071b3d5dc7ccc4e9.jpg?imageMogr2/thumbnail/280x373/extent/280x373/background/d2hpdGU=/position/center/quality/90',
  233 + 'url' => 'http://item.yohobuy.com/product/pro_294497_377385.html',
  234 + 'name' => 'MARtube马克图布 暖手宝移动电源萌兔',
  235 + 'marketPrice' => '109',
  236 + 'salePrice' => '129'
  237 + ),
  238 + array(
  239 + 'thumb' => 'http://img13.static.yhbimg.com/goodsimg/2015/11/24/10/020dce58a189f3fbfc071b3d5dc7ccc4e9.jpg?imageMogr2/thumbnail/280x373/extent/280x373/background/d2hpdGU=/position/center/quality/90',
  240 + 'url' => 'http://item.yohobuy.com/product/pro_294497_377385.html',
  241 + 'name' => 'MARtube马克图布 暖手宝移动电源萌兔',
  242 + 'marketPrice' => '109',
  243 + 'salePrice' => '129'
  244 + ),
  245 + array(
  246 + 'thumb' => 'http://img13.static.yhbimg.com/goodsimg/2015/11/24/10/020dce58a189f3fbfc071b3d5dc7ccc4e9.jpg?imageMogr2/thumbnail/280x373/extent/280x373/background/d2hpdGU=/position/center/quality/90',
  247 + 'url' => 'http://item.yohobuy.com/product/pro_294497_377385.html',
  248 + 'name' => 'MARtube马克图布 暖手宝移动电源萌兔',
  249 + 'marketPrice' => '109',
  250 + 'salePrice' => '129'
  251 + ),
  252 + array(
  253 + 'thumb' => 'http://img13.static.yhbimg.com/goodsimg/2015/11/24/10/020dce58a189f3fbfc071b3d5dc7ccc4e9.jpg?imageMogr2/thumbnail/280x373/extent/280x373/background/d2hpdGU=/position/center/quality/90',
  254 + 'url' => 'http://item.yohobuy.com/product/pro_294497_377385.html',
  255 + 'name' => 'MARtube马克图布 暖手宝移动电源萌兔',
  256 + 'marketPrice' => '109',
  257 + 'salePrice' => '129'
  258 + ),
  259 + )
  260 + )
  261 + )
  262 + )
  263 + );
  264 + $data = array( 'hotrankPage' => true,
  265 + 'footerTop'=> true,
  266 + 'hotrank' => array()
  267 + );
  268 + //焦点图 热门品牌
  269 + $focus = \Index\HomeModel::getChannelResource('lifestyle', 'd131aba83a84a6977eee3a7403a713de');
  270 + //print_r($focus);
  271 + $data['hotrank']['slide'] = $focus[0]['slide'];
  272 + $data['hotrank']['hotBrands'] = $focus[1]['hotBrands'];
  273 +
  274 + //人气单品 一周热卖
  275 + $page = 1;
  276 + $param = array('order'=>'s_n_desc','viewNum'=>60,'page'=>1,'stocknumber'=>1,'status'=>1,'gender'=>'','attribute_not'=>2);
  277 + $publiclist = \product\HotrankModel::getSearchData($param,$page);
  278 + $data['hotrank']['popular'] = $publiclist['popular'];
  279 + $data['hotrank']['hotWeek'] = $publiclist['hotWeek'];
  280 + //print_r($publiclist);
  281 +
  282 + //分类标签
  283 + $classes = array('gender' => 2);
  284 + $nav = \product\HotrankModel::getHotranktag($classes);
  285 + $data['hotrank']['hotWeek']['nav'] = $nav;
  286 + //print_r($data);
  287 + $this->_view->display('hotrank', $data);
  288 + }
50 } 289 }
51 ?> 290 ?>
@@ -5,11 +5,29 @@ class ListController extends WebAction @@ -5,11 +5,29 @@ class ListController extends WebAction
5 { 5 {
6 public function indexAction() 6 public function indexAction()
7 { 7 {
8 - 8 +
9 } 9 }
10 10
  11 + /**
  12 + * list列表new(模板new-sale)
  13 + */
11 public function newAction(){ 14 public function newAction(){
12 - 15 + $condition = array(
  16 + 'order' => 's_t_desc'
  17 + );
  18 + $options = array(
  19 + 'specialsale_id' => 'Y',
  20 + 'needDay' => 'Y'
  21 + );
  22 +
  23 + $newData = Product\NewModel::getNewSearchData($condition, $options);
  24 + $data = array(
  25 + 'productListPage' => true,
  26 + 'newSale' => $newData
  27 + );
  28 + $this->setWebNavHeader();
  29 + //渲染模板
  30 + $this->_view->display('new-sale', $data);
13 } 31 }
14 32
15 /** 33 /**
1 -<?php  
2 -  
3 -use Action\WebAction;  
4 -  
5 -/**  
6 - * new页  
7 - *  
8 - */  
9 -class NewController extends WebAction  
10 -{  
11 -  
12 - public function indexAction()  
13 - {  
14 - $condition = array(  
15 - 'order' => 's_t_desc'  
16 - );  
17 - $options = array(  
18 - 'specialsale_id' => 'Y',  
19 - 'needDay' => 'Y'  
20 - );  
21 -  
22 - $newData = Product\NewModel::getNewSearchData($condition, $options);  
23 - $data = array(  
24 - 'productListPage' => true,  
25 - 'newSale' => $newData  
26 - );  
27 - $this->setWebNavHeader();  
28 - //渲染模板  
29 - $this->_view->display('new-sale', $data);  
30 - }  
31 -  
32 -}