1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- <?php namespace App\Http\Controllers\Api;
- use App\Http\Controllers\Api\Api;
- use App\Models\Banner as Model;
- use App\Models\Custom;
- /**
- * 首页Banner
- *
- * @author 刘相欣
- *
- * */
- class Banner extends Api{
-
-
- /**
- * 获取客户信息 /api/banner/get_list
- *
- * @param string $code 授权码
- *
- * */
- public function get_list(Model $Model,Custom $Custom){
- // 接口验签
- // $this->verify_sign();
- // 检查登录
- $uid = $this->getUid();
- // 获取客户信息
- $custom = $uid ? $Custom->getOne($uid) : [];
- // 客户的城市ID
- $cityId = empty($custom['city_id']) ? 0 : $custom['city_id'];
- // 查新客户类型
- $list = $Model->getList();
- // 循环处理数据
- foreach ($list as $key => $value) {
- // 如果没有限制城市
- if( !$value['city_ids'] ) continue;
- // 如果限制了的话,转数组
- $value['city_ids'] = explode(',',$value['city_ids']);
- // 判断用户的城市是否在内
- if( in_array($cityId,$value['city_ids']) ) continue;
- // 不在范围的删除
- unset($list[$key]);
- }
- // 获取数组格式
- $list = array_values($list);
- // 返回结果
- return json_send(['code'=>'success','msg'=>'获取成功','data'=>$list]);
- }
-
- }
|