Authored by Rock Zhang

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 OnlineData
  12 + * @package LibModels/Wap/Home
  13 + * @copyright yoho.inc
  14 + * @version 1.0 (2015-11-13)
  15 + * @author xiaowei
  16 + */
  17 +class OnlineData
  18 +{
  19 + const ONLINE_URI = 'operations/api/v1/help/';
  20 +
  21 + //获取帮助列表(分类)
  22 + public static function getOnlineServiceInfo($clientType='iphone')
  23 + {
  24 + return Yohobuy::get(Yohobuy::SERVICE_URL .self::ONLINE_URI.'getCategory', array('client_type'=>$clientType));
  25 + }
  26 +
  27 + //获取问题详情
  28 + public static function getOnlineServiceDetail($cateId, $clientType = 'iphone')
  29 + {
  30 + return Yohobuy::get(Yohobuy::SERVICE_URL .self::ONLINE_URI.'getHelp', array('category_id'=>$cateId,'client_type'=>$clientType));
  31 + }
  32 +
  33 +}
@@ -241,20 +241,23 @@ class HomeController extends AbstractAction @@ -241,20 +241,23 @@ class HomeController extends AbstractAction
241 )); 241 ));
242 } 242 }
243 243
244 - /**  
245 - * 在线客服  
246 - */ 244 + //在线客服
247 public function onlineServiceAction() 245 public function onlineServiceAction()
248 { 246 {
249 - $service = \Index\UserModel::getOnlineServiceData();  
250 -  
251 - print_r($service); 247 + $service = home\OnlineModel::getOnlineServiceInfo();
  248 + $this->_view->display('online_service', $service);
  249 + }
252 250
253 - $this->_view->display('online_service', array(  
254 - 'onlineServicePage' => true,  
255 - 'pageFooter' => true,  
256 - 'service' => $service  
257 - )); 251 + //在线客服-具体详情
  252 + public function onlineServiceDetailAction()
  253 + {
  254 + $service = array();
  255 + $cateId = $this->get('cateId', 0);
  256 + if ($cateId > 0)
  257 + {
  258 + $service = home\OnlineModel::getOnlineServiceDetail($cateId);
  259 + }
  260 + $this->_view->display('online_service_detail', $service);
258 } 261 }
259 262
260 /** 263 /**
  1 +<?php
  2 +
  3 +namespace home;
  4 +
  5 +use LibModels\Wap\Home\OnlineData;
  6 +use Action\AbstractAction;
  7 +use Plugin\Helpers;
  8 +
  9 +/**
  10 + * 在线客服相关数据处理
  11 + */
  12 +class OnlineModel
  13 +{
  14 +
  15 + //获取在线帮助分类
  16 + public static function getOnlineServiceInfo($clientType = 'iphone')
  17 + {
  18 + //调用接口获取数据
  19 + $res = OnlineData::getOnlineServiceInfo($clientType);
  20 + $cateInfo = $res['data'];
  21 + $question = array();
  22 + $tab = array();
  23 + if ($cateInfo)
  24 + {
  25 + foreach ($cateInfo as $key => $value)
  26 + {
  27 + //强制截成3个tab
  28 + if ($key > 2)
  29 + {
  30 + break;
  31 + }
  32 + $tab[$key]['tabid'] = 'tab' . $value['id'];
  33 + $tab[$key]['tabname'] = $value['category_name'];
  34 + $tab[$key]['iscut'] = true;
  35 + $tab[$key]['current'] = (!$key) ? TRUE : FALSE;
  36 + $question[$key]['name'] = 'tab' . $value['id'];
  37 + $question[$key]['current'] = (!$key) ? TRUE : FALSE;
  38 + $sub = $value['sub'];
  39 + $qTmp = array();
  40 + if ($sub)
  41 + {
  42 + foreach ($sub as $sk => $sv)
  43 + {
  44 + $qTmp[$sk]['title'] = $sv['category_name'];
  45 + $qTmp[$sk]['link'] = '/home/onlineservicedetail?cateId=' . $sv['id'];
  46 + }
  47 + }
  48 + $question[$key]['list'] = $qTmp;
  49 + }
  50 + $question[0]['current'] = true;
  51 + $tab[count($tab) - 1]['iscut'] = false;
  52 + }
  53 + //处理返回信息
  54 + $result = array(
  55 + 'header' => array('title' => '在线客服'),
  56 + 'tab' => $tab,
  57 + 'question' => $question
  58 + );
  59 +
  60 + return $result;
  61 + }
  62 +
  63 + //加载分类下的问题和解决方法
  64 + public static function getOnlineServiceDetail($cateId, $clinetType = 'iphone')
  65 + {
  66 + $result = array();
  67 + if (!$cateId)
  68 + {
  69 + return $result;
  70 + }
  71 + $res = OnlineData::getOnlineServiceDetail($cateId, $clinetType);
  72 + $questionInfo = $res['data'];
  73 + if ($questionInfo)
  74 + {
  75 + $list = array();
  76 + if ($questionInfo)
  77 + {
  78 + foreach ($questionInfo as $qk => $qv)
  79 + {
  80 + $list[$qk]['q'] = $qv['title'];
  81 + $list[$qk]['a'] = $qv['content'];
  82 + }
  83 + }
  84 + //处理返回信息
  85 + $result = array(
  86 + 'header' => array('title' => '在线客服'),
  87 + 'list' => $list
  88 + );
  89 + }
  90 + return $result;
  91 + }
  92 +
  93 +}