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.

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