Authored by hf

code review by hf: format help center code

@@ -22,7 +22,7 @@ class HelpData @@ -22,7 +22,7 @@ class HelpData
22 $param['method'] = 'app.help.li'; 22 $param['method'] = 'app.help.li';
23 $param['client_secret'] = Sign::getSign($param); 23 $param['client_secret'] = Sign::getSign($param);
24 24
25 - return Yohobuy::post(Yohobuy::API_URL, $param, $param); 25 + return Yohobuy::post(Yohobuy::API_URL, $param);
26 } 26 }
27 27
28 28
@@ -867,7 +867,8 @@ class HomeController extends AbstractAction @@ -867,7 +867,8 @@ class HomeController extends AbstractAction
867 /** 867 /**
868 * 帮助中心列表详细信息 868 * 帮助中心列表详细信息
869 */ 869 */
870 - public function helpDetailAction() { 870 + public function helpDetailAction()
  871 + {
871 $caption = $this->get('caption', '帮助中心'); 872 $caption = $this->get('caption', '帮助中心');
872 $code = $this->get('code', 0); 873 $code = $this->get('code', 0);
873 if (empty($code)) { 874 if (empty($code)) {
@@ -877,9 +878,8 @@ class HomeController extends AbstractAction @@ -877,9 +878,8 @@ class HomeController extends AbstractAction
877 $this->setTitle($caption); 878 $this->setTitle($caption);
878 $this->setNavHeader($caption); 879 $this->setNavHeader($caption);
879 880
880 - $service = Home\HelpModel::serviceDetail($code);  
881 $this->_view->display('helpDetail', array( 881 $this->_view->display('helpDetail', array(
882 - 'iHelp' => $service, 882 + 'iHelp' => Home\HelpModel::serviceDetail($code),
883 )); 883 ));
884 } 884 }
885 885
@@ -8,36 +8,37 @@ use Plugin\Helpers; @@ -8,36 +8,37 @@ use Plugin\Helpers;
8 /** 8 /**
9 * 帮助中心相关数据处理 9 * 帮助中心相关数据处理
10 */ 10 */
11 -  
12 -class HelpModel { 11 +class HelpModel
  12 +{
13 /* 13 /*
14 * 获取帮助中心列表 14 * 获取帮助中心列表
15 */ 15 */
16 -  
17 - public static function serviceInfo() {  
18 - //调用接口获取数据  
19 - $res = json_decode(HelpData::serviceInfo(), TRUE);  
20 - $cateInfo = $res['data']; 16 + public static function serviceInfo()
  17 + {
21 $iHelp = array(); 18 $iHelp = array();
22 - $list = array();  
23 - if ($cateInfo) {  
24 - foreach ($cateInfo as $key => $value) { 19 +
  20 + $cateInfo = HelpData::serviceInfo();
  21 + if (!empty($cateInfo['data'])) {
  22 + foreach ($cateInfo['data'] as $key => $value) {
25 $iHelp[$key]['name'] = $value['caption']; 23 $iHelp[$key]['name'] = $value['caption'];
26 $iHelp[$key]['code'] = $value['code']; 24 $iHelp[$key]['code'] = $value['code'];
27 - $iHelp[$key]['url'] = Helpers::url('/home/helpDetail', array('code' => $value['code'], 'caption' => $value['caption']) ); 25 + $iHelp[$key]['url'] = Helpers::url('/home/helpDetail', array('code' => $value['code'], 'caption' => $value['caption']));
28 } 26 }
29 } 27 }
  28 +
30 return $iHelp; 29 return $iHelp;
31 } 30 }
32 - 31 +
33 /* 32 /*
34 * 获取帮助中心详细内容 33 * 获取帮助中心详细内容
35 */ 34 */
36 - public static function serviceDetail($code) { 35 +
  36 + public static function serviceDetail($code)
  37 + {
37 $res = HelpData::serviceDetail($code); 38 $res = HelpData::serviceDetail($code);
38 if (!empty($res)) { 39 if (!empty($res)) {
39 - if (false !== ($part = strstr($res,'<div class="deal_main">'))) {  
40 - $res = strstr($part,'</body>',TRUE); 40 + if (false !== ($part = strstr($res, '<body>'))) {
  41 + $res = strstr($part, '</body>', true);
41 } 42 }
42 } 43 }
43 return $res; 44 return $res;
@@ -212,7 +212,7 @@ class DetailModel @@ -212,7 +212,7 @@ class DetailModel
212 212
213 // 统计每个尺码对应的各个颜色的库存量 213 // 统计每个尺码对应的各个颜色的库存量
214 foreach ($sizeList as &$sizeArr) { 214 foreach ($sizeList as &$sizeArr) {
215 - $sizeArr['colorNumStr'] = implode('/', array_values($colorStorageGroup[ $sizeArr['sizeName'] ]) ); 215 + $sizeArr['colorNumStr'] = implode('/', array_values($colorStorageGroup[ $sizeArr['name'] ]) );
216 } 216 }
217 217
218 // 商品库存总数 218 // 商品库存总数