Banner.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php namespace App\Http\Controllers\Api;
  2. use App\Http\Controllers\Api\Api;
  3. use App\Models\Banner as Model;
  4. use App\Models\Custom;
  5. /**
  6. * 首页Banner
  7. *
  8. * @author 刘相欣
  9. *
  10. * */
  11. class Banner extends Api{
  12. /**
  13. * 获取客户信息 /api/banner/get_list
  14. *
  15. * @param string $code 授权码
  16. *
  17. * */
  18. public function get_list(Model $Model,Custom $Custom){
  19. // 接口验签
  20. // $this->verify_sign();
  21. // 检查登录
  22. $uid = $this->getUid();
  23. // 获取客户信息
  24. $custom = $uid ? $Custom->getOne($uid) : [];
  25. // 客户的城市ID
  26. $cityId = empty($custom['city_id']) ? 0 : $custom['city_id'];
  27. // 查新客户类型
  28. $list = $Model->getList();
  29. // 循环处理数据
  30. foreach ($list as $key => $value) {
  31. // 如果没有限制城市
  32. if( !$value['city_ids'] ) continue;
  33. // 如果限制了的话,转数组
  34. $value['city_ids'] = explode(',',$value['city_ids']);
  35. // 判断用户的城市是否在内
  36. if( in_array($cityId,$value['city_ids']) ) continue;
  37. // 不在范围的删除
  38. unset($list[$key]);
  39. }
  40. // 获取数组格式
  41. $list = array_values($list);
  42. // 返回结果
  43. return json_send(['code'=>'success','msg'=>'获取成功','data'=>$list]);
  44. }
  45. }