// isVoice: 0-未录音 1-录音中 2-录完音
// 点击录音/录音中 按钮展示
<div class="vm-voice-box" v-show="isVoice < 2">
<p v-show="!isVoice" @click="voiceStart">点击录音</p>
<img v-show="isVoice" @click="voiceEnd" src="../../xxx/ico-voice.png" alt="">
</div>
// isListen // 0-未试听/试听结束 1-试听中 2-暂停试听
// 录完音 按钮展示
<div class="vm-voice-player" v-show="isVoice == 2">
<div class="vm-vp-button">
<p class="vm-vp-revoice" @click="openMask(0)">重录</p>
<p class="vm-vp-submit" :class="{'vm-vp-no-submit' : isSubmit}" @click="openMask(1)">提交</p>
<p class="vm-vp-pause" v-show="!isListen" @click="play">试听</p>
<p class="vm-vp-pause" v-show="isListen==1" @click="pause">| |</p>
<p class="vm-vp-pause vm-vp-border" v-show="isListen==2" @click="play"> ▶ </p>
</div>
</div>
data() {
return {
id: '',
startTime: 0,
recordTimer: null,
localId: '', // 录音本地id
serverId: '', // 录音微信服务id
showMask: false,
tip: 1, //提交 0- 重录
isVoice: 0, // 0-未录音 1-录音中 2-录完音
isListen: 0, // 0-未试听/试听结束 1-试听中 2-暂停试听
data1: 0,
work: {},
isPlay: false, // 是否播放
isSubmit: false, // 是否已提交
}
}
// 微信配置
getConfig() {
let _url = encodeURIComponent(window.location.href)
// 后台提供接口,传入当前url(返回基础配置信息)
voiceApi.wechatConfig(_url)
.then(res => {
if (res.data.code == 200) {
wx.config({
debug: false,
appId: res.data.content.appid,
timestamp: res.data.content.timestamp, // 必填,生成签名的时间戳
nonceStr: res.data.content.nonceStr, // 必填,生成签名的随机串
signature: res.data.content.signature, // 必填,签名
// 需要授权的api接口
jsApiList: [
'startRecord', 'stopRecord', 'onVoiceRecordEnd', 'uploadVoice', 'downloadVoice', 'playVoice', 'pauseVoice', 'onVoicePlayEnd'
]
})
|