You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2185 lines
61 KiB

1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
3 weeks ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
  1. <template>
  2. <view class="main">
  3. <!-- 顶部状态栏占位 -->
  4. <view class="top" :style="{height:iSMT+'px'}"></view>
  5. <!-- 登录的提示 -->
  6. <LoginPrompt ref="loginPrompt"></LoginPrompt>
  7. <!-- 头部导航 -->
  8. <view class="header">
  9. <view class="headphone-icon" @click="goToCustomerService">
  10. <image src="https://d31zlh4on95l9h.cloudfront.net/images/bef2edba6cc0c85671fde07cfab5270d.png" class="header-icon-image"></image>
  11. </view>
  12. <view class="title">DeepChart</view>
  13. <view class="notification-icon" @click="goToNotificationCenter">
  14. <image src="https://d31zlh4on95l9h.cloudfront.net/images/2554c84b91712d2a6cb6b00380e63bac.png" class="header-icon-image"></image>
  15. </view>
  16. </view>
  17. <!-- 内容区域 - 使用滚动视图 -->
  18. <scroll-view scroll-y class="content-container">
  19. <!-- 1. 今日市场概览 -->
  20. <market-overview :stock-info-list="currentStockInfoList"></market-overview>
  21. <!-- 间隔 -->
  22. <view class="section-gap"></view>
  23. <!-- 新增欢迎部分 -->
  24. <view class="section welcome-section">
  25. <!-- 轮播图 -->
  26. <swiper class="welcome-swiper" circular autoplay interval="3000" duration="500" indicator-dots indicator-active-color="#4080ff">
  27. <swiper-item v-for="(imageUrl, index) in swiperImages" :key="index">
  28. <image class="swiper-image" :src="imageUrl" mode="aspectFill"></image>
  29. </swiper-item>
  30. </swiper>
  31. </view>
  32. <!-- 2. DeepMate -->
  33. <view class="section deepmate-section">
  34. <DeepMate />
  35. </view>
  36. <!-- 3. 深度探索 -->
  37. <view class="section deep-exploration">
  38. <!-- 上部分标题和查看更多按钮 -->
  39. <view class="section-header-container">
  40. <view class="section-header">
  41. <view class="header-left">
  42. <text class="section-title">深度探索</text>
  43. </view>
  44. <view class="header-right">
  45. <text class="more-btn" @click="goToDeepExploration">查看更多</text>
  46. </view>
  47. </view>
  48. </view>
  49. <!-- 下部分四个图标 -->
  50. <view class="exploration-container">
  51. <view class="exploration-content">
  52. <view class="exploration-item">
  53. <image class="exploration-icon" src="https://d31zlh4on95l9h.cloudfront.net/images/199472b0ee90a1c897f7c87b85accd84.png" mode="aspectFit" lazy-load="true"></image>
  54. <text class="exploration-text">主力追踪</text>
  55. </view>
  56. <view class="exploration-item">
  57. <image class="exploration-icon" src="https://d31zlh4on95l9h.cloudfront.net/images/c25ca5e176efc961dabfa5d0d1b486b0.png" mode="aspectFit" lazy-load="true"></image>
  58. <text class="exploration-text">主力雷达</text>
  59. </view>
  60. <view class="exploration-item">
  61. <image class="exploration-icon" src="https://d31zlh4on95l9h.cloudfront.net/images/c064d7066dc8129a7df7b052762f82cf.png" mode="aspectFit" lazy-load="true"></image>
  62. <text class="exploration-text">主力解码</text>
  63. </view>
  64. <view class="exploration-item">
  65. <image class="exploration-icon" src="https://d31zlh4on95l9h.cloudfront.net/images/9d69cceee9c515911477078af6f68d88.png" mode="aspectFit" lazy-load="true"></image>
  66. <text class="exploration-text">主力资金流</text>
  67. </view>
  68. </view>
  69. </view>
  70. </view>
  71. <!-- 4. 我的自选 -->
  72. <view class="section my-selection">
  73. <!-- 上部分标题和查看更多按钮 -->
  74. <view class="section-header-container">
  75. <view class="section-header">
  76. <text class="section-title">我的自选</text>
  77. <text class="more-btn" @click="goToMarketSituation">添加自选股</text>
  78. </view>
  79. <!-- 我的自选TCP连接状态和控制 -->
  80. <!-- <view class="my-stocks-tcp-control">
  81. <view class="tcp-status" :class="{'connected': myStocksTcpConnected, 'disconnected': !myStocksTcpConnected}">
  82. <text class="status-text">{{myStocksTcpConnected ? '自选已连接' : '自选未连接'}}</text>
  83. </view>
  84. <view class="tcp-buttons">
  85. <button class="tcp-btn connect-btn" @click="connectMyStocksTcp" :disabled="myStocksTcpConnected">连接</button>
  86. <button class="tcp-btn disconnect-btn" @click="disconnectMyStocksTcp" :disabled="!myStocksTcpConnected">断开</button>
  87. </view>
  88. </view> -->
  89. </view>
  90. <!-- 下部分股票列表 -->
  91. <view class="stock-container">
  92. <view class="stock-list">
  93. <!-- 如果有TCP数据显示实时数据否则显示静态数据 -->
  94. <view class="stock-item" v-for="(item, index) in (myStocksInfoList.length > 0 ? myStocksInfoList : myStocks)" :key="item.code || item.stock_code">
  95. <view class="stock-info">
  96. <view class="name-container">
  97. <text class="stock-name">{{item.name || item.stock_name}}</text>
  98. <text class="stock-code-label">{{item.code || item.stock_code}}</text>
  99. </view>
  100. <view class="price-container">
  101. <text class="stock-price">{{item.price || item.current_price}}</text>
  102. <text class="stock-change" :class="{'stock-up': (item.change_percent || item.change || item.change_amount || 0) > 0, 'stock-down': (item.change_percent || item.change || item.change_amount || 0) < 0}">
  103. {{(item.change_percent || item.change || item.change_amount || 0) > 0 ? '+' : ''}}{{(parseFloat(item.change_percent || item.change || item.change_amount || 0)).toFixed(2)}}%
  104. </text>
  105. </view>
  106. </view>
  107. <view class="stock-chart">
  108. <image :src="item.chartImg || '/static/c5.png'" mode="aspectFit" class="chart-image"></image>
  109. </view>
  110. </view>
  111. </view>
  112. <!-- 机构动向简报数据 -->
  113. <view class="institutional-reports">
  114. <view class="section-title-container">
  115. <text class="section-title-text">机构动向简报</text>
  116. </view>
  117. <view class="text-gap"></view>
  118. <view class="report-item" v-for="(report, index) in institutionalReports" :key="index" @click="goToNotFoundBriefing(report)">
  119. <view class="report-stock">{{report.stock}}</view>
  120. <view class="report-status">{{report.status}}</view>
  121. </view>
  122. <view class="view-more" @click="goToCustomStockList">
  123. <text>查看更多 >></text>
  124. </view>
  125. </view>
  126. </view>
  127. <view class="disclaimer">
  128. <text class="disclaimer-text">以上数据由AI生成不作为最终投资建议决策需独立</text>
  129. </view>
  130. </view>
  131. <!-- 5. TCP连接测试 -->
  132. <!-- <view class="section tcp-test-section">
  133. <view class="section-header">
  134. <text class="section-title">TCP连接测试</text>
  135. <view class="tcp-status" :class="{'connected': tcpConnected, 'disconnected': !tcpConnected}">
  136. <text class="status-text">{{tcpConnected ? '已连接' : '未连接'}}</text>
  137. </view>
  138. </view> -->
  139. <!-- TCP控制按钮 -->
  140. <!-- <view class="tcp-controls">
  141. <button class="tcp-btn connect-btn" @click="connectTcp" :disabled="tcpConnected">连接</button>
  142. <button class="tcp-btn disconnect-btn" @click="disconnectTcp" :disabled="!tcpConnected">断开</button>
  143. <button class="tcp-btn send-btn" @click="sendTcpMessage" :disabled="!tcpConnected">发送测试消息</button>
  144. <button class="tcp-btn status-btn" @click="getTcpStatus">查看状态</button>
  145. </view> -->
  146. <!-- 消息记录 -->
  147. <!-- <view class="tcp-messages" v-if="tcpMessages.length > 0">
  148. <view class="messages-header">
  149. <text class="messages-title">消息记录 ({{tcpMessages.length}})</text>
  150. <button class="clear-btn" @click="clearTcpMessages">清空</button>
  151. </view>
  152. <scroll-view scroll-y class="messages-list" scroll-top="{{tcpMessages.length * 50}}">
  153. <view class="message-item" v-for="(msg, index) in tcpMessages" :key="index"
  154. :class="{'sent': msg.direction === 'sent', 'received': msg.direction === 'received'}">
  155. <view class="message-info">
  156. <text class="message-direction">{{msg.direction === 'sent' ? '发送' : '接收'}}</text>
  157. <text class="message-time">{{msg.timestamp}}</text>
  158. </view>
  159. <text class="message-content">{{msg.content}}</text>
  160. </view>
  161. </scroll-view>
  162. </view>
  163. </view> -->
  164. <!-- 6. 今日市场看点 -->
  165. <view class="section-header highlights-title-container">
  166. <text class="section-title">今日市场核心看点</text>
  167. </view>
  168. <view class="highlights-image-container" @click="goToAnalysisInstitutionalTrends">
  169. <image src="https://d31zlh4on95l9h.cloudfront.net/images/8d5365af968402a18cedb120c09460b0.png" mode="aspectFit" class="highlights-image"></image>
  170. </view>
  171. <!-- 底部空间 - 为底部导航腾出空间 -->
  172. <view class="bottom-space"></view>
  173. </scroll-view>
  174. <!-- 底部导航 -->
  175. <footerBar class="static-footer" :type="type"></footerBar>
  176. </view>
  177. </template>
  178. <script>
  179. import footerBar from '../../components/footerBar.vue'
  180. import MarketOverview from '../../components/MarketOverview.vue'
  181. import DeepMate from '../../components/DeepMate.vue'
  182. import tcpConnection from '../../api/tcpConnection.js'
  183. import th from '../../static/language/th'
  184. import MySelectionsAPI from '../../api/home/mySelections.js'
  185. import { useUserStore } from '../../stores/modules/userInfo'
  186. export default {
  187. components: {
  188. footerBar,
  189. MarketOverview,
  190. DeepMate
  191. },
  192. data() {
  193. return {
  194. type: 'home',
  195. iSMT: 0,
  196. // 用户信息 store
  197. userStore: null,
  198. // 深度探索数据
  199. explorationItems: [
  200. { title: '主力追踪', icon: '/static/c1.png' },
  201. { title: '主力资金', icon: '/static/c2.png' },
  202. { title: '主力解码', icon: '/static/c3.png' },
  203. { title: '主力资金流', icon: '/static/c4.png' }
  204. ],
  205. // 轮播图片数据
  206. swiperImages: [
  207. 'https://d31zlh4on95l9h.cloudfront.net/images/44ec37501cf3ecf5438d401c3d66fcd3.png',
  208. 'https://d31zlh4on95l9h.cloudfront.net/images/80274b6626bb403d717469b3672333c9.png',
  209. 'https://d31zlh4on95l9h.cloudfront.net/images/14481c76b09509977d3879ba3141ebc7.png',
  210. 'https://d31zlh4on95l9h.cloudfront.net/images/19e4c5542e5f974e1c6938897aa20ef9.png',
  211. 'https://d31zlh4on95l9h.cloudfront.net/images/d0bc1c1bb71917132865b82dab99831b.png'
  212. ],
  213. // 我的自选股票数据
  214. myStocks: [
  215. { name: '特斯拉', code: 'TSLA', price: '482.00', change: 2.80, chartImg: '/static/c5.png' },
  216. { name: '英伟达', code: 'NVDA', price: '189.800', change: -2.92, chartImg: '/static/c6.png' },
  217. { name: '苹果', code: 'AAPL', price: '256.430', change: 2.60, chartImg: '/static/c7.png' }
  218. ],
  219. // 机构动向简报数据
  220. institutionalReports: [
  221. { stock: '特斯拉', status: '当前市场多头资金占比,且多头资金持续流入。' },
  222. { stock: '英伟达', status: '当前市场多头资金占比,且多头资金持续流入。' },
  223. { stock: '苹果', status: '当前市场多头资金占比,且多头资金持续流入。' }
  224. ],
  225. // 防抖定时器
  226. debounceTimer: null,
  227. // TCP连接相关状态
  228. tcpConnected: false,
  229. tcpMessages: [],
  230. lastSentMessage: '',
  231. // 我的自选TCP连接状态
  232. myStocksTcpConnected: false,
  233. // TCP监听器引用,用于移除监听器
  234. connectionListener: null,
  235. messageListener: null,
  236. // TCP股票数据存储
  237. tcpStockData: {
  238. count: 0,
  239. data: {},
  240. stock_count: 0,
  241. timestamp: '',
  242. type: ''
  243. },
  244. // 当前TCP使用的股票代码
  245. currentStockCodes: ['SH.000001', 'SH.000002', 'SH.000003'],
  246. // 我的自选TCP股票数据存储
  247. myStocksTcpData: {
  248. count: 0,
  249. data: {},
  250. stock_count: 0,
  251. timestamp: '',
  252. type: ''
  253. },
  254. // TCP数据缓存机制,用于处理分片数据
  255. tcpDataCache: {
  256. isCollecting: false, // 是否正在收集数据片段
  257. expectedCount: 0, // 期望的数据总数
  258. collectedData: {}, // 已收集的数据对象(用于对象级拼接)
  259. timestamp: '', // 数据时间戳
  260. type: '', // 数据类型
  261. // 新增:字符串片段缓存
  262. firstPartData: '', // 前半部分数据字符串
  263. isWaitingSecondPart: false // 是否正在等待后半部分数据
  264. },
  265. // 我的自选TCP数据缓存机制,用于处理分片数据
  266. myStocksTcpDataCache: {
  267. isCollecting: false, // 是否正在收集数据片段
  268. expectedCount: 0, // 期望的数据总数
  269. collectedData: {}, // 已收集的数据对象(用于对象级拼接)
  270. timestamp: '', // 数据时间戳
  271. type: '', // 数据类型
  272. // 字符串片段缓存
  273. firstPartData: '', // 前半部分数据字符串
  274. isWaitingSecondPart: false // 是否正在等待后半部分数据
  275. },
  276. // 当前显示的3个股票数据(用于MarketOverview组件)
  277. currentStockInfoList: [
  278. {
  279. stock_name: '美元/日元',
  280. current_price: '151.13',
  281. change: '+1.62%',
  282. change_value: 0,
  283. change_percent: 0
  284. },
  285. {
  286. stock_name: '美元/韩元',
  287. current_price: '1424.900',
  288. change: '-2.92%',
  289. change_value: 0,
  290. change_percent: 0
  291. },
  292. {
  293. stock_name: '美元/英镑',
  294. current_price: '0.730',
  295. change: '+2.92%',
  296. change_value: 0,
  297. change_percent: 0
  298. }
  299. ],
  300. // 我的自选处理后的股票信息列表
  301. myStocksInfoList: []
  302. }
  303. },
  304. // Vue 2生命周期方法
  305. mounted() {
  306. // 状态栏高度
  307. this.iSMT = uni.getSystemInfoSync().statusBarHeight;
  308. // 初始化用户信息 store
  309. this.userStore = useUserStore();
  310. // 预加载图片资源
  311. this.myStocks.forEach(stock => {
  312. // 使用uni.getImageInfo替代Image对象
  313. uni.getImageInfo({
  314. src: stock.chartImg,
  315. success: function(res) {
  316. // 图片加载成功
  317. console.log('图片预加载成功:', stock.name)
  318. },
  319. fail: function(err) {
  320. console.log('图片预加载失败:', err)
  321. }
  322. })
  323. })
  324. // 检查用户登录状态,只有已登录并且不是游客才加载自选股数据
  325. if (this.userStore.userInfo && !this.userStore.userInfo.isVisitor) {
  326. console.log('是用户登录,加载自选股数据', this.userStore.userInfo)
  327. this.loadMySelectionsData()
  328. } else if (this.userStore.userInfo && this.userStore.userInfo.isVisitor){
  329. console.log('是游客登录,加载默认自选股',this.userStore.userInfo)
  330. this.loadGuestDefaultStocks()
  331. }else {
  332. console.log('用户未登录',this.userStore.userInfo)
  333. }
  334. // 初始化TCP连接监听器
  335. this.initTcpListeners()
  336. // 监听游客登录成功事件
  337. uni.$on('visitorLoginSuccess', this.handleVisitorLoginSuccess)
  338. // 页面渲染完成后自动连接两个TCP连接
  339. // this.$nextTick(() => {
  340. // console.log('页面渲染完成,开始自动连接TCP服务器...')
  341. // // 延迟一小段时间确保页面完全加载后再连接
  342. // setTimeout(() => {
  343. // // 连接今日市场概览TCP(channel 1)
  344. // console.log('连接今日市场概览TCP(channel 1)...')
  345. // this.connectTcp()
  346. // // 稍微延迟后连接我的自选TCP(channel 2)
  347. // setTimeout(() => {
  348. // console.log('连接我的自选TCP(channel 2)...')
  349. // this.connectMyStocksTcp()
  350. // }, 500)
  351. // }, 1000)
  352. // })
  353. },
  354. // 页面销毁前的清理工作
  355. onUnload() {
  356. // 自动关闭主TCP连接
  357. if (this.tcpConnected) {
  358. console.log('页面销毁,自动关闭主TCP连接')
  359. tcpConnection.disconnect({
  360. ip: '39.102.136.61',
  361. port: '8080',
  362. channel: '1',
  363. charsetname: 'UTF-8'
  364. })
  365. this.tcpConnected = false
  366. }
  367. // 自动关闭我的自选TCP连接
  368. if (this.myStocksTcpConnected) {
  369. console.log('页面销毁,自动关闭我的自选TCP连接')
  370. tcpConnection.disconnect({
  371. ip: '39.102.136.61',
  372. port: '8088',
  373. channel: '2',
  374. charsetname: 'UTF-8'
  375. })
  376. this.myStocksTcpConnected = false
  377. }
  378. // 清理防抖定时器
  379. if (this.debounceTimer) {
  380. clearTimeout(this.debounceTimer)
  381. this.debounceTimer = null
  382. }
  383. // 移除TCP监听器,防止内存泄漏
  384. this.removeTcpListeners()
  385. // 移除游客登录成功事件监听器
  386. uni.$off('visitorLoginSuccess', this.handleVisitorLoginSuccess)
  387. },
  388. methods: {
  389. // 跳转到客服中台
  390. goToCustomerService() {
  391. uni.navigateTo({
  392. url: '/pages/customerServicePlatform/csPlatformIndex'
  393. })
  394. },
  395. // 跳转到通知中心
  396. goToNotificationCenter() {
  397. uni.navigateTo({
  398. url: '/pages/blank/notice'
  399. })
  400. },
  401. // 跳转到自定义股票列表页面
  402. goToCustomStockList() {
  403. uni.navigateTo({
  404. url: '/pages/customStockList/customStockList'
  405. })
  406. },
  407. // 跳转到行情页面
  408. goToMarketSituation() {
  409. uni.navigateTo({
  410. url: '/pages/marketSituation/marketSituation'
  411. })
  412. },
  413. // 跳转到机构动向解析页面
  414. goToAnalysisInstitutionalTrends() {
  415. uni.navigateTo({
  416. url: '/pages/analysisInstitutionalTrends/analysisInstitutionalTrends'
  417. })
  418. },
  419. // 跳转到深度探索页面
  420. goToDeepExploration() {
  421. uni.navigateTo({
  422. url: '/pages/deepExploration/deepExploration'
  423. })
  424. },
  425. // 跳转到缺省页面(机构动向简报点击)
  426. goToNotFoundBriefing(report) {
  427. uni.navigateTo({
  428. url: '/pages/notFoundBriefing/notFoundBriefing'
  429. })
  430. },
  431. // 处理游客登录成功事件
  432. handleVisitorLoginSuccess(data) {
  433. console.log('收到游客登录成功事件:', data)
  434. // 重新加载页面数据
  435. this.reloadPageData()
  436. },
  437. // 重新加载页面数据
  438. reloadPageData() {
  439. console.log('重新加载页面数据...')
  440. // 更新用户信息store
  441. this.userStore = useUserStore()
  442. // 根据新的用户状态加载相应的数据
  443. if (this.userStore.userInfo && this.userStore.userInfo.isVisitor) {
  444. console.log('游客登录成功,加载默认自选股')
  445. this.loadGuestDefaultStocks()
  446. } else if (this.userStore.userInfo && !this.userStore.userInfo.isVisitor) {
  447. console.log('用户登录,加载自选股数据')
  448. this.loadMySelectionsData()
  449. }
  450. },
  451. // 防抖函数
  452. debounce(fn, delay = 300) {
  453. if (this.debounceTimer) clearTimeout(this.debounceTimer)
  454. this.debounceTimer = setTimeout(() => {
  455. fn()
  456. this.debounceTimer = null
  457. }, delay)
  458. },
  459. // 自选股数据加载相关方法
  460. // 加载自选股数据的主方法
  461. async loadMySelectionsData() {
  462. try {
  463. console.log('开始加载自选股数据...')
  464. // 调用checkExist判断用户是否存在自选股
  465. const checkResult = await MySelectionsAPI.checkExist()
  466. console.log('检查用户自选股存在性结果:', checkResult)
  467. if (checkResult.code === 200) {
  468. const isHave = checkResult.data.is_have
  469. if (isHave === 1) {
  470. // 用户有自选股,查询所有分组
  471. console.log('用户存在自选股,查询所有分组...')
  472. await this.loadUserStockGroups()
  473. } else {
  474. // 用户没有自选股,查询默认自选股
  475. console.log('用户不存在自选股,查询默认自选股...')
  476. await this.loadDefaultStocks()
  477. }
  478. } else {
  479. console.error('检查用户自选股存在性失败:', checkResult.message)
  480. // 失败时也尝试加载默认自选股
  481. // await this.loadDefaultStocks()
  482. }
  483. } catch (error) {
  484. console.error('加载自选股数据失败:', error)
  485. // 出错时尝试加载默认自选股
  486. await this.loadDefaultStocks()
  487. }
  488. },
  489. // 加载用户自选股分组
  490. async loadUserStockGroups() {
  491. try {
  492. const groupResult = await MySelectionsAPI.getUserStockGroupList()
  493. console.log('查询用户自选股分组结果:', groupResult)
  494. if (groupResult.code === 200 && groupResult.data && groupResult.data.length > 0) {
  495. // 找到id最小的分组
  496. const minIdGroup = groupResult.data.reduce((min, current) => {
  497. return current.id < min.id ? current : min
  498. })
  499. console.log('找到最小id分组:', minIdGroup)
  500. // 查询该分组下的股票
  501. await this.loadGroupStocks(minIdGroup.id)
  502. } else {
  503. console.log('没有找到用户自选股分组,加载默认自选股')
  504. await this.loadDefaultStocks()
  505. }
  506. } catch (error) {
  507. console.error('加载用户自选股分组失败:', error)
  508. await this.loadDefaultStocks()
  509. }
  510. },
  511. // 加载指定分组下的股票
  512. async loadGroupStocks(groupId) {
  513. try {
  514. const stockResult = await MySelectionsAPI.getUserStockList(null, null, {
  515. groupId: groupId,
  516. pageNum: 1,
  517. pageSize: 20
  518. })
  519. console.log('查询分组自选股结果:', stockResult)
  520. if (stockResult.code === 200 && stockResult.data) {
  521. this.processStockData(stockResult.data)
  522. } else {
  523. console.log('分组下没有股票数据,加载默认自选股')
  524. await this.loadDefaultStocks()
  525. }
  526. } catch (error) {
  527. console.error('加载分组股票失败:', error)
  528. await this.loadDefaultStocks()
  529. }
  530. },
  531. // 加载默认自选股
  532. async loadDefaultStocks() {
  533. try {
  534. const defaultResult = await MySelectionsAPI.getUserOrDefault()
  535. console.log('查询默认自选股结果:', defaultResult)
  536. if (defaultResult.code === 200 && defaultResult.data) {
  537. this.processStockData(defaultResult.data)
  538. } else {
  539. console.log('没有默认自选股数据')
  540. }
  541. } catch (error) {
  542. console.error('加载默认自选股失败:', error)
  543. }
  544. },
  545. // 游客加载默认自选股
  546. async loadGuestDefaultStocks() {
  547. try {
  548. console.log('游客开始加载默认自选股...')
  549. const guestResult = await MySelectionsAPI.getDefaultStocks()
  550. console.log('游客查询默认自选股结果:', guestResult)
  551. if (guestResult.code === 200 && guestResult.data) {
  552. this.processStockData(guestResult.data)
  553. } else {
  554. console.log('游客没有默认自选股数据')
  555. }
  556. } catch (error) {
  557. console.error('游客加载默认自选股失败:', error)
  558. }
  559. },
  560. // 处理股票数据
  561. processStockData(stockData) {
  562. console.log('处理股票数据:', stockData)
  563. // 根据返回的数据结构更新myStocks数组
  564. // 这里需要根据实际API返回的数据结构进行调整
  565. if (Array.isArray(stockData)) {
  566. // 如果是数组格式
  567. this.myStocks = stockData.map(stock => ({
  568. name: stock.name || stock.stock_name || '',
  569. code: stock.code || stock.stock_code || '',
  570. // price: stock.price || stock.current_price || '0.00',
  571. // change: stock.change || stock.change_percent || 0,
  572. chartImg: stock.chartImg || '/static/c5.png' // 默认图片
  573. }))
  574. //重新赋值机构动向简报
  575. this.institutionalReports = stockData.map(stock => ({
  576. stock: stock.name || stock.stock_name || '',
  577. status: stock.code || stock.stock_code || '',
  578. }))
  579. } else if (stockData.list && Array.isArray(stockData.list)) {
  580. // 如果是分页格式
  581. this.myStocks = stockData.list.map(stock => ({
  582. name: stock.name || stock.stock_name || '',
  583. code: stock.code || stock.stock_code || '',
  584. // price: stock.price || stock.current_price || '0.00',
  585. // change: stock.change || stock.change_percent || 0,
  586. chartImg: stock.chartImg || '/static/c5.png' // 默认图片
  587. }))
  588. //重新赋值机构动向简报
  589. //重新赋值机构动向简报
  590. this.institutionalReports = stockData.map(stock => ({
  591. stock: stock.name || stock.stock_name || '',
  592. status: stock.code || stock.stock_code || '',
  593. }))
  594. }
  595. console.log('更新后的自选股数据:', this.myStocks)
  596. // 更新TCP消息中的股票代码
  597. this.updateTcpStockCodes()
  598. },
  599. // 更新TCP消息中的股票代码
  600. updateTcpStockCodes() {
  601. // 从myStocks中提取前3个股票代码
  602. const stockCodes = this.myStocks.slice(0, 3).map(stock => stock.code).filter(code => code)
  603. console.log('更新TCP消息股票代码:', stockCodes)
  604. // 如果有股票代码,更新TCP消息
  605. if (stockCodes.length > 0) {
  606. // 补充到3个代码(如果不足3个,用默认代码补充)
  607. while (stockCodes.length < 3) {
  608. stockCodes.push('SH.000001') // 默认代码
  609. }
  610. // 保存到组件数据中,供TCP方法使用
  611. this.currentStockCodes = stockCodes
  612. console.log('当前TCP使用的股票代码:', this.currentStockCodes)
  613. }
  614. },
  615. // TCP连接相关方法
  616. // 初始化TCP监听器
  617. initTcpListeners() {
  618. // 创建连接状态监听器并保存引用
  619. this.connectionListener = (status, result, channel) => {
  620. console.log('TCP连接状态变化:', status, 'channel:', channel)
  621. // 根据channel更新对应的连接状态
  622. if (channel === '1') {
  623. // 主TCP连接
  624. this.tcpConnected = (status === 'connected')
  625. console.log('主TCP连接状态:', this.tcpConnected)
  626. // 显示连接状态提示
  627. uni.showToast({
  628. title: status === 'connected' ? '主连接服务器成功' : '主服务器连接断开',
  629. icon: status === 'connected' ? 'success' : 'none',
  630. duration: 1000
  631. })
  632. // 连接成功后自动发送股票数据请求命令
  633. if (status === 'connected') {
  634. console.log('主TCP连接成功,自动发送股票数据请求...')
  635. // 延迟一小段时间确保连接稳定后再发送命令
  636. setTimeout(() => {
  637. this.sendTcpMessage()
  638. }, 500)
  639. }
  640. } else if (channel === '2') {
  641. // 我的自选TCP连接
  642. this.myStocksTcpConnected = (status === 'connected')
  643. console.log('我的自选TCP连接状态:', this.myStocksTcpConnected)
  644. // 显示连接状态提示
  645. uni.showToast({
  646. title: status === 'connected' ? '我的自选连接成功' : '我的自选连接断开',
  647. icon: status === 'connected' ? 'success' : 'none',
  648. duration: 1000
  649. })
  650. // 连接成功后自动发送我的自选股票数据请求
  651. if (status === 'connected') {
  652. console.log('我的自选TCP连接成功,自动发送自选股票数据请求...')
  653. // 延迟一小段时间确保连接稳定后再发送命令
  654. setTimeout(() => {
  655. this.sendMyStocksTcpMessage()
  656. }, 500)
  657. }
  658. }
  659. }
  660. // 创建消息监听器并保存引用
  661. this.messageListener = (type, message, parsedArray, channel) => {
  662. const messageObj = {
  663. type: type,
  664. content: message,
  665. parsedArray: parsedArray,
  666. channel: channel,
  667. timestamp: new Date().toLocaleTimeString(),
  668. direction: 'received'
  669. }
  670. this.tcpMessages.push(messageObj)
  671. console.log('收到TCP消息:', messageObj)
  672. console.log('消息来源channel:', channel)
  673. // 根据channel调用相应的数据处理方法
  674. if (channel === '1') {
  675. // 主TCP连接 - 今日市场概览数据
  676. // console.log('处理今日市场概览数据')
  677. this.parseStockData(message)
  678. } else if (channel === '2') {
  679. // 我的自选TCP连接 - 我的自选数据
  680. console.log('处理我的自选数据')
  681. this.parseMyStocksData(message)
  682. } else {
  683. console.warn('未知的channel:', channel)
  684. }
  685. }
  686. // 注册监听器
  687. tcpConnection.onConnectionChange(this.connectionListener)
  688. tcpConnection.onMessage(this.messageListener)
  689. },
  690. // 连接TCP服务器
  691. connectTcp() {
  692. // console.log('开始连接TCP服务器...')
  693. // 先断开现有连接(如果存在)
  694. if (this.tcpConnected) {
  695. // console.log('检测到现有连接,先断开...')
  696. this.disconnectTcp()
  697. // 等待断开完成后再连接
  698. setTimeout(() => {
  699. this.performTcpConnect()
  700. }, 500)
  701. } else {
  702. // 直接连接
  703. this.performTcpConnect()
  704. }
  705. },
  706. // 执行TCP连接
  707. performTcpConnect() {
  708. // console.log('执行TCP连接...')
  709. tcpConnection.connect(
  710. {
  711. ip: '39.102.136.61',
  712. port: '8088',
  713. channel: '1', // 可选 1~20
  714. charsetname: 'UTF-8' // 默认UTF-8,可选GBK
  715. }
  716. )
  717. },
  718. // 断开TCP连接
  719. disconnectTcp() {
  720. // console.log('断开TCP连接...')
  721. tcpConnection.disconnect(
  722. {
  723. ip: '39.102.136.61',
  724. port: '8088',
  725. channel: '1', // 可选 1~20
  726. charsetname: 'UTF-8' // 默认UTF-8,可选GBK
  727. }
  728. )
  729. this.tcpConnected = false
  730. },
  731. // 连接我的自选TCP服务器
  732. connectMyStocksTcp() {
  733. console.log('开始连接我的自选TCP服务器...')
  734. // 先断开现有连接(如果存在)
  735. if (this.myStocksTcpConnected) {
  736. console.log('检测到我的自选现有连接,先断开...')
  737. this.disconnectMyStocksTcp()
  738. // 等待断开完成后再连接
  739. setTimeout(() => {
  740. this.performMyStocksTcpConnect()
  741. }, 500)
  742. } else {
  743. // 直接连接
  744. this.performMyStocksTcpConnect()
  745. }
  746. },
  747. // 执行我的自选TCP连接
  748. performMyStocksTcpConnect() {
  749. console.log('执行我的自选TCP连接...')
  750. tcpConnection.connect(
  751. {
  752. ip: '39.102.136.61',
  753. port: '8088',
  754. channel: '2', // 我的自选使用channel 2
  755. charsetname: 'UTF-8' // 默认UTF-8,可选GBK
  756. }
  757. )
  758. },
  759. // 断开我的自选TCP连接
  760. disconnectMyStocksTcp() {
  761. console.log('断开我的自选TCP连接...')
  762. tcpConnection.disconnect(
  763. {
  764. ip: '39.102.136.61',
  765. port: '8088',
  766. channel: '2', // 我的自选使用channel 2
  767. charsetname: 'UTF-8' // 默认UTF-8,可选GBK
  768. }
  769. )
  770. this.myStocksTcpConnected = false
  771. },
  772. // 解析我的自选TCP股票数据
  773. parseMyStocksData(message) {
  774. try {
  775. console.log('进入parseMyStocksData, message类型:', typeof message, '长度:', message.length)
  776. // 第一步:检查数据状态(完整、前半部分、后半部分)
  777. const dataStatus = this.getMyStocksDataStatus(message)
  778. let completeMessage = ''
  779. switch (dataStatus) {
  780. case 'complete':
  781. // 完整数据,直接处理
  782. console.log('我的自选:检测到完整数据,直接处理')
  783. completeMessage = message
  784. break
  785. case 'first_part':
  786. // 前半部分数据,缓存并等待后半部分
  787. console.log('我的自选:检测到前半部分数据,开始缓存')
  788. this.cacheMyStocksFirstPartData(message)
  789. return // 等待后半部分数据
  790. case 'second_part':
  791. // 后半部分数据,检查是否有缓存的前半部分
  792. if (this.myStocksTcpDataCache.isWaitingSecondPart) {
  793. console.log('我的自选:检测到后半部分数据,开始拼接')
  794. completeMessage = this.concatenateMyStocksDataParts(message)
  795. } else {
  796. console.log('我的自选:收到后半部分数据,但没有缓存的前半部分,跳过处理')
  797. return
  798. }
  799. break
  800. case 'invalid':
  801. default:
  802. console.log('我的自选:数据格式无效,跳过处理')
  803. return
  804. }
  805. // 第二步:解析完整的JSON数据
  806. let parsedMessage
  807. try {
  808. console.log('我的自选:开始解析完整JSON数据,长度:', completeMessage.length)
  809. parsedMessage = JSON.parse(completeMessage)
  810. console.log('我的自选:JSON解析成功,解析后类型:', typeof parsedMessage, parsedMessage)
  811. } catch (parseError) {
  812. console.error('我的自选:JSON解析失败:', parseError.message)
  813. // 清空字符串片段缓存
  814. this.clearMyStocksStringFragmentCache()
  815. return
  816. }
  817. // 第三步:检查是否是股票数据类型
  818. if (!((parsedMessage.type === 'batch_data_chunk' || parsedMessage.type === 'batch_realtime_data') && parsedMessage.data)) {
  819. console.log('我的自选:不是batch_data_chunk或batch_realtime_data类型的消息,跳过处理')
  820. return
  821. }
  822. console.log('我的自选:开始处理股票数据')
  823. // 第四步:验证数据完整性(对象级别的完整性检查)
  824. // 注意:batch_data_chunk类型的数据不需要验证完整性,直接处理
  825. if (parsedMessage.type === 'batch_data_chunk') {
  826. console.log('我的自选:batch_data_chunk类型数据,跳过完整性验证,直接处理')
  827. this.processCompleteMyStocksData(parsedMessage)
  828. } else {
  829. const isDataComplete = this.validateMyStocksDataIntegrity(parsedMessage)
  830. if (isDataComplete) {
  831. // 数据完整,直接处理
  832. console.log('我的自选:对象级数据完整,直接处理')
  833. this.processCompleteMyStocksData(parsedMessage)
  834. } else {
  835. // 数据不完整,需要拼接(对象级别的拼接)
  836. console.log('我的自选:对象级数据不完整,开始拼接处理')
  837. // 将当前数据合并到缓存中
  838. this.mergeMyStocksDataToCache(parsedMessage)
  839. // 检查缓存中的数据是否已经完整
  840. if (this.isMyStocksCacheDataComplete()) {
  841. console.log('我的自选:缓存数据已完整,开始处理')
  842. const completeData = this.getCompleteMyStocksDataFromCache()
  843. this.processCompleteMyStocksData(completeData)
  844. } else {
  845. console.log('我的自选:缓存数据仍不完整,等待更多数据片段')
  846. }
  847. }
  848. }
  849. } catch (error) {
  850. console.error('我的自选:解析TCP股票数据失败:', error.message)
  851. console.error('我的自选:错误详情:', error)
  852. // 发生错误时清空所有缓存
  853. this.clearMyStocksStringFragmentCache()
  854. if (this.myStocksTcpDataCache.isCollecting) {
  855. console.log('我的自选:发生错误,清空对象级数据缓存')
  856. this.myStocksTcpDataCache.isCollecting = false
  857. this.myStocksTcpDataCache.expectedCount = 0
  858. this.myStocksTcpDataCache.collectedData = {}
  859. this.myStocksTcpDataCache.timestamp = ''
  860. this.myStocksTcpDataCache.type = ''
  861. }
  862. }
  863. },
  864. // 验证我的自选数据完整性
  865. validateMyStocksDataIntegrity(parsedMessage) {
  866. if (!parsedMessage.count || !parsedMessage.data) {
  867. return false
  868. }
  869. const dataObjectCount = Object.keys(parsedMessage.data).length
  870. const expectedCount = parsedMessage.count
  871. console.log(`我的自选数据完整性验证: 期望${expectedCount}个对象,实际${dataObjectCount}个对象`)
  872. return dataObjectCount === expectedCount
  873. },
  874. // 检查我的自选数据状态(完整数据、前半部分数据、后半部分数据)
  875. getMyStocksDataStatus(message) {
  876. if (typeof message !== 'string') {
  877. return 'invalid'
  878. }
  879. const trimmedMessage = message.trim()
  880. const startsWithBrace = trimmedMessage.startsWith('{')
  881. const endsWithBrace = trimmedMessage.endsWith('}')
  882. if (startsWithBrace && endsWithBrace) {
  883. // 以{开头,以}结尾 - 完整数据
  884. console.log('我的自选:检测到完整数据格式')
  885. return 'complete'
  886. } else if (startsWithBrace && !endsWithBrace) {
  887. // 以{开头,不以}结尾 - 前半部分数据
  888. console.log('我的自选:检测到前半部分数据')
  889. return 'first_part'
  890. } else if (!startsWithBrace && endsWithBrace) {
  891. // 不以{开头,以}结尾 - 后半部分数据
  892. console.log('我的自选:检测到后半部分数据')
  893. return 'second_part'
  894. } else {
  895. // 其他情况 - 无效数据
  896. console.log('我的自选:检测到无效数据格式')
  897. return 'invalid'
  898. }
  899. },
  900. // 缓存我的自选前半部分数据
  901. cacheMyStocksFirstPartData(message) {
  902. this.myStocksTcpDataCache.firstPartData = message.trim()
  903. this.myStocksTcpDataCache.isWaitingSecondPart = true
  904. console.log('我的自选:已缓存前半部分数据,长度:', this.myStocksTcpDataCache.firstPartData.length)
  905. },
  906. // 拼接我的自选前后两部分数据
  907. concatenateMyStocksDataParts(secondPartMessage) {
  908. const completeMessage = this.myStocksTcpDataCache.firstPartData + secondPartMessage.trim()
  909. console.log('我的自选:数据拼接完成,完整数据长度:', completeMessage.length)
  910. // 清空缓存
  911. this.clearMyStocksStringFragmentCache()
  912. return completeMessage
  913. },
  914. // 清空我的自选字符串片段缓存
  915. clearMyStocksStringFragmentCache() {
  916. this.myStocksTcpDataCache.firstPartData = ''
  917. this.myStocksTcpDataCache.isWaitingSecondPart = false
  918. console.log('我的自选:字符串片段缓存已清空')
  919. },
  920. // 合并我的自选数据到缓存中
  921. mergeMyStocksDataToCache(parsedMessage) {
  922. // 如果是第一次收集数据,初始化缓存
  923. if (!this.myStocksTcpDataCache.isCollecting) {
  924. this.myStocksTcpDataCache.isCollecting = true
  925. this.myStocksTcpDataCache.expectedCount = parsedMessage.count
  926. this.myStocksTcpDataCache.collectedData = {}
  927. this.myStocksTcpDataCache.timestamp = parsedMessage.timestamp
  928. this.myStocksTcpDataCache.type = parsedMessage.type
  929. console.log('我的自选:开始收集数据片段,期望总数:', parsedMessage.count)
  930. }
  931. // 合并新数据到缓存中
  932. if (parsedMessage.data) {
  933. Object.assign(this.myStocksTcpDataCache.collectedData, parsedMessage.data)
  934. console.log('我的自选:数据片段已合并,当前已收集:', Object.keys(this.myStocksTcpDataCache.collectedData).length, '个对象')
  935. }
  936. },
  937. // 检查我的自选缓存数据是否完整
  938. isMyStocksCacheDataComplete() {
  939. const collectedCount = Object.keys(this.myStocksTcpDataCache.collectedData).length
  940. const expectedCount = this.myStocksTcpDataCache.expectedCount
  941. console.log(`我的自选缓存数据检查: 已收集${collectedCount}个,期望${expectedCount}`)
  942. return collectedCount === expectedCount && collectedCount > 0
  943. },
  944. // 获取我的自选完整的缓存数据并清空缓存
  945. getCompleteMyStocksDataFromCache() {
  946. const completeData = {
  947. count: this.myStocksTcpDataCache.expectedCount,
  948. data: { ...this.myStocksTcpDataCache.collectedData },
  949. stock_count: this.myStocksTcpDataCache.expectedCount,
  950. timestamp: this.myStocksTcpDataCache.timestamp,
  951. type: this.myStocksTcpDataCache.type
  952. }
  953. // 清空缓存
  954. this.myStocksTcpDataCache.isCollecting = false
  955. this.myStocksTcpDataCache.expectedCount = 0
  956. this.myStocksTcpDataCache.collectedData = {}
  957. this.myStocksTcpDataCache.timestamp = ''
  958. this.myStocksTcpDataCache.type = ''
  959. console.log('我的自选:获取完整数据并清空缓存,数据对象数:', Object.keys(completeData.data).length)
  960. return completeData
  961. },
  962. // 处理我的自选完整的股票数据
  963. processCompleteMyStocksData(completeData) {
  964. console.log("我的自选:开始更新我的自选TCP股票数据存储")
  965. // 更新我的自选TCP股票数据存储
  966. this.myStocksTcpData = {
  967. count: completeData.count || 0,
  968. data: completeData.data || {},
  969. stock_count: completeData.stock_count || 0,
  970. timestamp: completeData.timestamp || '',
  971. type: completeData.type || ''
  972. }
  973. // 获取所有股票的数据用于显示
  974. const stockCodes = Object.keys(completeData.data)
  975. const newMyStocksInfoList = []
  976. // 只处理前3条股票数据
  977. const maxStocks = Math.min(3, stockCodes.length)
  978. for (let i = 0; i < maxStocks; i++) {
  979. const stockCode = stockCodes[i]
  980. // 检查数据结构
  981. if (completeData.data[stockCode] && Array.isArray(completeData.data[stockCode]) && completeData.data[stockCode].length > 0) {
  982. const stockData = completeData.data[stockCode][0] // 取第一条数据
  983. console.log('遍历的数据:', stockCode, stockData)
  984. if (stockData && stockData.current_price !== undefined) {
  985. // 直接使用返回的数据,不重新计算
  986. newMyStocksInfoList.push({
  987. stock_code: stockCode,
  988. stock_name: stockData.stock_name || '未知股票',
  989. current_price: parseFloat(stockData.current_price).toFixed(2),
  990. change: stockData.change || '0.00%',
  991. change_value: stockData.change_value || 0,
  992. change_percent: parseFloat(stockData.change) || 0
  993. })
  994. }
  995. }
  996. }
  997. // 更新我的自选股票信息列表
  998. if (newMyStocksInfoList.length > 0) {
  999. this.myStocksInfoList = newMyStocksInfoList
  1000. console.log('我的自选:股票数据更新成功,共', newMyStocksInfoList.length, '个股票:', this.myStocksInfoList)
  1001. }
  1002. },
  1003. // 发送TCP消息
  1004. sendTcpMessage() {
  1005. // 构造要发送的消息对象
  1006. const messageData =
  1007. // {
  1008. // command: "real_time",
  1009. // stock_code: "SH.000001"
  1010. // }
  1011. // {"command": "stock_list"}
  1012. // {"command": "batch_real_time", "stock_codes": ["SH.000001"]}
  1013. {"command": "batch_real_time", "stock_codes": this.currentStockCodes}
  1014. // 发送消息
  1015. const success = tcpConnection.send(messageData)
  1016. if (success) {
  1017. // console.log('home发送TCP消息:', messageData)
  1018. uni.showToast({
  1019. title: '服务器连接成功',
  1020. icon: 'success',
  1021. duration: 1500
  1022. })
  1023. }
  1024. },
  1025. // 发送我的自选TCP消息
  1026. sendMyStocksTcpMessage() {
  1027. // 构造要发送的消息对象 - 我的自选股票数据请求
  1028. const messageData = {"command": "batch_real_time", "stock_codes": this.currentStockCodes}
  1029. // 发送消息到channel 2(我的自选TCP连接)
  1030. const success = tcpConnection.send(messageData, { channel: '2' })
  1031. if (success) {
  1032. console.log('我的自选:发送TCP消息成功:', messageData)
  1033. uni.showToast({
  1034. title: '我的自选数据请求已发送',
  1035. icon: 'success',
  1036. duration: 1500
  1037. })
  1038. } else {
  1039. console.error('我的自选:发送TCP消息失败')
  1040. uni.showToast({
  1041. title: '我的自选连接失败',
  1042. icon: 'error',
  1043. duration: 1500
  1044. })
  1045. }
  1046. },
  1047. // 清空消息记录
  1048. clearTcpMessages() {
  1049. this.tcpMessages = []
  1050. uni.showToast({
  1051. title: '消息记录已清空',
  1052. icon: 'success',
  1053. duration: 1500
  1054. })
  1055. },
  1056. // 获取TCP连接状态
  1057. getTcpStatus() {
  1058. const status = tcpConnection.getConnectionStatus()
  1059. uni.showModal({
  1060. title: 'TCP连接状态',
  1061. content: `当前状态: ${status ? '已连接' : '未连接'}\n消息数量: ${this.tcpMessages.length}`,
  1062. showCancel: false
  1063. })
  1064. },
  1065. // 验证数据完整性(检查count值与data对象个数是否相等)
  1066. validateDataIntegrity(parsedMessage) {
  1067. if (!parsedMessage.count || !parsedMessage.data) {
  1068. return false
  1069. }
  1070. const dataObjectCount = Object.keys(parsedMessage.data).length
  1071. const expectedCount = parsedMessage.count
  1072. // console.log(`数据完整性验证: 期望${expectedCount}个对象,实际${dataObjectCount}个对象`)
  1073. return dataObjectCount === expectedCount
  1074. },
  1075. // 检查数据状态(完整数据、前半部分数据、后半部分数据)
  1076. getDataStatus(message) {
  1077. if (typeof message !== 'string') {
  1078. return 'invalid'
  1079. }
  1080. const trimmedMessage = message.trim()
  1081. const startsWithBrace = trimmedMessage.startsWith('{')
  1082. const endsWithBrace = trimmedMessage.endsWith('}')
  1083. if (startsWithBrace && endsWithBrace) {
  1084. // 以{开头,以}结尾 - 完整数据
  1085. // console.log('检测到完整数据格式')
  1086. return 'complete'
  1087. } else if (startsWithBrace && !endsWithBrace) {
  1088. // 以{开头,不以}结尾 - 前半部分数据
  1089. // console.log('检测到前半部分数据')
  1090. return 'first_part'
  1091. } else if (!startsWithBrace && endsWithBrace) {
  1092. // 不以{开头,以}结尾 - 后半部分数据
  1093. // console.log('检测到后半部分数据')
  1094. return 'second_part'
  1095. } else {
  1096. // 其他情况 - 无效数据
  1097. // console.log('检测到无效数据格式')
  1098. return 'invalid'
  1099. }
  1100. },
  1101. // 缓存前半部分数据
  1102. cacheFirstPartData(message) {
  1103. this.tcpDataCache.firstPartData = message.trim()
  1104. this.tcpDataCache.isWaitingSecondPart = true
  1105. // console.log('已缓存前半部分数据,长度:', this.tcpDataCache.firstPartData.length)
  1106. },
  1107. // 拼接前后两部分数据
  1108. concatenateDataParts(secondPartMessage) {
  1109. const completeMessage = this.tcpDataCache.firstPartData + secondPartMessage.trim()
  1110. // console.log('数据拼接完成,完整数据长度:', completeMessage.length)
  1111. // 清空缓存
  1112. this.clearStringFragmentCache()
  1113. return completeMessage
  1114. },
  1115. // 清空字符串片段缓存
  1116. clearStringFragmentCache() {
  1117. this.tcpDataCache.firstPartData = ''
  1118. this.tcpDataCache.isWaitingSecondPart = false
  1119. // console.log('字符串片段缓存已清空')
  1120. },
  1121. // 合并数据到缓存中
  1122. mergeDataToCache(parsedMessage) {
  1123. // 如果是第一次收集数据,初始化缓存
  1124. if (!this.tcpDataCache.isCollecting) {
  1125. this.tcpDataCache.isCollecting = true
  1126. this.tcpDataCache.expectedCount = parsedMessage.count
  1127. this.tcpDataCache.collectedData = {}
  1128. this.tcpDataCache.timestamp = parsedMessage.timestamp
  1129. this.tcpDataCache.type = parsedMessage.type
  1130. // console.log('开始收集数据片段,期望总数:', parsedMessage.count)
  1131. }
  1132. // 合并新数据到缓存中
  1133. if (parsedMessage.data) {
  1134. Object.assign(this.tcpDataCache.collectedData, parsedMessage.data)
  1135. // console.log('数据片段已合并,当前已收集:', Object.keys(this.tcpDataCache.collectedData).length, '个对象')
  1136. }
  1137. },
  1138. // 检查缓存数据是否完整
  1139. isCacheDataComplete() {
  1140. const collectedCount = Object.keys(this.tcpDataCache.collectedData).length
  1141. const expectedCount = this.tcpDataCache.expectedCount
  1142. // console.log(`缓存数据检查: 已收集${collectedCount}个,期望${expectedCount}个`)
  1143. return collectedCount === expectedCount && collectedCount > 0
  1144. },
  1145. // 获取完整的缓存数据并清空缓存
  1146. getCompleteDataFromCache() {
  1147. const completeData = {
  1148. count: this.tcpDataCache.expectedCount,
  1149. data: { ...this.tcpDataCache.collectedData },
  1150. stock_count: this.tcpDataCache.expectedCount,
  1151. timestamp: this.tcpDataCache.timestamp,
  1152. type: this.tcpDataCache.type
  1153. }
  1154. // 清空缓存
  1155. this.tcpDataCache.isCollecting = false
  1156. this.tcpDataCache.expectedCount = 0
  1157. this.tcpDataCache.collectedData = {}
  1158. this.tcpDataCache.timestamp = ''
  1159. this.tcpDataCache.type = ''
  1160. // console.log('获取完整数据并清空缓存,数据对象数:', Object.keys(completeData.data).length)
  1161. return completeData
  1162. },
  1163. // 解析TCP股票数据
  1164. parseStockData(message) {
  1165. try {
  1166. // console.log('进入parseStockData, message类型:', typeof message, '长度:', message.length)
  1167. // 第一步:检查数据状态(完整、前半部分、后半部分)
  1168. const dataStatus = this.getDataStatus(message)
  1169. let completeMessage = ''
  1170. switch (dataStatus) {
  1171. case 'complete':
  1172. // 完整数据,直接处理
  1173. // console.log('检测到完整数据,直接处理')
  1174. completeMessage = message
  1175. break
  1176. case 'first_part':
  1177. // 前半部分数据,缓存并等待后半部分
  1178. // console.log('检测到前半部分数据,开始缓存')
  1179. this.cacheFirstPartData(message)
  1180. return // 等待后半部分数据
  1181. case 'second_part':
  1182. // 后半部分数据,检查是否有缓存的前半部分
  1183. if (this.tcpDataCache.isWaitingSecondPart) {
  1184. // console.log('检测到后半部分数据,开始拼接')
  1185. completeMessage = this.concatenateDataParts(message)
  1186. } else {
  1187. // console.log('收到后半部分数据,但没有缓存的前半部分,跳过处理')
  1188. return
  1189. }
  1190. break
  1191. case 'invalid':
  1192. default:
  1193. // console.log('数据格式无效,跳过处理')
  1194. return
  1195. }
  1196. // 第二步:解析完整的JSON数据
  1197. let parsedMessage
  1198. try {
  1199. // console.log('开始解析完整JSON数据,长度:', completeMessage.length)
  1200. parsedMessage = JSON.parse(completeMessage)
  1201. // console.log('JSON解析成功,解析后类型:', typeof parsedMessage, parsedMessage)
  1202. } catch (parseError) {
  1203. // console.error('JSON解析失败:', parseError.message)
  1204. // 清空字符串片段缓存
  1205. this.clearStringFragmentCache()
  1206. return
  1207. }
  1208. // 第三步:检查是否是股票数据类型
  1209. if (!((parsedMessage.type === 'batch_data_chunk' || parsedMessage.type === 'batch_realtime_data') && parsedMessage.data)) {
  1210. // console.log('不是batch_data_chunk或batch_realtime_data类型的消息,跳过处理')
  1211. return
  1212. }
  1213. // console.log('开始处理股票数据')
  1214. // 第四步:验证数据完整性(对象级别的完整性检查)
  1215. // 注意:batch_data_chunk类型的数据不需要验证完整性,直接处理
  1216. if (parsedMessage.type === 'batch_data_chunk') {
  1217. // console.log('batch_data_chunk类型数据,跳过完整性验证,直接处理')
  1218. this.processCompleteStockData(parsedMessage)
  1219. } else {
  1220. const isDataComplete = this.validateDataIntegrity(parsedMessage)
  1221. if (isDataComplete) {
  1222. // 数据完整,直接处理
  1223. // console.log('对象级数据完整,直接处理')
  1224. this.processCompleteStockData(parsedMessage)
  1225. } else {
  1226. // 数据不完整,需要拼接(对象级别的拼接)
  1227. // console.log('对象级数据不完整,开始拼接处理')
  1228. // 将当前数据合并到缓存中
  1229. this.mergeDataToCache(parsedMessage)
  1230. // 检查缓存中的数据是否已经完整
  1231. if (this.isCacheDataComplete()) {
  1232. // console.log('缓存数据已完整,开始处理')
  1233. const completeData = this.getCompleteDataFromCache()
  1234. this.processCompleteStockData(completeData)
  1235. } else {
  1236. // console.log('缓存数据仍不完整,等待更多数据片段')
  1237. }
  1238. }
  1239. }
  1240. } catch (error) {
  1241. // console.error('解析TCP股票数据失败:', error.message)
  1242. // console.error('错误详情:', error)
  1243. // 发生错误时清空所有缓存
  1244. this.clearStringFragmentCache()
  1245. if (this.tcpDataCache.isCollecting) {
  1246. // console.log('发生错误,清空对象级数据缓存')
  1247. this.tcpDataCache.isCollecting = false
  1248. this.tcpDataCache.expectedCount = 0
  1249. this.tcpDataCache.collectedData = {}
  1250. this.tcpDataCache.timestamp = ''
  1251. this.tcpDataCache.type = ''
  1252. }
  1253. }
  1254. },
  1255. // 处理完整的股票数据
  1256. processCompleteStockData(completeData) {
  1257. // console.log("开始更新TCP股票数据存储")
  1258. // 更新TCP股票数据存储
  1259. this.tcpStockData = {
  1260. count: completeData.count || 0,
  1261. data: completeData.data || {},
  1262. stock_count: completeData.stock_count || 0,
  1263. timestamp: completeData.timestamp || '',
  1264. type: completeData.type || ''
  1265. }
  1266. // 获取所有股票的数据用于显示(最多3个)
  1267. const stockCodes = Object.keys(completeData.data)
  1268. const newStockInfoList = []
  1269. // 处理最多3个股票数据
  1270. for (let i = 0; i < Math.min(stockCodes.length, 3); i++) {
  1271. const stockCode = stockCodes[i]
  1272. // 检查数据结构
  1273. if (completeData.data[stockCode] && Array.isArray(completeData.data[stockCode]) && completeData.data[stockCode].length > 0) {
  1274. const stockData = completeData.data[stockCode][0] // 取第一条数据
  1275. if (stockData && stockData.current_price !== undefined && stockData.pre_close !== undefined) {
  1276. // 计算涨跌幅
  1277. const changeValue = stockData.current_price - stockData.pre_close
  1278. const changePercent = ((changeValue / stockData.pre_close) * 100).toFixed(2)
  1279. const changeSign = changeValue >= 0 ? '+' : ''
  1280. // 添加到股票信息列表
  1281. newStockInfoList.push({
  1282. stock_name: stockData.stock_name || '未知股票',
  1283. current_price: stockData.current_price ? stockData.current_price.toFixed(2) : '0.00',
  1284. change: `${changeSign}${changePercent}%`,
  1285. change_value: changeValue,
  1286. change_percent: parseFloat(changePercent)
  1287. })
  1288. }
  1289. }
  1290. }
  1291. // 更新当前显示的股票信息列表
  1292. if (newStockInfoList.length > 0) {
  1293. this.currentStockInfoList = newStockInfoList
  1294. // console.log('股票数据更新成功,共', newStockInfoList.length, '个股票:', this.currentStockInfoList)
  1295. }
  1296. },
  1297. // 移除TCP监听器
  1298. removeTcpListeners() {
  1299. if (this.connectionListener) {
  1300. tcpConnection.removeConnectionListener(this.connectionListener)
  1301. this.connectionListener = null
  1302. // console.log('已移除TCP连接状态监听器')
  1303. }
  1304. if (this.messageListener) {
  1305. tcpConnection.removeMessageListener(this.messageListener)
  1306. this.messageListener = null
  1307. // console.log('已移除TCP消息监听器')
  1308. }
  1309. }
  1310. }
  1311. }
  1312. </script>
  1313. <style scoped>
  1314. .main {
  1315. display: flex;
  1316. flex-direction: column;
  1317. height: 100vh;
  1318. background-color: #ffffff;
  1319. }
  1320. .header {
  1321. display: flex;
  1322. justify-content: space-between;
  1323. align-items: center;
  1324. padding: 10px 15px;
  1325. background-color: #ffffff;
  1326. }
  1327. .title {
  1328. font-size: 22px;
  1329. font-weight: bold;
  1330. text-align: center;
  1331. flex: 1;
  1332. }
  1333. .headphone-icon, .notification-icon {
  1334. width: 40px;
  1335. display: flex;
  1336. align-items: center;
  1337. justify-content: center;
  1338. }
  1339. .header-icon-image {
  1340. width: 24px;
  1341. height: 24px;
  1342. object-fit: contain;
  1343. }
  1344. .content-container {
  1345. flex: 1;
  1346. padding: 10px;
  1347. width: 100%;
  1348. box-sizing: border-box;
  1349. overflow-x: hidden;
  1350. }
  1351. .section {
  1352. margin-bottom: 15px;
  1353. /* background-color: #f5f5f5; */
  1354. background-color: #ffffff;
  1355. border-radius: 8px;
  1356. padding: 15px;
  1357. }
  1358. .section-header {
  1359. display: flex;
  1360. justify-content: space-between;
  1361. align-items: center;
  1362. margin-bottom: 15px;
  1363. padding-bottom: 10px;
  1364. }
  1365. .section-title {
  1366. font-size: 18px;
  1367. font-weight: bold;
  1368. color: #000000;
  1369. }
  1370. .section-title-text{
  1371. font-size: 14px;
  1372. }
  1373. .text-gap{
  1374. height: 10px;
  1375. }
  1376. .more-btn {
  1377. font-size: 12px;
  1378. font-weight: bold;
  1379. color: #ffffff;
  1380. background-color: #000000;
  1381. padding: 4px 8px;
  1382. border-radius: 4px;
  1383. }
  1384. /* 市场概览样式 */
  1385. .market-header {
  1386. display: flex;
  1387. justify-content: space-between;
  1388. align-items: center;
  1389. padding: 10px 15px;
  1390. background-color: #ffffff;
  1391. margin-bottom: 10px;
  1392. }
  1393. .market-content {
  1394. background-color: #f5f5f5;
  1395. border-radius: 8px;
  1396. padding: 15px;
  1397. margin: 0 15px;
  1398. }
  1399. .market-image {
  1400. margin-bottom: 15px;
  1401. display: flex;
  1402. justify-content: center;
  1403. }
  1404. .overview-image {
  1405. width: 100%;
  1406. border-radius: 8px;
  1407. }
  1408. .market-data {
  1409. display: flex;
  1410. flex-direction: column;
  1411. gap: 10px;
  1412. }
  1413. /* 间隔样式 */
  1414. .section-gap {
  1415. height: 20px;
  1416. }
  1417. .market-item {
  1418. display: flex;
  1419. justify-content: space-between;
  1420. padding: 8px 0;
  1421. border-bottom: 1px solid #f0f0f0;
  1422. }
  1423. .down {
  1424. color: #ff4d4f;
  1425. }
  1426. .up {
  1427. color: #52c41a;
  1428. }
  1429. /* DeepMate样式 */
  1430. .deepmate-container {
  1431. background-color: #ffe6e6;
  1432. border-radius: 10px;
  1433. padding: 15px;
  1434. margin: 0 15px;
  1435. }
  1436. .deepmate-header {
  1437. margin-bottom: 10px;
  1438. }
  1439. .title-container {
  1440. display: flex;
  1441. align-items: center;
  1442. justify-content: space-between;
  1443. width: 100%;
  1444. }
  1445. .title-left {
  1446. width: 50%;
  1447. }
  1448. .title-right {
  1449. width: 50%;
  1450. display: flex;
  1451. justify-content: flex-end;
  1452. }
  1453. .deepmate-title {
  1454. font-size: 18px;
  1455. font-weight: bold;
  1456. color: #ff4d4f;
  1457. }
  1458. .deepmate-icon {
  1459. width: 60px;
  1460. height: 60px;
  1461. margin-left: 0;
  1462. }
  1463. .deepmate-subtitle {
  1464. font-size: 12px;
  1465. color: #666;
  1466. margin-left: 5px;
  1467. }
  1468. .deepmate-hotspots {
  1469. margin: 10px 0;
  1470. }
  1471. .hotspot-item {
  1472. background-color: #f5f5f5;
  1473. padding: 8px 12px;
  1474. border-radius: 6px;
  1475. margin-bottom: 8px;
  1476. }
  1477. .hotspot-item text {
  1478. font-size: 14px;
  1479. color: #333;
  1480. }
  1481. .deepmate-action {
  1482. display: flex;
  1483. justify-content: center;
  1484. align-items: center;
  1485. background-color: #ffffff;
  1486. border-radius: 20px;
  1487. padding: 10px;
  1488. margin-top: 10px;
  1489. }
  1490. /* 欢迎部分样式 */
  1491. .welcome-section {
  1492. margin-bottom: 15px;
  1493. padding: 0;
  1494. }
  1495. .welcome-swiper {
  1496. width: 100%;
  1497. height: 110px;
  1498. border-radius: 0;
  1499. overflow: hidden;
  1500. }
  1501. .deepmate-section {
  1502. padding: 0;
  1503. }
  1504. .swiper-image {
  1505. width: 100%;
  1506. height: 100%;
  1507. border-radius: 8px;
  1508. object-fit: contain;
  1509. }
  1510. /* 深度探索样式 */
  1511. .deep-exploration {
  1512. margin-top: 15px;
  1513. padding: 0; /* 移除内边距,让子容器自己控制 */
  1514. }
  1515. .section-header-container {
  1516. margin-bottom: 10px;
  1517. }
  1518. .section-header {
  1519. display: flex;
  1520. justify-content: space-between;
  1521. align-items: center;
  1522. padding: 10px 15px;
  1523. background-color: #ffffff;
  1524. }
  1525. .header-left {
  1526. display: flex;
  1527. align-items: center;
  1528. }
  1529. .header-right {
  1530. display: flex;
  1531. align-items: center;
  1532. }
  1533. .section-title {
  1534. font-size: 16px;
  1535. font-weight: bold;
  1536. color: #333;
  1537. }
  1538. .more-btn {
  1539. font-size: 12px;
  1540. color: #ffffff;
  1541. }
  1542. .exploration-container {
  1543. border-radius: 8px;
  1544. overflow: hidden;
  1545. }
  1546. .exploration-content {
  1547. display: flex;
  1548. justify-content: space-between;
  1549. padding: 15px;
  1550. background-color: #f5f5f5;
  1551. border-radius: 8px;
  1552. }
  1553. .exploration-item {
  1554. display: flex;
  1555. flex-direction: column;
  1556. align-items: center;
  1557. width: 22%;
  1558. background-color: #ffffff;
  1559. border-radius: 8px;
  1560. padding: 10px 0;
  1561. }
  1562. .exploration-icon {
  1563. width: 50px;
  1564. height: 50px;
  1565. margin-bottom: 8px;
  1566. }
  1567. .exploration-text {
  1568. font-size: 12px;
  1569. color: #333;
  1570. }
  1571. .icon-text {
  1572. font-size: 12px;
  1573. }
  1574. /* 我的自选样式 */
  1575. .my-selection {
  1576. padding: 0; /* 移除内边距,让子容器自己控制 */
  1577. }
  1578. .stock-container {
  1579. border-radius: 8px;
  1580. overflow: hidden;
  1581. background-color: #f5f5f5;
  1582. padding: 15px;
  1583. box-sizing: border-box;
  1584. }
  1585. .stock-list {
  1586. display: flex;
  1587. flex-direction: row;
  1588. justify-content: center;
  1589. background-color: #f8f8f8;
  1590. border-radius: 8px;
  1591. padding: 15px;
  1592. gap: 10px; /* 添加卡片之间的间距 */
  1593. }
  1594. .stock-item {
  1595. display: flex;
  1596. flex-direction: column;
  1597. justify-content: space-between;
  1598. padding: 3px;
  1599. background-color: #ffffff;
  1600. border-radius: 8px;
  1601. width: 30%;
  1602. box-shadow: 0 2px 5px rgba(0,0,0,0.1);
  1603. will-change: transform;
  1604. transform: translateZ(0);
  1605. }
  1606. .stock-info {
  1607. display: flex;
  1608. flex-direction: column;
  1609. align-items: center;
  1610. margin-bottom: 5px;
  1611. }
  1612. .stock-chart {
  1613. display: flex;
  1614. align-items: center;
  1615. justify-content: center;
  1616. }
  1617. .name-container {
  1618. display: flex;
  1619. align-items: center;
  1620. gap: 5px;
  1621. }
  1622. .stock-name {
  1623. font-size: 12px;
  1624. font-weight: bold;
  1625. color: #333;
  1626. }
  1627. .stock-code-label {
  1628. font-size: 12px;
  1629. color: #666;
  1630. background-color: #f5f5f5;
  1631. padding: 0 4px;
  1632. border-radius: 3px;
  1633. }
  1634. .stock-price {
  1635. font-size: 12px;
  1636. color: #666;
  1637. }
  1638. .price-container {
  1639. display: flex;
  1640. align-items: center;
  1641. gap: 5px;
  1642. }
  1643. .stock-change {
  1644. font-size: 12px;
  1645. }
  1646. .stock-up {
  1647. color: #4cd964;
  1648. }
  1649. .stock-down {
  1650. color: #ff3b30;
  1651. }
  1652. .chart-image {
  1653. width: 100px;
  1654. height: 40px;
  1655. }
  1656. /* 市场看点样式 */
  1657. .highlights-title-container {
  1658. background-color: #ffffff;
  1659. margin-bottom: 10px;
  1660. }
  1661. .highlights-image-container {
  1662. background-color: #f5f5f5;
  1663. border-radius: 8px;
  1664. padding: 10px;
  1665. margin-bottom: 15px;
  1666. }
  1667. .highlights-image {
  1668. width: 100%;
  1669. height: 150px;
  1670. border-radius: 4px;
  1671. }
  1672. /* 机构动向简报样式 */
  1673. .institutional-reports {
  1674. margin-top: 15px;
  1675. background-color: #f8f8f8;
  1676. border-radius: 8px;
  1677. padding: 10px;
  1678. }
  1679. .section-title-container {
  1680. position: relative;
  1681. padding-left: 10px;
  1682. margin-bottom: 5px;
  1683. }
  1684. .section-title-container:before {
  1685. content: "";
  1686. position: absolute;
  1687. left: 0;
  1688. top: 0;
  1689. bottom: 0;
  1690. width: 4px;
  1691. background-color: #ff4d4f;
  1692. border-radius: 2px;
  1693. }
  1694. .report-item {
  1695. background-color: #ffffff;
  1696. border-radius: 8px;
  1697. padding: 10px;
  1698. margin-bottom: 8px;
  1699. }
  1700. .report-stock {
  1701. font-size: 14px;
  1702. font-weight: bold;
  1703. color: #e74c3c;
  1704. margin-bottom: 5px;
  1705. }
  1706. .report-status {
  1707. font-size: 12px;
  1708. color: #333;
  1709. }
  1710. .view-more {
  1711. text-align: center;
  1712. color: #1890ff;
  1713. font-size: 12px;
  1714. padding: 5px;
  1715. }
  1716. .disclaimer {
  1717. text-align: center;
  1718. padding: 8px 10px;
  1719. margin-top: 5px;
  1720. border-radius: 4px;
  1721. }
  1722. .disclaimer-text {
  1723. font-size: 11px;
  1724. color: grey;
  1725. line-height: 1.4;
  1726. }
  1727. /* 底部空间 */
  1728. .bottom-space {
  1729. height: 60px;
  1730. }
  1731. /* 底部导航 */
  1732. .static-footer {
  1733. position: fixed;
  1734. bottom: 0;
  1735. width: 100%;
  1736. }
  1737. /* TCP测试区域样式 */
  1738. .tcp-test-section {
  1739. border: 1px solid #e0e0e0;
  1740. background-color: #f9f9f9;
  1741. }
  1742. .tcp-status {
  1743. padding: 4px 12px;
  1744. border-radius: 12px;
  1745. font-size: 12px;
  1746. }
  1747. .tcp-status.connected {
  1748. background-color: #e8f5e8;
  1749. color: #4caf50;
  1750. border: 1px solid #4caf50;
  1751. }
  1752. .tcp-status.disconnected {
  1753. background-color: #ffeaea;
  1754. color: #f44336;
  1755. border: 1px solid #f44336;
  1756. }
  1757. .status-text {
  1758. font-size: 12px;
  1759. font-weight: bold;
  1760. }
  1761. .tcp-controls {
  1762. display: flex;
  1763. flex-wrap: wrap;
  1764. gap: 8px;
  1765. margin-bottom: 15px;
  1766. }
  1767. .tcp-btn {
  1768. flex: 1;
  1769. min-width: 80px;
  1770. height: 36px;
  1771. border-radius: 6px;
  1772. font-size: 12px;
  1773. border: none;
  1774. color: white;
  1775. font-weight: bold;
  1776. }
  1777. .connect-btn {
  1778. background-color: #4caf50;
  1779. }
  1780. .connect-btn:disabled {
  1781. background-color: #cccccc;
  1782. }
  1783. .disconnect-btn {
  1784. background-color: #f44336;
  1785. }
  1786. .disconnect-btn:disabled {
  1787. background-color: #cccccc;
  1788. }
  1789. .send-btn {
  1790. background-color: #2196f3;
  1791. }
  1792. .send-btn:disabled {
  1793. background-color: #cccccc;
  1794. }
  1795. .status-btn {
  1796. background-color: #ff9800;
  1797. }
  1798. .tcp-messages {
  1799. margin-top: 15px;
  1800. border-top: 1px solid #e0e0e0;
  1801. padding-top: 15px;
  1802. }
  1803. .messages-header {
  1804. display: flex;
  1805. justify-content: space-between;
  1806. align-items: center;
  1807. margin-bottom: 10px;
  1808. }
  1809. .messages-title {
  1810. font-size: 14px;
  1811. font-weight: bold;
  1812. color: #333;
  1813. }
  1814. .clear-btn {
  1815. padding: 4px 8px;
  1816. background-color: #f44336;
  1817. color: white;
  1818. border: none;
  1819. border-radius: 4px;
  1820. font-size: 10px;
  1821. }
  1822. .messages-list {
  1823. max-height: 200px;
  1824. border: 1px solid #e0e0e0;
  1825. border-radius: 6px;
  1826. padding: 8px;
  1827. background-color: white;
  1828. }
  1829. .message-item {
  1830. margin-bottom: 8px;
  1831. padding: 8px;
  1832. border-radius: 6px;
  1833. border-left: 3px solid #ccc;
  1834. }
  1835. .message-item.sent {
  1836. background-color: #e3f2fd;
  1837. border-left-color: #2196f3;
  1838. }
  1839. .message-item.received {
  1840. background-color: #f1f8e9;
  1841. border-left-color: #4caf50;
  1842. }
  1843. .message-info {
  1844. display: flex;
  1845. justify-content: space-between;
  1846. margin-bottom: 4px;
  1847. }
  1848. .message-direction {
  1849. font-size: 10px;
  1850. font-weight: bold;
  1851. color: #666;
  1852. }
  1853. .message-time {
  1854. font-size: 10px;
  1855. color: #999;
  1856. }
  1857. .message-content {
  1858. font-size: 12px;
  1859. color: #333;
  1860. word-break: break-all;
  1861. }
  1862. /* 我的自选TCP控制样式 */
  1863. .my-stocks-tcp-control {
  1864. display: flex;
  1865. align-items: center;
  1866. justify-content: space-between;
  1867. margin-top: 8px;
  1868. padding: 8px 12px;
  1869. background-color: #f8f9fa;
  1870. border-radius: 8px;
  1871. border: 1px solid #e9ecef;
  1872. }
  1873. .tcp-buttons {
  1874. display: flex;
  1875. gap: 6px;
  1876. }
  1877. .my-stocks-tcp-control .tcp-btn {
  1878. flex: none;
  1879. min-width: 50px;
  1880. height: 28px;
  1881. border-radius: 4px;
  1882. font-size: 11px;
  1883. border: none;
  1884. color: white;
  1885. font-weight: bold;
  1886. }
  1887. </style>