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

36
components/GPT/utils/socket.js

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

57
pages/index/iSoul.vue

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

27
pages/index/sensoryStore.vue

@ -16,12 +16,26 @@
</view> </view>
</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"> <view class="product-content">
<!-- <image class="head-img" src="https://static.ticket.sz-trip.com/uploads/20250625/e3112c280ef9761af741907a737ef221.png"></image> --> <!-- <image class="head-img" src="https://static.ticket.sz-trip.com/uploads/20250625/e3112c280ef9761af741907a737ef221.png"></image> -->
<view class="title-sec"> <view class="title-sec">
有感商品上新 有感商品上新
</view> </view>
<scroll-view style="width: 100%;" scroll-x> <scroll-view style="width: 100%;" scroll-x>
<view class="product"> <view class="product">
<view class="item" v-for="(item,i) in list" :key="item.goods.id" @click="goDetailByType(item)"> <view class="item" v-for="(item,i) in list" :key="item.goods.id" @click="goDetailByType(item)">
@ -234,4 +248,15 @@
font-weight: 500; font-weight: 500;
margin: 30rpx 0; margin: 30rpx 0;
} }
.desc-box{
padding: 0 20rpx;
color: #616161;
margin: 30rpx 0;
font-size: 22rpx;
padding: 0 30rpx;
view{
margin-bottom: 20rpx;
}
}
</style> </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.js-dyyj.com';
const PROD_API_URL = 'https://epic.new.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 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 = 'http://192.168.124.177:8083/xcx';
// const DEV_API_URL_DES = 'https://des.js-dyyj.com/xcx'; const DEV_API_URL_DES = 'https://des.js-dyyj.com/xcx';
const PROD_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 NEWAPIURL_DES = process.env.NODE_ENV === 'development' ? DEV_API_URL_DES : PROD_API_URL_DES;
const getToken = () => { const getToken = () => {

17
subPackages/other/evita.vue

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

Loading…
Cancel
Save