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.

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