You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

105 lines
3.4 KiB

7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
  1. <?php
  2. namespace App\Http\Controllers\Api;
  3. use App\Http\Controllers\Api\CommonController;
  4. use Illuminate\Http\Request;
  5. use App\Common\ReturnData;
  6. use App\Common\Token;
  7. class IndexController extends CommonController
  8. {
  9. public function __construct()
  10. {
  11. parent::__construct();
  12. }
  13. //安卓升级信息
  14. public function andriodUpgrade()
  15. {
  16. $res = array(
  17. 'appname' => 'lqycms', //app名字
  18. 'serverVersion' => 2, //服务器版本号
  19. 'serverFlag' => 1, //服务器标志
  20. 'lastForce' => 0, //是否强制更新,0不强制,1强制
  21. 'updateurl' => 'http://api.52danchuang.com/wap/app-release.apk', //apk下载地址
  22. 'upgradeinfo' => '描述:3.0.0' //版本更新的描述
  23. );
  24. return ReturnData::create(ReturnData::SUCCESS, $res);
  25. }
  26. //关于
  27. public function about(Request $request)
  28. {
  29. return ReturnData::create(ReturnData::SUCCESS,array('url'=>'http://www.baidu.com'));
  30. }
  31. //文章列表页
  32. public function listarc()
  33. {
  34. $res["code"] = 0;
  35. $res["msg"] = "success";
  36. $res["data"] = "";
  37. $where = array();
  38. $result = "";
  39. $PageIndex = request('PageIndex',1);
  40. $PageSize = request('PageSize', sysconfig('CMS_PAGESIZE'));
  41. $skip = ($PageIndex-1)*$PageSize;
  42. $typeid = request('typeid');if(!empty($typeid)){ $where['typeid']=$typeid; }
  43. $tuijian = request('tuijian');if(!empty($tuijian)){ $where['tuijian']=$tuijian; }
  44. $field = array('field','id,typeid,click,title,writer,litpic,pubdate');
  45. $orderby = request('orderby',['pubdate','desc']);
  46. $mname = request('mname','article');
  47. $model = \DB::table($mname);
  48. if($where){$model = $model->where($where);}
  49. if($orderby == 'rand()'){$model = $model->orderBy(\DB::raw('rand()'));}else{$model = $model->orderBy($orderby[0], $orderby[1]);}
  50. $count = $model->count();
  51. $list = object_to_array($model->skip($skip)->take($PageSize)->get());
  52. if(!empty($list) && $PageIndex<=10)
  53. {
  54. /* foreach($list as $key=>$row)
  55. {
  56. //$list[$key]["pubdate"] = date("Y-m-d", $list[$key]["pubdate"]);
  57. $result .= '<div class="list">';
  58. if(!empty($row['litpic']) && file_exists($_SERVER['DOCUMENT_ROOT'].$row['litpic']))
  59. {
  60. $result .= '<a class="';
  61. //判断图片长宽
  62. if(getimagesize($row['litpic'])[0]>getimagesize($row['litpic'])[1])
  63. {
  64. $result .= 'limg';
  65. }
  66. else
  67. {
  68. $result .= 'simg';
  69. }
  70. $result .= '" href="'.WEBHOST.'/p/'.$row['id'].'"><img alt="'.$row['title'].'" src="'.$row['litpic'].'"></a>';
  71. }
  72. $result .= '<strong class="tit"><a href="'.WEBHOST.'/p/'.$row['id'].'">'.$row['title'].'</a></strong><p>'.mb_strcut(strip_tags($row['description']),0,126,'UTF-8').'..<a href="'.WEBHOST.'/p/'.$row['id'].'" class="more">[详情]</a></p>';
  73. $result .= '<div class="info"><span class="fl"><i class="pub-v"></i><em>'.date("Y-m-d H:i",$row['pubdate']).'</em></span><span class="fr"><em>'.$row['click'].'</em>人阅读</span></div><div class="cl"></div></div>';
  74. } */
  75. foreach($list as $key=>$row)
  76. {
  77. $list[$key]["url"] = get_front_url(array("id"=>$row['id'],"type"=>'content'));
  78. $list[$key]["pubdate"] = date("Y-m-d", $list[$key]["pubdate"]);
  79. }
  80. $res["data"] = $list;
  81. }
  82. /* $result['List']=$list;
  83. $result['Count']=$count>0?$count:0; */
  84. //return $res;
  85. exit(json_encode($res));
  86. }
  87. }