Authored by Rock Zhang

完成个人中心部分功能

@@ -34,6 +34,38 @@ class UserData @@ -34,6 +34,38 @@ class UserData
34 } 34 }
35 35
36 /** 36 /**
  37 + * 个人中心页面优惠券,收藏的商品等的数目数据
  38 + *
  39 + * @param int $uid 用户ID
  40 + * @return array 接口返回的数据
  41 + */
  42 + public static function infoNum($uid)
  43 + {
  44 + $param = Yohobuy::param();
  45 + $param['method'] = 'app.home.getInfoNum';
  46 + $param['uid'] = $uid;
  47 + $param['client_secret'] = Sign::getSign($param);
  48 +
  49 + return Yohobuy::get(Yohobuy::API_URL, $param);
  50 + }
  51 +
  52 + /**
  53 + * 个人中心页面优选新品数据
  54 + *
  55 + * @param int $yh_channel 频道,1代表男生,2代表女生,3代表潮童,4代表创意生活
  56 + * @return array 接口返回的数据
  57 + */
  58 + public static function preference($yh_channel)
  59 + {
  60 + $param = Yohobuy::param();
  61 + $param['method'] = 'app.home.preference';
  62 + $param['yh_channel'] = $yh_channel;
  63 + $param['client_secret'] = Sign::getSign($param);
  64 +
  65 + return Yohobuy::get(Yohobuy::API_URL, $param);
  66 + }
  67 +
  68 + /**
37 * 订单数据 69 * 订单数据
38 * 70 *
39 * @param int $uid 用户ID 71 * @param int $uid 用户ID
@@ -192,4 +224,37 @@ class UserData @@ -192,4 +224,37 @@ class UserData
192 return Yohobuy::get(Yohobuy::SERVICE_URL . 'suggest/api/v1/suggest/saveSuggest', $param); 224 return Yohobuy::get(Yohobuy::SERVICE_URL . 'suggest/api/v1/suggest/saveSuggest', $param);
193 } 225 }
194 226
  227 + /**
  228 + * 我的消息接口
  229 + *
  230 + * @param int $uid 用户ID
  231 + * @param int $page 获取第一页,默认是0
  232 + * @param int $size 获取数目,默认是10
  233 + * @return array 消息接口返回的数据
  234 + */
  235 + public static function messageData($uid, $page = 0, $size = 10)
  236 + {
  237 + $param = Yohobuy::param();
  238 + $param['uid'] = $uid;
  239 + $param['size'] = $size;
  240 + $param['page'] = $page;
  241 + $param['method'] = 'app.inbox.getlist';
  242 + $param['client_secret'] = Sign::getSign($param);
  243 +
  244 + return Yohobuy::get(Yohobuy::API_URL, $param);
  245 + }
  246 +
  247 + /**
  248 + * 在线客服接口
  249 + *
  250 + * @return array 消息接口返回的数据
  251 + */
  252 + public static function onlineServiceData()
  253 + {
  254 + $param = Yohobuy::param();
  255 + $param['client_secret'] = Sign::getSign($param);
  256 +
  257 + return Yohobuy::get(Yohobuy::SERVICE_URL . 'operations/api/v1/help/getCategory', $param);
  258 + }
  259 +
