model = new BoxModel(); } use Curd; // protected $allowModifyFields = [ // 'can_buy', // 'status' // ]; /** * @NodeAnotation(title="福袋列表") */ public function index () { if ($this->request->isAjax()) { if (input('selectFields')) { return $this->selectList(); } list($page, $limit, $where) = $this->buildTableParames(); $count = $this->model ->where($where) ->count(); // return 11; // return json_decode('[{"price":10, "fee":1},{"price":50, "fee":0.5},{"price":100, "fee":0}]'); $list = $this->model ->withoutField('password') // ->withAttr('buy_time', function ($val, $data){ // if (!$val){return '还未配置时间';} // $curdata = json_decode($val); // $cu_data['day'] = sr_getcurtime($curdata->day, 'Y-m-d'); // // $arr_time = $curdata->time; // for ($i = 0; $i < count($arr_time); $i++){ // $val1 = $curdata->time[$i]; // $key = 'time'.($i+1); // $cu_data[$key] = (sr_getcurtime($val1->start_time, 'H:i:s') . ' - ' . sr_getcurtime($val1->end_time, 'H:i:s')); // } // // return ($cu_data['day']. '日'. ($cu_data['time1']?('【'.$cu_data['time1'].'】'):'' ). '|'. (isset($cu_data['time2'])?('【'.$cu_data['time2'].'】'):''). '|' .(isset($cu_data['time3'])?('【'.$cu_data['time3'].'】'):'')); // }) ->withAttr('box_img', function($val, $data){ return getWebUrl().'/'.$val; }) ->where($where) ->page($page, $limit) ->order($this->sort) ->select(); $data = [ 'code' => 0, 'msg' => '', 'count' => $count, 'data' => $list, ]; return json($data); } return $this->fetch(); } }