1.拿到后台同事给到请求config的api接口,这里我拿到后不用传参数就直接可以get请求拿到微信config要配置的参数了,接着就配置config参数,控制台也正常请求返回请求到的参数
这是我请求的代码:
getConfig()
.then(res => {
if (res.code === '0000' && res.data) {
console.log('res', res)
// alert(location.href.split('#')[0])
let list = res.data
// console.log('list', list)
_this.config({
debug: true, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
appId: list.appId, // 必填,公众号的唯一标识
timestamp: list.timestamp, // 必填,生成签名的时间戳
nonceStr: list.nonceStr, // 必填,生成签名的随机串
signature: list.signature, // 必填,签名
jsApiList: [
'startRecord',
'stopRecord',
'playVoice',
'pauseVoice',
'stopVoice',
'uploadVoice',
'downloadVoice',
'downloadVoice'
] // 必填,需要使用的JS接口列表
// 接口 开始录音接口 停止录音接口 播放语音接口 暂停播放接口 停止播放接口 上传语音接口 下载语音接口 识别音频并返回识别结果接口
})
_this.checkJsApi({
jsApiList: ['startRecord'], // 需要检测的JS接口列表,所有JS接口列表见附录2,
success: function (res) {
// 以键值对的形式返回,可用的api值true,不可用为false
// 如:{"checkResult":{"chooseImage":true},"errMsg":"checkJsApi:ok"}
console.log('检查',res)
}
})
// config信息验证后才执行
_this.ready(() => {
wx.startRecord({
success: function () {
console.log('竟来了吗')
},
cancel: function () {}
})
})
// 微信sdk错误返回问题
_this.error(res => {
alert('出错了:' + res.errMsg) // 这个地方的好处就是wx.config配置错误,会弹出窗口哪里错误,然后根据微信文档查询即可。
})
}
})
.catch(e => {})
当我在页面调取录音事件时,后台就打印
我尝试用了手机端去打开这个也面就
求有经验的大神们,帮我看看我是哪里出了问题,一直用不了微信这边的sdk