diff --git a/pages/camera/camera.js b/pages/camera/camera.js index 99840a4..daac0fa 100644 --- a/pages/camera/camera.js +++ b/pages/camera/camera.js @@ -1,4 +1,3 @@ - const recorderManager = wx.getRecorderManager() Page({ @@ -21,20 +20,20 @@ /** * 生命周期函数--监听页面加载 */ - onLoad: function (options) { + onLoad: function(options) { // 加载摄像头 this.ctx = wx.createCameraContext(); this.setData({ type: options.type }) - + }, /** - * 用户不允许使用摄像头时 - */ - error(e){ + * 用户不允许使用摄像头时 + */ + error(e) { console.log(e.detail) }, @@ -46,10 +45,10 @@ quality: 'high', success: (res) => { this.setData({ - src: res.tempImagePath - }), + src: res.tempImagePath + }), - this.reback(1) + this.reback(1) } }) }, @@ -58,10 +57,8 @@ * 开始录像 */ takeVideo() { - - this.ctx.startRecord({ - success:()=>{ + success: () => { this.setData({ doing: true, tmpThumbPath: '', @@ -69,7 +66,7 @@ }) console.log('startRecord ' + this.data.doing) }, - timeoutCallback:(res)=>{ + timeoutCallback: (res) => { this.setData({ doing: false, tmpThumbPath: res.tempThumbPath, @@ -77,7 +74,7 @@ }) this.reback(2) - + console.log('startRecord ' + this.data.doing) console.log('timeout callback ' + res.tempThumbPath) console.log('timeout callback ' + res.tempVideoPath) @@ -90,24 +87,24 @@ */ stopVideo() { this.ctx.stopRecord({ - success:(res) => { + success: (res) => { this.setData({ doing: false, tmpThumbPath: res.tempThumbPath, tmpVideoPath: res.tempVideoPath, - }), - - this.reback(2) + }), + + this.reback(2) } }) }, /** - * 开始录音 - */ + * 开始录音 + */ takeRecord() { - + recorderManager.onStart(() => { console.log('recorder start') }) @@ -116,7 +113,9 @@ }) recorderManager.onStop((res) => { console.log('recorder stop', res) - const { tempFilePath } = res + const { + tempFilePath + } = res this.setData({ doing: false, tmpRecordPath: res.tempFilePath, @@ -127,7 +126,9 @@ // this.data.tmpRecordPath = res.tempFilePath }) recorderManager.onFrameRecorded((res) => { - const { frameBuffer } = res + const { + frameBuffer + } = res console.log('frameBuffer.byteLength', frameBuffer.byteLength) }) @@ -141,14 +142,14 @@ } recorderManager.start(options) - + this.setData({ doing: true, }) }, - stopRecord(){ + stopRecord() { this.setData({ doing: false, }) @@ -158,7 +159,7 @@ // console.log('record stop ... ' + res.tempFilePath); // this.doing = false; // this.tmpRecordPath = res.tempFilePath; - + // console.log("path => " + this.tmpRecordPath) // // this.reback(3); // }); @@ -170,21 +171,21 @@ /** * 拍照成功后返回到上一页 */ - reback(status){ + reback(status) { var pages = getCurrentPages(); var currPage = pages[pages.length - 1]; //当前页 var prevPage = pages[pages.length - 2]; //上一页 - if (status == 1){ + if (status == 1) { prevPage.setData({ tmpPhotoPath: this.data.src, }) - } else if (status == 2){ + } else if (status == 2) { prevPage.setData({ tmpThumbPath: this.data.tmpThumbPath, tmpVideoPath: this.data.tmpVideoPath }) - } else if (status == 3){ + } else if (status == 3) { console.log('333333'); prevPage.setData({ tmpRecordPath: this.data.tmpRecordPath @@ -200,48 +201,47 @@ /** * 生命周期函数--监听页面初次渲染完成 */ - onReady: function () { - }, + onReady: function() {}, /** * 生命周期函数--监听页面显示 */ - onShow: function () { - + onShow: function() { + }, /** * 生命周期函数--监听页面隐藏 */ - onHide: function () { - + onHide: function() { + }, /** * 生命周期函数--监听页面卸载 */ - onUnload: function () { - + onUnload: function() { + }, /** * 页面相关事件处理函数--监听用户下拉动作 */ - onPullDownRefresh: function () { - + onPullDownRefresh: function() { + }, /** * 页面上拉触底事件的处理函数 */ - onReachBottom: function () { - + onReachBottom: function() { + }, /** * 用户点击右上角分享 */ - onShareAppMessage: function () { - + onShareAppMessage: function() { + } }) \ No newline at end of file