Browse Source

fix:isoul

dev_des
1054425342@qq.com 2 months ago
parent
commit
e65ac2b6a0
  1. 51
      components/GPT/index.vue
  2. 36
      components/GPT/utils/socket.js
  3. 2
      components/GPT/utils/util.js
  4. 57
      pages/index/iSoul.vue
  5. 27
      pages/index/sensoryStore.vue
  6. 4
      static/js/request.js
  7. 17
      subPackages/other/evita.vue

51
components/GPT/index.vue

@ -77,6 +77,7 @@ import Socket from './utils/socket'
import { splitTextForTTS } from './utils/util'
import {
getHistroyMsg,
setMsgData
} from './utils/message'
import ClientData from './utils/ClientData';
import Pending from './components/pending';
@ -120,6 +121,7 @@ export default {
tmpMsg: {},
lastTxt: {},
txtAudioStaus: {},
requestMsg: {},
disabledStatus: false
}
},
@ -151,11 +153,11 @@ export default {
this.socketObj = new Socket({
agentId: this.agentId,
onMessage: (e) => {
const index = this.msgList.findIndex(it => it.request_id == e.request_id && it.type == 'reply')
console.log(e.request_id + '回复内容', e.content)
// const index = this.msgList.findIndex(it => it.request_id == e.request_id && it.type == 'reply')
// this.tmpMsg[e.request_id] = this.tmpMsg[e.request_id] ?? []
// if (this.tmpMsg[e.request_id].length) {
// const txt = this.removeSpecificText(e.content??'', this.lastTxt[e.request_id] ?? '')
// const txt = e.content
// if (txt) {
// this.tmpMsg[e.request_id].push(txt)
// }
@ -163,7 +165,7 @@ export default {
// this.tmpMsg[e.request_id].push(e.content)
// }
// this.lastTxt[e.request_id] = e.content
// // console.log(this.tmpMsg[e.request_id])
// if (!this.txtAudioStaus[e.request_id]) {
// this.txtAudioStaus[e.request_id] = true
// this.renderTxt(e)
@ -171,8 +173,12 @@ export default {
// console.log(e.content)
e.pending = false
//
// if (index > -1) {
// this.msgList[index] = e
// this.msgList[index] = {
// ...e,
// content: this.msgList[index].content + e.content
// }
// } else {
// if (this.msgList.length) {
// const obj = this.msgList[this.msgList.length - 1]
@ -184,34 +190,43 @@ export default {
// } else {
// this.msgList.push(e)
// }
// } else {
// this.msgList.push(e)
// }
// }
// //
// if (!e.is_from_self && e.is_final) {
// setMsgData(this.msgList[index])
// }
this.requestMsg[e.request_id] = (this.requestMsg[e.request_id] ? this.requestMsg[e.request_id] : '') + e.content
if (!e.is_from_self && e.is_final) {
e.content = this.requestMsg[e.request_id]
const audioParams = e
console.log( audioParams);
//
//
setMsgData(audioParams)
console.log('开始',audioParams);
this.audio(audioParams, (txt)=> {
const index = this.msgList.findIndex(it => it.request_id == e.request_id && it.type == 'reply')
console.log(1111111, txt, index)
if (index > -1) {
this.msgList[index].content += txt
this.$nextTick(() => {
this.msgList[index].content += txt
this.scrollToBottom()
})
} else {
if (this.msgList.length) {
const obj = this.msgList[this.msgList.length - 1]
if (obj.pending) {
const tmp = {
...e,
pending: false,
content: txt
}
this.msgList[this.msgList.length - 1] = tmp
this.$nextTick(() => {
const tmp = {
...e,
pending: false,
content: txt
}
this.msgList[this.msgList.length - 1] = tmp
this.scrollToBottom()
})
} else {
@ -222,8 +237,8 @@ export default {
...e,
pending: false
}
this.msgList.push(tmp)
this.$nextTick(() => {
this.msgList.push(tmp)
this.scrollToBottom()
})
}
@ -231,8 +246,8 @@ export default {
this.scrollToBottom()
})
//
this.disabledStatus = false
// //
// this.disabledStatus = false
}
this.scrollToBottom()
}
@ -307,8 +322,8 @@ export default {
audioText(text, cb) {
return new Promise(async (resolve, reject) => {
if (!this.audioStatus) { reject() }
const url = await this.loadAudioUrl(text)
if (!this.audioStatus) { reject() }
console.log('开始播放文字', text)
cb && cb(text)
this.audioCtx = wx.createInnerAudioContext();

36
components/GPT/utils/socket.js

@ -18,7 +18,6 @@ export default class Socket {
this.selfCloseStatus = false
this.reconnectLock = false
console.log("Socket init", GLOBAL_OBJ);
// 失败回答
this.failMsg = {}
}
@ -122,7 +121,7 @@ export default class Socket {
});
socket.onMessage((e) => {
// console.log("socket.onMessage", e);
console.log("socket.onMessage", e);
const { data } = e;
if (data == 2) {
// 触发浪涌
@ -134,10 +133,6 @@ export default class Socket {
const params = this.getMsgData(data);
const { type } = params ?? {};
this.on(type, params);
if (params && params.type === "reply" && !params.is_from_self) {
// 回复消息
this._options.onMessage && this._options.onMessage(params);
}
const num = "" + data.substring(0, 2);
if (num == "40") {
console.log("创建对话成功", e);
@ -169,6 +164,10 @@ export default class Socket {
}
doConnectTimeout() {
if (this.selfCloseStatus){
// 主动退出 不在重连
return
}
// 重连一次
console.log("websocket 异常关闭 开始重连");
this.connectSocketTimeOut = setTimeout(() => {
@ -192,17 +191,12 @@ export default class Socket {
sendFailMsg() {
const content = Object.values(this.failMsg)
if (content.length) {
console.log('开始重新发送失败信息')
const lastFailMsgIndex = content.findLastIndex(it => !it.status)
if (lastFailMsgIndex > -1) {
const msg = content[lastFailMsgIndex]
console.log('开始重新发送失败信息', msg)
// 重新发送失败的信息
for (let index = 0; index < content.length; index++) {
const item = content[index];
if (!item.status) {
console.log('失败消息', item)
// 失败消息 在发送一遍
this.send(item.data.socketParams,item.data.contentType )
}
}
this.send(msg.data.socketParams,msg.data.contentType)
}
}
getMsgData(e) {
@ -230,8 +224,12 @@ export default class Socket {
emit(type, params, contentType) {
console.log("emit", type, params);
const tmpParams = params
tmpParams.incremental = true
const data = {
payload: params,
//incremental:true,
payload: tmpParams
};
switch (type) {
case "send":
@ -280,6 +278,7 @@ export default class Socket {
params.can_rating
) {
// 回复消息
console.log('reply回复内容', tmpParams.content, tmpParams)
this._options.onMessage && this._options.onMessage(tmpParams);
}
@ -290,7 +289,7 @@ export default class Socket {
}
// 回复结束 写入缓存
setMsgData(tmpParams);
// setMsgData(tmpParams);
}
// 回复
break;
@ -310,6 +309,7 @@ export default class Socket {
if (this.timeoutObj) {
clearTimeout(this.timeoutObj);
}
return
this.timeoutObj = setTimeout(() => {
this.socket && this.socket.send && this.socket.send({ data: 3 });
}, HEART_BEAT_TIME);

2
components/GPT/utils/util.js

@ -81,7 +81,7 @@ function escapeHtml (str) {
}
export const splitTextForTTS = (text, maxLength = 30) => {
export const splitTextForTTS = (text, maxLength = 15) => {
// 定义优先分割的标点符号
const punctuation = ['。', ',', ';', '?', '!', ',', ';', '?', '!', '、'];
let segments = [];

57
pages/index/iSoul.vue

@ -81,27 +81,28 @@
</view> -->
</view>
</view>
<view class="action-box">
<image
@click="showExchangePopup"
:src="showImg('/uploads/20250822/7f18265ca351dfd2d6477322b17c1751.png')"
style="width: 233rpx; height: 43rpx"
></image>
<view class="column-divider"></view>
<image
@click="showActivateAgentPopup"
:src="showImg('/uploads/20250822/53718d0d8a655ac33d7197ad11a32f98.png')"
style="width: 200rpx; height: 43rpx"
></image>
</view>
<!-- 数字资产权益 -->
<view class="digital-assets">
<view class="memorial-divider" style="margin-bottom: 0">
<view class="memorial-divider" style="margin-bottom: 0;padding-top: 60rpx;">
<view class="divider-line"></view>
<view class="divider-text">数字资产权益</view>
<view class="divider-text">我的数字资产权益</view>
<view class="divider-line"></view>
</view>
<view class="action-box">
<image
@click="showExchangePopup"
src="https://des.js-dyyj.com/data/2025/09/01/3ebc09d5-f526-40ab-b698-d45de81034b7.png"
style="width: 233rpx; height: 40rpx"
></image>
<view class="column-divider"></view>
<image
@click="showActivateAgentPopup"
src="https://des.js-dyyj.com/data/2025/09/01/6215d940-a57d-4a4f-a69b-df6770132d12.png"
style="width: 200rpx; height: 43.6rpx"
></image>
</view>
<!-- 有数据时显示 -->
<view v-if="assetList.length > 0" class="asset-content">
<!-- 单个数据时铺满显示 -->
@ -174,7 +175,7 @@
<!-- 无数据时显示原来的图片风格 -->
<view v-else class="asset-card-old">
<image
@click="handleAssetAction('待使用')"
@click="handleAssetAction('待核销')"
:src="
showImg('/uploads/20250729/42598a2dcf4c9a6f8c6e122e54b65c4f.png')
"
@ -185,13 +186,13 @@
<!-- 底部操作按钮 -->
<view class="goods-actions">
<view class="goods-action" @click="handleAssetAction('待使用')">
<view class="goods-action" @click="handleAssetAction('待核销')">
<uni-badge
size="small"
:text="orderStatus && orderStatus[1].orderQuantity"
absolute="rightTop"
>
<text>使用</text>
<text>核销</text>
</uni-badge>
</view>
<view class="goods-action" @click="handleAssetAction('待收货')">
@ -226,9 +227,9 @@
<!-- 有感商品 -->
<view class="feeling-goods">
<view class="memorial-divider" style="margin-bottom: 0">
<view class="memorial-divider" style="margin-bottom: 0;padding-top: 10rpx;">
<view class="divider-line"></view>
<view class="divider-text">有感商品订单</view>
<view class="divider-text">我的有感商品</view>
<view class="divider-line"></view>
</view>
<view class="goods-card">
@ -257,7 +258,7 @@
</view>
<!-- 数字资产纪念册 -->
<view class="memorial-section">
<view class="memorial-section" style="padding-top: 10rpx;">
<view class="memorial-divider">
<view class="divider-line"></view>
<view class="divider-text">数字资产收藏夹</view>
@ -515,7 +516,7 @@ export default {
image:
item.goodsImg ||
"/uploads/20250729/42598a2dcf4c9a6f8c6e122e54b65c4f.png",
badge: "待使用",
badge: "待核销",
name: item.goodsTitle || "数字资产权益",
desc:
item.type == 1
@ -529,7 +530,7 @@ export default {
: item.type == 2
? "去预约"
: "去核销",
status: "待使用",
status: "待核销",
...item, //
}));
} else {
@ -663,7 +664,7 @@ export default {
//
switch (action) {
case "待使用":
case "待核销":
uni.navigateTo({
url: "/subPackages/orderQy/list?status=1",
});
@ -1417,7 +1418,7 @@ view {
.memorial-divider {
display: flex;
align-items: center;
padding: 30rpx 0;
padding: 50rpx 0;
margin-bottom: 30rpx;
}
@ -1738,9 +1739,9 @@ view {
.column-divider {
width: 2rpx;
height: 60rpx;
height: 50rpx;
background: rgba(0, 0, 0, 0.1);
margin: 35rpx 16rpx;
margin: 0rpx 16rpx;
flex-shrink: 0;
}
@ -1748,7 +1749,7 @@ view {
display: flex;
align-items: center;
justify-content: space-around;
padding: 20rpx 40rpx 0;
padding: 0rpx 40rpx 37rpx;
}
.popup-actions-bottom {

27
pages/index/sensoryStore.vue

@ -16,12 +16,26 @@
</view>
</view>
<view class="desc-box">
<view class="title-sec" style="color: black;">
关于有感商品
</view>
<view class="">
寻常商品满足你的日常所需有感商品则回应你的精神所向
</view>
<view class="">
我们坚信意义大于产品这里的每一件商品都诞生于EPIC SOUL交响阅读体的史诗是精神漫游的实体回响它的存在是为了让你在消费中完成一次次深刻的情感连接与自我认同
</view>
<view class="">
在这里消费的终点不是拥有而是更深刻的连接与共鸣欢迎探索一件件写满故事与想象力的生活信物
</view>
</view>
<view class="product-content">
<!-- <image class="head-img" src="https://static.ticket.sz-trip.com/uploads/20250625/e3112c280ef9761af741907a737ef221.png"></image> -->
<view class="title-sec">
有感商品上新
</view>
<scroll-view style="width: 100%;" scroll-x>
<view class="product">
<view class="item" v-for="(item,i) in list" :key="item.goods.id" @click="goDetailByType(item)">
@ -234,4 +248,15 @@
font-weight: 500;
margin: 30rpx 0;
}
.desc-box{
padding: 0 20rpx;
color: #616161;
margin: 30rpx 0;
font-size: 22rpx;
padding: 0 30rpx;
view{
margin-bottom: 20rpx;
}
}
</style>

4
static/js/request.js

@ -8,8 +8,8 @@ const DEV_API_URL = 'https://epic.new.js-dyyj.com';
// const PROD_API_URL = 'https://epic.js-dyyj.com';
const PROD_API_URL = 'https://epic.new.js-dyyj.com';
const NEWAPIURL = process.env.NODE_ENV === 'development' ? DEV_API_URL : PROD_API_URL;
const DEV_API_URL_DES = 'http://192.168.124.177:8083/xcx';
// const DEV_API_URL_DES = 'https://des.js-dyyj.com/xcx';
// const DEV_API_URL_DES = 'http://192.168.124.177:8083/xcx';
const DEV_API_URL_DES = 'https://des.js-dyyj.com/xcx';
const PROD_API_URL_DES = 'https://des.js-dyyj.com/xcx';
const NEWAPIURL_DES = process.env.NODE_ENV === 'development' ? DEV_API_URL_DES : PROD_API_URL_DES;
const getToken = () => {

17
subPackages/other/evita.vue

@ -119,13 +119,16 @@
url: "/pages/agent/index?id="+this.agentInfo.agentId
});
}else{
uni.redirectTo({
url: "/subPackages/equityGoods/detail?id="+this.agentId
});
// uni.showToast({
// title: '',
// icon: 'none'
// })
uni.showToast({
title: '为您跳转商品购买页~',
icon: 'none'
})
setTimeout(() =>{
uni.redirectTo({
url: "/subPackages/equityGoods/detail?id="+this.agentId
});
},900)
}
}

Loading…
Cancel
Save