Authored by Lynnic

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

  1 +<?php
  2 +
  3 +namespace LibModels\Wap\Home;
  4 +
  5 +use Api\Sign;
  6 +use Api\Yohobuy;
  7 +
  8 +/**
  9 + * 我的逛数据模型
  10 + *
  11 + * @name GuangData
  12 + * @package LibModels/Wap/Home
  13 + * @copyright yoho.inc
  14 + * @version 1.0 (2015-11-13)
  15 + * @author xiaowei
  16 + */
  17 +class GuangData
  18 +{
  19 +
  20 + const GUANG_URI = 'guang/api/v1/favorite/';
  21 +
  22 + //我的guang
  23 + public static function getGuangInfo($uid, $page, $yh_channel = 1, $gender = '1,3', $limit = 10)
  24 + {
  25 + $param = Yohobuy::param();
  26 + $param['uid'] = $uid;
  27 + $param['page'] = $page;
  28 + $param['gender'] = $gender;
  29 + $param['limit'] = $limit;
  30 + $param['yh_channel'] = $yh_channel;
  31 + $param['client_secret'] = Sign::getSign($param);
  32 +// return Yohobuy::post(Yohobuy::API_URL, $param);
  33 + return Yohobuy::post(Yohobuy::SERVICE_URL . self::GUANG_URI . 'getUserFavArticleList', $param);
  34 + }
  35 +
  36 +}
@@ -2,7 +2,6 @@ @@ -2,7 +2,6 @@
2 2
3 namespace LibModels\Wap\Home; 3 namespace LibModels\Wap\Home;
4 4
5 -use Api\Sign;  
6 use Api\Yohobuy; 5 use Api\Yohobuy;
7 6
8 /** 7 /**
@@ -18,16 +17,23 @@ class OnlineData @@ -18,16 +17,23 @@ class OnlineData
18 { 17 {
19 const ONLINE_URI = 'operations/api/v1/help/'; 18 const ONLINE_URI = 'operations/api/v1/help/';
20 19
21 - //获取帮助列表(分类) 20 + /*
  21 + * 获取帮助列表(分类),缓存1h
  22 + * clientType客户端
  23 + */
22 public static function getOnlineServiceInfo($clientType='iphone') 24 public static function getOnlineServiceInfo($clientType='iphone')
23 { 25 {
24 - return Yohobuy::get(Yohobuy::SERVICE_URL .self::ONLINE_URI.'getCategory', array('client_type'=>$clientType)); 26 + return Yohobuy::get(Yohobuy::SERVICE_URL .self::ONLINE_URI.'getCategory', array('client_type'=>$clientType),3600);
25 } 27 }
26 28
27 - //获取问题详情 29 + /*
  30 + * 获取问题详情,缓存1h
  31 + * cateId问题分类ID
  32 + * clientType客户端
  33 + */
28 public static function getOnlineServiceDetail($cateId, $clientType = 'iphone') 34 public static function getOnlineServiceDetail($cateId, $clientType = 'iphone')
29 { 35 {
30 - return Yohobuy::get(Yohobuy::SERVICE_URL .self::ONLINE_URI.'getHelp', array('category_id'=>$cateId,'client_type'=>$clientType)); 36 + return Yohobuy::get(Yohobuy::SERVICE_URL .self::ONLINE_URI.'getHelp', array('category_id'=>$cateId,'client_type'=>$clientType),3600);
31 } 37 }
32 38
33 } 39 }
@@ -15,7 +15,7 @@ @@ -15,7 +15,7 @@
15 {{product_favorite_total}} 15 {{product_favorite_total}}
16 <p>收藏的商品</p> 16 <p>收藏的商品</p>
17 </a> 17 </a>
18 - <a class="link-item" href="/home/favoritebrand"> 18 + <a class="link-item" href="/home/favorite?tab=brand">
19 {{brand_favorite_total}} 19 {{brand_favorite_total}}
20 <p>收藏的品牌</p> 20 <p>收藏的品牌</p>
21 </a> 21 </a>
@@ -68,20 +68,26 @@ class HomeController extends AbstractAction @@ -68,20 +68,26 @@ class HomeController extends AbstractAction
68 $this->setTitle('我的收藏'); 68 $this->setTitle('我的收藏');
69 $this->setNavHeader('我的收藏', true, SITE_MAIN); 69 $this->setNavHeader('我的收藏', true, SITE_MAIN);
70 70
  71 + $tab = $this->get('tab', '');
