我也遇到这个问题了,同问现在有解决方案吗
JSSDK 录音stopRecord没有localId?wx.startRecord({ success: res => { message.success('开始录音...', res) }, fail: res => { message.warn('录音失败...', res) // 直接进这里 } }); wx.stopRecord({ success: (res) => { var localId = res.localId; alert('stop localId == ', localId) uploadRecord(localId) }, fail: res=>{ alert('停止录音失败 == ', res) } }) const uploadRecord = (localId) => { wx.uploadVoice({ localId, // 需要上传的音频的本地ID,由stopRecord接口获得 isShowProgressTips: 1, // 默认为1,显示进度提示 success: (res) => { var serverId = res.serverId; // 返回音频的服务器端ID alert('upload serverId == ', serverId) downloadRecord(serverId) }, fail: res=>{ alert('上传录音失败 == ', res) } }); } const downloadRecord = (serverId) => { alert('download access_token == ', this.state.wechatToken) alert('download serverId == ', serverId) let url = `http://file.api.weixin.qq.com/cgi-bin/media/get?access_token=${this.state.wechatToken}&media_id=${serverId}` let options = { method: 'get', } fetch(url, options).then(res => { alert(res) }).catch(e => { alert('download err == ', e) }) } 复现链接: 1.关注公众号《yqctest》 2.点击《智能机器人》菜单 3.点击页面语音图片 4.《开始录音》长按
2020-07-27