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.
132 lines
2.3 KiB
132 lines
2.3 KiB
5 years ago
|
// pages/previewTxtWork/previewTxtWork.js
|
||
|
Page({
|
||
|
|
||
|
/**
|
||
|
* 页面的初始数据
|
||
|
*/
|
||
|
data: {
|
||
|
list: ''
|
||
|
},
|
||
|
|
||
|
/**
|
||
|
* 生命周期函数--监听页面加载
|
||
|
*/
|
||
|
onLoad: function (options) {
|
||
|
this.setData({
|
||
|
list: options.list,
|
||
|
})
|
||
|
//console.log(this.data.list)
|
||
|
},
|
||
|
|
||
|
/**
|
||
|
* 生命周期函数--监听页面初次渲染完成
|
||
|
*/
|
||
|
onReady: function () {
|
||
|
|
||
|
},
|
||
|
|
||
|
/**
|
||
|
* 生命周期函数--监听页面显示
|
||
|
*/
|
||
|
onShow: function () {
|
||
|
|
||
|
},
|
||
|
|
||
|
/**
|
||
|
* 生命周期函数--监听页面隐藏
|
||
|
*/
|
||
|
onHide: function () {
|
||
|
|
||
|
},
|
||
|
|
||
|
/**
|
||
|
* 生命周期函数--监听页面卸载
|
||
|
*/
|
||
|
onUnload: function () {
|
||
|
|
||
|
},
|
||
|
|
||
|
/**
|
||
|
* 页面相关事件处理函数--监听用户下拉动作
|
||
|
*/
|
||
|
onPullDownRefresh: function () {
|
||
|
|
||
|
},
|
||
|
|
||
|
/**
|
||
|
* 页面上拉触底事件的处理函数
|
||
|
*/
|
||
|
onReachBottom: function () {
|
||
|
|
||
|
},
|
||
|
|
||
|
/**
|
||
|
* 用户点击右上角分享
|
||
|
*/
|
||
|
onShareAppMessage: function () {
|
||
|
|
||
|
},
|
||
|
//开始播放
|
||
|
startPreview() {
|
||
|
wx.showToast({
|
||
|
title: '开始播放',
|
||
|
});
|
||
|
console.log("作品路径为" + getApp().globalData.workPath);
|
||
|
wx.playVoice({
|
||
|
filePath: getApp().globalData.workPath,
|
||
|
success: function () {
|
||
|
wx.showToast({
|
||
|
title: '播放结束',
|
||
|
})
|
||
|
},
|
||
|
})
|
||
|
|
||
|
},
|
||
|
onAdd() {
|
||
|
const db = wx.cloud.database()
|
||
|
db.collection('user-video').add({
|
||
|
data: {
|
||
|
|
||
|
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: '',
|
||
|
filePath: getApp().globalData.workPath,
|
||
|
success: res => {
|
||
|
// get resource ID
|
||
|
console.log(res.fileID)
|
||
|
},
|
||
|
fail: err => {
|
||
|
// handle error
|
||
|
}
|
||
|
})
|
||
|
this.onAdd();
|
||
|
},
|
||
|
onShareAppMessage: function () {
|
||
|
}
|
||
|
})
|