71 $uid = $this->getUid(); 72 $uid = $this->getUid();
72 $uid = 8826435; 73 $uid = 8826435;
73 $gender = Helpers::getGenderByCookie(); 74 $gender = Helpers::getGenderByCookie();
74 75
75 $favProducts = \Index\UserModel::getFavProductData($uid); 76 $favProducts = \Index\UserModel::getFavProductData($uid);
76 $favBrands = \Index\UserModel::getFavBrandData($uid, $gender); 77 $favBrands = \Index\UserModel::getFavBrandData($uid, $gender);
77 -  
78 - $this->_view->display('favorite', array( 78 + $data = array(
79 'favPage' => true, //加载js 79 'favPage' => true, //加载js
80 'pageFooter' => true, 80 'pageFooter' => true,
81 'favorite' => true, 81 'favorite' => true,
82 'hasFavProduct' => $favProducts, 82 'hasFavProduct' => $favProducts,
83 'hasFavBrand' => $favBrands 83 'hasFavBrand' => $favBrands
84 - )); 84 + );
  85 + // 判断时候为品牌页
  86 + if ($tab === 'brand') {
  87 + $data['brandTab'] = true;
  88 + }
  89 +
  90 + $this->_view->display('favorite', $data);
85 } 91 }
86 92
87 /** 93 /**
@@ -106,19 +112,6 @@ class HomeController extends AbstractAction @@ -106,19 +112,6 @@ class HomeController extends AbstractAction
106 } 112 }
107 113
108 /** 114 /**
109 - * 用户收藏的品牌  
110 - */  
111 - public function favoritebrandAction()  
112 - {  
113 - $uid = $this->getUid();  
114 - $gender = Helpers::getGenderByCookie();  
115 -  
116 - $favBrands = \Index\UserModel::getFavBrandData($uid, $gender);  
117 -  
118 - print_r($favBrands);  
119 - }  
120 -  
121 - /**  
122 * 个人信息 115 * 个人信息
123 */ 116 */
124 public function personalDetailsAction() 117 public function personalDetailsAction()
@@ -314,7 +307,14 @@ class HomeController extends AbstractAction @@ -314,7 +307,14 @@ class HomeController extends AbstractAction
314 */ 307 */
315 public function myGuangAction() 308 public function myGuangAction()
316 { 309 {
317 - echo 'My Guang'; 310 + $page = $this->get('page', 1);
  311 + $limit = $this->get('limit', 10);
  312 + $uid = $this->getUid();
  313 + $yh_channel = Helpers::getChannelByCookie();
  314 + $uid=5687179;
  315 + $gender = Helpers::getGenderByCookie();
  316 + $guangInfo = \home\GuangModel::getMyGuang($uid, $page,$yh_channel,$gender, $limit);
  317 + $this->_view->display('my-guang', array('myGuang'=>$guangInfo));
318 } 318 }
319 319
320 /** 320 /**
  1 +<?php
  2 +
  3 +namespace Home;
  4 +
  5 +use LibModels\Wap\Home\GuangData;
  6 +use Action\AbstractAction;
  7 +use Plugin\Helpers;
  8 +
  9 +/**
  10 + * 我的逛数据处理
  11 + */
  12 +class GuangModel
  13 +{
  14 +
  15 + //获取我的逛列表
  16 + public static function getMyGuang($uid, $page,$yh_channel=1, $gender = '1,3', $limit = 10)
  17 + {
  18 + $result = array();
  19 + //调用接口获取数据
  20 + $res = GuangData::getGuangInfo($uid, $page, $yh_channel,$gender, $limit);
  21 + $guangInfo = $res['data']['data'];
  22 + if ($guangInfo)
  23 + {
  24 + foreach ($guangInfo as $k => $v)
  25 + {
  26 + $result[$k]['id'] = $v['id'];
  27 + $result[$k]['author'] = $v['author'];
  28 + $tag = self::getTag(TRUE, intval($v['category_id']));
  29 + $result[$k]['url'] = $v['url'];
  30 + $result[$k]['img'] = $v['src'];
  31 + $result[$k]['title'] = $v['title'];
  32 + $result[$k]['text'] = $v['intro'];
  33 + $result[$k]['pageView'] = $v['views_num'];
  34 + $result[$k]['publish_time'] = $v['publish_time'];
  35 + $like = ($v['isPraise'] == "Y") ? true : false;
  36 + $collect = ($v['isFavor'] == "Y") ? true : false;
  37 + $result[$k]['like'] = array('isLiked' => $like, 'count' => $v['praise_num']);
  38 + $result[$k]['collect'] = array('isCollected' => $collect, 'url' => $v['url']);
  39 + $result[$k] += $tag;
  40 + $result[$k]['share'] = $v['url'];
  41 + }
  42 + }
  43 +
  44 + return $result;
  45 + }
  46 +
  47 + //【标签】isTip-小贴士;isCollocation-搭配 isFashionMan-潮人 isFashionGood-潮品 isTopic-话题
  48 + private static function getTag($isShow, $tagId)
  49 + {
  50 + $ret['showTags'] = $isShow;
  51 + $ret['isTopic'] = false;
  52 + $ret['isCollocation'] = false;
  53 + $ret['isFashionMan'] = false;
  54 + $ret['isFashionGood'] = false;
  55 + $ret['isTip'] = false;
  56 + switch ($tagId)
  57 + {
  58 + case 1:
  59 + $ret['isTopic'] = true;
  60 + break;
  61 + case 2:
  62 + $ret['isCollocation'] = true;
  63 + break;
  64 + case 3:
  65 + $ret['isFashionMan'] = true;
  66 + break;
  67 + case 4:
  68 + $ret['isFashionGood'] = true;
  69 + break;
  70 + case 5:
  71 + $ret['isTip'] = true;
  72 + break;
  73 + default:
  74 + $ret['showTags'] = FALSE;
  75 + break;
  76 + }
  77 + return $ret;
  78 + }
  79 +
  80 +}
