接口删除篇

审核后台删除接口
public function del_video()
{
$input = $this->getinput->json(array('id'));
$this->db->where('id', $input['id']);
$this->db->delete('video');
$nu = $this->db->affected_rows();
if ($nu) {
$data['status'] = 0;
$data['msg'] = '删除成功';
echo json_encode($data);
} else {
$data['status'] = -1;
$data['msg'] = '删除失败';
echo json_encode($data);
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
vue前端

handleDelete: async function (item) {
let self = this;
this.$confirm('此操作将删除该视频, 是否删除?', '提示', {
confirmButtonText: '确认',
cancelButtonText: '取消',
type: 'info'
}).then(async () => {
let {data} = await this.$http.post('/del_video', {id: item.id})
if (data.status == 0) {
this.$message({
showClose: true,
message: '删除成功',
type: 'success'
});
self.get_VideoList();
} else {
this.$message({
showClose: true,
message: data.msg,
type: data.code
});
}
}).catch(() => {
}};

你可能感兴趣的:(接口删除篇)