123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127 |
- <template>
- <view>
- <view class="video">
- <video :src="data.url" :poster="data.cover_image" @timeupdate='TimeUpdate($event,data.id)' @ended="ended"
- controls style="width: 100%;"></video>
- </view>
- <view class="wrapper">
- <view class="title">
- {{data.title}}
- </view>
- <view class="desc" v-if='data.isGift'>
- 券已领取
- </view>
- <view class="desc" v-else>
- 奖励券:{{data.integral}}
- </view>
- <view class="details">
- <view class="">
- 视频详情:
- </view>
- <view class="content" v-html="data.content">
- </view>
- </view>
- </view>
- </view>
- </template>
- <script>
- import {
- seeVideoGift
- } from '@/api/shop.js';
- import {
- mapGetters,
- mapActions
- } from 'vuex'
- export default {
- data() {
- return {
- data: {},
- currentId: '',
- playTime: '',
- allTime: "",
- currentId: null
- }
- },
- onLoad(option) {
- // let data = JSON.parse(option.infos)
- // this.data = data
- // console.log(data)
- let data = uni.getStorageSync('videoData')
- this.data = data
- console.log(data)
- },
- methods: {
- // 看完视频获取券
- async getVideoGift() {
- const {
- code,
- data,
- msg
- } = await seeVideoGift({
- id: this.currentId
- })
- if (code == 1) {
- uni.showToast({
- title: msg
- })
- } else {
- uni.showToast({
- title: msg
- })
- }
- },
- TimeUpdate(e, id) {
- this.currentId = id
- this.playTime = e.detail.currentTime
- this.allTime = e.detail.duration
- // 当播放时间大于 视频总时长 即播放结束发起请求 获取券
- if (this.playTime >= this.allTime) {
- }
- },
- // 播放结束给券
- ended() {
- this.getVideoGift()
- }
- }
- }
- </script>
- <style lang="scss">
- page {
- height: 100vh;
- }
- .wrapper {
- box-sizing: border-box;
- background-color: #fff;
- padding: 20rpx 30rpx;
- .title {
- font-weight: bold;
- line-height: 80rpx;
- }
- .desc {
- font-size: 28rpx;
- color: #F73E33;
- }
- .details {
- margin: 40rpx auto;
- .title {
- font-weight: bold;
- }
- .content {
- margin-top: 40rpx;
- }
- }
- }
- </style>
|