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.
136 lines
2.4 KiB
136 lines
2.4 KiB
// miniprogram/pages/previewWork/previewWork.js
|
|
Page({
|
|
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
muted: 'false',
|
|
step: 1,
|
|
counterId: '',
|
|
openid: '',
|
|
count: null,
|
|
queryResult: '',
|
|
},
|
|
|
|
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
onLoad: function (options) {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
*/
|
|
onReady: function () {
|
|
this.videoContext = wx.createVideoContext('myVideo');
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面显示
|
|
*/
|
|
onShow: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面隐藏
|
|
*/
|
|
onHide: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面卸载
|
|
*/
|
|
onUnload: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
*/
|
|
onPullDownRefresh: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面上拉触底事件的处理函数
|
|
*/
|
|
onReachBottom: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 用户点击右上角分享
|
|
*/
|
|
startPreview() {
|
|
this.videoContext.play();
|
|
wx.showToast({
|
|
title: '开始播放',
|
|
});
|
|
console.log("作品路径为" + getApp().globalData.workPath);
|
|
wx.playVoice({
|
|
filePath: getApp().globalData.workPath,
|
|
success: function () {
|
|
wx.showToast({
|
|
title: '播放结束',
|
|
})
|
|
},
|
|
})
|
|
|
|
},
|
|
stopPreview() {
|
|
this.videoContext.stop();
|
|
},
|
|
onAdd() {
|
|
const db = wx.cloud.database()
|
|
db.collection('user-video').add({
|
|
data: {
|
|
//count: 1,
|
|
videoID: '',
|
|
fileID: '',
|
|
cloudPath: '',
|
|
},
|
|
success: res => {
|
|
// 在返回结果中会包含新创建的记录的 _id
|
|
this.setData({
|
|
counterId: res._id,
|
|
count: 1,
|
|
fileID: '',
|
|
cloudPath:''
|
|
})
|
|
wx.showToast({
|
|
title: '新增记录成功',
|
|
})
|
|
console.log('[数据库] [新增记录] 成功,记录 _id: ', res._id)
|
|
},
|
|
fail: err => {
|
|
wx.showToast({
|
|
icon: 'none',
|
|
title: '新增记录失败'
|
|
})
|
|
console.error('[数据库] [新增记录] 失败:', err)
|
|
}
|
|
})
|
|
},
|
|
saveWork() {
|
|
wx.cloud.uploadFile({
|
|
cloudPath: 'work-1',
|
|
filePath: getApp().globalData.workPath,
|
|
success: res => {
|
|
// get resource ID
|
|
console.log(res.fileID)
|
|
},
|
|
fail: err => {
|
|
// handle error
|
|
}
|
|
})
|
|
this.onAdd();
|
|
},
|
|
onShareAppMessage: function () {
|
|
|
|
}
|
|
}) |