加入审核模式下播放不了视频

This commit is contained in:
A1300399510 2024-04-12 11:38:35 +08:00
parent 6f84410c11
commit 425f2dd197
17 changed files with 107 additions and 422 deletions

1
app.js
View File

@ -184,6 +184,7 @@ App({
},
isMapFindState: false, // 地图找房入口
isShowVideo: true, // 是否显示视频
socketTask: null, // 全局的 socket 值
isHideState: true, // 判断是否 隐藏了 在 onshow 为 true 是代表小程序后台打开

View File

@ -16,7 +16,6 @@ Page({
banner: [],
service: '',
servicename: '',
video: '',
screen_data: {},
advListHKhousing: {},
advListotherHousing: {},
@ -208,16 +207,6 @@ Page({
const content = this.data.servicename;
miucms.copy(content).then((res) => {}).catch(err => {})
},
play(e) {
this.setData({
video: e.detail.src
})
},
closePage(e) {
this.setData({
video: ''
})
},
// 关闭广告
closeAd(e) {
let {

View File

@ -136,13 +136,6 @@
</view>
<fix-footer unreadMessages="{{ unreadMessages }}" bottomLift="{{ bottomLift }}"></fix-footer>
<view class='video-box' wx:if="{{ video }}">
<video src="{{ video }}" custom-cache="{{false}}" autoplay='true'>
<cover-view bindtap="closePage" style="top:{{ screen_data.statusBarHeight -5 }}px;height:{{ screen_data.titleBarHeight +10 }}px;width:{{ screen_data.titleBarHeight +10 }}px" class="cover">
<cover-image class="image" src="/img/close-f.png"></cover-image>
</cover-view>
</video>
</view>
<!-- 区域找房的 弹窗 -->
<page-container show="{{ areaPopState }}" z-index="{{ 1001 }}" bind:clickoverlay="openAreaPop">

View File

@ -54,30 +54,6 @@
border-radius: 10rpx;
}
.video-box {
width: 100vw;
height: 100vh;
z-index: 100000;
background: rgba(0, 0, 0, 0.8);
position: fixed;
left: 0;
top: 0;
}
.video-box .close {
position: fixed;
left: 20rpx;
top: 20rpx;
width: 50rpx;
height: 50rpx;
z-index: 1000000
}
.video-box video {
width: 100vw;
height: 100vh;
}
.cover {
position: fixed;
left: 5px;

View File

@ -64,7 +64,7 @@ Page({
bottomLift: 0,
operationsTop: false,
isShowVideo: true, // 是否显示 视频
},
timer: null,
@ -137,6 +137,7 @@ Page({
listTab: app.globalData.listTab,
screen_data: app.globalData.screen_data,
bottomLift: app.globalData.screen_data.bottomLift,
isShowVideo: app.globalData.isShowVideo,
})
this.get_content();
@ -207,6 +208,14 @@ Page({
} else {
data = data.data
let info = data.info
if (!this.data.isShowVideo) {
info.videos = []
const roomList = data.roomList || []
roomList.forEach(element =>{
element.videos = []
})
}
let coordinate = info.coordinate
this.data.coordinate = coordinate.split(',').map(item => {
return item * 1
@ -586,12 +595,6 @@ Page({
sources: attachment,
current
})
// return
// wx.setStorageSync('attachment', attachment)
// wx.navigateTo({
// url: `/pages/video_show/video_show?frompage=apartment&current=${current}`
// });
},
// 公共跳转

View File

@ -111,6 +111,8 @@ Page({
targetAcademyPitch: [], // 附近学校距离选中院校 数据
specialSchoolDistance: null, // 特殊的 用户带有school参数 则需要特殊显示 学校距离
isShowVideo: true, // 是否显示 视频
},
to_share() {
wx.navigateTo({
@ -166,7 +168,8 @@ Page({
show_btn: options.show_btn ? options.show_btn : 'show',
options: options || {},
irentCouponBig: app.globalData.irentCouponBig,
['info.cityid']: options.cityid
['info.cityid']: options.cityid,
isShowVideo: app.globalData.isShowVideo,
})
screenWidth = wx.getSystemInfoSync().screenWidth;
center_position = screenWidth / 2;
@ -265,6 +268,10 @@ Page({
} else {
data = data.data
let info = data.info
if (!this.data.isShowVideo) info.video = null
let arr = ["wechat", "wechatdata", "whatsapp", "tel"]
let contactValue = []
let contactObj = this.data.contactObj
@ -650,9 +657,15 @@ Page({
},
show_video: function (e) {
var src = e.currentTarget.dataset.src;
wx.navigateTo({
url: '../video_show/video_show?src=' + src
wx.previewMedia({
sources: [{
url: src,
type: "video",
}]
})
// wx.navigateTo({
// url: '../video_show/video_show?src=' + src
// })
},
showSchoolAlert(e) {
this.setData({

View File

@ -327,6 +327,7 @@
</view>
{{ targetAcademyPitch.school }}
</view>
<view class="academy-school-hint">本数据来自高德地图,仅供参考。</view>
<view class="academy-school-item" wx:for="{{ targetAcademyPitch.list }}" wx:key="index">
<view class="academy-school-item-header flexacenter">
<view class="academy-school-item-left flexacenter">

View File

@ -2366,7 +2366,8 @@ map .clickmap {
color: #000;
font-size: 30rpx;
font-weight: 650;
margin-bottom: 46rpx;
/* margin-bottom: 46rpx; */
margin-bottom: 30rpx;
font-family: 'PingFangSC-Semibold', 'PingFang SC Semibold', 'PingFang SC', sans-serif;
}
@ -2534,4 +2535,10 @@ map .clickmap {
border-radius: 15rpx;
margin-right: 15rpx;
color: #333333;
}
.academy-school-hint {
color: #a09e9e;
font-size: 22.5rpx;
margin-bottom: 30rpx;
}

View File

@ -1,177 +1,66 @@
// pages/img_show/img_show.js
var app = getApp()
// pages/video_show/video_show.js
Page({
/**
* 页面的初始数据
*/
data: {
src: '',
screen_data: {},
videoLength: 0,
imgLength: 0,
liveLength: 0,
windowWidth: 0,
swiperHeight: 320,
attachment: [],
indicatorDots: true,
autoplay: false,
interval: 5000,
duration: 500,
circular: true,
skip: true,
videoautoplay: true,
controls: true,
current: 0,
imgIndex: 0,
videoIndex: 0,
liveIndex: 0,
tab: 'video',
currentTime: 0,
loop: false,
videoLoading: true, // 视频组件 是否加载中
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
let that = this;
this.setData({
src: options.src || '',
frompage: options.frompage || '',
screen_data: app.globalData.screen_data,
current: options.current || 0,
currentTime: options.currentTime || 0,
loop: options.loop || false
})
onLoad(options) {
wx.getSystemInfo({
success: function (res) {
that.setData({
windowWidth: res.windowWidth
})
}
})
if (options.frompage && options.frompage == 'apartment') {
let attachment = wx.getStorageSync('attachment')
this.setData({
attachment
})
wx.removeStorageSync('attachment')
this.calculateimgLength()
}
if (!this.data.frompage) {
this.videoContext = wx.createVideoContext('videobox', this) //这里对应的视频id
setTimeout(() => {
// this.videoContext.play()
}, 2000)
}
},
/**
* 用户点击关闭
* 生命周期函数--监听页面初次渲染完成
*/
closePage() {
wx.navigateBack()
},
// 计算视频个数
calculateimgLength() {
let that = this;
this.data.attachment.forEach(item => {
if (item.islive) that.data.liveLength++;
else if (item.isvideo) that.data.videoLength++;
else that.data.imgLength++;
})
this.setData({
videoLength: this.data.videoLength,
imgLength: this.data.imgLength,
liveLength: this.data.liveLength,
})
// if (this.data.current >= this.data.videoLength + this.data.liveLength) {
// this.setData({
// tab: 'img',
// imgIndex: this.data.current + this.data.videoLength + this.data.liveLength
// })
// } else if (this.data.current >= this.data.liveLength) {
// this.setData({
// tab: 'video',
// videoIndex: this.data.current + this.data.liveLength
// })
// } else {
// this.setData({
// tab: 'live',
// liveIndex: this.data.current
// })
// }
let tab = "live"
let index = this.data.current
if (this.data.current >= this.data.videoLength + this.data.liveLength) {
tab = "img"
index = this.data.current + this.data.videoLength + this.data.liveLength
} else if (this.data.current >= this.data.liveLength) {
tab = "video"
index = this.data.current + this.data.liveLength
}
this.setData({
tab,
[`${tab}Index`]: index
})
},
// 切换图片或视频
changeTab(e) {
let tab = e.currentTarget.dataset.tab;
if (this.data.tab == tab) return false
let current = 0
if (tab == 'live') {} else if (tab == 'video') current = this.data.liveLength
else current = this.data.liveLength + this.data.videoLength
this.setData({
current,
imgIndex: 0,
videoIndex: 0,
tab
})
},
currentIndex: 0,
bindchangeSwiper(e) {
if (this.data.tab == 'video') {
let videoID = wx.createVideoContext('video' + this.currentIndex, this)
videoID.pause()
}
let current = e.detail.current;
let videoLength = this.data.videoLength
let liveLength = this.data.liveLength
let tab = "img"
if (current >= liveLength + videoLength) tab = "img"
else if (current >= liveLength) tab = "video"
else tab = "live"
this.setData({
tab,
current,
})
onReady() {
},
load(e) {
this.setData({
swiperHeight: Math.max(this.data.swiperHeight, this.data.windowWidth * e.detail.height / e.detail.width)
})
/**
* 生命周期函数--监听页面显示
*/
onShow() {
},
bindloadedmetadata(e) {
this.setData({
videoLoading: false
})
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})

View File

@ -1,9 +0,0 @@
{
"navigationBarTitleText": "视频",
"navigationBarBackgroundColor": "#000000",
"navigationBarTextStyle": "white",
"enablePullDownRefresh": false,
"usingComponents": {
"header-nav": "../../template/headerNav/index"
}
}

View File

@ -1,44 +1,2 @@
<!-- <header-nav inner-text="Some text"> {{ !frompage ? '视频' : (tab=='img' ? (imgIndex*1+1 + '/' + imgLength) : (videoIndex*1+1 + '/' + videoLength)) }}</header-nav> -->
<header-nav inner-text="Some text" wx:if="{{ frompage }}">
<block wx:if="{{ tab == 'img' }}">{{(current - videoLength - liveLength) + 1 + '/' + imgLength }} </block>
<block wx:if="{{ tab == 'video' }}">{{ (current - liveLength) + 1 + '/' + videoLength }}</block>
<block wx:if="{{ tab == 'live' }}">{{ current * 1 + 1 + '/' + liveLength }}</block>
</header-nav>
<view class='video-box' wx:if="{{ !frompage }}">
<video src="{{ src }}" id="videobox" loop="{{ loop }}" initial-time="{{ currentTime }}" custom-cache="{{false}}" autoplay='{{false}}'>
<cover-view bindtap="closePage" style="top:{{ screen_data.statusBarHeight -5 }}px;height:{{ screen_data.titleBarHeight +10 }}px;width:{{ screen_data.titleBarHeight +10 }}px" class="cover">
<cover-view class="inner" style="height:{{ screen_data.titleBarHeight }}px;width:{{ screen_data.titleBarHeight }}px">
<cover-image class="image" src="../../img/close-f.png"></cover-image>
</cover-view>
</cover-view>
</video>
</view>
<!-- <view class="video-img-box" style="padding-top:{{screen_data.totalTopHeight}}px" wx:if="{{ frompage=='apartment' }}"> -->
<view class="video-img-box" wx:if="{{ frompage=='apartment' }}">
<view class="tab">
<view class="{{ tab=='live' ? 'item active':'item'}}" wx:if="{{ liveLength>0}}" data-tab="live" bindtap='changeTab'>live({{ liveLength }})</view>
<view class="{{ tab=='video' ? 'item active':'item'}}" wx:if="{{ videoLength>0}}" data-tab="video" bindtap='changeTab'>视频({{ videoLength }})</view>
<view class="{{ tab=='img' ? 'item active':'item'}}" wx:if="{{ imgLength>0}}" data-tab="img" bindtap='changeTab'>图片({{ imgLength }})</view>
</view>
<view class="content">
<swiper class='swiper' style="height:{{ swiperHeight }}px" wx:if="{{ attachment.length>0}}" autoplay="{{autoplay}}" current="{{ current }}" circular="{{ circular }}" interval="{{interval}}" duration="{{duration}}" bindchange="bindchangeSwiper">
<block wx:for="{{ attachment }}" wx:key="index">
<swiper-item>
<view class="img-box">
<video src="{{ item.video || item.videourl }}" class="flexcenter" id="video{{ index }}" data-index="{{ index }}" wx:if="{{ (item.video || item.videourl) && index == current }}" bindloadedmetadata="bindloadedmetadata" show-center-play-btn="{{ false }}" autoplay="{{ true }}">
<cover-image wx:if="{{videoLoading}}" class="load" src="/img/load.png"></cover-image>
</video>
<image wx:else show-menu-by-longpress src="{{ current == index ? item.image : '' }}" bindload='load' lazy-load class="slide-image" mode="widthFix" />
<!-- <image wx:if="{{ !(item.video || item.videourl) }}" src="{{ item.image }}" bindload='load' class="slide-image" mode="widthFix" />
<video src="{{ item.video || item.videourl }}" id="video{{ index }}" data-index="{{ index }}" wx:if="{{ item.video || item.videourl }}"></video> -->
</view>
</swiper-item>
</block>
</swiper>
</view>
</view>
<!--pages/video_show/video_show.wxml-->
<text>pages/video_show/video_show.wxml</text>

View File

@ -1,142 +0,0 @@
/* pages/video_show/video_show.wxss */
.video-box {
width: 100vw;
height: 100vh;
z-index: 100000;
background: rgba(0, 0, 0, 0.8);
position: fixed;
left: 0;
top: 0;
}
.video-box .close {
position: fixed;
left: 20rpx;
top: 20rpx;
width: 50rpx;
height: 50rpx;
z-index: 1000000
}
.video-box video {
/* margin: calc(50vh - 120px) auto;
display: block; */
width: 100vw;
height: 100vh;
}
.cover {
position: fixed;
left: 5px;
top: 0;
display: flex;
justify-content: center;
align-items: center;
box-sizing: border-box;
}
.image {
width: 30rpx;
height: 30rpx;
}
.inner {
border: 1px solid #aaa;
background: rgba(0, 0, 0, 0.2);
display: inline-flex;
justify-content: center;
align-items: center;
border-radius: 50%;
}
.video-img-box {
background: #000;
width: 100vw;
height: 100vh;
color: #fff;
overflow: hidden;
/* position: fixed; */
left: 0;
top: 0
}
.video-img-box .tab {
display: flex;
font-size: 28rpx;
height: 100rpx;
}
.video-img-box .tab .item {
display: inline-flex;
flex: 1;
color: #e8e8e8;
align-items: center;
justify-content: center;
font-weight: 400
}
.video-img-box .tab .item.active {
font-weight: bold;
font-size: 32rpx;
color: #fff;
}
.video-img-box .content {
/* position: absolute; */
left: 0;
top: 50%;
/* transform: translateY(-50%); */
width: 100vw;
}
.img-box {
width: 100vw;
height: 100%;
display: flex;
align-items: center;
}
.img-box image {
display: block;
width: 100vw;
}
.img-box video {
display: block;
margin: 0 auto;
width: 100vw;
/* max-height: 70vh; */
/* position: static !important; */
position: fixed;
/* top: 50%;
left: 50%; */
/* transform: translate(-50%,-50%); */
}
.img-box .load {
z-index: 9999999;
width: 80rpx;
height: 80rpx;
color: #fff;
position: absolute;
top: calc(50% - 40rpx);
left: calc(50% - 40rpx);
/* transform: translate(-50%, -50%); */
animation: rotate 3s linear infinite;
/* 使用动画效果实现无限旋转 */
/* background: aquamarine; */
}
@keyframes rotate {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}

View File

@ -86,7 +86,7 @@ Component({
// 直接将图片或者视频放大
if (this.data.isvideo) {
wx.navigateTo({
url: `/pages/video_show/video_show?loop=true&src=${this.properties.item.annex.url}`,
// url: `/pages/video_show/video_show?loop=true&src=${this.properties.item.annex.url}`,
})
}else{
wx.previewImage({

View File

@ -80,6 +80,7 @@ Component({
})
},
previewImg(e) {
console.log("img");
let that = this;
let url = e.currentTarget.dataset.url;
let appid = e.currentTarget.dataset.appid;
@ -130,9 +131,20 @@ Component({
if (this.properties.pages == 'apartmentDetail') {
wx.setStorageSync('attachment', this.properties.attachment)
wx.navigateTo({
url: `/pages/video_show/video_show?frompage=apartment&current=${this.data.current}`
});
// console.log("attachment", this.properties.attachment);
let sources = this.properties.attachment || []
sources.forEach(element => {
if (element['videourl']) element['type'] = 'video'
element['url'] = element['videourl'] || element['image']
})
wx.previewMedia({
sources,
current: this.data.current,
})
// wx.navigateTo({
// url: `/pages/video_show/video_show?frompage=apartment&current=${this.data.current}`
// });
return false
}
@ -260,11 +272,12 @@ Component({
aState: false,
})
},
play(e) {
wx.navigateTo({
url: '/pages/video_show/video_show?src=' + e.currentTarget.dataset.video,
})
},
// play(e) {
// wx.navigateTo({
// url: '/pages/video_show/video_show?src=' + e.currentTarget.dataset.video,
// })
// },
closePage() {
this.setData({
video: ''

View File

@ -1,5 +1,4 @@
<view class='container newcontainer'>
<!-- <swiper class='swiper' current="{{ swiperCurrent }}" style="height:{{ swiperHeight }}px;height: {{ swiperHeightObj[current] }}rpx;" wx:if="{{ attachment.length>0}}" autoplay="{{autoplay}}" circular="{{ circular }}" interval="{{interval}}" duration="{{duration}}" bindchange="bindchangeSwiper"> -->
<swiper class='swiper' current="{{ swiperCurrent }}" style="height: {{ swiperHeightObj[current] }}rpx;" wx:if="{{ attachment.length > 0 }}" autoplay="{{autoplay}}" circular="{{ circular }}" interval="{{interval}}" duration="{{duration}}" bindchange="bindchangeSwiper">
<block wx:for="{{ attachment }}" wx:key="index">
<swiper-item>
@ -8,11 +7,7 @@
<block wx:if="{{ index >= swiperCurrent - 1 && index <= swiperCurrent + 1 }}">
<image src="{{ item.image || item.imageurl }}" data-index="{{ index }}" bindload='load' class="slide-image" mode="widthFix" bindtap='previewImg' />
</block>
<!-- <image src="{{ item.image || item.imageurl }}" data-index="{{ index }}" bindload='load' class="slide-image" mode="widthFix" bindtap='previewImg' /> -->
<!-- <image wx:if="{{ swiperCurrent == index }}" src="{{ item.image || item.imageurl }}" data-index="{{ index }}" bindload='load' class="slide-image" mode="widthFix" bindtap='previewImg' /> -->
<image wx:if="{{ item.islive == 1 || item.isvideo == 1 }}" class="play-btn" src="/img/play-btn.svg" catchtap="play" data-video="{{ item.video }}"></image>
<image wx:if="{{ item.islive == 1 || item.isvideo == 1 }}" class="play-btn" src="/img/play-btn.svg" data-video="{{ item.video }}"></image>
</view>
<button form-type="submit" hover-class="none" type="default" size="mini"></button>
</form>
@ -50,12 +45,9 @@
</view>
</block>
<view class='video-box' wx:if="{{ video }}">
<!-- <image src="../../img/close.png" class='close' bindtap='close_video'></image> -->
<video src="{{ video }}" custom-cache="{{false}}" autoplay='true'>
<cover-view bindtap="closePage" style="top:{{ screen_data.statusBarHeight -5 }}px;height:{{ screen_data.titleBarHeight +10 }}px;width:{{ screen_data.titleBarHeight +10 }}px" class="cover">
<cover-image class="image" src="/img/close-f.png"></cover-image>
</cover-view>
</video>
</view>

View File

@ -55,6 +55,7 @@ function sendData(code) {
app.globalData.listTab = data.listTab;
app.globalData.wechat = data.wechat;
app.globalData.isMapFindState = data.isMapFindState;
app.globalData.isShowVideo = data.reviewmode == 1 ? false : true;
app.globalData.header = {
'content-type': 'application/json',

View File

@ -13,7 +13,7 @@
<template name="wxParseVideo">
<!--增加video标签支持并循环添加-->
<view class="{{item.classStr}} wxParse-{{item.tag}}" style="{{item.styleStr}}">
<video class="{{item.classStr}} wxParse-{{item.tag}}-video" src="{{item.attr.src}}"></video>
<!-- <video class="{{item.classStr}} wxParse-{{item.tag}}-video" src="{{item.attr.src}}"></video> -->
</view>
</template>