Active.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: qisse
  5. * Date: 2017/6/27
  6. * Time: 20:02
  7. */
  8. namespace app\mobile\logic;
  9. use app\core\model\Active as Model;
  10. use tool\Common;
  11. class Active extends Base
  12. {
  13. public function getActiveList() {
  14. $map = [];
  15. if($this->data['osType'] == 3) {
  16. $map['isOnLinePc'] = 1;
  17. }
  18. else {
  19. $map['isOnLineApp'] = 1;
  20. }
  21. if(!isset($this->app['pageIndex']) || !$this->app['pageIndex']) {
  22. $this->app['pageIndex'] = 1;
  23. }
  24. if(!isset($this->app['pageItemCount']) || !$this->app['pageItemCount']) {
  25. $this->app['pageItemCount'] = 10;
  26. }
  27. $count = Model::where($map)->count();
  28. $list = Model::where($map)->limit(($this->app['pageIndex'] - 1) * $this->app['pageItemCount'], $this->app['pageItemCount'])->order('addTime desc')->select();
  29. if($list->isEmpty()) {
  30. return Common::rm(-2, '数据为空');
  31. }
  32. $list = $list->hidden(['listOrder','isOnLinePc','isOnLineApp','updateTime'])->toArray();
  33. foreach ($list as $k=>$item) {
  34. $list[$k]['share'] = [
  35. 'headImgUrl'=>'https://static.qimai.cn/static/img/newaso100@2x.png',
  36. 'title'=>$item['title'],
  37. 'desc'=>$item['title'],
  38. 'link'=>'http://www.qq.com'
  39. ];
  40. }
  41. return Common::rm(1, '操作成功', [
  42. 'activeList'=>$list,
  43. 'count'=>$count,
  44. 'pageItemCount'=>$this->app['pageItemCount']
  45. ]);
  46. }
  47. }