/** * 删除我的收藏. * * @access public * @return void */ public function deleteCollectAction() { $ids = I('post.ids', []); $ids = array_map(function ($id) { if ((int) $id > 0) { return (int) $id; } }, $ids); $collectType = (int) I('post.collectType', 0); // 收藏类型: 0: 分类, 1: 社区资讯. $allowType = [0, 1]; if (empty($ids) || !in_array($collectType, $allowType, TRUE)) { $this->setAjaxData(Message::PARAM_ERROR, Message::get(Message::PARAM_ERROR))->myAjaxReturn(); } $loginedInfo = $this->getLoginedUserInfo(); // 登录的用户信息. $modelUserCollect = new UserCollectModel(); try { $result = $modelUserCollect->remove($loginedInfo['uid'], $collectType, $ids); if ($result) { $this->setAjaxData(Message::SUCCESS, '删除成功')->myAjaxReturn(); } else { $this->setAjaxData(Message::FAILED, '删除失败')->myAjaxReturn(); } } catch (\Exception $e) { $this->setAjaxData($e->getCode(), $e->getMessage())->myAjaxReturn(); } }