Commit aa504631 by luyt

feat:视频全屏组件弹框

1 parent da3a605c
// components/FullscreenVideo/FullscreenVideo.js
Component({
/**
* 组件的属性列表
*/
properties: {
src:String,
title:String,
},
/**
* 组件的初始数据
*/
data: {
fullScreen: false,
},
lifetimes: {
ready() {
// this.play();
},
},
/**
* 组件的方法列表
*/
methods: {
/**播放视屏 */
play(e) {
//执行全屏方法
var videoContext = wx.createVideoContext("myvideo", this);
videoContext.requestFullScreen();
this.setData({
fullScreen: true,
});
},
/**关闭视屏 */
closeVideo() {
//执行退出全屏方法
var videoContext = wx.createVideoContext("myvideo", this);
videoContext.exitFullScreen();
this.setData({
fullScreen: false,
});
},
/**视屏进入、退出全屏 */
fullScreenFn(e) {
var isFull = e.detail.fullScreen;
//视屏全屏时显示加载video,非全屏时,不显示加载video
this.setData({
fullScreen: isFull,
});
},
},
});
{
"component": true,
"usingComponents": {}
}
\ No newline at end of file
/* components/FullscreenVideo/FullscreenVideo.wxss */
.show{
display:block;
}
.hide{
display:none;
}
\ No newline at end of file
<!-- components/FullscreenVideo/FullscreenVideo.wxml -->
<!-- -->
<video id='myvideo' class='{{fullScreen?"show":"hide"}}' src="{{src}}" title="{{title}}" autoplay="true" bindfullscreenchange="fullScreenFn" bindended="closeVideo" controls></video>
\ No newline at end of file
......@@ -49,7 +49,10 @@ Page({
hasUserInfo: false,
phone: '', //授权手机号
userInfo: '',
isAuthphone: true //授权昵称弹窗显示,更多按钮显示
isAuthphone: true, //授权昵称弹窗显示,更多按钮显示
// 视频播放地址
videoSrc:'',
videoTitle:''
},
observers: {
actNum: function (actNum) {
......@@ -130,7 +133,7 @@ Page({
//接受跳转的路由参数(小程序页面跳转)
onRoute(options) {
console.log('分享options: ', options)
// console.log('分享onRoute ', options)
if (!options || utils.isEmptyObj(options)) return
// if(!Object.keys(options).includes('actNum'))return
let { senceData } = this.data
......@@ -418,7 +421,7 @@ Page({
*/
async onLoad(options) {
await this.getData()
console.log('分享options12255565: ', options)
// console.log('分享onLoad: ', options)
// actNum,activeNavIdx isShare
if (!options || utils.isEmptyObj(options)) return
......@@ -536,11 +539,33 @@ Page({
}, 500)
}
})(),
//视频弹窗
videoplay(){
wx.$eventbus.on('getvideo',(e)=>{
// console.log('getvideo event bus: ', e);
let obj = {
videoTitle:e.title,
videoSrc:e.src
}
this.getVideoUrl(obj)
wx.nextTick(() => {
this.videocomp.play();
});
})
},
//设置视频url
getVideoUrl(params){
this.setData(params)
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {},
onReady: function() {
this.videocomp = this.selectComponent("#videocomp1");
this.videoplay()
},
/**
* 生命周期函数--监听页面显示
......
{
"usingComponents": {
"product": "../tab/index/components/product/product"
"product": "../tab/index/components/product/product",
"FullscreenVideo":"../../components/FullscreenVideo/FullscreenVideo"
},
"navigationStyle": "custom",
"onReachBottomDistance": 10,
......
......@@ -55,4 +55,6 @@
</view>
<!-- 授权昵称 -->
<!-- !hasUserInfo && !isShow -->
<view wx:if="{{!hasUserInfo && isShare && isAuthphone}}" class="user-profile" bindtap="getUserProfile"></view>
\ No newline at end of file
<view wx:if="{{!hasUserInfo && isShare && isAuthphone}}" class="user-profile" bindtap="getUserProfile"></view>
<!-- 全屏视频组件 -->
<FullscreenVideo id="videocomp1" src="{{videoSrc}}" title="{{videoTitle}}"></FullscreenVideo>
\ No newline at end of file
......@@ -64,7 +64,7 @@ Component({
ready: function () {
this.init();
this.getImgHeight();
console.log("ready");
// console.log("ready");
// //获取当前路径
// let currentUrl = this.getCurrentPageUrl()
// // console.log('currentUrl: ', currentUrl);
......@@ -461,5 +461,15 @@ Component({
// isShare: true
});
},
// 点击获取视频的url
getVideoUrl(e){
// console.log('e: ', e);
let {title,src} = e.currentTarget.dataset
wx.$eventbus.emit('getvideo',{title:title,src:src})
// this.triggerEvent('getvideo', {
// title,
// src
// })
},
},
});
\ No newline at end of file
......@@ -281,7 +281,6 @@
.video-item {
width: 100%;
video {
border-radius: 16rpx;
height: 348rpx;
......@@ -426,6 +425,10 @@
width: calc(50% - 12rpx);
margin-bottom: 32rpx;
}
.video-item .video-card{
width: 100%;
height: 590rpx;
}
.video-item video {
width: 100%;
......@@ -436,9 +439,13 @@
.video-item .download {
position: absolute;
top: 0;
right: 2px;
font-size: 26rpx;
color: #666;
right: 0;
width:48rpx;
height: 48rpx;
background-image: url("https://img02.glsx.com.cn/weapp/resource/saas/business-assistant/index/down-video.png");
background-repeat:no-repeat;
// font-size: 26rpx;
// color: #666;
z-index: 1;
}
......
......@@ -80,7 +80,8 @@
<block wx:for="{{senceData[actNum].videoList}}" wx:key="i">
<view class="video-item">
<view class="download" bindtap="downVideo" data-url="{{videoBaseUrl}}video/{{item.videoUrl}}.mp4?v={{img_version}}">视频下载</view>
<video poster="{{videoBaseUrl}}video/{{item.posterUrl}}.png?v={{img_version}}" title="{{item.name}}" src="{{videoBaseUrl}}video/{{item.videoUrl}}.mp4?v={{img_version}}" />
<!-- <video poster="{{videoBaseUrl}}video/{{item.posterUrl}}.png?v={{img_version}}"/> -->
<image class="video-card" bindtap="getVideoUrl" data-title="{{item.name}}" data-src="{{videoBaseUrl}}video/{{item.videoUrl}}.mp4?v={{img_version}}" src="{{videoBaseUrl}}video/{{item.posterUrl}}.png?v={{img_version}}"></image>
<view class="video-text">{{item.name}}</view>
</view>
</block>
......
const navStyle = 'background-color: transparent;'
import { IMG_URL } from '~/utils/constantData.js'
import Util from '~/utils/util.js'
import { senceData } from './constant/data'
const IMAGES = Object.freeze({
arrow: `${IMG_URL}/index/point.png`,
......@@ -45,7 +46,9 @@ Page({
// 定义数据
senceData,
isShow: false,
// 视频播放地址
videoSrc:'',
videoTitle:''
},
//引导图
......@@ -314,6 +317,24 @@ Page({
disLikeRecordFlag
})
}
//视频弹窗
wx.$eventbus.on('getvideo',(e)=>{
// console.log('getvideo event bus: ', e);
let url = Util.getCurrentPageUrl()
if(url == '/pages/tab/index/index'){
let obj = {
videoTitle:e.title,
videoSrc:e.src
}
this.getVideoUrl(obj)
wx.nextTick(() => {
this.videocomp.play();
});
}
})
},
//接口数据,本地数据对接
compositionData(localData, apiData) {
......@@ -344,13 +365,13 @@ Page({
actNum: actTndex
})
},
// 看线索相关
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
this.prompt = this.selectComponent('#toast')
this.videocomp = this.selectComponent("#videocomp");
},
// //点击收藏提示框
......@@ -442,6 +463,10 @@ Page({
}, 300)
}
})(),
//设置视频url
getVideoUrl(params){
this.setData(params)
},
/**
* 生命周期函数--监听页面隐藏
*/
......
......@@ -3,7 +3,8 @@
"vas-toast": "./components/likeToast/likeToast",
"crowdfund-poster": "./components/CrowdfundPoster/CrowdfundPoster",
"indexProduct":"./components/indexProduct/indexProduct",
"indexClue":"./components/indexClue/indexClue"
"indexClue":"./components/indexClue/indexClue",
"FullscreenVideo":"../../../components/FullscreenVideo/FullscreenVideo"
},
"navigationStyle": "custom",
"onReachBottomDistance": 50,
......
......@@ -99,4 +99,6 @@
</view>
</view>
<crowdfund-poster item="{{posterItem}}" />
<!-- 全屏视频组件 -->
<FullscreenVideo id="videocomp" src="{{videoSrc}}" title="{{videoTitle}}"></FullscreenVideo>
......@@ -152,6 +152,14 @@ const getImgVersion = () => {
return '1.0.0'
};
//获取当前页面路径
const getCurrentPageUrl = () =>{
const pages = getCurrentPages()
const currentPage = pages[pages.length - 1]
const url = `/${currentPage.route}`
return url
}
const Util = {
getImgVersion,
onReachBottom,
......@@ -160,5 +168,6 @@ const Util = {
throttle,
isEmptyObj,
parseString,
getCurrentPageUrl
};
export default Util;
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!