Commit dfb37eb4 authored by xiabin's avatar xiabin

修改支付后的弹窗问题

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