Commit dfb37eb4 authored by xiabin's avatar xiabin

修改支付后的弹窗问题

parent 46d46201
......@@ -143,6 +143,7 @@ class HomeController extends \yii\web\Controller
$coursewareInfo['isSupport'] = (Support::findByUserIdAndCoursewareId($userId, $coursewareInfo['id']) === NULL ? FALSE : TRUE);
$coursewareInfo['isFavorite'] = (Favorite::findByUserIdAndCoursewareId($userId, $coursewareInfo['id']) === NULL ? FALSE : TRUE);
$coursewareInfo['isShop'] = FALSE;
//已登录
if (!Yii::$app->user->isGuest) {
$coursewareInfo['userAvatar'] = User::getAvatarUrl(Yii::$app->user->identity->avatar);
$order = Orders::findByUserIdAndCourseId($userId, $courseId);
......@@ -150,15 +151,16 @@ class HomeController extends \yii\web\Controller
}
if ($coursewareInfo['isShop']) {
$coursewareInfo['videoUrl'] = Yii::$app->qiniu->getUrl('video', $coursewareInfo['src_stand']);
} else if($course->free_time > 0) {
} else if ($course->free_time > 0) {
$coursewareInfo['videoUrl'] = Yii::$app->qiniu->getUrl('video', $coursewareInfo['src_free']);
}else{
} else {
$coursewareInfo['videoUrl'] = NULL;
}
unset($coursewareInfo['src_stand']);
unset($coursewareInfo['src_free']);
$coursewareInfo['price'] = $course->price;
$coursewareInfo['classId'] = $course->class_id;
$coursewareInfo['free_time'] = $course->free_time;
$coursewareInfo['className'] = Classes::findOne(['id' => $course->class_id])->name;
$coursewareInfo['isMobile'] = Yii::$app->deviceDetect->isMobile();
//处理讲师头像
......
......@@ -13,8 +13,7 @@
<a href="javascript:;" class="qzone post-icons bds_qzone" data-cmd="qzone" title="分享到QQ空间"></a>
</div>
</div>
<myvideo v-if="!coursewareInfo.isPreview" :preview-url="coursewareInfo.previewUrl"
:video-url="coursewareInfo.videoUrl"></myvideo>
<myvideo v-on:pay-click="payClick" v-if="!coursewareInfo.isPreview" :video-info="videoInfo" ></myvideo>
<div v-else class="video-main">
<div class="video-empty"
style="height:500px; width: 100%; background-color: #444; color: #fff; text-align: center;">
......@@ -140,6 +139,17 @@
videoShow: false
}
},
computed:{
videoInfo(){
return {
videoUrl: this.coursewareInfo.videoUrl,
previewUrl: this.coursewareInfo.previewUrl,
freeTime:this.coursewareInfo.free_time,
price:this.coursewareInfo.price,
isShop:this.coursewareInfo.isShop
}
}
},
watch: {
reload(){
window.location.reload();
......@@ -178,6 +188,15 @@
}
},
methods: {
payClick(){
if(this.isMobile == false && this.isWeixin == false){
$('#web-pay').trigger('click');
}else if(this.isMobile == true && this.isWeixin == false){
this.mobileAliPay(this.coursewareInfo.course_id);
}else if(this.isWeixin === true){
this.weixinJsPay(this.coursewareInfo.course_id);
}
},
alipay(courseId){
var url = __BASE_URL__ + 'home/pay?courseId=' + courseId;
......
<template>
<div style="width:100%;height:100%" class="video-main">
<video id="my-video-play" class="video-js vjs-default-skin vjs-big-play-centered"
<video v-if="videoInfo.freeTime > 0" id="my-video-play" class="video-js vjs-default-skin vjs-big-play-centered"
controls preload="auto">
<source :src="videoUrl"/>
<source :src="videoInfo.videoUrl"/>
</video>
<!-- 付费视频的样式
<img src="http://deimg.c.pp.cc/preview/f0/97/a3/f8s68SyefrZj3841.jpg" width="100%" height="auto">
<!-- 付费视频的样式 -->
<template v-if="showTips">
<img v-if="videoInfo.freeTime == 0" :src="videoInfo.previewUrl" width="100%" height="auto">
<div class="play-mask-box">
<div class="look-video">
<p v-if="videoInfo.freeTime >0">本课程可试看{{videoInfo.freeTime}}分钟</p>
<div class="play-mask-box">
<div class="look-video">
<p>本课程为付费课程,价格¥108.00 <a href="#">立即购买</a></p>
&lt;!&ndash;<p>本课程可试看2分钟</p>&ndash;&gt;
<p v-else>本课程为付费课程,{{videoInfo.price}} <a @click="pay" href="javascript:;">立即购买</a></p>
</div>
</div>
</div>
-->
</template>
</div>
</template>
......@@ -26,38 +28,55 @@
window.VIDEOJS_NO_BASE_THEME = true;
export default{
data(){
return {}
return {
showTips: false
}
},
props: {
videoUrl: String,
previewUrl: String
videoInfo: Object,
},
methods: {
pay(){
this.$dispatch('pay-click');
}
},
ready(){
var self = this;
var rate = 9 / 16;
var w = $('.video-main').width();
var h = w * rate;
videojs("my-video-play", {
"techOrder": ['html5', 'flash'],
"controls": true,
"autoplay": false,
"language": "zh-CN",
"width": w,
"height": h,
"poster": self.previewUrl
}).ready(function () {
$('#my-video-play').css('width', '100%');
var wVideo = $('#my-video-play').width();
var hVideo = wVideo * rate;
$('#my-video-play').css('height', hVideo);
window.onresize = function () {
if (this.videoInfo.isShop) {
this.showTips = false;
} else {
this.showTips = true;
}
//不显示视频则不绑定
if (this.videoInfo.freeTime > 0) {
var self = this;
var rate = 9 / 16;
var w = $('.video-main').width();
var h = w * rate;
var myPlayer = videojs("my-video-play", {
"techOrder": ['html5', 'flash'],
"controls": true,
"autoplay": false,
"language": "zh-CN",
"width": w,
"height": h,
"poster": this.videoInfo.previewUrl,
}).ready(function () {
$('#my-video-play').css('width', '100%');
var wVideo = $('#my-video-play').width();
var hVideo = wVideo * rate;
$('#my-video-play').css('height', hVideo);
};
});
window.onresize = function () {
var wVideo = $('#my-video-play').width();
var hVideo = wVideo * rate;
$('#my-video-play').css('height', hVideo);
};
});
myPlayer.bigPlayButton.on('click', function () {
self.showTips = false;
});
}
}
}
</script>
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