Commit fac78315 authored by xiabin's avatar xiabin

修改登录后支付的问题

parent b99c79bd
...@@ -143,12 +143,18 @@ class HomeController extends \yii\web\Controller ...@@ -143,12 +143,18 @@ 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;
$coursewareInfo['isMe'] = true;
//已登录 //已登录
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);
$coursewareInfo['isShop'] = ($order !== NULL and $order->status === Orders::PAID ? TRUE : FALSE); $coursewareInfo['isShop'] = ($order !== NULL and $order->status === Orders::PAID ? TRUE : FALSE);
$coursewareInfo['isMe'] = (Yii::$app->user->id == $coursewareInfo['user_id']);
if($coursewareInfo['isMe'] === true){
$coursewareInfo['isShop'] = true;
}
} }
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) {
......
...@@ -48,9 +48,15 @@ ...@@ -48,9 +48,15 @@
¥{{coursewareInfo.price}} ¥{{coursewareInfo.price}}
</button> </button>
<template v-else> <template v-else>
<button v-if="coursewareInfo.isGuest" @click="login" class="btn btn-danger m-l-20 mb-left">购买 <template v-if="coursewareInfo.isShop">
¥{{coursewareInfo.price}} <button v-if="coursewareInfo.isShop && coursewareInfo.isMe == false" class="btn btn-danger m-l-20 hidden-xs mb-left"
</button> data-toggle="modal" disabled="disabled">已购买
</button>
<button v-else
class="btn btn-danger m-l-20 mb-left"
>购买 ¥{{coursewareInfo.price}}
</button>
</template>
<template v-else> <template v-else>
<button v-if="coursewareInfo.isShop" class="btn btn-danger m-l-20 hidden-xs mb-left" <button v-if="coursewareInfo.isShop" class="btn btn-danger m-l-20 hidden-xs mb-left"
data-toggle="modal" disabled="disabled">已购买 data-toggle="modal" disabled="disabled">已购买
...@@ -146,7 +152,8 @@ ...@@ -146,7 +152,8 @@
previewUrl: this.coursewareInfo.previewUrl, previewUrl: this.coursewareInfo.previewUrl,
freeTime:this.coursewareInfo.free_time, freeTime:this.coursewareInfo.free_time,
price:this.coursewareInfo.price, price:this.coursewareInfo.price,
isShop:this.coursewareInfo.isShop isShop:this.coursewareInfo.isShop,
isMe:this.coursewareInfo.isMe
} }
} }
}, },
......
<template> <template>
<div style="width:100%;height:100%" class="video-main"> <div style="width:100%;height:100%" class="video-main">
<video v-if="videoInfo.freeTime > 0" id="my-video-play" class="video-js vjs-default-skin vjs-big-play-centered" <video v-if="videoInfo.freeTime > 0 || videoInfo.isShop" id="my-video-play"
class="video-js vjs-default-skin vjs-big-play-centered"
controls preload="auto"> controls preload="auto">
<source :src="videoInfo.videoUrl"/> <source :src="videoInfo.videoUrl"/>
</video> </video>
...@@ -9,12 +10,12 @@ ...@@ -9,12 +10,12 @@
<template v-if="showTips"> <template v-if="showTips">
<img v-if="videoInfo.freeTime == 0" :src="videoInfo.previewUrl" width="100%" height="auto"> <img v-if="videoInfo.freeTime == 0" :src="videoInfo.previewUrl" width="100%" height="auto">
<div class="play-mask-box"> <div class="play-mask-box">
<div v-if="videoInfo.freeTime >0" class="look-video"> <div v-if="videoInfo.freeTime >0" class="look-video">
<p>本课程可试看{{videoInfo.freeTime}}分钟</p> <p>本课程可试看{{videoInfo.freeTime}}分钟</p>
</div> </div>
<div v-else class="has-icon-part"> <div v-else class="has-icon-part">
<p> <p>
<a @click="pay" href="javascript:;"><span class="icon-play"></span></a> <a @click="pay" href="javascript:;"><span class="icon-play"></span></a>
<span>本课程为付费课程,{{videoInfo.price}} <a @click="pay" href="javascript:;">立即购买</a></span> <span>本课程为付费课程,{{videoInfo.price}} <a @click="pay" href="javascript:;">立即购买</a></span>
...@@ -22,6 +23,13 @@ ...@@ -22,6 +23,13 @@
</div> </div>
</div> </div>
</template> </template>
<template v-if="videoInfo.isMe">
<div v-if="showIsMeTips" class="play-mask-box">
<div class="look-video">
<p>您发布的课程,无需购买可直接观看。</p>
</div>
</div>
</template>
</div> </div>
</template> </template>
...@@ -34,7 +42,8 @@ ...@@ -34,7 +42,8 @@
export default{ export default{
data(){ data(){
return { return {
showTips: false showTips: false,
showIsMeTips:false
} }
}, },
props: { props: {
...@@ -52,6 +61,9 @@ ...@@ -52,6 +61,9 @@
} else { } else {
this.showTips = true; this.showTips = true;
} }
if(this.videoInfo.isMe){
this.showIsMeTips = true;
}
//不显示视频则不绑定 不为没有购买且为不免费 //不显示视频则不绑定 不为没有购买且为不免费
if (this.videoInfo.freeTime > 0 || this.videoInfo.isShop == true) { if (this.videoInfo.freeTime > 0 || this.videoInfo.isShop == true) {
var self = this; var self = this;
...@@ -90,6 +102,10 @@ ...@@ -90,6 +102,10 @@
self.pay(); self.pay();
}); });
}); });
}else if(this.videoInfo.isMe){
myPlayer.bigPlayButton.on('click', function () {
self.showIsMeTips = false;
});
} }
} }
......
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