Commit 8bcd0ac9 by 冷斌

fix bug

parent 1ffa98dd
...@@ -154,7 +154,7 @@ ...@@ -154,7 +154,7 @@
</template> </template>
<template v-if="showList(1)"> <template v-if="showList(1)">
<div v-for="(item, idx) in options[1].items" :key="idx" class="layout_v home_question_item"> <div v-for="(item, idx2) in options[1].items" :key="idx2" class="layout_v home_question_item">
<!-- <!--
<div v-if="item.price == 0" class="layout_h"> <div v-if="item.price == 0" class="layout_h">
<div class="home_item_mark_green layout_center">免费</div> <div class="home_item_mark_green layout_center">免费</div>
...@@ -179,10 +179,10 @@ ...@@ -179,10 +179,10 @@
<div v-if="item.price > 0" class="home_item_mark_orange layout_center">付费</div> <div v-if="item.price > 0" class="home_item_mark_orange layout_center">付费</div>
<div v-if="item.price == 0" class="home_item_mark_green layout_center">免费</div> <div v-if="item.price == 0" class="home_item_mark_green layout_center">免费</div>
<span class="text_14_600 color_333333 weight_full van-multi-ellipsis--l2" style="margin-left: 0.625rem;">{{item.title}}</span> <span class="text_14_600 color_333333 weight_full van-multi-ellipsis--l2" style="margin-left: 0.625rem;">{{item.title}}</span>
<div @click="onTapQuestion(item)" v-if="(item.price == 0 || item.is_buy) && item.hasQuestion > 0" class="home_button_green layout_center">开始做题</div> <div @click="onTapQuestion(item, idx2)" v-if="(item.price == 0 || item.is_buy) && item.hasQuestion > 0" class="home_button_green layout_center">开始做题</div>
<div @click="onTapQuestion(item)" v-else-if="(item.price == 0 || item.is_buy) && item.hasQuestion <= 0" class="home_button_green layout_center">开始下载</div> <div @click="onTapQuestion(item, idx2)" v-else-if="(item.price == 0 || item.is_buy) && item.hasQuestion <= 0" class="home_button_green layout_center">开始下载</div>
<div @click="onTapQuestion(item)" v-else-if="item.price > 0 && item.hasQuestion > 0" class="button_orange layout_center">预览</div> <div @click="onTapQuestion(item, idx2)" v-else-if="item.price > 0 && item.hasQuestion > 0" class="button_orange layout_center">预览</div>
<div @click="onTapQuestion(item)" v-else-if="item.price > 0 && item.hasQuestion <= 0" class="button_orange layout_center">预览下载</div> <div @click="onTapQuestion(item, idx2)" v-else-if="item.price > 0 && item.hasQuestion <= 0" class="button_orange layout_center">预览下载</div>
</div> </div>
<div class="layout_h_b" style="margin-top: 0.5rem;"> <div class="layout_h_b" style="margin-top: 0.5rem;">
...@@ -340,7 +340,7 @@ ...@@ -340,7 +340,7 @@
items: [] items: []
}], }],
cacheKeyWorlds: this.getCacheKeyWorlds(), cacheKeyWorlds: this.getCacheKeyWorlds(),
yulan: false yulan: false,
} }
}, },
computed: { computed: {
...@@ -380,44 +380,77 @@ ...@@ -380,44 +380,77 @@
let url = "{:U('course/Video/view')}" let url = "{:U('course/Video/view')}"
window.location.href = url.replace(/\[.*?\]/g, item.id) window.location.href = url.replace(/\[.*?\]/g, item.id)
}, },
//点击真题 onDownload: function () {
onTapQuestion: function (item) { let item = this.options[1].items[this.yulan];
var MID = '<php> echo $mid;</php>'; let path = item.attach;
let title = item.title;
if ( path ) {
var link = document.createElement('a');
// 设置下载的文件名
link.download = title;
link.style.display = 'none';
//设置下载路径
link.href = path;
//触发点击
document.body.appendChild(link);
link.click();
//移除节点
document.body.removeChild(link);
this.close_yulan();
} else {
alert('当前课程无文件下载');
}
},
onPay: function() {
if (MID <= 0) { if (MID <= 0) {
ui.confirm('请先登录', { ui.confirm('请先登录', {
yes: function () { yes: function() {
window.location.href = "{:U('basic/Passport/login')}"; window.location.href = "{:U('basic/Passport/login')}";
} }
}) })
return return
} }
if (item.hasQuestion) { let item = this.options[1].items[this.yulan];
let url = "{:U('exams/index/examsroom')}" + "&paper_id=" + item.id + "&joinType=1" let id = item.id;
window.location.href = url; $.ajax({
} else { type: "POST",
url: "{:U('exams/index/getPayUrl')}",
data: {
paper_id: id,
},
dataType: "json",
success: function(res) {
var res = getResponseData(res)
if (res.status == 1) {
window.location.href = res.data
} else {
ui.error(res.message)
}
}
})
},
onStart: function(id) {
if (MID <= 0) {
ui.confirm('请先登录', {
yes: function() {
window.location.href = "{:U('basic/Passport/login')}";
}
})
return
} }
let url = "{:U('exams/index/examsroom')}" + "&paper_id=" + id + "&joinType=1"
window.location.href = url
},
//点击真题
if (item.price == 0) { onTapQuestion: function (item, index) {
if (item.hasQuestion > 0) {
this.onStart(item.id);
} else { } else {
$.ajax({ this.yulan = index;
type: "POST", if (item.price == 0) {
url: "{:U('exams/index/getPayUrl')}", this.onDownload();
data: { }
paper_id: item.id,
},
dataType: "json",
success: function (res) {
var res = getResponseData(res)
if (res.status == 1) {
window.location.href = res.data
} else {
ui.error(res.message)
}
}
})
} }
}, },
//点击实物 //点击实物
......
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