Commit dfa07430 by Administrator

Merge remote-tracking branch 'origin/master'

parents ea1c4af4 12f2ee79
...@@ -36,6 +36,7 @@ class ZyCollectionModel extends Model ...@@ -36,6 +36,7 @@ class ZyCollectionModel extends Model
'zy_teacher', //讲师收藏 'zy_teacher', //讲师收藏
'doc', //文库收藏 'doc', //文库收藏
'zy_teacher_course', //线下课收藏 'zy_teacher_course', //线下课收藏
'exams_paper',
'exams_question', // 新版考试系统试题收藏 'exams_question', // 新版考试系统试题收藏
); );
......
...@@ -333,6 +333,10 @@ class IndexAction extends Action ...@@ -333,6 +333,10 @@ class IndexAction extends Action
$paper_options['options_type'] = $options_type; $paper_options['options_type'] = $options_type;
} }
} }
// 是否收藏
$paper['iscollect'] = D('ZyCollection', 'classroom')->isCollect($paper_id, 'exams_paper', intval($this->mid));
$this->assign('paper', $paper); $this->assign('paper', $paper);
// 是否练习模式 // 是否练习模式
$this->assign('isPractice', ($_GET['joinType'] == 1) ? 1 : 2); $this->assign('isPractice', ($_GET['joinType'] == 1) ? 1 : 2);
...@@ -643,6 +647,30 @@ class IndexAction extends Action ...@@ -643,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> * @Author MartinSun<syh@sunyonghong.com>
......
...@@ -17,6 +17,9 @@ ...@@ -17,6 +17,9 @@
</small> </small>
</div> </div>
<div class="view-stop"> <div class="view-stop">
<i class="icon" onclick="changeCollect()" style="margin-top: 0.8rem;font-size: 16px;">
<img id = "collectImage" src="" class="van-icon__image">
</i>
<neq name="Think.get.joinType" value="2"><i class="icon icon-zanting"></i></neq> <neq name="Think.get.joinType" value="2"><i class="icon icon-zanting"></i></neq>
<a href="javascript:;" id="show-answer-card"><i class="icon icon-datiqia"></i></a> <a href="javascript:;" id="show-answer-card"><i class="icon icon-datiqia"></i></a>
</div> </div>
...@@ -246,6 +249,59 @@ ...@@ -246,6 +249,59 @@
window.location.href = ve; window.location.href = ve;
} }
}); });
}
var isCollect = "{$paper['iscollect']}" > 0 ? 1 : 0;
function changeCollect() {
if (isCollect) {
isCollect = 0;
} else {
isCollect = 1;
}
if (MID <= 0) {
ui.confirm('请先登录', {
yes: function () {
window.location.href = "{:U('basic/Passport/login')}";
}
});
return false;
}
$.ajax({
type: 'POST',
url: "{:U('exams/Index/collect2')}",
data: {
action: isCollect,
source_id: "{$paper.exams_paper_id}",
},
dataType: "json",
cache: false,
success: function (data) {
if (data.status == '0') {
ui.error(data.message);
} else {
ui.success(data.data.info);
iscollect(isCollect);
}
},
});
}
function iscollect(type)
{
var image = '';
if (type) {
image = "__THEME__/img/share_star.png";
} else {
image = "__THEME__/img/share_unstar.png";
}
$('#collectImage').attr('src', image);
} }
$(function () {
iscollect(isCollect);
});
</script> </script>
...@@ -745,8 +745,6 @@ class HomeAction extends UserAction ...@@ -745,8 +745,6 @@ class HomeAction extends UserAction
unset($val); unset($val);
} }
$this->assign("data", $data); $this->assign("data", $data);
//如果是ajax并且为h5访问 直接输出后边的数据 //如果是ajax并且为h5访问 直接输出后边的数据
...@@ -756,10 +754,39 @@ class HomeAction extends UserAction ...@@ -756,10 +754,39 @@ class HomeAction extends UserAction
echo json_encode($data); echo json_encode($data);
exit(); exit();
} }
$this->display(); $this->display();
} }
public function collect2()
{
$data = [];
$map['uid'] = intval($_GET['uid']) ? intval($_GET['uid']) : intval($this->mid);
$results = D("ZyCollection", 'classroom')->where(['source_table_name' => 'zy_video', 'uid' => $map['uid']])->order('ctime desc')->findpage();
if ($results['data']) {
$model = D('ZyVideo', 'course');
foreach ($results['data'] as &$result) {
$result['video_info'] = $model->getVideoById($result['source_id'], '*');
}
}
$list = D("ZyCollection", 'classroom')->where(['source_table_name' => 'exams_paper', 'uid' => $map['uid']])->order('ctime desc')->findpage();
if ($list['data']) {
$mod = D("ExamsPaper", 'exams');
foreach ($list['data'] as &$val) {
$val['exams_info'] = $mod->getPaperById($val['source_id']);
}
}
$data = [
'video' => $results,
'exams' => $list,
];
echo json_encode($data);
exit();
}
/** /**
* 会员中心学习次数--列表处理 * 会员中心学习次数--列表处理
* @return void * @return void
...@@ -2306,7 +2333,7 @@ class HomeAction extends UserAction ...@@ -2306,7 +2333,7 @@ class HomeAction extends UserAction
break; break;
case '4': case '4':
// 题目收藏 // 题目收藏
$list = D("ZyCollection", 'classroom')->where(['source_table_name' => 'exams_question', 'uid' => $map['uid']])->findpage(); $list = D("ZyCollection", 'classroom')->where(['source_table_name' => 'exams_question', 'uid' => $map['uid']])->order('ctime desc')->findpage();
if ($list['data']) { if ($list['data']) {
$mod = D("ExamsQuestion", 'exams'); $mod = D("ExamsQuestion", 'exams');
foreach ($list['data'] as &$val) { foreach ($list['data'] as &$val) {
......
...@@ -15,12 +15,12 @@ ...@@ -15,12 +15,12 @@
@load="onLoad"> @load="onLoad">
<template v-if="tab == 0"> <template v-if="tab == 0">
<div v-for="(item, index) in options[0].items" :key="index" class="layout_h collect_video_item"> <div v-for="(item, index) in options[0].items" :key="index" class="layout_h collect_video_item">
<van-image height="68" width="120" fit="cover" src="https://img.yzcdn.cn/vant/cat.jpeg" ></van-image> <van-image height="68" width="120" fit="cover" :src="item.video_info.cover_path" ></van-image>
<div class="weight_full layout_v_b" style="margin-left: 0.75rem;"> <div class="weight_full layout_v_b" style="margin-left: 0.75rem;">
<span class="text_14_600 color_333333">[班级课程]透视理论01——认识透视</span> <span class="text_14_600 color_333333">{{item.video_info.video_title}}</span>
<div class="layout_h_b"> <div class="layout_h_b">
<span class="text_14_600 color_FF3B3B">¥100</span> <span class="text_14_600 color_FF3B3B">{{(item.video_info.t_price == 0 || item.video_info.is_charge > 0) ? '免费' : ('¥' + item.video_info.t_price) }}</span>
<div class="collect_view_button layout_center text_12_400 color_white">查看</div> <div @click="onShow(item)" class="collect_view_button layout_center text_12_400 color_white">查看</div>
</div> </div>
</div> </div>
</div> </div>
...@@ -28,10 +28,10 @@ ...@@ -28,10 +28,10 @@
<template v-if="tab == 1"> <template v-if="tab == 1">
<div v-for="(item, index) in options[1].items" :key="index" class="layout_v collect_question_item"> <div v-for="(item, index) in options[1].items" :key="index" class="layout_v collect_question_item">
<span class="text_14_600 color_333333">[班级课程]透视理论01——认识透视[班级课程]透视理论01——认识透视</span> <span class="text_14_600 color_333333">{{item.exams_info.exams_paper_title}}</span>
<div class="layout_h_b"> <div class="layout_h_b">
<span class="text_14_600 color_FF3B3B">¥100</span> <span class="text_14_600 color_FF3B3B">{{(item.exams_info.price == 0) ? '免费' : ('¥' + item.exams_info.price) }}</span>
<div class="collect_view_button layout_center text_12_400 color_white">查看</div> <div @click="onShow2(item)" class="collect_view_button layout_center text_12_400 color_white">查看</div>
</div> </div>
</div> </div>
</template> </template>
...@@ -50,19 +50,42 @@ ...@@ -50,19 +50,42 @@
finished: true, finished: true,
options: [{ options: [{
title: "我的视频", title: "我的视频",
items: [1], items: [],
page: 0, page: 0,
finished: true finished: true
},{ },{
title: "我的真题", title: "我的真题",
items: [2], items: [],
page: 0, page: 0,
finished: true finished: true
}] }]
} }
}, },
created:function(){ created:function(){
document.title = "我的收藏" document.title = "我的收藏";
let _this = this;
$.get("{:U('home/Home/collect2')}", function (res) {
let exams = video = [];
if (res.exams.data.length > 0) {
exams = res.exams.data;
}
if (res.video.data.length > 0) {
video = res.video.data;
}
_this.options = [{
title: "我的视频",
items: video,
page: 0,
finished: true
},{
title: "我的真题",
items: exams,
page: 0,
finished: true
}];
}, 'json');
}, },
methods: { methods: {
onTab: function(tab) { onTab: function(tab) {
...@@ -70,8 +93,14 @@ ...@@ -70,8 +93,14 @@
}, },
onLoad: function() { onLoad: function() {
let that = this let that = this
let opt = that.options[this.tab] },
//TODO LOADING onShow: function(item) {
let url = "/course/"+item.video_info.id+".html"
window.location.href = url;
},
onShow2: function(item) {
let url = "{:U('exams/index/examsroom')}" + "&paper_id=" + item.exams_info.exams_paper_id + "&joinType=1"
window.location.href = url;
} }
} }
}) })
......
...@@ -105,10 +105,12 @@ ...@@ -105,10 +105,12 @@
<div @click="onMyTab(1)" class="layout_center weight_full" :class="myTab == 1 ? 'zhenti_tab_selected' : 'zhenti_tab_normal'">收藏</div> <div @click="onMyTab(1)" class="layout_center weight_full" :class="myTab == 1 ? 'zhenti_tab_selected' : 'zhenti_tab_normal'">收藏</div>
</div> </div>
<template v-if="myTab == 1"> <template v-if="myTab == 1">
<!-- <div class="zhenti_my_collect_cell layout_v">--> <div v-for="(item, index) in myCollect" :key="index" class="class_item layout_h">
<!-- <div class="text_16_600 color_333333"></div>--> <div class="zhenti_my_collect_cell layout_v" @click="showQuestion(item)">
<!-- <div class="text_12_400 color_999999 zhenti_my_collect_cell_time">2020-04-04 03:12:56</div>--> <div class="text_16_600 color_333333" v-html="item.content"></div>
<!-- </div>--> <div class="text_12_400 color_999999 zhenti_my_collect_cell_time">{{item.time}}</div>
</div>
</div>
<span style="margin-top: 35vh;" v-if="myCollect.length == 0" class="text_14_400 color_999999 self_center">没有找到!</span> <span style="margin-top: 35vh;" v-if="myCollect.length == 0" class="text_14_400 color_999999 self_center">没有找到!</span>
</template> </template>
<template v-if="myTab == 0"> <template v-if="myTab == 0">
...@@ -125,7 +127,7 @@ ...@@ -125,7 +127,7 @@
</div> </div>
</div> </div>
<div class="class_right layout_center"> <div class="class_right layout_center">
<div class="button_green layout_center">查看详情</div> <div class="button_green layout_center" @click="onShow(item)">查看详情</div>
</div> </div>
</div> </div>
<span style="margin-top: 35vh;" v-if="myYiZuo.length == 0" class="text_14_400 color_999999 self_center">没有找到!</span> <span style="margin-top: 35vh;" v-if="myYiZuo.length == 0" class="text_14_400 color_999999 self_center">没有找到!</span>
...@@ -177,6 +179,7 @@ ...@@ -177,6 +179,7 @@
</div> </div>
<script type="text/javascript"> <script type="text/javascript">
new Vue({ new Vue({
el: '#app', el: '#app',
data: function() { data: function() {
...@@ -272,7 +275,7 @@ ...@@ -272,7 +275,7 @@
if(tab == 0) { if(tab == 0) {
this.loadMy() this.loadMy()
} else { } else {
this.loadMyTi()
} }
}, },
onCondition: function(condition) { onCondition: function(condition) {
...@@ -359,17 +362,17 @@ ...@@ -359,17 +362,17 @@
let that = this let that = this
$.ajax({ $.ajax({
type: "GET", type: "GET",
url: "{:U('home/Home/exams')}" + "?api=1&tab=2", url: "{:U('home/Home/exams')}" + "?api=1",
dataType: "json", dataType: "json",
success: function(res) { success: function(res) {
if(res.status == 1) { if(res.status == 1) {
let array = res.data.data.length > 0 ? res.data.data : [] let array = res.data.data.length > 0 ? res.data.data : []
that.download = [].concat(array.map( r => { that.myYiZuo = [].concat(array.map( r => {
return { return {
id: r.exams_paper_id, id: r.exams_paper_id,
title: r.exams_paper_title, title: r.paper_info.exams_paper_title,
price: r.price, price: r.paper_info.price,
time: new Date(r.start_time).format('yyyy-mm-dd HH:MM:ss'), time: new Date(r.update_time * 1000).format('yyyy-MM-dd HH:mm:ss'),
score: r.score score: r.score
} }
})) }))
...@@ -377,9 +380,34 @@ ...@@ -377,9 +380,34 @@
} }
}) })
}, },
onShow: function (item) {
let url = "{:U('exams/index/examsroom')}" + "&paper_id=" + item.id + "&joinType=1&review=true"
window.location.href = url
},
//加载我收藏的题 //加载我收藏的题
loadMyTi: function() { loadMyTi: function() {
let that = this
$.ajax({
type: "GET",
url: "{:U('home/Home/exams')}" + "?api=1&tab=4",
dataType: "json",
success: function(res) {
if(res.status == 1) {
let array = res.data.data.length > 0 ? res.data.data : []
that.myCollect = [].concat(array.map( r => {
return {
id: r.question_info.exams_question_id,
content: r.question_info.content,
time: new Date(r.ctime * 1000).format('yyyy-mm-dd HH:MM:ss'),
}
}))
}
}
})
},
showQuestion: function (item) {
let url = "{:U('exams/index/showQuestioninfo')}" + "&question_id=" + item.id;
window.location.href = url
} }
} }
}) })
......
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