You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

131 lines
2.5 KiB

5 years ago
// miniprogram/pages/lookmyVideo/lookmyVideo.js
var Path=''
var Voice=''
Page({
/**
* 页面的初始数据
*/
data: {
muted:true,
src:'',
path:'',
cloudPath: '',
Works:[],//音频voice
voice:''
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
var Path = options.path;
var a = Path.length;
Path = Path.substring(0, a - 5) + '.mp4'
this.setData({
path: Path//根据图片路径得到相应的视频路径
});
//this.onQuery()
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
this.audioCtx=wx.createAudioContext('myAudio')
this.audioCtx.setSrc(Voice);
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
},
/**播放视频 */
play(e) {
//执行全屏方法
var videoContext = wx.createVideoContext('myvideo',this);
videoContext.requestFullScreen();
this.setData({
fullScreen:true
})
this.audioCtx.play()
},
/**关闭视屏 */
closeVideo() {
//执行退出全屏方法
var videoContext = wx.createVideoContext('myvideo', this);
videoContext.exitFullScreen();
},
/**视屏进入、退出全屏 */
fullScreen(e){
var isFull = e.detail.fullScreen;
//视屏全屏时显示加载video非全屏时不显示加载video
this.setData({
fullScreen:isFull
})
},
onQuery: function () {
const db = wx.cloud.database()
var i;
var a = options.path.length
// 查询当前用户所有的 counters
db.collection('text').where({
Picture:Path,
_openid:getApp().globalData.openid
}).get({
success: res => {
this.setData({
queryResult: JSON.stringify,
})
console.log('[数据库] [查询记录] 成功: ', res)
CloudPath=res.data[0].cloudPath;
},
fail: err => {
wx.showToast({
icon: 'none',
title: '查询记录失败'
})
console.error('[数据库] [查询记录] 失败:', err)
}
})
}
})