Commit ffee4d1a by 前端

fixed

1 parent d9e1b533
...@@ -23,14 +23,19 @@ Component({ ...@@ -23,14 +23,19 @@ Component({
}, },
// 对话灵感内容 // 对话灵感内容
inspirationContent: { inspirationContent: {
type: String type: String,
observer: function (n) {
this.setData({content:n})
}
} }
}, },
/** /**
* 组件的初始数据 * 组件的初始数据
*/ */
data: { data: {
times: 0 times: 0,
recorder1: wx.getRecorderManager(),
recorder2: wx.getRecorderManager(),
}, },
lifetimes:{ lifetimes:{
attached() { attached() {
...@@ -39,7 +44,7 @@ Component({ ...@@ -39,7 +44,7 @@ Component({
}, },
detached: function() { detached: function() {
this.data.srStart = false this.data.srStart = false
wx.getRecorderManager().stop() this.data.recorder1.stop()
if (this.data.sr) { if (this.data.sr) {
this.data.sr.shutdown() this.data.sr.shutdown()
} else { } else {
...@@ -61,7 +66,8 @@ Component({ ...@@ -61,7 +66,8 @@ Component({
}, },
onSrStop: async function () { onSrStop: async function () {
console.log('onSrStop') console.log('onSrStop')
wx.getRecorderManager().stop() this.data.recorder1.stop()
this.data.recorder2.stop();
await sleep(500) await sleep(500)
if (this.data.srStart && this.data.sr) { if (this.data.srStart && this.data.sr) {
try { try {
...@@ -105,16 +111,23 @@ Component({ ...@@ -105,16 +111,23 @@ Component({
console.log("start failed:" + e) console.log("start failed:" + e)
return return
} }
wx.getRecorderManager().start({ this.data.recorder1.start({
duration: 600000, duration: 600000,
numberOfChannels: 1, numberOfChannels: 1,
sampleRate: 16000, sampleRate: 16000,
format: "PCM", format: "PCM",
frameSize: 4 frameSize: 4
}) })
this.data.recorder2.start({
duration: 600000,
numberOfChannels: 1,
sampleRate: 16000,
format: "mp3",
frameSize: 4
})
}, },
connectSr: async function (options) { connectSr: async function (options) {
wx.getRecorderManager().onFrameRecorded((res) => { this.data.recorder1.onFrameRecorded((res) => {
if (res.isLastFrame) { if (res.isLastFrame) {
console.log("record done") console.log("record done")
} }
...@@ -123,10 +136,23 @@ Component({ ...@@ -123,10 +136,23 @@ Component({
this.data.sr.sendAudio(res.frameBuffer) this.data.sr.sendAudio(res.frameBuffer)
} }
}) })
wx.getRecorderManager().onStart(() => { this.data.recorder1.onStart(() => {
console.log("start recording...") console.log("start recording...")
}) })
wx.getRecorderManager().onStop((res) => { this.data.recorder2.onStop((res) => {
console.log(res.tempFilePath)
// if (res.tempFilePath) {
// const {isClose} = this.data
// if(isClose) {
// wx.removeSavedFile({
// filePath: res.tempFilePath
// })
// }else {
// this.setData({filePath:res.tempFilePath})
// }
// }
})
this.data.recorder1.onStop((res) => {
console.log("stop recording...") console.log("stop recording...")
if (res.tempFilePath) { if (res.tempFilePath) {
const {isClose} = this.data const {isClose} = this.data
...@@ -139,7 +165,7 @@ Component({ ...@@ -139,7 +165,7 @@ Component({
} }
} }
}) })
wx.getRecorderManager().onError((res) => { this.data.recorder1.onError((res) => {
console.log("recording failed:" + res) console.log("recording failed:" + res)
}) })
try { try {
...@@ -216,7 +242,7 @@ Component({ ...@@ -216,7 +242,7 @@ Component({
this.onSrStart() this.onSrStart()
}) })
},300) },1000)
},1500), },1500),
onClose() { onClose() {
this.setData({ this.setData({
......
<!--packageEquity/pages/aiCheck/components/SpeechPopup/SpeechPopup.wxml--> <!--packageEquity/pages/aiCheck/components/SpeechPopup/SpeechPopup.wxml-->
<pop-up class="speech-popup" title="{{inspirationContent?'对话灵感':'正在录音'}}" show="{{show}}" height="{{inspirationContent ? '850rpx':'530rpx'}}" bindcancel="onClose"> <pop-up class="speech-popup" title="{{content?'对话灵感':'正在录音'}}" show="{{show}}" height="{{content ? '850rpx':'530rpx'}}" bindcancel="onClose">
<!-- <view class="inspiration-title"> <!-- <view class="inspiration-title">
<view wx:if="{{inspirationContent}}">对话灵感</view> --> <view wx:if="{{content}}">对话灵感</view> -->
<!-- <view class="inspiration-title-icon" bindtap="openInspiration"> <!-- <view class="inspiration-title-icon" bindtap="openInspiration">
<gl-image class="inspiration-icon" src="/aiCheck/inspiration-icon.png"></gl-image> <gl-image class="inspiration-icon" src="/aiCheck/inspiration-icon.png"></gl-image>
对话灵感 对话灵感
</view> --> </view> -->
<!-- <view class="inspiration-title-description">用自己的话说出来效果更佳~</view> --> <!-- <view class="inspiration-title-description">用自己的话说出来效果更佳~</view> -->
<!-- </view> --> <!-- </view> -->
<view class="inspiration-content" wx:if="{{inspirationContent}}"> <view class="inspiration-content" wx:if="{{content}}">
<scroll-view scroll-y class="inspiration-scroll"> <scroll-view scroll-y class="inspiration-scroll">
<view class="content">{{inspirationContent}}</view> <view class="content">{{content}}</view>
</scroll-view> </scroll-view>
<!-- <block wx:else> <!-- <block wx:else>
<view class="first loadding"></view> <view class="first loadding"></view>
<view class="second loadding"></view> <view class="second loadding"></view>
<view class="third loadding"></view> <view class="third loadding"></view>
</block> </block>
<view wx:if="{{!inspirationContent}}" class="loadding-text">对话灵感生成中...</view> --> <view wx:if="{{!content}}" class="loadding-text">对话灵感生成中...</view> -->
</view> </view>
<view class="inspiration-line" wx:if="{{inspirationContent}}">用自己的话说出来效果更佳</view> <view class="inspiration-line" wx:if="{{content}}">用自己的话说出来效果更佳</view>
<view class="loading-box"> <view class="loading-box">
<view class="loading-item" wx:for="{{36}}"> <view class="loading-item" wx:for="{{36}}">
</view> </view>
......
...@@ -71,6 +71,7 @@ Page({ ...@@ -71,6 +71,7 @@ Page({
wx.navigateBack({ wx.navigateBack({
delta: 1, delta: 1,
}); });
prevPage.setData({tabIndex:1})
} else { } else {
wx.navigateBack({ wx.navigateBack({
delta: 2, delta: 2,
......
...@@ -67,7 +67,6 @@ console.log(wx.$util.getUserInfo(), '==============') ...@@ -67,7 +67,6 @@ console.log(wx.$util.getUserInfo(), '==============')
* 生命周期函数--监听页面显示 * 生命周期函数--监听页面显示
*/ */
onShow() { onShow() {
this.setData({tabIndex:1})
}, },
/** /**
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!