123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430 |
- <template>
- <view class="">
- <view class="ddxqship">
- <view class="u-rela" style="width: 100%; height: 100%;" v-if="!videoShow" @click="playVideo">
- <image :src="info.img" mode="aspectFill" style="width: 100%;height: 100%;"></image>
- <u-icon name="play-right-fill" size="80" color="#fff" class="u-abso"
- style="z-index: 9; left: 50%; top: 50%; transform: translate(-50%,-50%);"></u-icon>
- </view>
- <video v-if="videoShow" @timeupdate="timeupdate" :src="videoinfo.content" autoplay
- style="width: 100%;height: 100%;"></video>
- </view>
- <view class="ddxqfayu">
- <view class="indhuyr">
- <view class="indjbrr"></view>
- <text>课程详情</text>
- </view>
- <view style="margin-top: 30rpx;">
- <view class="fzctob">
- <view class="kcxquyr">
- <text>课程名称</text>
- </view>
- <view class="kcxquyra">
- <text>{{item.title}}</text>
- </view>
- </view>
- <view style="border-top: 2rpx dashed #e8e8e8;width: 100%;margin: 22rpx 0;"></view>
-
- {{item}}
- </view>
- </view>
- <view class="ddxqfayu" v-for="(item1,index1) in catalog" :key="index1">
- <view class="indhuyr">
- <view class="indjbrr"></view>
- <text>{{item1.title}}</text>
- </view>
- <view style="margin-top: 10rpx;">
- <view class="fsxto kandyyr" v-for="(item2,index2) in item1.list" :key="index2" @click="changevideo(item2)">
- <view class="flztoa">
- <text>{{item2.title}}</text>
- <image src="/static/zy/zyb3.png" style="width: 24px;height: 24px;" mode=""></image>
- </view>
- <view class="flztoa" style="margin-top: 4px;" v-if="item2.type == 1">
- <text class="ooddte">{{item2.video_title}}</text>
- <text class="ooddte">时长: {{item2.video_time}}</text>
- </view>
- <view class="flztoa" style="margin-top: 4px;" v-if="item2.type == 5"
- @click="goWxLive(item2.url,item2)">
- <text class="ooddte">{{item2.video_title}}</text>
- <text class="ooddte">点击进入直播间</text>
- </view>
- </view>
- </view>
- </view>
- <view class="" style="height: 200rpx;"></view>
- <view class="kcquuer" v-if="!is_pay">
-
- {{coupon.title}}{{coupon.price}}
- <view class="flztoa">
- <view class="kqyyefh" @click="pay(0)">
- <text>¥{{item.current_price}}/领取</text>
- </view>
-
- {{info.vip_price}}
-
- {{info.price}}
- {{info.vip_price}}
- </view>
- </view>
-
- {{coupon.title}}{{coupon.price}}
- {{info.price}}
- {{info.vip_price}}
- {{info.price}}
- {{info.vip_price}}
- </view>
- </template>
- <style>
- page {
- background: #FAFAFA;
- }
- </style>
- <script>
- export default {
- data() {
- return {
- xqaxuye: false,
- info: {},
- videoinfo: {},
- catalog: [],
- is_pay: 0,
- is_vip: '',
- videoShow: false,
- roomId: 0,
- customParams: {},
- seconds: 0,
- id: 0,
- deviceType: 'wxapp',
- coupon: false,
- coupon_id:0,
- item:null
- }
- },
- onLoad(e) {
-
- this.deviceType = 'wxh5'
-
-
- this.deviceType = 'wxapp'
-
- let item = JSON.parse(e.item);
- this.id = item.id;
-
- this.getCourseChapter(item.id);
- this.item = item;
- this.is_pay = item.is_pay;
- this.is_vip = uni.getStorageSync('is_vip');
- },
-
- onUnload() {
- if (this.seconds != 0) {
- this.$post({
- data: {
- do: 'ChangeRecordHistory',
- data: {
- user_id: uni.getStorageSync('id'),
- course_id: this.id,
- catalog_id: this.videoinfo.catalog_id,
- chapter_id: this.videoinfo.id,
- chapter_time: this.formatSeconds(this.seconds)
- }
- }
- })
- }
- },
- methods: {
- getMyCoupon() {
- },
- timeupdate(e) {
- let time = e.detail.currentTime
- this.seconds = time
- },
-
- formatSeconds(value) {
-
- let second = parseInt(value)
-
- let minute = 0
-
- let hour = 0
-
-
-
- if (second >= 60) {
-
- minute = parseInt(second / 60)
-
- second = parseInt(second % 60)
-
- if (minute > 60) {
-
- hour = parseInt(minute / 60)
-
- minute = parseInt(minute % 60)
-
-
-
-
-
-
-
- }
- }
- let h = parseInt(hour) > 9 ? parseInt(hour) : '0' + parseInt(hour)
- let m = parseInt(minute) > 9 ? parseInt(minute) : '0' + parseInt(minute)
- let s = parseInt(second) > 9 ? parseInt(second) : '0' + parseInt(second)
- let result = '' + s;
- if (minute > 0) {
- result = '' + m + ':' + result
- }
- if (hour > 0) {
- result = '' + h + ':' + result
- }
-
-
-
- result = result.includes(':') ? result : '00:' + result
- console.log('result:', result)
- return result
- },
- goWxLive(id, item2) {
-
- console.log(id);
- let roomId = [id];
- let customParams = encodeURIComponent(JSON.stringify({
- path: 'pages/index/index',
- pid: 1
- }))
- this.roomId = roomId;
- this.customParams = customParams;
- uni.navigateTo({
- url: 'plugin-private://wx2b03c6e691cd7370/pages/live-player-plugin?room_id=' + roomId +
- '&custom_params=' + customParams
- })
-
-
- console.log(item2)
- uni.navigateTo({
- url: '/pages/index/watchLive?id=' + item2.id
- })
-
- },
- playVideo() {
-
-
-
-
-
-
- this.videoShow = true
- },
- changevideo(info) {
- if (this.is_buy) {
- this.videoinfo = info
- } else {
- uni.showModal({
- title: '此课程未购买'
- })
- }
- },
- getCourseChapter() {
- let that = this;
- that.$request.getCourseChapter({course_id: that.id}).then(res => {
- console.log(res)
- if(res.code == 0){
- this.videoinfo = res.data[0];
- }else{
- wx.showToast({
- title: res.message,
- icon: 'none'
- })
- }
-
- }).catch(err => {
- console.log(err)
- })
-
- return
- let user_id = uni.getStorageSync('id');
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- },
- pay(indexs) {
- let that = this;
- that.$request.receive({course_id: that.id}).then(res => {
- console.log(res)
- if(res.code == 0){
- if(that.data.item.current_price <= 0){
- wx.showToast({
- title: '领取成功',
- })
- that.getCourseChapter();
- }else{
- that.wechatpay(res.data);
- }
-
- }else{
- wx.showToast({
- title: res.message,
- icon: 'none'
- })
- }
- }).catch(err => {
- console.log(err)
- })
- },
- wechatpay(pay) {
- console.log(pay)
- var that = this
-
- uni.requestPayment({
- provider: 'wxpay',
- orderInfo: pay.orderinfo,
- success() {
- uni.showToast({
- title: '支付成功'
- })
- that.getCourseChapter();
- },
- fail(res) {
- console.log(res)
- uni.showToast({
- title: '支付失败',
- icon: 'error'
- })
- }
- })
-
-
- uni.requestPayment({
- provider: 'wxpay',
- timeStamp: pay.timeStamp,
- nonceStr: pay.nonceStr,
- package: pay.package,
- signType: 'MD5',
- paySign: pay.paySign,
- success() {
- uni.showToast({
- title: '支付成功'
- })
- that.getCourseChapter();
- },
- fail(res) {
- console.log(res)
- uni.showToast({
- title: '支付失败',
- icon: 'error'
- })
- }
- })
-
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .flztoa{
- justify-content: center;
- }
- .kandyyr {
- font-size: 14px;
- font-family: PingFang SC-常规体, PingFang SC;
- font-weight: normal;
- color: #333333;
- margin-top: 20px;
- }
- .ooddte {
- font-size: 12px;
- font-family: PingFang SC-常规体, PingFang SC;
- font-weight: normal;
- color: #999999;
- line-height: 17px;
- }
- </style>
|