Online.php
2.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<?php
namespace Home;
use LibModels\Wap\Home\OnlineData;
use Plugin\Helpers;
/**
* 在线客服相关数据处理
*/
class OnlineModel
{
/*
* 获取在线帮助分类
* $clientType客户端类型
*/
public static function getOnlineServiceInfo($clientType = 'iphone')
{
//调用接口获取数据
$res = OnlineData::getOnlineServiceInfo($clientType);
$question = array();
$tab = array();
if (isset($res['data'])) {
$cateInfo = $res['data'];
foreach ($cateInfo as $key => $value) {
//强制截成3个tab
if ($key > 2) {
break;
}
$tab[$key]['tabid'] = 'tab' . $value['id'];
$tab[$key]['tabname'] = $value['category_name'];
$tab[$key]['iscut'] = true;
$tab[$key]['current'] = (!$key) ? TRUE : FALSE;
$question[$key]['name'] = 'tab' . $value['id'];
$question[$key]['current'] = (!$key) ? TRUE : FALSE;
$sub = $value['sub'];
$qTmp = array();
if ($sub) {
foreach ($sub as $sk => $sv) {
$qTmp[$sk]['title'] = $sv['category_name'];
$qTmp[$sk]['link'] = Helpers::url('/home/onlineservicedetail', array('cateInfo' => $sv['id'] . '_' . $sv['category_name']));
}
}
$question[$key]['list'] = $qTmp;
}
$question[0]['current'] = true;
$tab[count($tab) - 1]['iscut'] = false;
}
//处理返回信息
$result = array(
'header' => array('title' => '在线客服'),
'tab' => $tab,
'question' => $question
);
return $result;
}
/*
* 加载分类下的问题和解决方法
* cateId问题分类ID
* clientType客户端
*/
public static function getOnlineServiceDetail($cateId, $clinetType = 'iphone')
{
$result = array();
if (!$cateId) {
return $result;
}
$res = OnlineData::getOnlineServiceDetail($cateId, $clinetType);
if (isset($res['code']) && $res['code'] === 200) {
$questionInfo = $res['data'];
$list = array();
foreach ($questionInfo as $qk => $qv) {
$list[$qk]['q'] = $qv['title'];
$list[$qk]['a'] = $qv['content'];
}
!empty($list) && $result['list'] = $list;
}
return $result;
}
}