@@ -162,7 +162,7 @@ class UserModel @@ -162,7 +162,7 @@ class UserModel
162 $product['price'] = '¥'.$val['market_price']; 162 $product['price'] = '¥'.$val['market_price'];
163 $product['discountPrice'] = '¥'.$val['sales_price']; 163 $product['discountPrice'] = '¥'.$val['sales_price'];
164 $product['savePrice'] = ($val['market_price'] - $val['sales_price'] > 0) ? '¥'.($val['market_price'] - $val['sales_price']) : false; 164 $product['savePrice'] = ($val['market_price'] - $val['sales_price'] > 0) ? '¥'.($val['market_price'] - $val['sales_price']) : false;
165 - $product['sellOut'] = boolval($val['price_down']); 165 + $product['sellOut'] = (bool)($val['price_down']);
166 166
167 $result[] = $product; 167 $result[] = $product;
168 } 168 }
@@ -432,7 +432,7 @@ class UserModel @@ -432,7 +432,7 @@ class UserModel
432 $one['imgUrl'] = Helpers::getImageUrl($val['cover_image'], 640, 240); 432 $one['imgUrl'] = Helpers::getImageUrl($val['cover_image'], 640, 240);
433 $one['title'] = $val['filter_content']; 433 $one['title'] = $val['filter_content'];
434 $one['content'] = $val['reply_content']; 434 $one['content'] = $val['reply_content'];
435 - $one['good'] = boolval($val['is_reliable']); 435 + $one['good'] = (bool)($val['is_reliable']);
436 $one['bad'] = !$one['good']; 436 $one['bad'] = !$one['good'];
437 437
438 $result[] = $one; 438 $result[] = $one;
@@ -11,7 +11,10 @@ use Plugin\Helpers; @@ -11,7 +11,10 @@ use Plugin\Helpers;
11 class OnlineModel 11 class OnlineModel
12 { 12 {
13 13
14 - //获取在线帮助分类 14 + /*
  15 + * 获取在线帮助分类
  16 + * $clientType客户端类型
  17 + */
15 public static function getOnlineServiceInfo($clientType = 'iphone') 18 public static function getOnlineServiceInfo($clientType = 'iphone')
16 { 19 {
17 //调用接口获取数据 20 //调用接口获取数据
@@ -19,10 +22,13 @@ class OnlineModel @@ -19,10 +22,13 @@ class OnlineModel
19 $cateInfo = $res['data']; 22 $cateInfo = $res['data'];
20 $question = array(); 23 $question = array();
21 $tab = array(); 24 $tab = array();
22 - if ($cateInfo) {  
23 - foreach ($cateInfo as $key => $value) { 25 + if ($cateInfo)
  26 + {
  27 + foreach ($cateInfo as $key => $value)
  28 + {
24 //强制截成3个tab 29 //强制截成3个tab
25 - if ($key > 2) { 30 + if ($key > 2)
  31 + {
26 break; 32 break;
27 } 33 }
28 $tab[$key]['tabid'] = 'tab' . $value['id']; 34 $tab[$key]['tabid'] = 'tab' . $value['id'];
@@ -33,10 +39,12 @@ class OnlineModel @@ -33,10 +39,12 @@ class OnlineModel
33 $question[$key]['current'] = (!$key) ? TRUE : FALSE; 39 $question[$key]['current'] = (!$key) ? TRUE : FALSE;
34 $sub = $value['sub']; 40 $sub = $value['sub'];
35 $qTmp = array(); 41 $qTmp = array();
36 - if ($sub) {  
37 - foreach ($sub as $sk => $sv) { 42 + if ($sub)
  43 + {
  44 + foreach ($sub as $sk => $sv)
  45 + {
38 $qTmp[$sk]['title'] = $sv['category_name']; 46 $qTmp[$sk]['title'] = $sv['category_name'];
39 - $qTmp[$sk]['link'] = '/home/onlineservicedetail?cateId=' . $sv['id'] . '&cateName=' . $sv['category_name']; 47 + $qTmp[$sk]['link'] = Helpers::url('/home/onlineservicedetail',array('cateId'=>$sv['id'],'cateName'=>$sv['category_name']));
40 } 48 }
41 } 49 }
42 $question[$key]['list'] = $qTmp; 50 $question[$key]['list'] = $qTmp;
@@ -54,19 +62,27 @@ class OnlineModel @@ -54,19 +62,27 @@ class OnlineModel
54 return $result; 62 return $result;
55 } 63 }
56 64
57 - //加载分类下的问题和解决方法 65 + /*
  66 + * 加载分类下的问题和解决方法
  67 + * cateId问题分类ID
  68 + * clientType客户端
  69 + */
58 public static function getOnlineServiceDetail($cateId, $clinetType = 'iphone') 70 public static function getOnlineServiceDetail($cateId, $clinetType = 'iphone')
59 { 71 {
60 $result = array(); 72 $result = array();
61 - if (!$cateId) { 73 + if (!$cateId)
  74 + {
62 return $result; 75 return $result;
63 } 76 }
64 $res = OnlineData::getOnlineServiceDetail($cateId, $clinetType); 77 $res = OnlineData::getOnlineServiceDetail($cateId, $clinetType);
65 $questionInfo = $res['data']; 78 $questionInfo = $res['data'];
66 - if ($questionInfo) { 79 + if ($questionInfo)
  80 + {
67 $list = array(); 81 $list = array();
68 - if ($questionInfo) {  
69 - foreach ($questionInfo as $qk => $qv) { 82 + if ($questionInfo)
  83 + {
  84 + foreach ($questionInfo as $qk => $qv)
  85 + {
70 $list[$qk]['q'] = $qv['title']; 86 $list[$qk]['q'] = $qv['title'];
71 $list[$qk]['a'] = $qv['content']; 87 $list[$qk]['a'] = $qv['content'];
72 } 88 }