Home.php 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  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-04-30
  10. // +—————————————————————————————————————————————————————————————————————
  11. class Api_Home extends PhalApi_Api {
  12. public function getRules() {
  13. return array(
  14. 'search' => array(
  15. 'uid' => array('name' => 'uid', 'type' => 'int', 'desc' => '用户ID'),
  16. 'key' => array('name' => 'key', 'type' => 'string', 'default'=>'' ,'desc' => '用户ID'),
  17. 'p' => array('name' => 'p', 'type' => 'int', 'default'=>'1' ,'desc' => '页数'),
  18. ),
  19. 'videoSearch' => array(
  20. 'uid' => array('name' => 'uid', 'type' => 'int', 'desc' => '用户ID'),
  21. 'key' => array('name' => 'key', 'type' => 'string', 'default'=>'' ,'desc' => '关键词'),
  22. 'p' => array('name' => 'p', 'type' => 'int', 'default'=>'1' ,'desc' => '页数'),
  23. ),
  24. );
  25. }
  26. /**
  27. * 获取配置信息
  28. * @desc 用于获取配置信息
  29. * @return int code 操作码,0表示成功
  30. * @return array info
  31. * @return array info[0] 配置信息
  32. * @return string msg 提示信息
  33. */
  34. public function getConfig() {
  35. $rs = array('code' => 0, 'msg' => '', 'info' => array());
  36. $configpri = getConfigPri();
  37. $info = getConfigPub();
  38. $info['video_audit_switch']=$configpri['video_audit_switch']; //视频审核是否开启
  39. /* 引导页 */
  40. $domain = new Domain_Guide();
  41. $guide_info = $domain->getGuide();
  42. $info['guide']=$guide_info;
  43. $info['qiniu_domain']=$configpri['qiniu_protocol'].'://'.$configpri['qiniu_domain'].'/';//七牛云存储空间地址
  44. $rs['info'][0] = $info;
  45. return $rs;
  46. }
  47. /**
  48. * 登录方式开关信息
  49. * @desc 用于获取登录方式开关信息
  50. * @return int code 操作码,0表示成功
  51. * @return array info
  52. * @return array info[0].login_type 开启的登录方式
  53. * @return string info[0].login_type.login_qq qq登录,0表示关闭,1表示开启
  54. * @return string info[0].login_type.login_wx 微信登录,0表示关闭,1表示开启
  55. * @return array info[0].login_alert 登录弹窗信息
  56. * @return array info[0].login_alert['title'] 登录弹窗标题
  57. * @return array info[0].login_alert['content'] 登录弹窗协议内容
  58. * @return array info[0].login_alert['login_title'] 登录页底部提示信息
  59. * @return array info[0].login_alert['message'] 登录页信息
  60. * @return array info[0].login_alert['message'][]['title'] 登录页弹窗信息标题
  61. * @return array info[0].login_alert['message'][]['url'] 登录页弹窗信息链接
  62. * @return string msg 提示信息
  63. */
  64. public function getLogin() {
  65. $rs = array('code' => 0, 'msg' => '', 'info' => array());
  66. $info = getConfigPub();
  67. //登录弹框那个地方
  68. $login_alert=array(
  69. 'title'=>$info['login_alert_title'],
  70. 'content'=>$info['login_alert_content'],
  71. 'login_title'=>$info['login_clause_title'],
  72. 'message'=>array(
  73. array(
  74. 'title'=>$info['login_service_title'],
  75. 'url'=>get_upload_path($info['login_service_url']),
  76. ),
  77. array(
  78. 'title'=>$info['login_private_title'],
  79. 'url'=>get_upload_path($info['login_private_url']),
  80. ),
  81. )
  82. );
  83. $configpri=getConfigPri();
  84. $sendcode_type='0'; //获取短信验证码方式 0国内 1 国外【用于登录或忘记密码时是否选择国家代号】
  85. $typecode_switch=$configpri['code_switch'];
  86. if($typecode_switch==1){ //阿里云
  87. $aly_sendcode_type=$configpri['aly_sendcode_type'];
  88. if($aly_sendcode_type==2){ //国外
  89. $sendcode_type='1';
  90. }
  91. }
  92. $rs['info'][0]['login_alert'] = $login_alert;
  93. $rs['info'][0]['sendcode_type']=$sendcode_type;
  94. return $rs;
  95. }
  96. /**
  97. * 首页搜索会员
  98. * @desc 用于首页搜索会员
  99. * @return int code 操作码,0表示成功
  100. * @return array info 会员列表
  101. * @return string info[].id 用户ID
  102. * @return string info[].user_nicename 用户昵称
  103. * @return string info[].avatar 头像
  104. * @return string info[].sex 性别
  105. * @return string info[].signature 签名
  106. * @return string info[].level 等级
  107. * @return string info[].isattention 是否关注,0未关注,1已关注
  108. * @return string msg 提示信息
  109. */
  110. public function search() {
  111. $rs = array('code' => 0, 'msg' => '', 'info' => array());
  112. $isBlackUser=isBlackUser($this->uid);
  113. if($isBlackUser=='0'){
  114. $rs['code'] = 700;
  115. $rs['msg'] = '该账号已被禁用';
  116. return $rs;
  117. }
  118. $uid=checkNull($this->uid);
  119. $key=checkNull($this->key);
  120. $p=checkNull($this->p);
  121. if($key==''){
  122. $rs['code'] = 1001;
  123. $rs['msg'] = "请填写关键词";
  124. return $rs;
  125. }
  126. if(!$p){
  127. $p=1;
  128. }
  129. $domain = new Domain_Home();
  130. $info = $domain->search($uid,$key,$p);
  131. $rs['info'] = $info;
  132. return $rs;
  133. }
  134. /**
  135. * 视频搜索
  136. * @desc 视频搜索
  137. * @return int code 状态码 0表示成功
  138. * @return string msg 提示信息
  139. * @return array info 返回信息
  140. * @return
  141. */
  142. public function videoSearch(){
  143. $rs = array('code' => 0, 'msg' => '', 'info' => array());
  144. $isBlackUser=isBlackUser($this->uid);
  145. if($isBlackUser=='0'){
  146. $rs['code'] = 700;
  147. $rs['msg'] = '该账号已被禁用';
  148. return $rs;
  149. }
  150. $uid=checkNull($this->uid);
  151. $key=checkNull($this->key);
  152. $p=checkNull($this->p);
  153. if($key==''){
  154. $rs['code'] = 1001;
  155. $rs['msg'] = "请填写关键词";
  156. return $rs;
  157. }
  158. if(!$p){
  159. $p=1;
  160. }
  161. $key1='videoSearch'.'_'.$key.'_'.$p;
  162. $info=getcache($key1);
  163. if(!$info){
  164. $domain = new Domain_Home();
  165. $info = $domain->videoSearch($uid,$key,$p);
  166. setcaches($key1,$info,2);
  167. }
  168. $rs['info'] = $info;
  169. return $rs;
  170. }
  171. }