|
@@ -13,166 +13,66 @@ Page({
|
|
|
* 页面的初始数据
|
|
|
*/
|
|
|
data: {
|
|
|
- video: "",
|
|
|
- poster: 'http://y.gtimg.cn/music/photo_new/T002R300x300M000003rsKF44GyaSk.jpg?max_age=2592000',
|
|
|
- name: '此时此刻',
|
|
|
- author: '许巍',
|
|
|
- audiosrc: 'https://www.1ting.com/api/audio?/2020/05/18/18a_yx/01.mp3',
|
|
|
+ height: 0,
|
|
|
+ animation: {},
|
|
|
+ left: 750
|
|
|
},
|
|
|
|
|
|
- changeVideo:function(){
|
|
|
- var that = this
|
|
|
- var uploader = new VODUpload({
|
|
|
-
|
|
|
- userId: "WaWQOn6gXod13WLEp8cr4ljUdvcbXJ",
|
|
|
-
|
|
|
- retryCount: 3,
|
|
|
-
|
|
|
- retryDuration: 2,
|
|
|
-
|
|
|
- 'onUploadstarted': function (uploadInfo) {
|
|
|
- console.log(uploadInfo)
|
|
|
-
|
|
|
-
|
|
|
- if (uploadInfo.videoId) {
|
|
|
- console.log('true');
|
|
|
-
|
|
|
- } else {
|
|
|
- console.log('false');
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- uploader.setUploadAuthAndAddress(uploadInfo, that.data.uploadAuth, that.data.uploadAddress, that.data.videoId);
|
|
|
+ takePhoto() {
|
|
|
+ const ctx = wx.createCameraContext()
|
|
|
+ ctx.takePhoto({
|
|
|
+ quality: 'high',
|
|
|
+ success: (res) => {
|
|
|
+ console.log(res.tempImagePath)
|
|
|
},
|
|
|
-
|
|
|
- 'onUploadSucceed': function (uploadInfo) {
|
|
|
- console.log("上传成功:" + JSON.stringify(uploadInfo))
|
|
|
- that.setData({
|
|
|
- poster: uploadInfo.coverUrl,
|
|
|
- src: uploadInfo.url
|
|
|
- })
|
|
|
-
|
|
|
- },
|
|
|
-
|
|
|
- 'onUploadFailed': function (uploadInfo, code, message) {
|
|
|
- console.log("onUploadFailed: file:" + uploadInfo.file.name + ",code:" + code + ", message:" + message);
|
|
|
- },
|
|
|
-
|
|
|
- 'onUploadProgress': function (uploadInfo, totalSize, loadedPercent) {
|
|
|
-
|
|
|
- },
|
|
|
-
|
|
|
- 'onUploadTokenExpired': function (uploadInfo) {
|
|
|
- console.log("onUploadTokenExpired");
|
|
|
-
|
|
|
-
|
|
|
- uploader.resumeUploadWithAuth(uploadAuth);
|
|
|
- },
|
|
|
-
|
|
|
- 'onUploadEnd': function (uploadInfo) {
|
|
|
- console.log("onUploadEnd: uploaded all the files");
|
|
|
- }
|
|
|
- });
|
|
|
-
|
|
|
- wx.chooseVideo({
|
|
|
- camera: ['album'],
|
|
|
- success(res){
|
|
|
- var file = {url: res.tempFilePath, coverUrl: res.thumbTempFilePath};
|
|
|
- var userData = '{"Vod":{}}';
|
|
|
- const urls = urlDef.urls;
|
|
|
- let createUrl = urls.video_create_upload + '?title=' + res.tempFilePath + '&fileName=' + res.tempFilePath;
|
|
|
- util.apiPost(createUrl).then((rs) => {
|
|
|
-
|
|
|
- let d = JSON.parse(rs.data);
|
|
|
-
|
|
|
- that.setData({
|
|
|
- uploadAuth : d.UploadAuth,
|
|
|
- uploadAddress : d.UploadAddress,
|
|
|
- videoId : d.VideoId,
|
|
|
- })
|
|
|
- uploader.addFile(file, null, null, null, userData)
|
|
|
- uploader.startUpload();
|
|
|
-
|
|
|
- }, e => {
|
|
|
- console.log('createUploadVideo error ' + JSON.stringify(e));
|
|
|
- });
|
|
|
+ error(e) {
|
|
|
+ console.log(e.detail)
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
-
|
|
|
- audioPlay: function () {
|
|
|
-
|
|
|
-
|
|
|
- audio.src = this.data.audioSrc
|
|
|
- audio.play()
|
|
|
-
|
|
|
- },
|
|
|
- audioPause: function () {
|
|
|
- this.audioCtx.pause()
|
|
|
- },
|
|
|
- audio14: function () {
|
|
|
- this.audioCtx.seek(14)
|
|
|
- },
|
|
|
- audioStart: function () {
|
|
|
- this.audioCtx.seek(0)
|
|
|
+ scanCode:function(e){
|
|
|
+ console.log(JSON.stringify(e))
|
|
|
},
|
|
|
|
|
|
- startRecord:function(){
|
|
|
- var that = this
|
|
|
- wx.getSetting({
|
|
|
- success(res) {
|
|
|
- if (!res.authSetting['scope.record']) {
|
|
|
- wx.authorize({
|
|
|
- scope: 'scope.record',
|
|
|
- success () {
|
|
|
-
|
|
|
- that.getRecord()
|
|
|
- }
|
|
|
- })
|
|
|
- } else {
|
|
|
- that.getRecord()
|
|
|
- }
|
|
|
- }
|
|
|
+ closeCamera:function(){
|
|
|
+ this.animation = wx.createAnimation({
|
|
|
+ timingFunction: 'linear',
|
|
|
+ duration: 500
|
|
|
})
|
|
|
-
|
|
|
+ const left = 750
|
|
|
|
|
|
-
|
|
|
- },
|
|
|
-
|
|
|
- getRecord: function () {
|
|
|
- const options = {}
|
|
|
- recordManager.start(options)
|
|
|
- },
|
|
|
-
|
|
|
- endRecord: function () {
|
|
|
- recordManager.stop()
|
|
|
- recordManager.onStop((res) => {
|
|
|
- console.log("监听录音停止事件",res)
|
|
|
- if (res.duration < 1000) {
|
|
|
- wx.showToast({
|
|
|
- title: '录音时间太短'
|
|
|
- })
|
|
|
- return;
|
|
|
- } else {
|
|
|
-
|
|
|
- var tempFilePath = res.tempFilePath;
|
|
|
- console.log("文件临时路径", tempFilePath)
|
|
|
- audio.src = tempFilePath
|
|
|
- audio.play()
|
|
|
- }
|
|
|
- });
|
|
|
+ this.animation.translateX(left).step()
|
|
|
+ this.setData({
|
|
|
+ animation:this.animation.export()
|
|
|
+ })
|
|
|
},
|
|
|
|
|
|
- playAudio:function(){
|
|
|
- this.audioContext.play()
|
|
|
+ showCamera:function(){
|
|
|
+ this.animation = wx.createAnimation({
|
|
|
+ timingFunction: 'linear',
|
|
|
+ duration: 500
|
|
|
+ })
|
|
|
+ const left = 0
|
|
|
+ this.animation.translateX(left).step()
|
|
|
+ this.setData({
|
|
|
+ animation:this.animation.export(),
|
|
|
+ })
|
|
|
},
|
|
|
+
|
|
|
|
|
|
|
|
|
* 生命周期函数--监听页面加载
|
|
|
*/
|
|
|
onLoad: function (options) {
|
|
|
- this.audioCtx = wx.createAudioContext('myAudio')
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
+ wx.getSystemInfo({
|
|
|
+ success: (result) => {
|
|
|
+ this.setData({
|
|
|
+ height: result.windowHeight
|
|
|
+ })
|
|
|
+ },
|
|
|
+ })
|
|
|
},
|
|
|
|
|
|
|