包装设计在线生成_网页设计多个页面怎么做_推广公司怎么运作_汕头排名推广
Page({data: {canRecord: false,isRecording: false,tempFilePath: '',playbackUrl: ''},onLoad: function () {this.requestMicrophonePermission();},requestMicrophonePermission: function () {wx.getSetting({success: (res) => {if (!res.authSetting['scope.record']) {wx.authorize({scope: 'scope.record',success: () => {this.setData({canRecord: true});},fail: (err) => {console.error('Failed to get microphone permission:', err);}});} else {this.setData({canRecord: true});}}});},startRecording: function () {if (this.data.canRecord && !this.data.isRecording) {wx.startRecord({success: () => {this.setData({isRecording: true});}});}},stopRecording: function () {if (this.data.canRecord && this.data.isRecording) {wx.stopRecord({success: (res) => {this.setData({tempFilePath: res.tempFilePath,isRecording: false});this.playRecording();}});}},playRecording: function () {if (this.data.canRecord && this.data.tempFilePath) {if (!this.innerAudioContext) {this.innerAudioContext = wx.createInnerAudioContext();}this.innerAudioContext.src = this.data.tempFilePath;this.innerAudioContext.onPlay(() => {console.log('Playing audio...');});this.innerAudioContext.onError((err) => {console.error('Error playing audio:', err);});this.innerAudioContext.play();}},uploadAudio: function () {if (this.data.canRecord && this.data.tempFilePath) {wx.uploadFile({url: 'https://your-server-url/upload',filePath: this.data.tempFilePath,name: 'file',formData: {'user': 'test'},success: (res) => {console.log('Upload successful:', res);},fail: (err) => {console.error('Upload failed:', err);}});}}">