User.php 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823
  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. session_start();
  12. class Api_User extends PhalApi_Api {
  13. public function getRules() {
  14. return array(
  15. 'iftoken' => array(
  16. 'uid' => array('name' => 'uid', 'type' => 'int', 'min' => 1, 'require' => true, 'desc' => '用户ID'),
  17. 'token' => array('name' => 'token', 'type' => 'string', 'require' => true, 'desc' => '用户token'),
  18. ),
  19. 'getBaseInfo' => array(
  20. 'uid' => array('name' => 'uid', 'type' => 'int', 'min' => 1, 'require' => true, 'desc' => '用户ID'),
  21. 'token' => array('name' => 'token', 'type' => 'string', 'require' => true, 'desc' => '用户token'),
  22. ),
  23. 'updateAvatar' => array(
  24. 'uid' => array('name' => 'uid', 'type' => 'int', 'min' => 1, 'require' => true, 'desc' => '用户ID'),
  25. 'token' => array('name' => 'token', 'type' => 'string', 'require' => true, 'desc' => '用户token'),
  26. 'file' => array('name' => 'file','type' => 'file', 'min' => 0, 'max' => 1024 * 1024 * 30, 'range' => array('image/jpg', 'image/jpeg', 'image/png'), 'ext' => array('jpg', 'jpeg', 'png')),
  27. ),
  28. 'updateFields' => array(
  29. 'uid' => array('name' => 'uid', 'type' => 'int', 'min' => 1, 'require' => true, 'desc' => '用户ID'),
  30. 'token' => array('name' => 'token', 'type' => 'string', 'require' => true, 'desc' => '用户token'),
  31. 'fields' => array('name' => 'fields', 'type' => 'string', 'require' => true, 'desc' => '修改信息,json字符串'),
  32. ),
  33. 'setAttent' => array(
  34. 'uid' => array('name' => 'uid', 'type' => 'int', 'min' => 1, 'require' => true, 'desc' => '用户ID'),
  35. 'token' => array('name' => 'token', 'type' => 'string', 'require' => true, 'desc' => '用户token'),
  36. 'touid' => array('name' => 'touid', 'type' => 'int', 'require' => true, 'desc' => '对方ID'),
  37. ),
  38. 'isAttent' => array(
  39. 'uid' => array('name' => 'uid', 'type' => 'int', 'min' => 1, 'require' => true, 'desc' => '用户ID'),
  40. 'touid' => array('name' => 'touid', 'type' => 'int', 'require' => true, 'desc' => '对方ID'),
  41. ),
  42. 'getFollowsList' => array(
  43. 'uid' => array('name' => 'uid', 'type' => 'int', 'require' => true, 'desc' => '用户ID'),
  44. 'touid' => array('name' => 'touid', 'type' => 'int', 'require' => true, 'desc' => '对方ID'),
  45. 'key' => array('name' => 'key', 'type' => 'string', 'desc' => '搜索关键词'),
  46. 'p' => array('name' => 'p', 'type' => 'int', 'min' => 1, 'default'=>1,'desc' => '页数'),
  47. ),
  48. 'getFansList' => array(
  49. 'uid' => array('name' => 'uid', 'type' => 'int', 'require' => true, 'desc' => '用户ID'),
  50. 'touid' => array('name' => 'touid', 'type' => 'int', 'require' => true, 'desc' => '对方ID'),
  51. 'p' => array('name' => 'p', 'type' => 'int', 'min' => 1, 'default'=>1,'desc' => '页数'),
  52. ),
  53. 'getUserHome' => array(
  54. 'uid' => array('name' => 'uid', 'type' => 'int', 'desc' => '用户ID'),
  55. 'touid' => array('name' => 'touid', 'type' => 'int', 'require' => true, 'desc' => '对方ID'),
  56. ),
  57. 'getLikeVideos'=>array(
  58. 'uid' => array('name' => 'uid', 'type' => 'int', 'require' => true, 'desc' => '用户ID'),
  59. 'touid' => array('name' => 'touid', 'type' => 'int', 'require' => true, 'desc' => '对方ID'),
  60. 'p' => array('name' => 'p', 'type' => 'int', 'default'=>'1' ,'desc' => '页数'),
  61. ),
  62. 'getBalance' => array(
  63. 'uid' => array('name' => 'uid', 'type' => 'int', 'min' => 1, 'require' => true, 'desc' => '用户ID'),
  64. 'token' => array('name' => 'token', 'type' => 'string', 'require' => true, 'desc' => '用户token'),
  65. ),
  66. 'updateBgImg' => array(
  67. 'uid' => array('name' => 'uid', 'type' => 'int', 'min' => 1, 'require' => true, 'desc' => '用户ID'),
  68. 'token' => array('name' => 'token', 'type' => 'string', 'require' => true, 'desc' => '用户token'),
  69. 'img' => array('name' => 'img','type' => 'string','require' => true, 'desc' => '背景图' ),
  70. ),
  71. );
  72. }
  73. /**
  74. * 判断token
  75. * @desc 用于判断token
  76. * @return int code 操作码,0表示成功, 1表示用户不存在
  77. * @return array info
  78. * @return string msg 提示信息
  79. */
  80. public function iftoken() {
  81. $rs = array('code' => 0, 'msg' => '', 'info' => array());
  82. $uid=checkNull($this->uid);
  83. $token=checkNull($this->token);
  84. $checkToken=checkToken($uid,$token);
  85. if($checkToken==700){
  86. $rs['code'] = $checkToken;
  87. $rs['msg'] = '您的登陆状态失效,请重新登陆!';
  88. return $rs;
  89. }else if($checkToken==10020){
  90. $rs['code'] = 700;
  91. $rs['msg'] = '该账号已被禁用';
  92. return $rs;
  93. }
  94. //获取用户信息存入app本地
  95. $domain=new Domain_User();
  96. $info=$domain->getBaseInfo($uid);
  97. $rs['info'][0]=$info;
  98. return $rs;
  99. }
  100. /**
  101. * 获取用户信息
  102. * @desc 用于获取单个用户基本信息
  103. * @return int code 操作码,0表示成功, 1表示用户不存在
  104. * @return array info
  105. * @return array info[0] 用户信息
  106. * @return int info[0].id 用户ID
  107. * @return string info[0].follows 关注数
  108. * @return string info[0].fans 粉丝数
  109. * @return string info[0].bg_img 背景墙图片
  110. * @return string msg 提示信息
  111. */
  112. public function getBaseInfo(){
  113. $rs = array('code' => 0, 'msg' => '', 'info' => array());
  114. $uid=checkNull($this->uid);
  115. $token=checkNull($this->token);
  116. $checkToken=checkToken($uid,$token);
  117. if($checkToken==700){
  118. $rs['code'] = $checkToken;
  119. $rs['msg'] = '您的登陆状态失效,请重新登陆!';
  120. return $rs;
  121. }else if($checkToken==10020){
  122. $rs['code'] = 700;
  123. $rs['msg'] = '该账号已被禁用';
  124. return $rs;
  125. }
  126. $domain = new Domain_User();
  127. $info = $domain->getBaseInfo($uid);
  128. if(!$info){
  129. $rs['code'] = 700;
  130. $rs['msg'] = '您的登陆状态失效,请重新登陆!';
  131. return $rs;
  132. }
  133. $rs['info'][0] = $info;
  134. return $rs;
  135. }
  136. /**
  137. * 头像上传 (七牛)[根据后台的配置信息来决定是走七牛云存储还是走腾讯云存储]
  138. * @desc 用于用户修改头像
  139. * @return int code 操作码,0表示成功
  140. * @return array info
  141. * @return string list[0].avatar 用户主头像
  142. * @return string list[0].avatar_thumb 用户头像缩略图
  143. * @return string msg 提示信息
  144. */
  145. public function updateAvatar() {
  146. $rs = array('code' => 0 , 'msg' => '', 'info' => array());
  147. $uid=checkNull($this->uid);
  148. $token=checkNull($this->token);
  149. $checkToken=checkToken($uid,$token);
  150. if($checkToken==700){
  151. $rs['code'] = $checkToken;
  152. $rs['msg'] = '您的登陆状态失效,请重新登陆!';
  153. return $rs;
  154. }else if($checkToken==10020){
  155. $rs['code'] = 700;
  156. $rs['msg'] = '该账号已被禁用';
  157. return $rs;
  158. }
  159. if (!isset($_FILES['file'])) {
  160. $rs['code'] = 1001;
  161. $rs['msg'] = T('miss upload file');
  162. return $rs;
  163. }
  164. if ($_FILES["file"]["error"] > 0) {
  165. $rs['code'] = 1002;
  166. $rs['msg'] = T('failed to upload file with error: {error}', array('error' => $_FILES['file']['error']));
  167. DI()->logger->debug('failed to upload file with error: ' . $_FILES['file']['error']);
  168. return $rs;
  169. }
  170. //获取后台配置的云存储方式
  171. $configpri=getConfigPri();
  172. $cloudtype=$configpri['cloudtype'];
  173. if($cloudtype==1){
  174. //七牛
  175. $url = DI()->qiniu->uploadFile($_FILES['file']['tmp_name'],$configpri['qiniu_accesskey'],$configpri['qiniu_secretkey'],$configpri['qiniu_bucket'],$configpri['qiniu_domain_url']);
  176. if (!empty($url)) {
  177. $avatar= $url.'?imageView2/2/w/600/h/600'; //600 X 600
  178. $avatar_thumb= $url.'?imageView2/2/w/200/h/200'; // 200 X 200
  179. $data=array(
  180. "avatar"=>setCloudType($avatar),
  181. "avatar_thumb"=>setCloudType($avatar_thumb),
  182. );
  183. }
  184. }else if($cloudtype==0){
  185. //本地上传
  186. //设置上传路径 设置方法参考3.2
  187. DI()->ucloud->set('save_path','avatar/'.date("Ymd"));
  188. //新增修改文件名设置上传的文件名称
  189. // DI()->ucloud->set('file_name', $this->uid);
  190. //上传表单名
  191. $res = DI()->ucloud->upfile($_FILES['file']);
  192. $files='../upload/'.$res['file'];
  193. $newfiles=str_replace(".png","_thumb.png",$files);
  194. $newfiles=str_replace(".jpg","_thumb.jpg",$newfiles);
  195. $newfiles=str_replace(".gif","_thumb.gif",$newfiles);
  196. $PhalApi_Image = new Image_Lite();
  197. //打开图片
  198. $PhalApi_Image->open($files);
  199. /**
  200. * 可以支持其他类型的缩略图生成,设置包括下列常量或者对应的数字:
  201. * IMAGE_THUMB_SCALING //常量,标识缩略图等比例缩放类型
  202. * IMAGE_THUMB_FILLED //常量,标识缩略图缩放后填充类型
  203. * IMAGE_THUMB_CENTER //常量,标识缩略图居中裁剪类型
  204. * IMAGE_THUMB_NORTHWEST //常量,标识缩略图左上角裁剪类型
  205. * IMAGE_THUMB_SOUTHEAST //常量,标识缩略图右下角裁剪类型
  206. * IMAGE_THUMB_FIXED //常量,标识缩略图固定尺寸缩放类型
  207. */
  208. // 按照原图的比例生成一个最大为150*150的缩略图并保存为thumb.jpg
  209. $PhalApi_Image->thumb(660, 660, IMAGE_THUMB_SCALING);
  210. $PhalApi_Image->save($files);
  211. $PhalApi_Image->thumb(200, 200, IMAGE_THUMB_SCALING);
  212. $PhalApi_Image->save($newfiles);
  213. $avatar= $res['url']; //600 X 600
  214. $avatar_thumb=str_replace(".png","_thumb.png",$avatar);
  215. $avatar_thumb=str_replace(".jpg","_thumb.jpg",$avatar_thumb);
  216. $avatar_thumb=str_replace(".gif","_thumb.gif",$avatar_thumb);
  217. $data=array(
  218. "avatar"=>$avatar,
  219. "avatar_thumb"=>$avatar_thumb,
  220. );
  221. }
  222. @unlink($_FILES['file']['tmp_name']);
  223. /* 清除缓存 */
  224. delCache("userinfo_".$uid);
  225. $domain = new Domain_User();
  226. $info = $domain->userUpdate($uid,$data);
  227. $rs['info'][0] = $data;
  228. return $rs;
  229. }
  230. /**
  231. * 修改用户信息
  232. * @desc 用于修改用户信息
  233. * @return int code 操作码,0表示成功
  234. * @return array info
  235. * @return string list[0].msg 修改成功提示信息
  236. * @return string msg 提示信息
  237. */
  238. public function updateFields() {
  239. $rs = array('code' => 0, 'msg' => '', 'info' => array());
  240. $uid=checkNull($this->uid);
  241. $token=checkNull($this->token);
  242. $checkToken=checkToken($uid,$token);
  243. if($checkToken==700){
  244. $rs['code'] = $checkToken;
  245. $rs['msg'] = '您的登陆状态失效,请重新登陆!';
  246. return $rs;
  247. }else if($checkToken==10020){
  248. $rs['code'] = 700;
  249. $rs['msg'] = '该账号已被禁用';
  250. return $rs;
  251. }
  252. $fields=urldecode($this->fields);
  253. $fields=json_decode($fields,true);
  254. $domain = new Domain_User();
  255. foreach($fields as $k=>$v){
  256. $fields[$k]=checkNull($v);
  257. }
  258. if(array_key_exists('user_nicename', $fields)){
  259. if($fields['user_nicename']==''){
  260. $rs['code'] = 1002;
  261. $rs['msg'] = '昵称不能为空';
  262. return $rs;
  263. }
  264. //判断昵称中是否有敏感词
  265. $keywordsIsExist=checkSensitiveWords($fields['user_nicename']);
  266. if($keywordsIsExist){
  267. $rs['code'] = 1002;
  268. $rs['msg'] = '输入非法,请重新输入';
  269. return $rs;
  270. }
  271. $isexist = $domain->checkName($uid,$fields['user_nicename']);
  272. if(!$isexist){
  273. $rs['code'] = 1002;
  274. $rs['msg'] = '昵称重复,请修改';
  275. return $rs;
  276. }
  277. //判断昵称里是否包含已注销
  278. if(strstr($fields['user_nicename'], '已注销')!==false){ //昵称包含已注销三个字
  279. $rs['code'] = 10011;
  280. $rs['msg'] = '输入非法,请重新输入';
  281. return $rs;
  282. }
  283. $fields['user_nicename']=filterField($fields['user_nicename']);
  284. }
  285. //个性签名
  286. if(array_key_exists('signature', $fields)){
  287. //判断个性签名中是否有敏感词
  288. $keywordsIsExist=checkSensitiveWords($fields['signature']);
  289. if($keywordsIsExist){
  290. $rs['code'] = 1002;
  291. $rs['msg'] = '个性签名输入非法,请重新输入';
  292. return $rs;
  293. }
  294. $fields['signature']=filterField($fields['signature']);
  295. }
  296. //手机号
  297. if(array_key_exists('mobile', $fields)){
  298. if($fields['mobile']==''){
  299. $rs['code'] = 1002;
  300. $rs['msg'] = '手机号码不能为空';
  301. return $rs;
  302. }
  303. $isexist = $domain->checkMobile($uid,$fields['mobile']);
  304. if(!$isexist){
  305. $rs['code'] = 1002;
  306. $rs['msg'] = '手机号码重复,请修改';
  307. return $rs;
  308. }
  309. $fields['mobile']=filterField($fields['mobile']);
  310. }
  311. //根据生日计算年龄
  312. if(array_key_exists('birthday', $fields)){
  313. if($fields['birthday']==''){
  314. $rs['code'] = 1002;
  315. $rs['msg'] = '请选择生日';
  316. return $rs;
  317. }
  318. $now=time();
  319. $time1=strtotime($fields['birthday']);
  320. $nowYear=date("Y",$now);
  321. $birthdayYear=date("Y",$time1);
  322. $nowMonth=date("m",$now);
  323. $month=date("m",$time1);
  324. if($nowMonth>=$month){
  325. $cha=0;
  326. }else{
  327. $cha=1;
  328. }
  329. $age=$nowYear-$birthdayYear-$cha;
  330. $fields['age']=$age;
  331. }
  332. $info = $domain->userUpdate($uid,$fields);
  333. if($info===false){
  334. $rs['code'] = 1001;
  335. $rs['msg'] = '修改失败';
  336. return $rs;
  337. }
  338. /* 清除缓存 */
  339. delCache("userinfo_".$uid);
  340. $rs['info'][0]['msg']='修改成功';
  341. return $rs;
  342. }
  343. /**
  344. * 判断是否关注
  345. * @desc 用于判断是否关注
  346. * @return int code 操作码,0表示成功
  347. * @return array info
  348. * @return string info[0].isattent 关注信息,0表示未关注,1表示已关注
  349. * @return string msg 提示信息
  350. */
  351. public function isAttent() {
  352. $rs = array('code' => 0, 'msg' => '', 'info' => array());
  353. $uid=checkNull($this->uid);
  354. $touid=checkNull($this->touid);
  355. $isBlackUser=isBlackUser($uid);
  356. if($isBlackUser=='0'){
  357. $rs['code'] = 700;
  358. $rs['msg'] = '该账号已被禁用';
  359. return $rs;
  360. }
  361. $info = isAttention($uid,$touid);
  362. $rs['info'][0]['isattent']=(string)$info;
  363. return $rs;
  364. }
  365. /**
  366. * 关注/取消关注
  367. * @desc 用于关注/取消关注
  368. * @return int code 操作码,0表示成功
  369. * @return array info
  370. * @return string info[0].isattent 关注信息,0表示未关注,1表示已关注
  371. * @return string msg 提示信息
  372. */
  373. public function setAttent() {
  374. $rs = array('code' => 0, 'msg' => '', 'info' => array());
  375. $uid=checkNull($this->uid);
  376. $token=checkNull($this->token);
  377. $touid=$this->touid;
  378. $isBlackUser=isBlackUser($uid);
  379. if($isBlackUser=='0'){
  380. $rs['code'] = 700;
  381. $rs['msg'] = '该账号已被禁用';
  382. return $rs;
  383. }
  384. $checkToken=checkToken($uid,$token);
  385. if($checkToken==700){
  386. $rs['code'] = $checkToken;
  387. $rs['msg'] = '您的登陆状态失效,请重新登陆!';
  388. return $rs;
  389. }else if($checkToken==10020){
  390. $rs['code'] = 700;
  391. $rs['msg'] = '该账号已被禁用';
  392. return $rs;
  393. }
  394. if($uid==$touid){
  395. $rs['code']=1001;
  396. $rs['msg']='不能关注自己';
  397. return $rs;
  398. }
  399. $domain = new Domain_User();
  400. $info = $domain->setAttent($uid,$touid);
  401. $rs['info'][0]['isattent']=(string)$info;
  402. return $rs;
  403. }
  404. /**
  405. * 获取用户的关注列表
  406. * @desc 用于获取用户的关注列表
  407. * @return int code 操作码,0表示成功
  408. * @return array info
  409. * @return string info[].isattent 是否关注,0表示未关注,1表示已关注
  410. * @return string msg 提示信息
  411. */
  412. public function getFollowsList() {
  413. $rs = array('code' => 0, 'msg' => '', 'info' => array());
  414. $uid=checkNull($this->uid);
  415. $touid=checkNull($this->touid);
  416. $p=checkNull($this->p);
  417. $key=checkNull($this->key);
  418. $isBlackUser=isBlackUser($uid);
  419. if($isBlackUser=='0'){
  420. $rs['code'] = 700;
  421. $rs['msg'] = '该账号已被禁用';
  422. return $rs;
  423. }
  424. $domain = new Domain_User();
  425. $info = $domain->getFollowsList($uid,$touid,$p,$key);
  426. $rs['info']=$info;
  427. return $rs;
  428. }
  429. /**
  430. * 获取用户的粉丝列表
  431. * @desc 用于获取用户的粉丝列表
  432. * @return int code 操作码,0表示成功
  433. * @return array info
  434. * @return string info[].isattent 是否关注,0表示未关注,1表示已关注
  435. * @return string msg 提示信息
  436. */
  437. public function getFansList() {
  438. $rs = array('code' => 0, 'msg' => '', 'info' => array());
  439. $uid=checkNull($this->uid);
  440. $touid=checkNull($this->touid);
  441. $p=checkNull($this->p);
  442. $isBlackUser=isBlackUser($uid);
  443. if($isBlackUser=='0'){
  444. $rs['code'] = 700;
  445. $rs['msg'] = '该账号已被禁用';
  446. return $rs;
  447. }
  448. $domain = new Domain_User();
  449. $info = $domain->getFansList($uid,$touid,$p);
  450. $rs['info']=$info;
  451. return $rs;
  452. }
  453. /**
  454. * 个人主页
  455. * @desc 用于获取个人主页数据
  456. * @return int code 操作码,0表示成功
  457. * @return array info
  458. * @return string info[0].id 用户id
  459. * @return string info[0].avatar 用户头像
  460. * @return string info[0].avatar_thumb 用户小头像
  461. * @return string info[0].sex 性别
  462. * @return string info[0].signature 用户签名
  463. * @return array info[0].province 省份
  464. * @return array info[0].city 城市
  465. * @return string info[0].birthday 生日
  466. * @return array info[0].age 年龄
  467. * @return array info[0].praise 视频点赞总数
  468. * @return array info[0].fans 粉丝数
  469. * @return array info[0].follows 关注数
  470. * @return array info[0].workVideos 作品数
  471. * @return array info[0].likeVideos 喜欢视频数
  472. * @return array info[0].isattention 是否关注
  473. * @return array info[0].isshop 是否开店
  474. * @return array info[0].shopname 店铺名称
  475. * @return array info[0].shop_thumb 店铺封面
  476. * @return array info[0].vipinfo 用户vip信息
  477. * @return array info[0].bonus_switch 签到奖励开关 0 关 1 开
  478. * @return array info[0].vipinfo['isvip'] 用户是否开通vip
  479. * @return array info[0].vipinfo['vip_endtime'] vip到期时间
  480. * @return string msg 提示信息
  481. */
  482. public function getUserHome() {
  483. $rs = array('code' => 0, 'msg' => '', 'info' => array());
  484. $uid=checkNull($this->uid);
  485. $touid=checkNull($this->touid);
  486. if($uid>0){ //非游客
  487. $isBlackUser=isBlackUser($uid);
  488. if($isBlackUser=='0'){
  489. $rs['code'] = 700;
  490. $rs['msg'] = '该账号已被禁用';
  491. return $rs;
  492. }
  493. }
  494. $domain = new Domain_User();
  495. $info=$domain->getUserHome($uid,$touid);
  496. $rs['info'][0]=$info;
  497. return $rs;
  498. }
  499. /**
  500. * 获取用户喜欢的视频
  501. * @desc 用户获取用户喜欢的视频
  502. * @return int code 状态码,0表示成功
  503. * @return string msg 提示信息
  504. * @return array info
  505. * @return string info[0].uid 视频发布者id
  506. * @return string info[0].title 视频标题
  507. * @return string info[0].thumb 视频封面图
  508. * @return string info[0].thumb_s 视频封面小图
  509. * @return string info[0].href 视频地址
  510. * @return string info[0].likes 视频被喜欢总数
  511. * @return string info[0].views 视频被浏览数
  512. * @return string info[0].comments 视频评论数
  513. * @return string info[0].shares 视频被分享数
  514. * @return string info[0].addtime 视频发布时间
  515. * @return string info[0].city 视频发布城市
  516. * @return string info[0].datetime 视频发布时间(格式化为汉字形式)
  517. * @return string info[0].userinfo 视频发布者信息
  518. */
  519. public function getLikeVideos(){
  520. $rs = array('code' => 0, 'msg' => '', 'info' => array());
  521. $uid=checkNull($this->uid);
  522. $touid=checkNull($this->touid);
  523. $p=checkNull($this->p);
  524. $domain = new Domain_User();
  525. $res=$domain->getLikeVideos($uid,$touid,$p);
  526. if($res==1001){
  527. $rs['code']=0;
  528. $rs['msg']="暂无视频列表";
  529. return $rs;
  530. }
  531. $rs['info']=$res;
  532. return $rs;
  533. }
  534. /**
  535. * 获取用户余额,充值规则 支付方式信息
  536. * @desc 用于获取用户余额,充值规则 支付方式信息
  537. * @return int code 操作码,0表示成功
  538. * @return array info
  539. * @return string info[0].coin 用户余额
  540. * @return string msg 提示信息
  541. */
  542. public function getBalance() {
  543. $rs = array('code' => 0, 'msg' => '', 'info' => array());
  544. $uid=checkNull($this->uid);
  545. $token=checkNull($this->token);
  546. $checkToken=checkToken($uid,$token);
  547. if($checkToken==700){
  548. $rs['code'] = $checkToken;
  549. $rs['msg'] = '您的登陆状态失效,请重新登陆!';
  550. return $rs;
  551. }else if($checkToken==10020){
  552. $rs['code'] = 700;
  553. $rs['msg'] = '该账号已被禁用';
  554. return $rs;
  555. }
  556. $domain = new Domain_User();
  557. $info = $domain->getBalance($uid);
  558. $rs['info'][0]=$info;
  559. return $rs;
  560. }
  561. /**
  562. * 获取用户是否可开播、是否可上传视频、发布视频时是否可发布商品、是否可发布广告链接
  563. * @desc 用于获取用户是否可开播、是否可上传视频、发布视频时是否可发布商品、是否可发布广告链接
  564. * @return int code 状态码 0表示成功
  565. * @return string msg 状态码 0表示成功
  566. * @return array info 返回信息
  567. * @return int info[0].live_status 是否可开播 0 否 1 是
  568. * @return int info[0].video_status 是否可发布视频 0 否 1 是
  569. * @return int info[0].setvideo_charge 发布视频时是否可设置视频收费价格 0 否 1 是
  570. * @return int info[0].isshop 发布视频时是否可发布商品 0 否 1 是
  571. * @return int info[0].isad 发布视频时是否可发布广告链接 0 否 1 是
  572. * @return string info[0].video_msg 发布视频受限 提示语
  573. * @return string info[0].live_msg 开播受限 提示语
  574. */
  575. public function checkLiveVipStatus(){
  576. $rs=array('code'=>0,'msg'=>"",'info'=>array());
  577. $uid=checkNull($this->uid);
  578. $token=checkNull($this->token);
  579. $checkToken=checkToken($uid,$token);
  580. if($checkToken==700){
  581. $rs['code'] = $checkToken;
  582. $rs['msg'] = '您的登陆状态失效,请重新登陆!';
  583. return $rs;
  584. }else if($checkToken==10020){
  585. $rs['code'] = 700;
  586. $rs['msg'] = '该账号已被禁用';
  587. return $rs;
  588. }
  589. $domain=new Domain_User();
  590. $result=$domain->checkLiveVipStatus($uid);
  591. if($result==1001){
  592. $rs['code']=1001; //此code值固定为1001,app要进行判断弹窗提示,并按钮跳转认证页面
  593. $rs['msg']="未认证,无法发布视频";
  594. return $rs;
  595. }
  596. $rs['info'][0]=$result;
  597. return $rs;
  598. }
  599. /**
  600. * 更换个人中心背景图
  601. * @desc 更换个人中心背景图
  602. * @retun int code 状态码,0表示成功
  603. * @retun string msg 返回信息
  604. * @retun array info 返回信息
  605. * @retun array info[0]['bg_img'] 返回上传的背景图
  606. * */
  607. public function updateBgImg(){
  608. $rs = array('code' => 0, 'msg' => '背景图更换成功', 'info' => array());
  609. $uid=checkNull($this->uid);
  610. $token=checkNull($this->token);
  611. $img=checkNull($this->img);
  612. $checkToken=checkToken($uid,$token);
  613. if($checkToken==700){
  614. $rs['code'] = $checkToken;
  615. $rs['msg'] = '您的登陆状态失效,请重新登陆!';
  616. return $rs;
  617. }
  618. if(!$img){
  619. $rs['code']=1001;
  620. $rs['msg']='请上传背景图';
  621. return $rs;
  622. }
  623. $img=setCloudType($img);
  624. $domain=new Domain_User();
  625. $res=$domain->updateBgImg($uid,$img);
  626. if($res==1001){
  627. $rs['code']=1002;
  628. $rs['msg']='背景图更换失败';
  629. return $rs;
  630. }
  631. $userinfo=getUserInfo($uid);
  632. $rs['info'][0]['bg_img']=$userinfo['bg_img'];
  633. return $rs;
  634. }
  635. }