assign([ 'homeLogo' => SystemConfigService::get('home_logo'), 'pid' => (int)$pid, 'cate_id' => (int)$cate_id ]); return $this->fetch(); } /**我的资料 * @return mixed */ public function my_material() { return $this->fetch(); } /** * 资料分类 */ public function get_material_cate() { $cateogry = DataDownloadCategpry::with('children')->where(['is_show' => 1, 'is_del' => 0])->order('sort desc,id desc')->where('pid', 0)->select(); return JsonService::successful($cateogry->toArray()); } /** * 资料列表 */ public function get_material_list() { list($page, $limit, $pid, $cate_id, $search) = UtilService::PostMore([ ['page', 1], ['limit', 10], ['pid', 0], ['cate_id', 0], ['search', ''] ], $this->request, true); return JsonService::successful(DataDownload::getDataDownloadExercisesList($page, $limit, $pid, $cate_id, $search)); } /** * 我的资料 */ public function my_material_list() { list($page, $limit) = UtilService::PostMore([ ['page', 1], ['limit', 10] ], $this->request, true); return JsonService::successful(DataDownloadBuy::getUserDataDownload($this->uid, $page, $limit)); } /** * 资料收藏 * @param $id int 资料id * @return json */ public function collect($id = 0) { if (!$id) return JsonService::fail('缺少参数'); if (SpecialRelation::SetCollect($this->uid, $id, 1)) return JsonService::successful('成功'); else return JsonService::fail('失败'); } /**用户下载记录 * @param $id * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\ModelNotFoundException * @throws \think\exception\DbException */ public function userDownload($id) { if (!$id) return JsonService::fail('缺少参数'); $res = DataDownloadRecords::addDataDownloadRecords($id, $this->uid); if ($res) { DataDownload::where('id', $id)->setInc('sales'); return JsonService::successful(''); } else return JsonService::fail(''); } }