增加预览组件

This commit is contained in:
A1300399510 2024-09-26 19:03:30 +08:00
parent d79738dd15
commit 87d9baf367
12 changed files with 944 additions and 647 deletions

View File

@ -19,7 +19,8 @@
"pages/webViewwebweb/index",
"pages/circularize/circularize",
"pages/askHousing/askHousing",
"pages/transfer/transfer"
"pages/transfer/transfer",
"pages/video_show/video_show"
],

View File

@ -2137,9 +2137,16 @@ Page({
UploadQRCodeSend(imgUrl) {
let that = this
const uploadTask = wx.uploadFile({
url: `${app.globalData.baseURL}/tenement/v2/api/publish/uploadweixinqrcode`,
// url: `${app.globalData.baseURL}/tenement/v2/api/publish/uploadweixinqrcode`,
url: `https://oss.gter.net/upload/qrcode`,
filePath: imgUrl,
name: 'files',
formData: {
// uniqid: that.data.uniqid,
// session: app.globalData.session,
// type,
data: this.data.uploadData,
},
header: app.globalData.header,
success: function (res) {
var res = JSON.parse(res.data);

File diff suppressed because it is too large Load Diff

View File

@ -653,16 +653,40 @@ Page({
})
},
show_video: function (e) {
var src = e.currentTarget.dataset.src;
wx.previewMedia({
sources: [{
url: src,
type: "video",
}]
const video = this.data.info.video || []
const images = this.data.info.images || []
let sources = []
video.forEach(element => {
sources.push({
url: element['url'],
poster: element['image'],
type: "video"
})
})
// wx.navigateTo({
// url: '../video_show/video_show?src=' + src
images.forEach(element => {
sources.push({
url: element,
type: "image"
})
})
const current = e.currentTarget.dataset.current;
// console.log("current", current);
// var image = e.currentTarget.dataset.image;
// console.log("sources", sources);
// return
// wx.previewMedia({
// sources,
// current: 0,
// })
wx.setStorageSync('sourcesList', sources);
wx.navigateTo({
url: '/pages/video_show/video_show?current=' + current
})
},
showSchoolAlert(e) {
this.setData({

View File

@ -29,8 +29,8 @@
<image class="housing-info-avatar" mode="widthFix" src="{{ info.avatar }}"></image>
<view class="housing-info-right flexflex">
<view class="housing-info-name flexacenter">
<text class="one-line-display" style="width: 420rpx;">{{ info.author }}</text>
<text class="one-line-display" style="max-width: 420rpx;">{{ info.author }}</text>
<image wx:if="{{ isintermediary == 1 }}" class="housing-info-identity-icon"
src="/img/certifying-agent.png"></image>
<view wx:else class="housing-info-identity">{{ info.intermediary_text }}</view>
@ -109,7 +109,8 @@
<scroll-view class="scroll-view_H" scroll-x="true" style="width: 100%">
<block wx:if="{{ info.video && info.video.length>0 }}">
<view class="media-item media-video" wx:for="{{ info.video }}" wx:key="index"
bindtap="show_video" data-src="{{ item.url }}">
bindtap="show_video" data-src="{{ item.url }}" data-image="{{ item.image }}"
data-current="{{ index }}">
<image class="media-video-bj" src="{{ item.image }}"></image>
<view class="media-video-play">
<image class="media-video-play-icon" mode="widthFix" src="/img/videoplay.png">
@ -120,8 +121,9 @@
</block>
<block wx:if="{{ info.images && info.images.length>0 }}">
<view class="media-item" wx:for="{{ info.picturegroup }}" wx:key="index">
<image mode="heightFix" src="{{ item.thumbnail }}" bindtap="preview_img"
lazy-load="true" data-index="{{ index }}"></image>
<image mode="heightFix" src="{{ item.thumbnail }}" bindtap="show_video"
data-current="{{ (info.video.length || 0) + index }}" lazy-load="true"
data-index="{{ index }}"></image>
</view>
</block>
</scroll-view>

View File

@ -0,0 +1,132 @@
// pages/video_show/video_show.js
var app = getApp()
var miucms = require('../../utils/miucms.js');
Page({
/**
* 页面的初始数据
*/
// {
// url: "",
// type: "image"
// },{
// url: "",
// poster:"",
// type: "video"
// }
data: {
screen_data: {},
list: [],
swiperCurrent: 0,
videoContexts: [],
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
this.get_config()
const list = wx.getStorageSync('sourcesList') || []
let videoContexts = []
list.forEach((element, index) => {
if (element.type == "video") {
videoContexts.push(wx.createVideoContext('video' + index, this))
}
})
this.setData({
videoContexts,
swiperCurrent: options.current || 0,
list,
});
wx.removeStorageSync('sourcesList');
},
timer: null,
get_config() {
if (app.globalData.config.lists) {
let screen_data = app.globalData.screen_data
this.setData({
screen_data,
})
console.log("screen_data", screen_data);
} else {
setTimeout(() => {
this.get_config()
}, 200)
}
},
// 新 轮播图 自动滑动事件,修改下标
bindchangeSwiper(e) {
let current = e.detail.current
this.data.videoContexts[current] && this.data.videoContexts[current].play();
this.setData({
swiperCurrent: current
})
},
back() {
wx.navigateBack({
fail: err => {
if (err.errMsg == "navigateBack:fail cannot navigate back at first page.") miucms.goPage("/pages/index/index")
}
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
onVideoPlay(e) {
const index = e.currentTarget.dataset.index || 0
// 遍历所有视频上下文,暂停其他视频
this.data.videoContexts.forEach((videoContext, i) => {
if (index != i) videoContext.pause();
});
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
})

View File

@ -0,0 +1,4 @@
{
"enablePullDownRefresh": false,
"usingComponents": {}
}

View File

@ -0,0 +1,45 @@
/* pages/video_show/video_show.wxss */
.main {
width: 100vw;
height: 100vh;
background-color: #000000;
}
.close {
width: 120rpx;
height: 120rpx;
border-radius: 20rpx;
background-color: rgba(255, 255, 255, .3);
position: fixed;
left: 20rpx;
top: 50rpx;
z-index: 1000;
.icon {
width: 40rpx;
height: 40rpx;
}
}
.swiper {
width: 100vw;
height: 100vh;
.video {
width: 100vw;
}
.icon {
width: 100vw;
max-height: 80vh;
}
}
.header {
width: 100vw;
padding-top: 48px;
text-align: center;
color: #ffffff;
position: fixed;
top: 0;
}

View File

@ -0,0 +1,18 @@
<!--pages/video_show/video_show.wxml-->
<view class="main">
<view class="close flexcenter" bindtap="back">
<image class="icon" mode="widthFix" src="/img/close-f.png"></image>
</view>
<view class="header"
style="padding-top: {{ screen_data.statusBarHeight + 'px' }}; height: {{ screen_data.totalTopHeight }}px;">
{{ (swiperCurrent * 1 + 1) + " / " + list.length }}</view>
<swiper class="swiper" current="{{ swiperCurrent }}" bindanimationfinish="bindchangeSwiper" bindtap="back">
<swiper-item class="flexcenter" wx:for="{{ list }}" wx:key="index">
<video catchtap="return" id="video{{ index }}" class="video" wx:if="{{ item.type == 'video' }}"
src="{{ item.url }}" poster="{{ item.poster }}" autoplay="{{ swiperCurrent == index ? true : false }}"
bindplay="onVideoPlay" data-index="{{ index }}"></video>
<image wx:else class="icon" mode="widthFix" show-menu-by-longpress src="{{ item.url }}">
</image>
</swiper-item>
</swiper>
</view>

View File

@ -0,0 +1,39 @@
/* pages/video_show/video_show.wxss */
.main {
width: 100vw;
height: 100vh;
background-color: #000000;
}
.close {
width: 120rpx;
height: 120rpx;
border-radius: 20rpx;
background-color: rgba(255, 255, 255, 0.3);
position: fixed;
left: 20rpx;
top: 50rpx;
z-index: 1000;
}
.close .icon {
width: 40rpx;
height: 40rpx;
}
.swiper {
width: 100vw;
height: 100vh;
}
.swiper .video {
width: 100vw;
}
.swiper .icon {
width: 100vw;
max-height: 80vh;
}
.header {
width: 100vw;
padding-top: 48px;
text-align: center;
color: #ffffff;
position: fixed;
top: 0;
}

View File

@ -130,7 +130,7 @@ Component({
}
if (this.properties.pages == 'apartmentDetail') {
wx.setStorageSync('attachment', this.properties.attachment)
// wx.setStorageSync('attachment', this.properties.attachment)
// console.log("attachment", this.properties.attachment);
let sources = this.properties.attachment || []
sources.forEach(element => {
@ -138,10 +138,14 @@ Component({
element['url'] = element['videourl'] || element['image']
})
wx.previewMedia({
sources,
current: this.data.current,
wx.setStorageSync('sourcesList', sources);
wx.navigateTo({
url: '/pages/video_show/video_show?current=' + this.data.current
})
// wx.previewMedia({
// sources,
// current: this.data.current,
// })
// wx.navigateTo({
// url: `/pages/video_show/video_show?frompage=apartment&current=${this.data.current}`
// });

View File

@ -464,6 +464,20 @@ const updateProperty = (key, options, brandSelectionObj) => {
else if (brandSelectionObj[key] != undefined) return brandSelectionObj[key]
}
// 公共跳转页面
function goPage(url) {
wx.navigateTo({
url,
fail: function (err) {
if (err.errMsg = "navigateTo:fail webview count limit exceed") {
wx.redirectTo({
url,
})
}
}
})
}
module.exports = {
initial: initial,
share: share,
@ -480,6 +494,7 @@ module.exports = {
getTimeAgo,
useSocket,
updateProperty,
goPage,
https: function (url, data, success, fail) {
wx.request({
url: url,