dataDel([ ['uid', '=', UID], ['product_id', '=', $param['product_id']], ['user_id', '=', USER_ID] ]); if (!$res) { return sendErrorMessage(4001, '取消收藏失败'); } $msg = '取消收藏成功'; $collect = false; } else { //收藏 $data = [ 'uid' => UID, 'user_id' => USER_ID, 'user_agent' => USER_AGENT, 'product_id' => $param['product_id'] ]; $res = $collect_model->dataUpdate($data); if (!$res) { return sendErrorMessage(4002, '收藏失败'); } $msg = '收藏成功'; $collect = true; } return sendSuccessMessage([ 'collect' => $collect ], $msg); } /** * 我的收藏 * @date 2022-12-01 */ public function listMyCollect() { $param = input('post.'); $collect_logic = new \app\mall\logic\Collect(); $result = $collect_logic -> listMyCollect($param['keyword']); return json($result); } /** * 删除我的收藏 * @date 2021-03-01 */ public function deleteMyCollect() { $param = input('post.'); $collect_logic = new \app\mall\logic\Collect(); $collect_ids = explode(',', $param['collect_ids']); $result = $collect_logic -> deleteMyCollect($collect_ids); return json($result); } /** * 商品是否收藏 * @date 2021-03-01 */ public function hasCollect() { $param = input('post.'); $collect_model = new MallCollect(); //判断是否收藏 $collect_id = $collect_model->getOneData([ ['uid', '=', UID], ['product_id', '=', $param['product_id']], ['user_id', '=', USER_ID] ], 'id'); $collect = $collect_id ? true : false; return sendSuccessMessage([ 'collect' => $collect ]); } }