|
|
|
|
(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["pages-users-yuyin-index"],{"1e3f":function(n,o,e){"use strict";e("6a54");var t=e("f5bd").default;Object.defineProperty(o,"__esModule",{value:!0}),o.default=void 0;var i=t(e("2634")),s=t(e("2fdc"));e("d4b5"),e("e966");var a=t(e("af29")),r=uni.getRecorderManager(),u=uni.createInnerAudioContext();u.autoplay=!0;var c=0,l={data:function(){return{baseUrl:"",count:0,show:!1,isPlay:!1,isPlays:!1,yuyinInfo:{},isRest:!1,counts:0,isPlay1:!1}},onReady:function(){var n=this;n.yuyinInfo=uni.getStorageSync("yuyinInfo"),console.log(n.yuyinInfo),n.baseUrl=n.$baseUrl,n.yuyinInfo.voiceTime=n.formatFun(n.yuyinInfo.voiceTime),r.onStop((function(o){n.yuyinInfo.voice=o.tempFilePath,n.isPlays=!1,n.count=0,n.counts=0,n.isPlay=!1,clearInterval(c),n.$forceUpdate(),console.log("that.yuyinInfo:"+JSON.stringify(n.yuyinInfo)),console.log(n.yuyinInfo.voice),console.log(n.yuyinInfo.voiceTime)})),u.onEnded((function(o){n.isPlay=!1})),u.onTimeUpdate((function(o){console.log(u.currentTime),n.counts=n.formatFun(Math.ceil(u.currentTime.toFixed(0)))})),uni.$on("onPopup",(function(o){1==o&&(n.show=!1)}))},methods:{recorderAuthModal:function(){var n=this;uni.showModal({title:"温馨提示",content:"为了麦克风的功能,我们需要申请麦克风权限,请您确认授权,否则无法使用该功能~",cancelText:"关闭",confirmText:"去授权",success:function(o){n.show=!1,o.confirm&&a.default.gotoAppPermissionSetting()}})},requestAndroidPermission:function(n){var o=this;return(0,s.default)((0,i.default)().mark((function e(){var t,s;return(0,i.default)().wrap((function(e){while(1)switch(e.prev=e.next){case 0:return t=o,e.next=3,a.default.requestAndroidPermission(n);case 3:s=e.sent,1!=s?t.recorderAuthModal():t.show=!1;case 5:case"end":return e.stop()}}),e)})))()},toDo:function(n){var o=this;if(1==n){if("android"==uni.getSystemInfoSync().platform)return plus.android.checkPermission("android.permission.RECORD_AUDIO",(function(n){-1==n.checkResult?o.show=!0:(o.show=!1,o.yuyinInfo.voice="",o.yuyinInfo.voiceTime=o.formatFun(0),o.yuyinInfo.voiceTimes=0,o.counts=0,o.count=0,o.isRest=!0,o.isPlay1&&(console.log(1111),u.pause(),o.isPlay1=!1))}),(function(n){console.error("Error checking permission:",n.message)})),void o.requestAndroidPermission("android.permission.RECORD_AUDIO");o.counts=0,o.count=0,o.yuyinInfo.voice="",o.yuyinInfo.voiceTime=o.formatFun(0),o.yuyinInfo.voiceTimes=0,o.isRest=!0}else if(2==n)r.stop();else if(3==n)console.log(111,u),u&&console.log(u.src),u.src=o.yuyinInfo.voice,u.play(),o.isPlay=!0,o.isPlay1=!0;else if(4==n)console.log(222,u),o.isPlay=!1,o.isPlay1=!1,u.pause();else if(5==n){if("android"==uni.getSystemInfoSync().platform)return plus.android.checkPermission("android.permission.RECORD_AUDIO",(function(n){-1==n.checkResult?o.show=!0:(o.show=!1,o.yuyinInfo.voice="",o.yuyinInfo.voiceTime=o.formatFun(0),o.isPlays=!0,clearInterval(c),c=setInterval((function(){o.count++,o.yuyinInfo.voiceTime=o.formatFun(o.count)}),1e3),r.start({format:"mp3"}))}),(function(n){console.error("Error checking permission:",n.message)})),void o.requestAndroidPermission("android.permission.RECORD_AUDIO");o.yuyinInfo.voice="",o.yuyinInfo.voiceTime=o.formatFun(0),o.isPlays=!0,clearInterval(c),c=setInterval((function(){o.count++,o.yuyinInfo.voiceTime=o.formatFun(o.count),o.yuyinInfo.voiceTimes=o.count}),1e3),r.start({format:"mp3"})}else 6==n?r.stop():51==n&&uni.uploadFile({url:o.$baseUrl+"/prod-api/api/user/voiceSign",filePath:o.yuyinInfo.voice,name:"file",formData:{userId:uni.getStorageSync("userInfo").id,voiceTime:o.formatFun2(o.yuyinInfo.voiceTime)+1},complete:function(n){if(console.log({userId:uni.getStorageSync("userInfo").id,voiceTime:o.formatFun2(o.yuyinInfo.voiceTime)}),console.log(n),200==n.statusCode){var e=JSON.parse(n.data),t=e.code;e.fileName,e.url,e.msg;200==t?(uni.showToast({title:"上传成功"}),o.isRest=!1,uni.$emit("changVioce",111),setTimeout((function(){uni.navigateBack({delta:1})}),2e3)):uni.showToast({icon:"error",title:"上传失败"})}else uni.showToast({icon:"error",title:"上传失<EFBFBD>
|