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.

1878 lines
51 KiB

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