Commit fac78315 authored by xiabin's avatar xiabin

修改登录后支付的问题

parent b99c79bd
......@@ -143,12 +143,18 @@ 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;
$coursewareInfo['isMe'] = true;
//已登录
if (!Yii::$app->user->isGuest) {
$coursewareInfo['userAvatar'] = User::getAvatarUrl(Yii::$app->user->identity->avatar);
$order = Orders::findByUserIdAndCourseId($userId, $courseId);
$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']) {
$coursewareInfo['videoUrl'] = Yii::$app->qiniu->getUrl('video', $coursewareInfo['src_stand']);
} else if ($course->free_time > 0) {
......
......@@ -48,9 +48,15 @@
¥{{coursewareInfo.price}}
</button>
<template v-else>
<button v-if="coursewareInfo.isGuest" @click="login" class="btn btn-danger m-l-20 mb-left">购买
¥{{coursewareInfo.price}}
</button>
<template v-if="coursewareInfo.isShop">
<button v-if="coursewareInfo.isShop && coursewareInfo.isMe == false" class="btn btn-danger m-l-20 hidden-xs mb-left"
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>
<button v-if="coursewareInfo.isShop" class="btn btn-danger m-l-20 hidden-xs mb-left"
data-toggle="modal" disabled="disabled">已购买
......@@ -146,7 +152,8 @@
previewUrl: this.coursewareInfo.previewUrl,
freeTime:this.coursewareInfo.free_time,
price:this.coursewareInfo.price,
isShop:this.coursewareInfo.isShop
isShop:this.coursewareInfo.isShop,
isMe:this.coursewareInfo.isMe
}
}
},
......
<template>
<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">
<source :src="videoInfo.videoUrl"/>
</video>
......@@ -9,12 +10,12 @@
<template v-if="showTips">
<img v-if="videoInfo.freeTime == 0" :src="videoInfo.previewUrl" width="100%" height="auto">
<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>
</div>
<div v-else class="has-icon-part">
<div v-else class="has-icon-part">
<p>
<a @click="pay" href="javascript:;"><span class="icon-play"></span></a>
<span>本课程为付费课程,{{videoInfo.price}} <a @click="pay" href="javascript:;">立即购买</a></span>
......@@ -22,6 +23,13 @@
</div>
</div>
</template>
<template v-if="videoInfo.isMe">
<div v-if="showIsMeTips" class="play-mask-box">
<div class="look-video">
<p>您发布的课程,无需购买可直接观看。</p>
</div>
</div>
</template>
</div>
</template>
......@@ -34,7 +42,8 @@
export default{
data(){
return {
showTips: false
showTips: false,
showIsMeTips:false
}
},
props: {
......@@ -52,6 +61,9 @@
} else {
this.showTips = true;
}
if(this.videoInfo.isMe){
this.showIsMeTips = true;
}
//不显示视频则不绑定 不为没有购买且为不免费
if (this.videoInfo.freeTime > 0 || this.videoInfo.isShop == true) {
var self = this;
......@@ -90,6 +102,10 @@
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