Commit 1fa66dcf by 冷斌

fix bug

parent 0745dcad
......@@ -335,7 +335,7 @@ class IndexAction extends Action
}
// 是否收藏
$paper['iscollect'] = D('ZyCollection', 'classroom')->isCollect($paper_id, 'exams_question', intval($this->mid));
$paper['iscollect'] = D('ZyCollection', 'classroom')->isCollect($paper_id, 'exams_paper', intval($this->mid));
$this->assign('paper', $paper);
// 是否练习模式
......@@ -647,6 +647,30 @@ class IndexAction extends Action
}
public function collect2()
{
if ($_POST) {
$action = ($_POST['action'] == '1') ? 1 : 0;
$data['uid'] = intval($this->mid);
$data['source_id'] = intval($_POST['source_id']);
$data['source_table_name'] = 'exams_paper';
// 收藏
$mod = D('ZyCollection', 'classroom');
if ($action === 1) {
$data['ctime'] = time();
if ($mod->addcollection($data)) {
echo json_encode(['status' => 1, 'data' => ['info' => '收藏成功']]);exit;
}
} else {
if ($mod->delcollection($data['source_id'], $data['source_table_name'], $data['uid'])) {
echo json_encode(['status' => 1, 'data' => ['info' => '取消收藏成功']]);exit;
}
}
echo json_encode(['status' => 0, 'message' => $mod->getError()]);exit;
}
}
/**
* 查看试题详情
* @Author MartinSun<syh@sunyonghong.com>
......
......@@ -271,7 +271,7 @@
$.ajax({
type: 'POST',
url: "{:U('exams/Index/collect')}",
url: "{:U('exams/Index/collect2')}",
data: {
action: isCollect,
source_id: "{$paper.exams_paper_id}",
......
......@@ -417,7 +417,7 @@
success: function(res) {
if(res.status == 1) {
let array = res.data.data.length > 0 ? res.data.data : []
that.download = [].concat(array.map( r => {
that.myCollect = [].concat(array.map( r => {
return {
id: r.exams_paper_id,
title: r.exams_paper_title,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment