Browse Source

金轮旋转的逻辑完成

ds_hxl
宋杰 3 weeks ago
parent
commit
61b4f98c4e
  1. 213
      src/views/AiEmotion.vue

213
src/views/AiEmotion.vue

@ -2,10 +2,10 @@
<div class="ai-emotion-container"> <div class="ai-emotion-container">
<!-- 金轮 --> <!-- 金轮 -->
<div class="golden-wheel"> <div class="golden-wheel">
<img src="@/assets/img/AiEmotion/金轮.png" alt="金轮图标" class="rotating-image">
<img src="@/assets/img/AiEmotion/金轮.png" alt="金轮图标" :class="{ 'rotating-image': isRotating }">
</div> </div>
<!-- 消息显示区域 --> <!-- 消息显示区域 -->
<div class="user-input-display">
<div class="user-input-display" ref="userInputDisplayRef">
<div v-for="(message, index) in messages" :key="index" class="message-container"> <div v-for="(message, index) in messages" :key="index" class="message-container">
<!-- 用户输入内容 --> <!-- 用户输入内容 -->
<div v-if="message.sender === 'user'" class="message-bubble user-message"> <div v-if="message.sender === 'user'" class="message-bubble user-message">
@ -18,10 +18,14 @@
</div> </div>
</div> </div>
<!-- 输入框和发送按钮 --> <!-- 输入框和发送按钮 -->
<div class="input-container fixed-bottom">
<footer class="input-container fixed-bottom">
<input type="text" v-model="userInput" placeholder="请输入内容..." class="input-box" /> <input type="text" v-model="userInput" placeholder="请输入内容..." class="input-box" />
<button @click="sendMessage" class="send-button">发送</button> <button @click="sendMessage" class="send-button">发送</button>
</div>
</footer>
<!-- <div class="input-container fixed-bottom">
<input type="text" v-model="userInput" placeholder="请输入内容..." class="input-box" />
<button @click="sendMessage" class="send-button">发送</button>
</div> -->
</div> </div>
@ -30,7 +34,7 @@
<!-- 四维矩阵图 --> <!-- 四维矩阵图 -->
<div class="class02"> <div class="class02">
<div class="span01"> <div class="span01">
{{ stockName }}
{{ stockName }}{{ stockName ? '量子四维矩阵图' : '' }}
</div> </div>
<span class="span02">{{ displayDate }}</span> <span class="span02">{{ displayDate }}</span>
</div> </div>
@ -135,7 +139,17 @@ const userInput = ref('');
const messages = ref([]); const messages = ref([]);
const displayDate = ref(''); // const displayDate = ref(''); //
const isPageLoaded = ref(false); // const isPageLoaded = ref(false); //
const isRotating = ref(false);//
const userInputDisplayRef = ref(null);//
//
function startImageRotation() {
isRotating.value = true;
//
setTimeout(() => {
isRotating.value = false;
}, 5000); // 5
}
// span01 // span01
function updateSpan01() { function updateSpan01() {
nextTick(() => { nextTick(() => {
@ -147,7 +161,7 @@ function updateSpan01() {
} }
//
//
async function sendMessage() { async function sendMessage() {
console.log('发送内容:', userInput.value); console.log('发送内容:', userInput.value);
@ -163,6 +177,16 @@ async function sendMessage() {
text: '数据加载中,请稍候...' text: '数据加载中,请稍候...'
}); });
//
nextTick(() => {
if (userInputDisplayRef.value) {
userInputDisplayRef.value.scrollTop = userInputDisplayRef.value.scrollHeight;
}
});
//
isRotating.value = true;
try { try {
// //
const params = { const params = {
@ -212,13 +236,22 @@ async function sendMessage() {
sender: 'ai', sender: 'ai',
text: '工作流接口请求失败,请稍后再试。', text: '工作流接口请求失败,请稍后再试。',
}); });
} finally {
//
isRotating.value = false;
} }
} else { } else {
console.warn('用户输入内容为空,无法发送请求');
messages.value.push({ messages.value.push({
sender: 'ai', sender: 'ai',
text: '请输入内容后再发送。', text: '请输入内容后再发送。',
}); });
//
nextTick(() => {
if (userInputDisplayRef.value) {
userInputDisplayRef.value.scrollTop = userInputDisplayRef.value.scrollHeight;
}
});
} }
} }
@ -245,19 +278,24 @@ async function fetchData(code, market) {
); );
const stockDataResponse = stockDataResult.data; // const stockDataResponse = stockDataResult.data; //
console.log('图表数据接口返回数据:', stockDataResponse);
console.log('图表数据接口返回数据:', stockDataResponse.data);
if (stockDataResponse.data) {
if (stockDataResponse.code === 200 && stockDataResponse.data) {
messages.value.push({ messages.value.push({
sender: 'ai', sender: 'ai',
text: `股票数据已成功获取: ${JSON.stringify(stockDataResponse.data)}`,
text: `股票数据已成功获取`,
});
//
nextTick(() => {
if (userInputDisplayRef.value) {
userInputDisplayRef.value.scrollTop = userInputDisplayRef.value.scrollHeight;
}
}); });
console.log('1111111111111111111111') console.log('1111111111111111111111')
// //
renderCharts(stockDataResponse.data); renderCharts(stockDataResponse.data);
console.log('2222222222222222222222') console.log('2222222222222222222222')
// //
const today = new Date(); const today = new Date();
const year = today.getFullYear(); const year = today.getFullYear();
@ -268,14 +306,18 @@ async function fetchData(code, market) {
// //
isPageLoaded.value = true; isPageLoaded.value = true;
} else { } else {
console.error('图表数据接口返回数据不完整');
messages.value.push({ messages.value.push({
sender: 'ai', sender: 'ai',
text: '图表数据接口返回数据不完整,请稍后再试。', text: '图表数据接口返回数据不完整,请稍后再试。',
}); });
//
nextTick(() => {
if (userInputDisplayRef.value) {
userInputDisplayRef.value.scrollTop = userInputDisplayRef.value.scrollHeight;
}
});
} }
} catch (error) { } catch (error) {
console.error('请求图表数据接口失败:', error);
messages.value.push({ messages.value.push({
sender: 'ai', sender: 'ai',
text: '图表数据接口请求失败,请稍后再试。', text: '图表数据接口请求失败,请稍后再试。',
@ -284,78 +326,81 @@ async function fetchData(code, market) {
} }
// //
// function renderCharts(data) {
// nextTick(() => {
// //
// if (marketTemperatureRef.value && data.GSWDJ) {
// console.log('');
// console.log('', data.GSWDJ)
// marketTemperatureRef.value.initChart(data.GSWDJ, data.KLine20, data.WDRL);
// console.log('');
// }
// //
// if (emotionDecodRef.value && data.QXJMQ) {
// console.log('');
// console.log('', data.QXJMQ)
// emotionDecodRef.value.initQXNLZHEcharts(data.KLine20, data.QXJMQ);
// console.log('');
// }
// //
// if (emotionalBottomRadarRef.value && data.QXTDLD) {
// console.log('');
// console.log('', data.QXTDLD)
// emotionalBottomRadarRef.value.initEmotionalBottomRadar(data.KLine20, data.QXTDLD);
// console.log('');
// }
// //
// if (emoEnergyConverterRef.value && data.QXNLZHQ) {
// console.log('');
// console.log('KLine20:', data.KLine20);
// console.log('QXNLZHQ:', data.QXNLZHQ);
// emoEnergyConverterRef.value.initQXNLZHEcharts(data.KLine20, data.QXNLZHQ);
// console.log('');
// }
// });
// }
function renderCharts(data) { function renderCharts(data) {
return new Promise((resolve) => {
nextTick(() => {
//
if (marketTemperatureRef.value && data.GSWDJ) {
console.log('开始渲染股市温度计图表');
console.log('股市温度计数据', data.GSWDJ)
marketTemperatureRef.value.initChart(data.GSWDJ, data.KLine20, data.WDRL);
console.log('股市温度计图表已渲染');
}
//
if (emotionDecodRef.value && data.QXJMQ) {
console.log('开始渲染情绪解码器图表');
console.log('情绪解码器数据', data.QXJMQ)
emotionDecodRef.value.initQXNLZHEcharts(data.KLine20, data.QXJMQ);
console.log('情绪解码器图表已渲染');
}
//
if (emotionalBottomRadarRef.value && data.QXTDLD) {
console.log('开始渲染情绪探底雷达图表');
console.log('数据', data.QXTDLD)
emotionalBottomRadarRef.value.initEmotionalBottomRadar(data.KLine20, data.QXTDLD);
console.log('情绪探底雷达图表已渲染');
}
//
if (emoEnergyConverterRef.value && data.QXNLZHQ) {
console.log('开始渲染情绪能量转化器图表');
console.log('KLine20:', data.KLine20);
console.log('QXNLZHQ:', data.QXNLZHQ);
emoEnergyConverterRef.value.initQXNLZHEcharts(data.KLine20, data.QXNLZHQ);
console.log('情绪能量转化器图表已渲染');
}
// resolve
resolve();
});
nextTick(() => {
//
if (marketTemperatureRef.value && data.GSWDJ) {
console.log('开始渲染股市温度计图表');
console.log('股市温度计数据', data.GSWDJ)
marketTemperatureRef.value.initChart(data.GSWDJ, data.KLine20, data.WDRL);
console.log('股市温度计图表已渲染');
}
//
if (emotionDecodRef.value && data.QXJMQ) {
console.log('开始渲染情绪解码器图表');
console.log('情绪解码器数据', data.QXJMQ)
emotionDecodRef.value.initQXNLZHEcharts(data.KLine20, data.QXJMQ);
console.log('情绪解码器图表已渲染');
}
//
if (emotionalBottomRadarRef.value && data.QXTDLD) {
console.log('开始渲染情绪探底雷达图表');
console.log('数据', data.QXTDLD)
emotionalBottomRadarRef.value.initEmotionalBottomRadar(data.KLine20, data.QXTDLD);
console.log('情绪探底雷达图表已渲染');
}
//
if (emoEnergyConverterRef.value && data.QXNLZHQ) {
console.log('开始渲染情绪能量转化器图表');
console.log('KLine20:', data.KLine20);
console.log('QXNLZHQ:', data.QXNLZHQ);
emoEnergyConverterRef.value.initQXNLZHEcharts(data.KLine20, data.QXNLZHQ);
console.log('情绪能量转化器图表已渲染');
}
}); });
} }
// function renderCharts(data) {
// return new Promise((resolve) => {
// nextTick(() => {
// //
// if (marketTemperatureRef.value && data.GSWDJ) {
// console.log('');
// console.log('', data.GSWDJ)
// marketTemperatureRef.value.initChart(data.GSWDJ, data.KLine20, data.WDRL);
// console.log('');
// }
// //
// if (emotionDecodRef.value && data.QXJMQ) {
// console.log('');
// console.log('', data.QXJMQ)
// emotionDecodRef.value.initQXNLZHEcharts(data.KLine20, data.QXJMQ);
// console.log('');
// }
// //
// if (emotionalBottomRadarRef.value && data.QXTDLD) {
// console.log('');
// console.log('', data.QXTDLD)
// emotionalBottomRadarRef.value.initEmotionalBottomRadar(data.KLine20, data.QXTDLD);
// console.log('');
// }
// //
// if (emoEnergyConverterRef.value && data.QXNLZHQ) {
// console.log('');
// console.log('KLine20:', data.KLine20);
// console.log('QXNLZHQ:', data.QXNLZHQ);
// emoEnergyConverterRef.value.initQXNLZHEcharts(data.KLine20, data.QXNLZHQ);
// console.log('');
// }
// // resolve
// resolve();
// });
// });
// }
//
onMounted(() => {
startImageRotation();
});
</script> </script>
@ -578,9 +623,9 @@ function renderCharts(data) {
} }
.span02 { .span02 {
margin-left: 500px;
font-size: 1.5rem; font-size: 1.5rem;
color: white; color: white;
float: right;
} }
.span01 { .span01 {

Loading…
Cancel
Save