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