Home.php 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399
  1. <?php
  2. // +—————————————————————————————————————————————————————————————————————
  3. // | Created by Yunbao
  4. // +—————————————————————————————————————————————————————————————————————
  5. // | Copyright (c) 2013~2022 http://www.yunbaokj.com All rights reserved.
  6. // +—————————————————————————————————————————————————————————————————————
  7. // | Author: https://gitee.com/yunbaokeji
  8. // +—————————————————————————————————————————————————————————————————————
  9. // | Date: 2022-02-17
  10. // +—————————————————————————————————————————————————————————————————————
  11. /**
  12. * 首页
  13. */
  14. class Api_Home extends PhalApi_Api {
  15. public function getRules() {
  16. return array(
  17. 'getConfig' => array(
  18. 'source'=>array('name' => 'source', 'type' => 'string','default'=>'app','desc' => '请求来源,app/wxmini'),
  19. 'qiniu_sign' => array('name' => 'qiniu_sign', 'type' => 'string','desc' => '七牛sign'),
  20. ),
  21. 'getHot' => array(
  22. 'uid' => array('name' => 'uid', 'type' => 'int', 'desc' => '用户ID'),
  23. 'p' => array('name' => 'p', 'type' => 'int', 'default'=>'1' ,'desc' => '页数'),
  24. ),
  25. 'search' => array(
  26. 'uid' => array('name' => 'uid', 'type' => 'int', 'require' => true, 'min'=>1 ,'desc' => '用户ID'),
  27. 'key' => array('name' => 'key', 'type' => 'string', 'default'=>'' ,'desc' => '用户ID'),
  28. 'p' => array('name' => 'p', 'type' => 'int', 'default'=>'1' ,'desc' => '页数'),
  29. ),
  30. 'getClassLive'=>array(
  31. 'liveclassid' => array('name' => 'liveclassid', 'type' => 'int', 'default'=>'0' ,'desc' => '直播分类ID'),
  32. 'p' => array('name' => 'p', 'type' => 'int', 'default'=>'1' ,'desc' => '页数'),
  33. ),
  34. );
  35. }
  36. /**
  37. * 配置信息
  38. * @desc 用于获取配置信息
  39. * @return int code 操作码,0表示成功
  40. * @return array info
  41. * @return array info[0] 配置信息
  42. * @return object info[0].guide 引导页
  43. * @return string info[0].guide.switch 开关,0关1开
  44. * @return string info[0].guide.type 类型,0图片1视频
  45. * @return string info[0].guide.time 图片时间
  46. * @return array info[0].guide.list
  47. * @return string info[0].guide.list[].thumb 图片、视频链接
  48. * @return string info[0].guide.list[].href 页面链接
  49. * @return string msg 提示信息
  50. */
  51. public function getConfig() {
  52. $rs = array('code' => 0, 'msg' => '', 'info' => array());
  53. $source=checkNull($this->source);
  54. $qiniu_sign=$this->qiniu_sign;
  55. $info = getConfigPub();
  56. unset($info['site_url']);
  57. unset($info['site_seo_title']);
  58. unset($info['site_seo_keywords']);
  59. unset($info['site_seo_description']);
  60. unset($info['site_icp']);
  61. unset($info['site_gwa']);
  62. unset($info['site_admin_email']);
  63. unset($info['site_analytics']);
  64. unset($info['copyright']);
  65. unset($info['qr_url']);
  66. unset($info['sina_icon']);
  67. unset($info['sina_title']);
  68. unset($info['sina_desc']);
  69. unset($info['sina_url']);
  70. unset($info['qq_icon']);
  71. unset($info['qq_title']);
  72. unset($info['qq_desc']);
  73. unset($info['qq_url']);
  74. unset($info['payment_des']);
  75. file_put_contents("qiniusign.txt", json_encode($qiniu_sign));
  76. $info_pri = getConfigPri();
  77. $list = getLiveClass();
  78. unset($info['voicelive_name']);
  79. unset($info['voicelive_icon']);
  80. $level= getLevelList();
  81. foreach($level as $k=>$v){
  82. unset($v['level_up']);
  83. unset($v['addtime']);
  84. unset($v['id']);
  85. unset($v['levelname']);
  86. $level[$k]=$v;
  87. }
  88. $levelanchor= getLevelAnchorList();
  89. foreach($levelanchor as $k=>$v){
  90. unset($v['level_up']);
  91. unset($v['addtime']);
  92. unset($v['id']);
  93. unset($v['levelname']);
  94. $levelanchor[$k]=$v;
  95. }
  96. $info['liveclass']=$list;
  97. $info['level']=$level;
  98. $info['levelanchor']=$levelanchor;
  99. /* 引导页 */
  100. $domain = new Domain_Guide();
  101. $guide_info = $domain->getGuide();
  102. $info['guide']=$guide_info;
  103. /** 敏感词集合*/
  104. $dirtyarr=array();
  105. if($info_pri['sensitive_words']){
  106. $dirtyarr=explode(',',$info_pri['sensitive_words']);
  107. }
  108. $info['sensitive_words']=$dirtyarr;
  109. $info['shopexplain_url']=$info['site']."/portal/page/index?id=38";
  110. $info['stricker_url']=$info['site']."/portal/page/index?id=39";
  111. $info['login_private_url']=get_upload_path($info['login_private_url']);
  112. $info['login_service_url']=get_upload_path($info['login_service_url']);
  113. $rs['info'][0] = $info;
  114. return $rs;
  115. }
  116. /**
  117. * 登录方式开关信息
  118. * @desc 用于获取登录方式开关信息
  119. * @return int code 操作码,0表示成功
  120. * @return array info
  121. * @return array info[0].login_type 开启的登录方式
  122. * @return string info[0].login_type[][0] 登录方式标识
  123. * @return string msg 提示信息
  124. */
  125. public function getLogin() {
  126. $rs = array('code' => 0, 'msg' => '', 'info' => array());
  127. $info = getConfigPub();
  128. //登录弹框那个地方
  129. $login_alert=array(
  130. 'title'=>$info['login_alert_title'],
  131. 'content'=>$info['login_alert_content'],
  132. 'login_title'=>$info['login_clause_title'],
  133. 'message'=>array(
  134. array(
  135. 'title'=>$info['login_service_title'],
  136. 'url'=>get_upload_path($info['login_service_url']),
  137. ),
  138. array(
  139. 'title'=>$info['login_private_title'],
  140. 'url'=>get_upload_path($info['login_private_url']),
  141. ),
  142. )
  143. );
  144. $login_type=$info['login_type'];
  145. $rs['info'][0]['login_alert'] = $login_alert;
  146. $rs['info'][0]['login_type'] = $login_type;
  147. return $rs;
  148. }
  149. /**
  150. * 获取热门主播
  151. * @desc 用于获取首页热门主播
  152. * @return int code 操作码,0表示成功
  153. * @return array info
  154. * @return array info[0]['slide']
  155. * @return string info[0]['slide'][].slide_pic 图片
  156. * @return string info[0]['slide'][].slide_url 链接
  157. * @return array info[0]['list'] 热门直播列表
  158. * @return string info[0]['list'][].uid 主播id
  159. * @return string info[0]['list'][].avatar 主播头像
  160. * @return string info[0]['list'][].avatar_thumb 头像缩略图
  161. * @return string info[0]['list'][].user_nicename 直播昵称
  162. * @return string info[0]['list'][].title 直播标题
  163. * @return string info[0]['list'][].city 主播位置
  164. * @return string info[0]['list'][].stream 流名
  165. * @return string info[0]['list'][].pull 播流地址
  166. * @return string info[0]['list'][].nums 人数
  167. * @return string info[0]['list'][].thumb 直播封面
  168. * @return string info[0]['list'][].level_anchor 主播等级
  169. * @return string info[0]['list'][].type 直播类型
  170. * @return string info[0]['list'][].goodnum 靓号
  171. * @return string msg 提示信息
  172. */
  173. public function getHot() {
  174. $rs = array('code' => 0, 'msg' => '', 'info' => array());
  175. $uid=checkNull($this->uid);
  176. $p=checkNull($this->p);
  177. $domain = new Domain_Home();
  178. $key1='getSlide';
  179. $slide=getcaches($key1);
  180. if(!$slide){
  181. $where="status='1' and slide_id='2' ";
  182. $slide = $domain->getSlide($where);
  183. setcaches($key1,$slide);
  184. }
  185. //获取热门主播
  186. $key2="getHot_".$p;
  187. if(!$uid){
  188. $uid=-9999;
  189. }
  190. if($uid<0){
  191. $key2="getHot_".$uid.'_'.$p;
  192. }
  193. $list=getcaches($key2);
  194. if(!$list){
  195. $list = $domain->getHot($p);
  196. setcaches($key2,$list,2);
  197. }
  198. $rs['info'][0]['slide'] = $slide;
  199. $rs['info'][0]['list'] = $list;
  200. return $rs;
  201. }
  202. /**
  203. * 搜索
  204. * @desc 用于首页搜索会员
  205. * @return int code 操作码,0表示成功
  206. * @return array info 会员列表
  207. * @return string info[].id 用户ID
  208. * @return string info[].user_nicename 用户昵称
  209. * @return string info[].avatar 头像
  210. * @return string info[].sex 性别
  211. * @return string info[].signature 签名
  212. * @return string info[].level 等级
  213. * @return string info[].isattention 是否关注,0未关注,1已关注
  214. * @return string msg 提示信息
  215. */
  216. public function search() {
  217. $rs = array('code' => 0, 'msg' => '', 'info' => array());
  218. $uid=checkNull($this->uid);
  219. $key=checkNull($this->key);
  220. $p=checkNull($this->p);
  221. if($key==''){
  222. $rs['code'] = 1001;
  223. $rs['msg'] = "请填写关键词";
  224. return $rs;
  225. }
  226. if(!$p){
  227. $p=1;
  228. }
  229. $domain = new Domain_Home();
  230. $info = $domain->search($uid,$key,$p);
  231. $rs['info'] = $info;
  232. return $rs;
  233. }
  234. /**
  235. * 获取分类下的直播
  236. * @desc 获取分类下的直播
  237. * @return int code 操作码 0表示成功
  238. * @return string msg 提示信息
  239. * @return array info
  240. * @return string info[].uid 主播id
  241. * @return string info[].avatar 主播头像
  242. * @return string info[].avatar_thumb 头像缩略图
  243. * @return string info[].user_nicename 直播昵称
  244. * @return string info[].title 直播标题
  245. * @return string info[].city 主播位置
  246. * @return string info[].stream 流名
  247. * @return string info[].pull 播流地址
  248. * @return string info[].nums 人数
  249. * @return string info[].distance 距离
  250. * @return string info[].thumb 直播封面
  251. * @return string info[].level_anchor 主播等级
  252. * @return string info[].type 直播类型
  253. * @return string info[].goodnum 靓号
  254. **/
  255. public function getClassLive(){
  256. $rs = array('code' => 0, 'msg' => '', 'info' => array());
  257. $liveclassid=checkNull($this->liveclassid);
  258. $p=checkNull($this->p);
  259. if(!$liveclassid){
  260. return $rs;
  261. }
  262. $domain=new Domain_Home();
  263. $res=$domain->getClassLive($liveclassid,$p);
  264. $rs['info']=$res;
  265. return $rs;
  266. }
  267. /**
  268. * 获取过滤词汇
  269. * @desc 用于获取聊天过滤词
  270. * @return int code 操作码,0表示成功
  271. * @return array info
  272. * @return array info[0] 配置信息
  273. * @return string msg 提示信息
  274. */
  275. public function getFilterField() {
  276. $rs = array('code' => 0, 'msg' => '', 'info' => array());
  277. $sensitive_words=getcaches('sensitive_words');
  278. if($sensitive_words){
  279. $rs['info']=$sensitive_words;
  280. }else{
  281. $configpri = getConfigPri();
  282. if($configpri['sensitive_words']){
  283. $rs['info'] =explode(',',$configpri['sensitive_words']);
  284. }
  285. setcaches("sensitive_words",$rs['info']);
  286. }
  287. return $rs;
  288. }
  289. }