123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261 |
- <template>
- <view class="container">
- <view class="conwarp">
- <view class="gdHead dffs">
- <view class="head flex1">{{ goodInfo.title }}</view>
- <text v-for="(item, index) in goodInfo.tags.split('|')" class="desc">{{ item }}</text>
- </view>
- <view class="subtit textgrey fontssm">{{ goodInfo.desc }}</view>
- <!-- -->
- <view class="cl-one"><video id='myVideo' class="vidBox" @timeupdate="timeupdate" @play="play"
- :initial-time="0" :src="goodInfo.files" controls></video></view>
- </view>
- <view class="conwarp">
- <view class="gdHead">
- <view class="head">课程简介</view>
- </view>
- <view class="cl-one">
- <view class="xqcont">
- <u-parse :content="goodInfo.content"></u-parse>
- </view>
- </view>
- </view>
- <view v-if="goodInfo.is_pay != 0 && goodInfo.my_is_pay == 0" class="fixBox dfsb">
- <view @tap="toPay()" class="li flex1 dffs">
- <image src="/static/img/pro/navlidown.png" mode=""></image>
- 普通购买
- </view>
- <block v-if="goodInfo.is_vip == 1">
- <view class="line"></view>
- <view @tap="toPay()" class="li flex1 dffs">
- <image src="/static/img/pro/navlivdown.png" mode=""></image>
- 会员购买
- </view>
- </block>
- </view>
- </view>
- </template>
- <script>
- export default {
- data() {
- return {
- id: 0, //商品id
- type: '',
- goodInfo: {
- tags: ''
- }
- };
- },
- onLoad(option) {
- this.id = option.id || '';
- this.type = option.type || '';
- this.loadData();
- },
- onReady: function(res) {
- this.videoContext = uni.createVideoContext('myVideo')
- },
- methods: {
- timeupdate(e) {
- console.log(parseInt(e.detail.currentTime));
- // is_pay 0 免费 1 付费 my_is_pay 0 未购买 1 已购买
- if (this.goodInfo.is_pay != 0 && this.goodInfo.my_is_pay != 1) {
- console.log(11);
- // is_vip/是否是会员: 0=否 1=是 see_time 可试看时长: 秒
- if (parseInt(e.detail.currentTime) >= parseInt(this.goodInfo.see_time)) {
- // e.detail.currentTime = 0;
- this.$api.toast('请购买后观看完整视频');
- setTimeout(res => {
- this.videoContext.pause()
- this.videoContext.seek(0);
- }, 800);
- }
- }
- },
- play(e) {
- let url = 'index/setSee';
- this.$api
- .request(url, {
- id: this.id
- })
- .then(res => {
- if (res.code != '200') {
- this.$api.toast(res.msg);
- }
- });
- },
- /**
- * 请求数据只是为了代码不那么乱
- * 分次请求未作整合
- */
- async loadData() {
- let url = 'index/getVideoInfo';
- this.$api
- .request(url, {
- id: this.id
- })
- .then(res => {
- if (res.code == '200') {
- let data = res.data;
- this.goodInfo = data;
- } else {
- this.$api.toast(res.msg);
- }
- });
- },
- //去支付购买
- toPay() {
- uni.navigateTo({
- url: '/pages/pay/payVid?item=' + JSON.stringify(this.goodInfo)
- });
- }
- }
- };
- </script>
- <style lang="scss" scoped>
- .container {
- .conwarp {
- background-color: #fff;
- padding: 26rpx 30rpx 39rpx;
- border-radius: 16rpx;
- margin-bottom: 20rpx;
- .gdHead {
- line-height: 58rpx;
- margin-bottom: 16rpx;
- .head {
- font-size: 34rpx;
- font-family: PingFangSC-Medium, PingFang SC;
- font-weight: 600;
- color: #333333;
- line-height: 48rpx;
- }
- .desc {
- background: #f89638;
- border-radius: 5rpx;
- font-size: 18rpx;
- height: 32rpx;
- line-height: 32rpx;
- padding: 0rpx 8rpx;
- display: inline-block;
- color: #fff;
- margin-left: 10rpx;
- &:nth-of-type(2) {
- background: #7fc06e;
- }
- &:nth-of-type(3) {
- background: #75b2c4;
- }
- &:nth-of-type(4) {
- background: #8875c0;
- }
- }
- }
- .subtit {
- margin-top: 10rpx;
- }
- .cl-one {
- .vidBox {
- margin-top: 30rpx;
- width: 690rpx;
- height: 335rpx;
- }
- .xqcont {
- min-height: 800rpx;
- width: 100%;
- align-items: center;
- position: relative;
- .xqleft {
- position: absolute;
- top: 100rpx;
- right: 0;
- align-items: center;
- justify-content: center;
- .small {
- width: 54rpx;
- height: 54rpx;
- }
- .big {
- width: 108rpx;
- height: 108rpx;
- }
- .word {
- margin: 8rpx 0 48rpx;
- font-size: 20rpx;
- color: #999;
- }
- }
- .btnsBox {
- align-items: center;
- .small {
- width: 90rpx;
- height: 90rpx;
- margin: 60rpx 0 16rpx;
- opacity: 0.8;
- }
- .btns {
- margin: 70rpx 60rpx 0;
- width: 154rpx;
- height: 54rpx;
- background: #f6f6f6;
- border-radius: 31px;
- align-items: center;
- padding: 0 15rpx;
- justify-content: space-around;
- .icon {
- width: 35rpx;
- height: 31rpx;
- }
- .word {
- font-size: 22rpx;
- color: #666;
- }
- }
- }
- }
- }
- }
- .fixBox {
- padding: 34rpx;
- .line {
- width: 1rpx;
- height: 20rpx;
- background: #b7b7bd;
- }
- .li {
- justify-content: center;
- color: #7fc06e;
- image {
- width: 42rpx;
- height: 32rpx;
- margin-right: 20rpx;
- }
- }
- }
- }
- </style>
|