| | |
| | | </template> |
| | | <script> |
| | | import { mapActions, mapState } from "vuex"; |
| | | import VConsole from 'vconsole'; |
| | | // import VConsole from 'vconsole'; |
| | | export default { |
| | | data(){ |
| | | return{ |
| | |
| | | this.iframeWin = this.$refs.iframe.contentWindow; |
| | | }, |
| | | created () { |
| | | let vConsole = new VConsole() // 初始化 |
| | | // let vConsole = new VConsole() // 初始化 |
| | | let item = JSON.parse(localStorage.getItem("item")); |
| | | this.scenes_id = item.scenes_id; |
| | | this.scenes_name = item.scenes_name; |
| | |
| | | 'uploadVoice' |
| | | ], //必填,传入需要使用的接口名称 |
| | | success: function (res) { |
| | | sendMsg({ |
| | | console.log(res,'企业微信初始化'); |
| | | _this.sendMsg({ |
| | | action:'init', |
| | | state:'ok', |
| | | data:{} |
| | |
| | | } |
| | | }); |
| | | wx.error(function(res){ |
| | | sendMsg({ |
| | | _this.sendMsg({ |
| | | action:'init', |
| | | state:'fail', |
| | | data:{} |
| | |
| | | case 'start': // 开始录音 |
| | | wx.startRecord({ |
| | | success: function (res) { |
| | | sendMsg({ |
| | | console.log(res,'开始录音成功'); |
| | | _this.sendMsg({ |
| | | action:'start', |
| | | state:'ok', |
| | | data:{} |
| | |
| | | } |
| | | }); |
| | | wx.error(function(res){ |
| | | sendMsg({ |
| | | _this.sendMsg({ |
| | | action:'start', |
| | | state:'fail', |
| | | data:{} |
| | |
| | | case 'stop': |
| | | wx.stopRecord({ |
| | | success: function (res) { |
| | | console.log(res,'停止录音成功'); |
| | | var localId = res.localId; |
| | | wx.uploadVoice({ |
| | | localId: localId, // 需要识别的音频的本地Id,由录音相关接口获得,音频时长不能超过60秒 |
| | | isShowProgressTips: 0, // 默认为1,显示进度提示 |
| | | success: function (ures) { |
| | | console.log(ures,'上传录音成功'); |
| | | let serverId = ures.serverId; |
| | | sendMsg({ |
| | | _this.sendMsg({ |
| | | action:'stop', |
| | | state:'ok', |
| | | data:{ |
| | |
| | | } |
| | | }); |
| | | wx.error(function(res){ |
| | | sendMsg({ |
| | | action:'start', |
| | | _this.sendMsg({ |
| | | action:'stop', |
| | | state:'fail', |
| | | data:{} |
| | | }); |
| | | }) |
| | | break; |
| | | case 'cleanup': |
| | | wx.stopRecord({ |
| | | success: function (res) { |
| | | console.log(res,'清除录音成功'); |
| | | _this.sendMsg({ |
| | | action:'cleanup', |
| | | state:'ok', |
| | | data:{ |
| | | } |
| | | }); |
| | | } |
| | | }); |
| | | wx.error(function(res){ |
| | | _this.sendMsg({ |
| | | action:'cleanup', |
| | | state:'fail', |
| | | data:{} |
| | | }); |