diff --git a/aiChat/mixins/chatMixins.js b/aiChat/mixins/chatMixins.js index 2cfed3b..72248c7 100644 --- a/aiChat/mixins/chatMixins.js +++ b/aiChat/mixins/chatMixins.js @@ -50,7 +50,9 @@ export const chatMixins = { ], errorMsg: Object.freeze('您提的问题未能理解,云灵思想跑偏啦,重新整理一下问题或者重新提问,让云灵再试试!'), audioAyy: [], - isPlayAudio: false + isPlayAudio: false, + audioContext: null, + audioPlayId: '' } }, computed: { @@ -408,9 +410,38 @@ export const chatMixins = { } }, ttsHandle(item) { + this.audioAyy = [] + if (this.audioContext) { + this.audioContext.stop() + // this.audioContext.destroy() + } + // 如果正在播放,点击当前播放的则认为是暂停 + if (this.isPlayAudio && item.conversationId === this.audioPlayId) { + this.isPlayAudio = false + this.audioPlayId = '' + return + } this.isPlayAudio = false - this.audioAyy = [] - this.splitAndSynthesize(removeMarkdown(item.content).replace(/[\n\t\s]/g, '')) + this.audioPlayId = item.conversationId + const flag = 1 + if (flag === 1) { + console.log(removeMarkdown(item.content).replace(/[\n\t\s]/g, '')) + uni.showLoading({ + title: '合成中...' + }) + this.splitAndSynthesize(removeMarkdown(item.content).replace(/[\n\t\s]/g, '')) + } else { + // 调试数据 + this.audioAyy = [ + 'https://ae.weixin.qq.com/cgi-bin/mmasrai-bin/getmedia?filename=1750749075_2f71887cc48d9b3753c39d119862d4bb&filekey=871027724&source=miniapp_plugin', + 'https://ae.weixin.qq.com/cgi-bin/mmasrai-bin/getmedia?filename=1750749077_0970508786c5e3edc3a68a5eb9de048c&filekey=871027724&source=miniapp_plugin', + 'https://ae.weixin.qq.com/cgi-bin/mmasrai-bin/getmedia?filename=1750749079_e77cec52cc077ba981892887c3df4cdf&filekey=871027724&source=miniapp_plugin', + 'https://ae.weixin.qq.com/cgi-bin/mmasrai-bin/getmedia?filename=1750749080_02db4235771f5561cdb73c06d8c67e53&filekey=871027724&source=miniapp_plugin', + 'https://ae.weixin.qq.com/cgi-bin/mmasrai-bin/getmedia?filename=1750749082_534e455c5d6ac5e9a4192ecf9952851a&filekey=871027724&source=miniapp_plugin', + 'https://ae.weixin.qq.com/cgi-bin/mmasrai-bin/getmedia?filename=1750749083_78c4a2fecad538561f81c48dc4ecd645&filekey=871027724&source=miniapp_plugin' + ] + this.playNextChunk() + } }, splitAndSynthesize(text) { const _this = this @@ -440,25 +471,38 @@ export const chatMixins = { _this.playNextChunk() } } + uni.hideLoading() }, fail: function(err) { console.log("转换失败:", err) + uni.hideLoading() } }) } else { if (!_this.isPlayAudio) { _this.playNextChunk() } + uni.hideLoading() } }, playNextChunk() { - if (this.audioAyy.length > 0) { + if (this.audioAyy.length > 0 && this.audioPlayId) { + const src = this.audioAyy.shift() this.isPlayAudio = true - const audioContext = uni.createInnerAudioContext() - audioContext.src = this.audioAyy.shift() - audioContext.onEnded(() => this.playNextChunk()) + const audioContext = uni.createInnerAudioContext({ + // 是否使用 WebAudio 作为底层音频驱动,默认关闭。对于短音频、播放频繁的音频建议开启此选项,开启后将获得更优的性能表现。由于开启此选项后也会带来一定的内存增长,因此对于长音频建议关闭此选项 + useWebAudioImplement: false + }) + this.audioContext = audioContext + audioContext.src = src + audioContext.onEnded(() => { + audioContext.destroy() + this.playNextChunk() + }) audioContext.play() + console.log('------------src:' + src) } else { + console.log('------------end') this.isPlayAudio = false } } diff --git a/aiChat/views/index.vue b/aiChat/views/index.vue index 791e92a..89c571e 100644 --- a/aiChat/views/index.vue +++ b/aiChat/views/index.vue @@ -32,6 +32,10 @@ }" class="fix-tabbar-body" > + @@ -234,15 +238,18 @@ 重新生成 - 播放 + 语音播放 拷贝 diff --git a/assets/css/aiChat.less b/assets/css/aiChat.less index 52971c3..9c249dd 100644 --- a/assets/css/aiChat.less +++ b/assets/css/aiChat.less @@ -518,6 +518,9 @@ page { margin: 0; color: transparent; } + .playing { + color: #3D4CF1; + } } } } diff --git a/pages/shop/GoodsCon/index.vue b/pages/shop/GoodsCon/index.vue index cc3a2f4..3e2d027 100644 --- a/pages/shop/GoodsCon/index.vue +++ b/pages/shop/GoodsCon/index.vue @@ -73,6 +73,7 @@ :style="giftBg ? 'background: url(' + giftBg + ') no-repeat center/cover' : ''" :class="giftBg ? '' : 'v12-primary'" > + 平台补贴限时{{ storeInfo.discount }}% 支持礼包赠送 @@ -1457,7 +1458,8 @@ export default { path: "/pages/order/OrderSubmission/index", query: { id: res.data.cartId, - couponId: that.couponId // 优惠券ID + couponId: that.couponId, // 优惠券ID + discount: that.storeInfo.discount, } }) return @@ -1465,7 +1467,7 @@ export default { if(news === 2) { const coupId = that.couponId ? that.couponId : (that.couponList.usable[0] && that.couponList.usable[0].id || '') uni.navigateTo({ - url: '/pkg_user/views/gift/gift?cartId=' + res.data.cartId + '&couponId=' + coupId + url: '/pkg_user/views/gift/gift?cartId=' + res.data.cartId + '&couponId=' + coupId + (that.storeInfo.discount ? '&discount=' + that.storeInfo.discount : '') }) } if(news === 0) { @@ -2181,4 +2183,8 @@ export default { left: 0; width: 100%; } +.ll-text{ + margin-left: 280rpx; + word-break: keep-all; +} diff --git a/pagesInn/inn/innHome.vue b/pagesInn/inn/innHome.vue index 253e055..7116590 100644 --- a/pagesInn/inn/innHome.vue +++ b/pagesInn/inn/innHome.vue @@ -293,7 +293,7 @@ class="seeNum-txt" >{{ item.zan }} - +