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.

1041 lines
25 KiB

4 weeks ago
4 weeks ago
4 weeks ago
3 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
3 weeks ago
4 weeks ago
4 weeks ago
3 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
3 weeks ago
3 weeks ago
3 weeks ago
3 weeks ago
3 weeks ago
3 weeks ago
3 weeks ago
3 weeks ago
3 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
  1. <!-- @format -->
  2. <template>
  3. <view class="main">
  4. <!-- 可滚动内容区域 -->
  5. <scroll-view class="content_scroll" scroll-y="true" :style="{ top: contentTopPosition + 'px' }">
  6. <view class="content">
  7. <view class="map">
  8. <view class="INDU"
  9. >道琼斯<view :class="getSignClass(INDU.value)" @click="viewDetail(INDU)">{{ judgeSymbol(INDU.value) }}</view></view
  10. >
  11. <view class="NDX"
  12. >纳斯达克<view :class="getSignClass(NDX.value)" @click="viewDetail(NDX)">{{ judgeSymbol(NDX.value) }}</view></view
  13. >
  14. <view class="HSI"
  15. >恒生指数<view :class="getSignClass(HSI.value)" @click="viewDetail(HSI)">{{ judgeSymbol(HSI.value) }}</view></view
  16. >
  17. <view class="CN"
  18. >上证指数<view :class="getSignClass(CN.value)" @click="viewDetail(CN)">{{ judgeSymbol(CN.value) }}</view></view
  19. >
  20. <image src="/static/marketSituation-image/map.png" mode="widthFix"></image>
  21. </view>
  22. <view class="global_index">
  23. <view class="global_index_title">
  24. {{ $t("marketSituation.globalIndex") }}
  25. </view>
  26. <view class="global_index_more" @click="goToGlobalIndex">
  27. <text>{{ $t("marketSituation.globalIndexMore") }}</text>
  28. <image src="/static/marketSituation-image/more.png" mode="aspectFit"></image>
  29. </view>
  30. </view>
  31. <!-- 卡片网格 -->
  32. <view class="cards_grid">
  33. <view v-for="(card, index) in marketSituationStore.cardData" :key="index" class="card_item">
  34. <IndexCard
  35. :market="card.market"
  36. :stockName="card.stockName"
  37. :currentPrice="card.currentPrice"
  38. :changeAmount="card.changeAmount"
  39. :changePercent="card.changePercent"
  40. :isRising="card.isRising"
  41. @click="viewIndexDetail(card, index)"
  42. />
  43. </view>
  44. </view>
  45. <view class="warn">
  46. <image src="/static/marketSituation-image/warn.png" mode="aspectFit"></image>
  47. <view class="warn_text_container">
  48. <text :class="warnTextClass">{{ $t("marketSituation.warn") }}</text>
  49. </view>
  50. </view>
  51. <!-- 底部安全区域防止被导航栏遮挡 -->
  52. <view class="bottom_safe_area"></view>
  53. </view>
  54. </scroll-view>
  55. </view>
  56. </template>
  57. <script setup>
  58. import { ref, onMounted, onUnmounted, watch, nextTick, computed } from "vue";
  59. import util from "../../common/util.js";
  60. import IndexCard from "../../components/IndexCard.vue";
  61. import { useMarketSituationStore } from "../../stores/modules/marketSituation.js";
  62. const marketSituationStore = useMarketSituationStore();
  63. import { getGlobalIndexAPI } from "../../api/marketSituation/marketSituation.js";
  64. const iSMT = ref(0);
  65. const searchValue = ref("");
  66. const contentHeight = ref(0);
  67. const headerHeight = ref(0); // 动态计算的header高度
  68. const isWarnTextOverflow = ref(false); // warn文字是否溢出
  69. const INDU = ref({stockName: "道琼斯",stockCode: "INDU",value: ""});
  70. const NDX = ref({stockName: "纳斯达克",stockCode: "NDX",value: ""});
  71. const HSI = ref({stockName: "恒生指数",stockCode: "HSI",value: ""});
  72. const CN = ref({stockName: "上证指数",stockCode: "1A0001",value: ""});
  73. const pageIndex = ref(0);
  74. const scrollToView = ref("");
  75. const viewDetail = (item) => {
  76. uni.navigateTo({
  77. url: `/pages/marketSituation/marketCondition?stockInformation=${encodeURIComponent(JSON.stringify(item))}&from=map`,
  78. });
  79. };
  80. // 计算属性:精准计算content区域的top值
  81. const contentTopPosition = computed(() => {
  82. const statusBarHeight = iSMT.value || 0;
  83. const currentHeaderHeight = headerHeight.value > 0 ? headerHeight.value : 140;
  84. return statusBarHeight + currentHeaderHeight;
  85. });
  86. // warn文字的class计算属性
  87. const warnTextClass = computed(() => {
  88. return isWarnTextOverflow.value ? "warn_text scroll-active" : "warn_text";
  89. });
  90. const globalIndexArray = ref([]);
  91. // 搜索输入事件
  92. const onSearchInput = (e) => {
  93. searchValue.value = e.detail.value;
  94. };
  95. // 搜索确认事件
  96. const onSearchConfirm = (e) => {
  97. console.log("搜索内容:", e.detail.value);
  98. // 这里可以添加搜索逻辑
  99. performSearch(e.detail.value);
  100. };
  101. // 搜索图标点击事件
  102. const onSearchClick = () => {
  103. if (searchValue.value.trim()) {
  104. performSearch(searchValue.value);
  105. }
  106. };
  107. // 执行搜索
  108. const performSearch = (keyword) => {
  109. if (!keyword.trim()) {
  110. uni.showToast({
  111. title: "请输入搜索内容",
  112. icon: "none",
  113. });
  114. return;
  115. }
  116. uni.showToast({
  117. title: `搜索: ${keyword}`,
  118. icon: "none",
  119. });
  120. // 这里添加实际的搜索逻辑
  121. };
  122. // 检测warn文字是否溢出
  123. const checkWarnTextOverflow = () => {
  124. nextTick(() => {
  125. setTimeout(() => {
  126. const query = uni.createSelectorQuery();
  127. // 同时查询容器和文字元素
  128. query.select(".warn_text_container").boundingClientRect();
  129. query.select(".warn_text").boundingClientRect();
  130. query.exec((res) => {
  131. const containerRect = res[0];
  132. const textRect = res[1];
  133. if (!containerRect || !textRect) {
  134. return;
  135. }
  136. // 判断文字是否超出容器(留一些余量)
  137. const isOverflow = textRect.width > containerRect.width - 10;
  138. isWarnTextOverflow.value = isOverflow;
  139. });
  140. }, 500);
  141. });
  142. };
  143. // 方法:查看指数详情
  144. const viewIndexDetail = (item, index) => {
  145. console.log("查看指数详情:", item.stockName);
  146. // uni.showToast({
  147. // title: `查看 ${item.stockName} 详情`,
  148. // icon: 'none',
  149. // duration: 2000
  150. // })
  151. // 这里可以跳转到具体的指数详情页面
  152. uni.navigateTo({
  153. url: `/pages/marketSituation/marketCondition?stockInformation=${encodeURIComponent(JSON.stringify(item))}&index=${index}&from=marketOverview`,
  154. });
  155. };
  156. // 跳转到全球指数页面
  157. const goToGlobalIndex = () => {
  158. uni.navigateTo({
  159. url: "/pages/marketSituation/globalIndex",
  160. });
  161. };
  162. const getGlobalIndex = async () => {
  163. try {
  164. const result = await getGlobalIndexAPI();
  165. globalIndexArray.value = result.data;
  166. } catch (e) {
  167. console.log("获取全球指数失败", e);
  168. }
  169. };
  170. // TCP相关响应式变量
  171. import tcpConnection, { TCPConnection, TCP_CONFIG } from "@/api/tcpConnection.js";
  172. const tcpConnected = ref(false);
  173. const connectionListener = ref(null);
  174. const messageListener = ref(null);
  175. // 初始化TCP监听器
  176. const initTcpListeners = () => {
  177. // 创建连接状态监听器并保存引用
  178. connectionListener.value = (status, result) => {
  179. tcpConnected.value = status === "connected";
  180. console.log("TCP连接状态变化:", status, tcpConnected.value);
  181. // 如果连接,发送获取批量数据
  182. if (status === "connected") {
  183. sendTcpMessage("batch_real_time");
  184. }
  185. };
  186. // 创建消息监听器并保存引用
  187. messageListener.value = (type, message, parsedArray) => {
  188. const messageObj = {
  189. type: type,
  190. content: message,
  191. parsedArray: parsedArray,
  192. timestamp: new Date().toLocaleTimeString(),
  193. direction: "received",
  194. };
  195. // 解析股票数据
  196. parseStockData(message);
  197. };
  198. // 注册监听器
  199. tcpConnection.onConnectionChange(connectionListener.value);
  200. tcpConnection.onMessage(messageListener.value);
  201. };
  202. // 连接TCP服务器
  203. const connectTcp = () => {
  204. console.log("开始连接TCP服务器...");
  205. tcpConnection.connect();
  206. };
  207. // 断开TCP连接
  208. const disconnectTcp = () => {
  209. console.log("断开TCP连接...");
  210. tcpConnection.disconnect();
  211. tcpConnected.value = false;
  212. };
  213. // 发送TCP消息
  214. const sendTcpMessage = (command) => {
  215. let messageData;
  216. let messageDataArray = [];
  217. if (command == "batch_real_time") {
  218. messageDataArray = globalIndexArray.value.map((item) => item.stockCode);
  219. }
  220. console.log(messageDataArray);
  221. switch (command) {
  222. // 实时行情推送
  223. case "real_time":
  224. messageData = {
  225. command: "real_time",
  226. stock_code: "SH.000001",
  227. };
  228. break;
  229. // 初始化获取行情历史数据
  230. case "init_real_time":
  231. messageData = {
  232. command: "init_real_time",
  233. stock_code: "SH.000001",
  234. };
  235. break;
  236. case "stop_real_time":
  237. messageData = {
  238. command: "stop_real_time",
  239. };
  240. break;
  241. // 股票列表
  242. case "stock_list":
  243. messageData = {
  244. command: "stock_list",
  245. };
  246. break;
  247. case "batch_real_time":
  248. messageData = {
  249. command: "batch_real_time",
  250. stock_codes: messageDataArray,
  251. };
  252. break;
  253. case "help":
  254. messageData = {
  255. command: "help",
  256. };
  257. break;
  258. }
  259. if (!messageData) {
  260. return;
  261. } else {
  262. try {
  263. // 发送消息
  264. const success = tcpConnection.send(messageData);
  265. if (success) {
  266. console.log("home发送TCP消息:", messageData);
  267. }
  268. } catch (error) {
  269. console.error("发送TCP消息时出错:", error);
  270. }
  271. }
  272. };
  273. // 获取TCP连接状态
  274. const getTcpStatus = () => {
  275. const status = tcpConnection.getConnectionStatus();
  276. uni.showModal({
  277. title: "TCP连接状态",
  278. content: `当前状态: ${status ? "已连接" : "未连接"}`,
  279. showCancel: false,
  280. });
  281. };
  282. let isMorePacket = {
  283. init_batch_real_time: false,
  284. batch_real_time: false,
  285. };
  286. let receivedMessage;
  287. // 解析TCP股票数据
  288. const parseStockData = (message) => {
  289. try {
  290. console.log("进入parseStockData, message类型:", typeof message);
  291. let parsedMessage;
  292. // 如果isMorePacket是true,说明正在接受分包数据,无条件接收
  293. // 如果message是字符串且以{开头,说明是JSON字符串,需要解析
  294. // 如果不属于以上两种情况,说明是普通字符串,不预解析
  295. if (message.includes("欢迎连接到股票数据服务器")) {
  296. console.log("服务器命令列表,不予处理");
  297. return;
  298. }
  299. if ((typeof message === "string" && message.includes("batch_data_start")) || isMorePacket.init_batch_real_time) {
  300. if (typeof message === "string" && message.includes("batch_data_start")) {
  301. console.log("开始接受分包数据");
  302. receivedMessage = "";
  303. } else {
  304. console.log("接收分包数据过程中");
  305. }
  306. isMorePacket.init_batch_real_time = true;
  307. receivedMessage += message;
  308. // 如果当前消息包含},说明收到JSON字符串结尾,结束接收,开始解析
  309. if (receivedMessage.includes("batch_data_complete")) {
  310. console.log("接受分包数据结束");
  311. isMorePacket.init_batch_real_time = false;
  312. console.log("展示数据", receivedMessage);
  313. let startIndex = 0;
  314. let startCount = 0;
  315. let endIndex = receivedMessage.indexOf("batch_data_complete");
  316. for (let i = 0; i < receivedMessage.length; ++i) {
  317. if (receivedMessage[i] == "{") {
  318. startCount++;
  319. if (startCount == 2) {
  320. startIndex = i;
  321. break;
  322. }
  323. }
  324. }
  325. for (let i = receivedMessage.indexOf("batch_data_complete"); i >= 0; --i) {
  326. if (receivedMessage[i] == "}" || startIndex == endIndex) {
  327. endIndex = i;
  328. break;
  329. }
  330. }
  331. if (startIndex >= endIndex) {
  332. throw new Error("JSON字符串格式错误");
  333. }
  334. console.log("message", startIndex, endIndex, receivedMessage[endIndex], receivedMessage[startIndex]);
  335. parsedMessage = JSON.parse(receivedMessage.substring(startIndex, endIndex + 1));
  336. console.log("JSON解析成功,解析后类型:", typeof parsedMessage, parsedMessage);
  337. const stockDataArray = parsedMessage.data;
  338. marketSituationStore.cardData = globalIndexArray.value.map((item) => ({
  339. market: item.market,
  340. stockCode: item.stockCode,
  341. stockName: item.stockName,
  342. currentPrice: stockDataArray[item.stockCode][0].current_price.toFixed(2),
  343. changeAmount: (stockDataArray[item.stockCode][0].current_price - stockDataArray[item.stockCode][0].pre_close).toFixed(2),
  344. changePercent: ((100 * (stockDataArray[item.stockCode][0].current_price - stockDataArray[item.stockCode][0].pre_close)) / stockDataArray[item.stockCode][0].pre_close).toFixed(2) + "%",
  345. isRising: stockDataArray[item.stockCode][0].current_price - stockDataArray[item.stockCode][0].pre_close >= 0,
  346. }));
  347. }
  348. } else if ((typeof message === "string" && message.includes('{"count')) || isMorePacket.batch_real_time) {
  349. if (typeof message === "string" && message.includes('{"count')) {
  350. console.log("开始接受分包数据");
  351. receivedMessage = "";
  352. } else {
  353. console.log("接收分包数据过程中");
  354. }
  355. isMorePacket.batch_real_time = true;
  356. receivedMessage += message;
  357. // 如果当前消息包含},说明收到JSON字符串结尾,结束接收,开始解析
  358. if (receivedMessage.includes("batch_realtime_data")) {
  359. console.log("接受分包数据结束");
  360. isMorePacket.batch_real_time = false;
  361. console.log("展示数据", receivedMessage);
  362. let startIndex = 0;
  363. let endIndex = receivedMessage.length - 1;
  364. for (let i = 0; i < receivedMessage.length; ++i) {
  365. if (receivedMessage[i] == "{") {
  366. startIndex = i;
  367. break;
  368. }
  369. }
  370. for (let i = receivedMessage.length - 1; i >= 0; --i) {
  371. if (receivedMessage[i] == "}" || startIndex == endIndex) {
  372. endIndex = i;
  373. break;
  374. }
  375. }
  376. if (startIndex >= endIndex) {
  377. throw new Error("JSON字符串格式错误");
  378. }
  379. parsedMessage = JSON.parse(receivedMessage.substring(startIndex, endIndex + 1));
  380. console.log("JSON解析成功,解析后类型:", typeof parsedMessage, parsedMessage);
  381. const stockDataArray = parsedMessage.data;
  382. marketSituationStore.cardData = globalIndexArray.value.map((item) => ({
  383. market: item.market,
  384. stockCode: item.stockCode,
  385. stockName: item.stockName,
  386. currentPrice: stockDataArray[item.stockCode][0].current_price.toFixed(2),
  387. changeAmount: (stockDataArray[item.stockCode][0].current_price - stockDataArray[item.stockCode][0].pre_close).toFixed(2),
  388. changePercent: ((100 * (stockDataArray[item.stockCode][0].current_price - stockDataArray[item.stockCode][0].pre_close)) / stockDataArray[item.stockCode][0].pre_close).toFixed(2) + "%",
  389. isRising: stockDataArray[item.stockCode][0].current_price - stockDataArray[item.stockCode][0].pre_close >= 0,
  390. }));
  391. }
  392. } else {
  393. // 没有通过JSON解析判断,说明不是需要的数据
  394. console.log("不是需要的数据,不做处理");
  395. }
  396. } catch (error) {
  397. console.error("解析TCP股票数据失败:", error.message);
  398. console.error("错误详情:", error);
  399. }
  400. };
  401. // 移除TCP监听器
  402. const removeTcpListeners = () => {
  403. if (connectionListener.value) {
  404. tcpConnection.removeConnectionListener(connectionListener.value);
  405. connectionListener.value = null;
  406. console.log("已移除TCP连接状态监听器");
  407. }
  408. if (messageListener.value) {
  409. tcpConnection.removeMessageListener(messageListener.value);
  410. messageListener.value = null;
  411. console.log("已移除TCP消息监听器");
  412. }
  413. };
  414. const startTcp = () => {
  415. try {
  416. removeTcpListeners();
  417. disconnectTcp();
  418. initTcpListeners();
  419. connectTcp();
  420. } catch (error) {
  421. console.error("建立连接并设置监听出错:", error);
  422. }
  423. };
  424. onUnmounted(() => {
  425. sendTcpMessage("stop_real_time");
  426. removeTcpListeners();
  427. disconnectTcp();
  428. });
  429. onMounted(async () => {
  430. await getGlobalIndex();
  431. initTcpListeners();
  432. await nextTick();
  433. // 开始连接
  434. startTcp();
  435. // 状态栏高度
  436. iSMT.value = uni.getSystemInfoSync().statusBarHeight;
  437. // 确保DOM渲染完成后再查询高度
  438. nextTick(() => {
  439. // 动态计算header实际高度
  440. uni
  441. .createSelectorQuery()
  442. .select(".header_fixed")
  443. .boundingClientRect((rect) => {
  444. if (rect) {
  445. headerHeight.value = rect.height;
  446. console.log("Header实际高度:", headerHeight.value, "px");
  447. }
  448. })
  449. .exec();
  450. // 检测warn文字是否溢出
  451. checkWarnTextOverflow();
  452. });
  453. });
  454. // 监听headerHeight变化,重新计算contentHeight
  455. watch(headerHeight, (newHeight) => {
  456. if (newHeight > 0) {
  457. const systemInfo = uni.getSystemInfoSync();
  458. const windowHeight = systemInfo.windowHeight;
  459. const statusBarHeight = systemInfo.statusBarHeight || 0;
  460. const footerHeight = 100;
  461. contentHeight.value = windowHeight - statusBarHeight - newHeight - footerHeight;
  462. console.log("重新计算contentHeight:", contentHeight.value);
  463. }
  464. });
  465. </script>
  466. <style scoped>
  467. /* 状态栏占位 */
  468. .top {
  469. position: fixed;
  470. top: 0;
  471. left: 0;
  472. right: 0;
  473. z-index: 1001;
  474. background-color: #ffffff;
  475. }
  476. /* 固定头部样式 */
  477. .header_fixed {
  478. position: fixed;
  479. left: 0;
  480. right: 0;
  481. z-index: 1000;
  482. background-color: #ffffff;
  483. padding: 20rpx 0 0 0;
  484. box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.1);
  485. }
  486. /* 可滚动内容区域 */
  487. .content_scroll {
  488. position: fixed;
  489. left: 0;
  490. right: 0;
  491. bottom: 100rpx;
  492. /* 底部导航栏高度 */
  493. overflow-y: auto;
  494. }
  495. .header_content {
  496. display: flex;
  497. align-items: center;
  498. justify-content: space-between;
  499. height: 80rpx;
  500. padding: 0 20rpx;
  501. margin-bottom: 10rpx;
  502. }
  503. .header_input_wrapper {
  504. display: flex;
  505. align-items: center;
  506. width: 100%;
  507. margin: 0 20rpx 0 0;
  508. height: 70rpx;
  509. border-radius: 35rpx;
  510. background-color: #ffffff;
  511. border: 1rpx solid #e9ecef;
  512. padding: 0 80rpx 0 30rpx;
  513. font-size: 28rpx;
  514. color: #5c5c5c;
  515. box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.1);
  516. }
  517. .search_icon {
  518. width: 40rpx;
  519. height: 40rpx;
  520. opacity: 0.6;
  521. }
  522. .header_input {
  523. margin-left: 10rpx;
  524. }
  525. .header_icons {
  526. display: flex;
  527. align-items: center;
  528. gap: 15rpx;
  529. }
  530. .header_icon {
  531. width: 40rpx;
  532. height: 40rpx;
  533. display: flex;
  534. align-items: center;
  535. justify-content: center;
  536. }
  537. .header_icon image {
  538. width: 40rpx;
  539. height: 40rpx;
  540. }
  541. /* Tab 栏样式 */
  542. .channel_li {
  543. display: flex;
  544. align-items: center;
  545. height: 80rpx;
  546. background-color: #ffffff;
  547. border-bottom: 1rpx solid #f0f0f0;
  548. }
  549. .channel_wrap {
  550. width: calc(100% - 60rpx);
  551. height: 100%;
  552. overflow: hidden;
  553. flex-shrink: 0;
  554. }
  555. .channel_innerWrap {
  556. display: flex;
  557. align-items: center;
  558. height: 100%;
  559. padding: 0 20rpx;
  560. white-space: nowrap;
  561. }
  562. .channel_item {
  563. position: relative;
  564. display: flex;
  565. flex-direction: column;
  566. align-items: center;
  567. justify-content: center;
  568. height: 60rpx;
  569. padding: 0 20rpx;
  570. border-radius: 30rpx;
  571. transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  572. cursor: pointer;
  573. white-space: nowrap;
  574. flex-shrink: 0;
  575. }
  576. .channel_item:active {
  577. transform: scale(0.98);
  578. }
  579. .channel_item.active {
  580. color: #333;
  581. font-weight: bold;
  582. }
  583. .channel_text {
  584. font-size: 28rpx;
  585. font-weight: 500;
  586. color: #666666;
  587. transition: color 0.3s ease;
  588. white-space: nowrap;
  589. }
  590. .channel_item.active .channel_text {
  591. color: #333333;
  592. font-weight: 400;
  593. z-index: 2;
  594. }
  595. .active_indicator {
  596. position: absolute;
  597. left: 50%;
  598. top: 60%;
  599. transform: translateX(-45%);
  600. width: calc(100% - 20rpx);
  601. min-width: 40rpx;
  602. max-width: 120rpx;
  603. height: 8rpx;
  604. background-image: url("/static/marketSituation-image/bg.png");
  605. background-size: cover;
  606. background-position: center;
  607. background-repeat: no-repeat;
  608. animation: slideIn 0.1s ease;
  609. border-radius: 8rpx;
  610. z-index: 1;
  611. }
  612. @keyframes slideIn {
  613. from {
  614. width: 0;
  615. opacity: 0;
  616. }
  617. to {
  618. width: 40rpx;
  619. opacity: 1;
  620. }
  621. }
  622. .scroll_indicator {
  623. border-left: 1rpx solid #b6b6b6;
  624. display: flex;
  625. align-items: center;
  626. justify-content: center;
  627. width: 60rpx;
  628. height: 30rpx;
  629. background-color: #ffffff;
  630. flex-shrink: 0;
  631. }
  632. .scroll_indicator image {
  633. width: 20rpx;
  634. height: 20rpx;
  635. opacity: 0.5;
  636. }
  637. .content {
  638. margin-top: 20rpx;
  639. background-color: white;
  640. }
  641. .map {
  642. width: calc(100% - 60rpx);
  643. margin: 0 30rpx;
  644. display: flex;
  645. align-items: center;
  646. justify-content: center;
  647. background-color: #f3f3f3;
  648. border-radius: 30rpx;
  649. border: 1rpx solid #e0e0e0;
  650. padding: 30rpx 20rpx;
  651. box-sizing: border-box;
  652. /* 设置最小高度保护,但允许内容撑开 */
  653. min-height: 200rpx;
  654. }
  655. .NDX {
  656. position: absolute;
  657. top: 23vh;
  658. left: 17vw;
  659. transform: translate(-50%, -50%);
  660. font-size: 11rpx;
  661. color: #000000;
  662. padding: 5rpx 10rpx;
  663. border-radius: 10rpx;
  664. background-color: #ffffff;
  665. z-index: 10;
  666. }
  667. .INDU {
  668. position: absolute;
  669. top: 15vh;
  670. left: 35vw;
  671. transform: translate(-50%, -50%);
  672. font-size: 11rpx;
  673. color: #000000;
  674. padding: 5rpx 10rpx;
  675. border-radius: 10rpx;
  676. background-color: #ffffff;
  677. z-index: 10;
  678. }
  679. .HSI {
  680. position: absolute;
  681. top: 23vh;
  682. right: 4vw;
  683. transform: translate(-50%, -50%);
  684. font-size: 11rpx;
  685. color: #000000;
  686. padding: 5rpx 10rpx;
  687. border-radius: 10rpx;
  688. background-color: #ffffff;
  689. z-index: 10;
  690. }
  691. .CN {
  692. position: absolute;
  693. top: 16vh;
  694. right: 8vw;
  695. transform: translate(-50%, -50%);
  696. font-size: 11rpx;
  697. color: #000000;
  698. padding: 5rpx 10rpx;
  699. border-radius: 10rpx;
  700. background-color: #ffffff;
  701. z-index: 10;
  702. }
  703. .map image {
  704. width: 100%;
  705. height: auto;
  706. max-width: 100%;
  707. display: block;
  708. /* widthFix模式下,高度会自动按比例调整 */
  709. /* 设置最大高度避免图片过大 */
  710. max-height: 60vh;
  711. /* 添加平滑过渡效果 */
  712. transition: all 0.3s ease;
  713. max-height: 60vh;
  714. }
  715. /* 响应式优化 */
  716. @media screen and (max-width: 750rpx) {
  717. .map {
  718. margin: 0 20rpx;
  719. width: calc(100% - 40rpx);
  720. padding: 20rpx 15rpx;
  721. }
  722. }
  723. @media screen and (max-width: 480rpx) {
  724. .map {
  725. margin: 0 15rpx;
  726. width: calc(100% - 30rpx);
  727. padding: 15rpx 10rpx;
  728. }
  729. }
  730. .static-footer {
  731. position: fixed;
  732. bottom: 0;
  733. }
  734. /* 弹窗样式 */
  735. .modal_overlay {
  736. position: fixed;
  737. top: 0;
  738. left: 0;
  739. right: 0;
  740. bottom: 0;
  741. background-color: rgba(0, 0, 0, 0.5);
  742. display: flex;
  743. align-items: flex-end;
  744. z-index: 1000;
  745. }
  746. .modal_content {
  747. width: 100%;
  748. background-color: #fff;
  749. border-radius: 20rpx 20rpx 0 0;
  750. max-height: 80vh;
  751. overflow: hidden;
  752. }
  753. .modal_header {
  754. position: relative;
  755. display: flex;
  756. justify-content: center;
  757. align-items: center;
  758. padding: 30rpx 40rpx;
  759. border-bottom: 1rpx solid #f0f0f0;
  760. }
  761. .modal_title {
  762. font-size: 32rpx;
  763. font-weight: bold;
  764. color: #333333;
  765. text-align: center;
  766. }
  767. .modal_close {
  768. position: absolute;
  769. right: 40rpx;
  770. top: 50%;
  771. transform: translateY(-50%);
  772. width: 60rpx;
  773. height: 60rpx;
  774. display: flex;
  775. align-items: center;
  776. justify-content: center;
  777. font-size: 40rpx;
  778. color: #999;
  779. }
  780. .modal_body {
  781. padding: 40rpx;
  782. }
  783. .country_grid {
  784. display: grid;
  785. grid-template-columns: 1fr 1fr;
  786. gap: 20rpx;
  787. }
  788. .country_item {
  789. padding: 24rpx 30rpx;
  790. border-radius: 12rpx;
  791. background-color: #f8f8f8;
  792. display: flex;
  793. align-items: center;
  794. justify-content: center;
  795. transition: all 0.3s ease;
  796. }
  797. .country_item.selected {
  798. background-color: #ff4444;
  799. color: #fff;
  800. }
  801. .country_text {
  802. font-size: 28rpx;
  803. color: #333;
  804. }
  805. .country_item.selected .country_text {
  806. color: #fff;
  807. }
  808. .global_index {
  809. margin: 30rpx 20rpx 0 20rpx;
  810. display: flex;
  811. justify-content: space-between;
  812. }
  813. .global_index_title {
  814. margin-left: 20rpx;
  815. font-size: 40rpx;
  816. font-weight: 100;
  817. color: #333333;
  818. align-items: center;
  819. }
  820. .global_index_more {
  821. display: flex;
  822. gap: 10rpx;
  823. font-size: 28rpx;
  824. color: #333333;
  825. align-items: center;
  826. }
  827. .global_index_more image {
  828. width: 40rpx;
  829. height: 40rpx;
  830. align-items: center;
  831. }
  832. /* 卡片网格样式 */
  833. .cards_grid {
  834. display: grid;
  835. grid-template-columns: repeat(3, 1fr);
  836. margin: 0;
  837. box-sizing: border-box;
  838. width: 100%;
  839. padding: 30rpx 0;
  840. }
  841. .card_item {
  842. width: 100%;
  843. box-sizing: border-box;
  844. min-width: 0;
  845. /* 防止内容溢出 */
  846. }
  847. /* 响应式布局 - 小屏幕时改为两列 */
  848. @media (max-width: 600rpx) {
  849. .cards_grid {
  850. grid-template-columns: repeat(2, 1fr);
  851. padding: 30rpx 0;
  852. }
  853. }
  854. /* 超小屏幕时改为单列 */
  855. @media (max-width: 400rpx) {
  856. .cards_grid {
  857. grid-template-columns: 1fr;
  858. padding: 30rpx 0;
  859. }
  860. }
  861. .warn {
  862. display: flex;
  863. align-items: center;
  864. justify-content: flex-start;
  865. gap: 10rpx;
  866. font-size: 28rpx;
  867. color: #666666;
  868. padding: 20rpx;
  869. max-width: 100%;
  870. overflow: hidden;
  871. position: relative;
  872. }
  873. .warn image {
  874. width: 40rpx;
  875. height: 40rpx;
  876. flex-shrink: 0;
  877. /* 防止图片被压缩 */
  878. position: relative;
  879. z-index: 2;
  880. /* 确保图片在最上层 */
  881. }
  882. .warn_text_container {
  883. flex: 1;
  884. overflow: hidden;
  885. position: relative;
  886. min-width: 0;
  887. /* 允许容器收缩 */
  888. }
  889. .warn_text {
  890. display: block;
  891. white-space: nowrap;
  892. will-change: transform;
  893. /* 优化动画性能 */
  894. }
  895. /* 文字滚动动画 */
  896. @keyframes scrollText {
  897. 0% {
  898. transform: translateX(0);
  899. }
  900. 20% {
  901. transform: translateX(0);
  902. }
  903. 80% {
  904. transform: translateX(-85%);
  905. }
  906. 100% {
  907. transform: translateX(-85%);
  908. }
  909. }
  910. /* 当文字超长时启用滚动动画 */
  911. .warn_text.scroll-active {
  912. animation: scrollText 12s linear infinite;
  913. animation-delay: 2s;
  914. /* 延迟2秒开始滚动,让用户先看到开头 */
  915. }
  916. /* 底部安全区域 */
  917. .bottom_safe_area {
  918. height: 40rpx;
  919. background-color: transparent;
  920. }
  921. /* 主容器样式调整 */
  922. .main {
  923. position: relative;
  924. height: 100vh;
  925. overflow: hidden;
  926. background-color: white;
  927. }
  928. </style>