195 } 260 }
@@ -12,15 +12,15 @@ @@ -12,15 +12,15 @@
12 </div> 12 </div>
13 <div class="my-link clearfix"> 13 <div class="my-link clearfix">
14 <a class="link-item" href="/home"> 14 <a class="link-item" href="/home">
15 - 15 15 + {{product_favorite_total}}
16 <p>收藏的商品</p> 16 <p>收藏的商品</p>
17 </a> 17 </a>
18 <a class="link-item" href="/home"> 18 <a class="link-item" href="/home">
19 - 6 19 + {{brand_favorite_total}}
20 <p>收藏的品牌</p> 20 <p>收藏的品牌</p>
21 </a> 21 </a>
22 <a class="link-item" href="/home"> 22 <a class="link-item" href="/home">
23 - 8 23 + {{product_browse}}
24 <p>浏览记录</p> 24 <p>浏览记录</p>
25 </a> 25 </a>
26 </div> 26 </div>
@@ -57,19 +57,19 @@ @@ -57,19 +57,19 @@
57 <div class="list-item"> 57 <div class="list-item">
58 <span class="iconfont icon">&#xe620;</span> 58 <span class="iconfont icon">&#xe620;</span>
59 优惠券 59 优惠券
60 - <span class="iconfont num">6 &#xe604;</span> 60 + <span class="iconfont num">{{coupon_num}} &#xe604;</span>
61 </div> 61 </div>
62 <div class="list-item"> 62 <div class="list-item">
63 <span class="iconfont icon">&#xe620;</span> 63 <span class="iconfont icon">&#xe620;</span>
64 YOHO 64 YOHO
65 - <span class="iconfont num">8 &#xe604;</span> 65 + <span class="iconfont num">{{yoho_coin_num}} &#xe604;</span>
66 </div> 66 </div>
67 </div> 67 </div>
68 <div class="group-list"> 68 <div class="group-list">
69 <div class="list-item"> 69 <div class="list-item">
70 <span class="iconfont icon">&#xe620;</span> 70 <span class="iconfont icon">&#xe620;</span>
71 消息 71 消息
72 - <span class="iconfont num">3 &#xe604;</span> 72 + <span class="iconfont num">{{inbox_total}} &#xe604;</span>
73 </div> 73 </div>
74 </div> 74 </div>
75 <div class="group-list"> 75 <div class="group-list">
@@ -22,18 +22,24 @@ class HomeController extends AbstractAction @@ -22,18 +22,24 @@ class HomeController extends AbstractAction
22 { 22 {
23 // 设置网站标题 23 // 设置网站标题
24 $this->setTitle('个人中心'); 24 $this->setTitle('个人中心');
  25 + $this->setNavHeader('个人中心', true, SITE_MAIN);
25 26
26 // $uid = $this->getUid(); 27 // $uid = $this->getUid();
27 $uid = 967016; 28 $uid = 967016;
28 $data = \Index\UserModel::getUserProfileData($uid); 29 $data = \Index\UserModel::getUserProfileData($uid);
  30 + $data += \Index\UserModel::getInfoNumData($uid);
  31 +
  32 + // 优选新品数据
  33 + $channel = Helpers::getChannelByCookie();
  34 + $data['recommendForYou'] = \Index\UserModel::getPreferenceData($channel);
  35 +// print_r($data);
29 36
30 - // print_r($data);  
31 $data['homeHeader'] = array( 37 $data['homeHeader'] = array(
32 'myHomePage' => true, 38 'myHomePage' => true,
33 'searchUrl' => Helpers::url('/search', null, 'search') 39 'searchUrl' => Helpers::url('/search', null, 'search')
34 ); 40 );
35 41
36 - $data['recommendForYou'] = array( 42 + /*$data['recommendForYou'] = array(
37 'recommendList' => array( 43 'recommendList' => array(
38 array( 44 array(
39 'img' => '', 45 'img' => '',
@@ -81,7 +87,7 @@ class HomeController extends AbstractAction @@ -81,7 +87,7 @@ class HomeController extends AbstractAction
81 'oldPrice' => '876.44' 87 'oldPrice' => '876.44'
82 ) 88 )
83 ) 89 )
84 - ); 90 + );*/
85 $data['myIndexPage'] = true; 91 $data['myIndexPage'] = true;
86 $data['pageFooter'] = true; 92 $data['pageFooter'] = true;
87 93
@@ -180,13 +186,12 @@ class HomeController extends AbstractAction @@ -180,13 +186,12 @@ class HomeController extends AbstractAction
180 public function currencyAction() 186 public function currencyAction()
181 { 187 {
182 // $uid = $this->getUid(); 188 // $uid = $this->getUid();
  189 + $this->setNavHeader('YOHO币', true, false);
183 190
184 $uid = 967016; 191 $uid = 967016;
185 - $favBrands = \Index\UserModel::getYohoCoinData($uid); 192 + $currency = \Index\UserModel::getYohoCoinData($uid);
186 193
187 - print_r($favBrands);  
188 -  
189 - $this->_view->display('currency', array('yohoCoin' => array('coinNum' => 0))); 194 + $this->_view->display('currency', $currency);
190 } 195 }
191 196
192 /** 197 /**
@@ -207,6 +212,22 @@ class HomeController extends AbstractAction @@ -207,6 +212,22 @@ class HomeController extends AbstractAction
207 } 212 }
208 213
209 /** 214 /**
  215 + * 我的消息
  216 + */
  217 + public function messageAction()
  218 + {
  219 + // $uid = $this->getUid();
  220 + $page = $this->get('page', 0);
  221 + $size = $this->get('size', 10);
  222 +
  223 + $uid = 967016;
  224 + $messages = \Index\UserModel::getMessageData($uid, $page, $size);
  225 +
  226 + print_r($messages);
  227 +
  228 + }
  229 +
  230 + /**
210 * 地址管理 231 * 地址管理
211 */ 232 */
212 public function addressAction() 233 public function addressAction()
@@ -219,6 +240,16 @@ class HomeController extends AbstractAction @@ -219,6 +240,16 @@ class HomeController extends AbstractAction
219 } 240 }
220 241
221 /** 242 /**
  243 + * 在线客服
  244 + */
  245 + public function onlineServiceAction()
  246 + {
  247 + $service = \Index\UserModel::getOnlineServiceData();
  248 +
  249 + print_r($service);
  250 + }
  251 +
  252 + /**
222 * 我的逛 253 * 我的逛
223 */ 254 */
224 public function myGuangAction() 255 public function myGuangAction()
@@ -3,6 +3,7 @@ @@ -3,6 +3,7 @@
3 namespace Index; 3 namespace Index;
4 4
5 use LibModels\Wap\Home\UserData; 5 use LibModels\Wap\Home\UserData;
  6 +use Plugin\Helpers;
6 use Plugin\Images; 7 use Plugin\Images;
7 8
8 /** 9 /**
@@ -32,8 +33,55 @@ class UserModel @@ -32,8 +33,55 @@ class UserModel
32 // 处理个人详情数据 33 // 处理个人详情数据
33 if (isset($userData['data']) && !empty($userData['data'])) { 34 if (isset($userData['data']) && !empty($userData['data'])) {
34 $result = $userData['data']; 35 $result = $userData['data'];
  36 + $result['head_ico'] = Images::getImageUrl($result['head_ico'], 128, 128);
  37 + }
35 38
36 - $result['head_ico'] = Images::getImageUrl($result['head_ico'], 150, 150); 39 + return $result;
  40 + }
  41 +
  42 + /**
  43 + * 处理个人中心页面优惠券,收藏的商品等的数目数据
  44 + *
  45 + * @param int $uid 用户ID
  46 + * @return array|mixed 处理之后的个人中心页面优惠券,收藏的商品等的数目数据
  47 + */
  48 + public static function getInfoNumData($uid)
  49 + {
  50 + $result = array();
  51 +
  52 + // 调用接口获取个人中心页面优惠券,收藏的商品等的数目数据
  53 + $infoNumData = UserData::infoNum($uid);
  54 +
  55 + // 处理个人中心页面优惠券,收藏的商品等的数目数据
  56 + if (isset($infoNumData['data']) && !empty($infoNumData['data'])) {
  57 + // 把没有数据的条目设置为0
  58 + foreach ($infoNumData['data'] as &$val) {
  59 + empty($val) && $val = 0;
  60 + }
  61 + $result = $infoNumData['data'];
  62 + }
  63 +
  64 + return $result;
  65 + }
  66 +
  67 + /**
  68 + * 处理个人中心页面优选新品数据
  69 + *
  70 + * @param int $yh_channel 频道,1代表男生,2代表女生,3代表潮童,4代表创意生活
  71 + * @return array|mixed 处理之后的个人中心页面优选新品数据
  72 + */
  73 + public static function getPreferenceData($yh_channel)
  74 + {
  75 + $result = array();
  76 +
  77 + // 调用接口获取个人中心页面优选新品数据
  78 + $preferenceData = UserData::preference($yh_channel);
  79 +
  80 + // 处理个人中心页面优选新品数据
  81 + if (isset($preferenceData['data']) && !empty($preferenceData['data'])) {
  82 + foreach ($preferenceData['data'] as $val) {
  83 + $result['recommendList'][] = Helpers::formatProduct($val, false);
  84 + }
37 } 85 }
38 86
39 return $result; 87 return $result;
@@ -56,8 +104,38 @@ class UserModel @@ -56,8 +104,38 @@ class UserModel
56 // 处理用户订单数据 104 // 处理用户订单数据
57 if (isset($orderData['data']) && !empty($orderData['data'])) { 105 if (isset($orderData['data']) && !empty($orderData['data'])) {
58 $result = $orderData['data']; 106 $result = $orderData['data'];
  107 +
  108 + $oneOrder = array();
  109 + foreach ($orderData['data']['order_list'] as $val) {
  110 + $oneOrder = array();
  111 + $oneOrder['orderNum'] = $val['order_code'];
  112 + $oneOrder['tradingStatus'] = $val['status_str'];
  113 + $oneOrder['count'] = count($val['order_goods']);
  114 + $oneOrder['sumCost'] = $val['amount'];
  115 + $oneOrder['unpaid'] = !$val['payment'];
  116 +
  117 + // 处理订单商品
  118 + $oneGoods = array();
  119 + foreach ($val['order_goods'] as $goods) {
  120 + $oneGoods = array();
  121 + $oneGoods['id'] = 1;
  122 + $oneGoods['thumb'] = Helpers::getImageUrl($goods['goods_image'], 60, 80);
  123 + $oneGoods['name'] = $val['product_name'];
  124 + $oneGoods['color'] = $val['color_name'];
  125 + $oneGoods['size'] = $val['size_name'];
  126 + $oneGoods['size_name'] = $val['size_name'];
  127 + $oneGoods['price'] = $val['goods_price'];
  128 + $oneGoods['count'] = $val['buy_number'];
  129 +
  130 + $result['goods'][] = $oneGoods;
  131 + }
  132 +
  133 + $result['orders'][] = $oneOrder;
59 } 134 }
60 135
  136 + }
  137 + print_r($result);
  138 +
61 return $result; 139 return $result;
62 } 140 }
63 141
@@ -119,7 +197,7 @@ class UserModel @@ -119,7 +197,7 @@ class UserModel
119 197
120 // 处理YOHO币数据 198 // 处理YOHO币数据
121 if (isset($yohoCoin['data']) && !empty($yohoCoin['data'])) { 199 if (isset($yohoCoin['data']) && !empty($yohoCoin['data'])) {
122 - $result = $yohoCoin['data']; 200 + $result['yohoCoin']['coinNum'] = $yohoCoin['data']['total'];
123 } 201 }
124 202
125 return $result; 203 return $result;
@@ -201,10 +279,49 @@ class UserModel @@ -201,10 +279,49 @@ class UserModel
201 */ 279 */
202 public static function saveSuggestData($uid, $content, $suggest_type) 280 public static function saveSuggestData($uid, $content, $suggest_type)
203 { 281 {
204 - $result = array();  
205 -  
206 // 调用接口保存意见反馈数据 282 // 调用接口保存意见反馈数据
207 return UserData::savesuggestData($uid, $content, $suggest_type); 283 return UserData::savesuggestData($uid, $content, $suggest_type);
208 } 284 }
209 285
  286 + /**
  287 + * 处理我的消息数据
  288 + *
  289 + * @param int $uid 用户ID
  290 + * @param int $page 获取第一页,默认是0
  291 + * @param int $size 获取数目,默认是10
  292 + * @return array|mixed 处理之后的返回
  293 + */
  294 + public static function getMessageData($uid, $page, $size)
  295 + {
  296 + $result = array();
  297 +
  298 + $messageData = UserData::messageData($uid, $page, $size);
  299 +
  300 + // 处理我的消息数据
  301 + if (isset($messageData['data']) && !empty($messageData['data'])) {
  302 + $result = $messageData['data'];
  303 + }
  304 +
  305 + return $result;
  306 + }
  307 +
  308 + /**
  309 + * 处理在线客服数据
  310 + *
  311 + * @return array|mixed 处理之后的返回
  312 + */
  313 + public static function getOnlineServiceData()
  314 + {
  315 + $result = array();
  316 +
  317 + $serviceData = UserData::onlineServiceData();
  318 +
  319 + // 处理在线客服数据
  320 + if (isset($serviceData['data']) && !empty($serviceData['data'])) {
  321 + $result = $serviceData['data'];
  322 + }
  323 +
  324 + return $result;
  325 + }
  326 +
210 } 327 }