second commit

master
dou18 5 years ago
parent 79f261bd43
commit 6bada63c77

@ -0,0 +1,129 @@
// miniprogram/pages/lookmyTxt/lookmyTxt.js
var CloudPath=''
var Path=''
Page({
/**
* 页面的初始数据
*/
data: {
list: '',
picturePath:''
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
console.log("picture=" + options.picturepath);
Path = options.path;
this.setData({
// list: options.list,
picturePath:options.picturepath,
path:Path
})
this.onQuery()
//console.log('cloudpath'+CloudPath)
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
},
RequestTxt:function(CloudPath){
wx.request({//获取文本内容
url: CloudPath,
header: { 'cntent-type': 'application/json;charset=utf-8' },
success: (res) => {
console.log(res.data);
this.setData({
list: res.data,
})
try {
wx.setStorageSync('list', res.data)
} catch (e) {
};
}
})
},
play:function(){
wx.playVoice({
filePath: Voice,
success: function () {
wx.showToast({
title: '播放结束',
})
},
})
},
onQuery: function () {
const db = wx.cloud.database()
var i;
// 查询当前用户所有的 counters
console.log('path'+Path)
db.collection('text').where({
picture:Path,
}).get({
success: res => {
this.setData({
queryResult: JSON.stringify,
})
console.log('[数据库] [查询记录] 成功: ', res)
CloudPath=res.data[0].cloudPath;
this.RequestTxt(CloudPath)
console.log('cloudpathfhdkhkhk'+CloudPath)
},
fail: err => {
wx.showToast({
icon: 'none',
title: '查询记录失败'
})
console.error('[数据库] [查询记录] 失败:', err)
}
})
}
})

@ -0,0 +1,3 @@
{
"usingComponents": {}
}

@ -0,0 +1,7 @@
<!--miniprogram/pages/lookmyTxt/lookmyTxt.wxml-->
<view>
<scroll-view scroll-y="true" style="width: 350px; height: 500px;">
<text>{{list}}</text>
</scroll-view>
</view>
<button bindtap='play' >播放</button>

@ -0,0 +1 @@
/* miniprogram/pages/lookmyTxt/lookmyTxt.wxss */

@ -0,0 +1,131 @@
// 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)
}
})
}
})

@ -0,0 +1,3 @@
{
"usingComponents": {}
}

@ -0,0 +1,6 @@
<!--miniprogram/pages/lookmyVideo/lookmyVideo.wxml-->
<view>
<video id='myvideo' class='{{fullScreen?"show":"hide"}}' muted="{{muted}}" src="{{path}}" autoplay="true" bindfullscreenchange="fullScreen" bindended="closeVideo" controls></video>
</view>
<audio src="{{src}}"id="myAudio"></audio>
<!--button bindtap='play' >播放</button-->

@ -0,0 +1 @@
/* miniprogram/pages/lookmyVideo/lookmyVideo.wxss */

@ -0,0 +1,156 @@
// miniprogram/pages/mine/mine.js
Page({
/**
* 页面的初始数据
*/
data: {
video:[],//视频数组
txt:[],
Works:[]//音频
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
this.onQuery(),
this.onQueryT()
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
},
//查看视频配音
bindlookmyvedio:function(e){
//console.log("你的路径是" + e.currentTarget.dataset.src);
var path = e.currentTarget.dataset.src;
wx.navigateTo({
url: '../lookmyVideo/lookmyVideo?path='+path,
success: function (res) { console.log("成功") },
fail: function (res) { console.log("失败"+res.data) },
})
},
bindlookmytxt:function(e){
//console.log("你的路径是" + e.currentTarget.dataset.src);
var path = e.currentTarget.dataset.src;
wx.navigateTo({
url: '../lookmyTxt/lookmyTxt?path='+path,
success: function (res) { console.log("成功") },
fail: function (res) { console.log("失败"+res.data) },
})
},
onQuery: function () {
const db = wx.cloud.database()
var i;
// 查询当前用户所有的 counters
db.collection('user-video').where({
_openid:getApp().globalData.openid
}).get({
success: res => {
this.setData({
queryResult: JSON.stringify,
})
console.log('[数据库] [查询记录] 成功: ', res)
var j = res.data.length;
for (i = 0; i < j; i++) {
var videoI = "video[" + i + "]"
var length = res.data[i].VideoPath.length
var picture = res.data[i].VideoPath.substring(0, length-4) + 't.jpg';
this.setData({
[videoI]:picture,
})
console.log('video'+picture)
}
},
fail: err => {
wx.showToast({
icon: 'none',
title: '查询记录失败'
})
console.error('[数据库] [查询记录] 失败:', err)
}
})
},
onQueryT: function () {
const db = wx.cloud.database()
var i;
// 查询当前用户所有的 counters
db.collection('user-text').where({
_openid:getApp().globalData.openid
}).get({
success: res => {
this.setData({
queryResult: JSON.stringify,
})
console.log('[数据库] [查询记录] 成功: ', res)
var j = res.data.length;
for (i = 0; i < j; i++) {
var txtI = "txt[" + i + "]"
var text = "txt["+i+"]"
var picture = res.data[i].Picture;
this.setData({
[txtI]:picture,
})
console.log('text'+picture)
}
},
fail: err => {
wx.showToast({
icon: 'none',
title: '查询记录失败'
})
console.error('[数据库] [查询记录] 失败:', err)
}
})
}
})

@ -0,0 +1,3 @@
{
"usingComponents": {}
}

@ -0,0 +1,22 @@
<!--miniprogram/pages/mine/mine.wxml-->
<view class="userinfo-avatar">
<open-data type="userAvatarUrl"></open-data>
</view>
<open-data type="userNickName" lang="zh_CN"></open-data>
<text>我的配音作品:</text>
<view style="height:30px;">
<text style="font-weight:bold;font-size:15px;padding-left:10px">视频配音</text>
</view>
<view>
<block wx:for="{{video}}" data-item="item">
<image bindtap="bindlookmyvedio" data-src="{{item}}" src="{{item}}" style="width: 200rpx; height: 80px;"></image>
</block>
</view>
<view style="height:30px;">
<text style="font-weight:bold;font-size:15px;padding-left:10px">文本配音</text>
</view>
<view>
<block wx:for="{{txt}}" data-item="item">
<image bindtap="bindlookmytxt" data-src="{{item}}" src="{{item}}" style="width: 200rpx; height: 80px;"></image>
</block>
</view>

@ -0,0 +1 @@
/* miniprogram/pages/mine/mine.wxss */
Loading…
Cancel
Save