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.

585 lines
15 KiB

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
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. <template>
  2. <view class="main">
  3. <!-- 固定头部 -->
  4. <view class="header_fixed" :style="{ top: iSMT + 'px' }">
  5. <view class="header_content">
  6. <view class="header_back" @click="goBack">
  7. <image src="/static/marketSituation-image/back.png" mode=""></image>
  8. </view>
  9. <view class="header_input_wrapper">
  10. <image class="search_icon" src="/static/marketSituation-image/search.png" mode=""
  11. @click="onSearchClick"></image>
  12. <input class="header_input" type="text" placeholder="搜索"
  13. placeholder-style="color: #A6A6A6; font-size: 22rpx;" v-model="searchValue"
  14. @input="onSearchInput" @confirm="onSearchConfirm" />
  15. </view>
  16. <view class="header_icons">
  17. <view class="header_icon" @click="selected">
  18. <image src="/static/marketSituation-image/mySeclected.png" mode=""></image>
  19. </view>
  20. <view class="header_icon" @click="history">
  21. <image src="/static/marketSituation-image/history.png" mode=""></image>
  22. </view>
  23. </view>
  24. </view>
  25. <view class="warn">
  26. <image src="/static/marketSituation-image/warn.png" mode="aspectFit"></image>
  27. <view class="warn_text_container">
  28. <text :class="warnTextClass">{{ $t('marketSituation.warn') }}</text>
  29. </view>
  30. </view>
  31. </view>
  32. <!-- 内容区域 -->
  33. <scroll-view class="content" :style="{ top: contentTopPosition + 'px' }" scroll-y="true">
  34. <!-- 亚太-中华 -->
  35. <view class="market-section">
  36. <view class="market-header">
  37. <text class="market-title">亚太-中华</text>
  38. <view class="market-more" @click="viewMore('asia-china')">
  39. <text class="more-text">查看更多</text>
  40. <text class="more-arrow">></text>
  41. </view>
  42. </view>
  43. <view class="cards-grid-three">
  44. <view v-for="(item, index) in asiachinaIndexes" :key="index" class="card-item">
  45. <IndexCard :flagIcon="item.flagIcon" :stockName="item.stockName"
  46. :currentPrice="item.currentPrice" :changeAmount="item.changeAmount"
  47. :changePercent="item.changePercent" :isRising="item.isRising"
  48. @click="viewIndexDetail(item)" />
  49. </view>
  50. </view>
  51. </view>
  52. <!-- 亚太 -->
  53. <view class="market-section">
  54. <view class="market-header">
  55. <text class="market-title">亚太</text>
  56. <view class="market-more" @click="viewMore('asia')">
  57. <text class="more-text">查看更多</text>
  58. <text class="more-arrow">></text>
  59. </view>
  60. </view>
  61. <view class="cards-grid-three">
  62. <view v-for="(item, index) in asiaIndexes" :key="index" class="card-item">
  63. <IndexCard :flagIcon="item.flagIcon" :stockName="item.stockName"
  64. :currentPrice="item.currentPrice" :changeAmount="item.changeAmount"
  65. :changePercent="item.changePercent" :isRising="item.isRising"
  66. @click="viewIndexDetail(item)" />
  67. </view>
  68. </view>
  69. </view>
  70. <!-- 美洲 -->
  71. <view class="market-section">
  72. <view class="market-header">
  73. <text class="market-title">美洲</text>
  74. <view class="market-more" @click="viewMore('america')">
  75. <text class="more-text">查看更多</text>
  76. <text class="more-arrow">></text>
  77. </view>
  78. </view>
  79. <view class="cards-grid-three">
  80. <view v-for="(item, index) in americaIndexes" :key="index" class="card-item">
  81. <IndexCard :flagIcon="item.flagIcon" :stockName="item.stockName"
  82. :currentPrice="item.currentPrice" :changeAmount="item.changeAmount"
  83. :changePercent="item.changePercent" :isRising="item.isRising"
  84. @click="viewIndexDetail(item)" />
  85. </view>
  86. </view>
  87. </view>
  88. <!-- 底部安全区域 -->
  89. <view class="bottom-safe-area"></view>
  90. </scroll-view>
  91. </view>
  92. <!-- 底部导航栏 -->
  93. <footerBar class="static-footer" :type="'marketSituation'"></footerBar>
  94. </template>
  95. <script setup>
  96. import { ref, onMounted, computed, nextTick, watch } from 'vue'
  97. import footerBar from '../../components/footerBar.vue'
  98. import IndexCard from '../../components/IndexCard.vue'
  99. // 响应式数据
  100. const iSMT = ref(0) // 状态栏高度
  101. const contentHeight = ref(0)
  102. const headerHeight = ref(0) // 头部高度
  103. const searchValue = ref('') // 搜索值
  104. const isWarnTextOverflow = ref(false) // warn文字是否溢出
  105. // warn文字的class计算属性
  106. const warnTextClass = computed(() => {
  107. return isWarnTextOverflow.value ? 'warn_text scroll-active' : 'warn_text'
  108. })
  109. // 检测warn文字是否溢出
  110. const checkWarnTextOverflow = () => {
  111. nextTick(() => {
  112. setTimeout(() => {
  113. const query = uni.createSelectorQuery()
  114. // 同时查询容器和文字元素
  115. query.select('.warn_text_container').boundingClientRect()
  116. query.select('.warn_text').boundingClientRect()
  117. query.exec((res) => {
  118. const containerRect = res[0]
  119. const textRect = res[1]
  120. if (!containerRect || !textRect) {
  121. return
  122. }
  123. // 判断文字是否超出容器(留一些余量)
  124. const isOverflow = textRect.width > (containerRect.width - 10)
  125. isWarnTextOverflow.value = isOverflow
  126. })
  127. }, 500)
  128. })
  129. }
  130. // 亚太-中华指数数据
  131. const asiachinaIndexes = ref([
  132. {
  133. flagIcon: '/static/c1.png',
  134. stockName: '上证指数',
  135. stockCode:'noCode',
  136. currentPrice: '3933.96',
  137. changeAmount: '+24.32',
  138. changePercent: '+0.62%',
  139. isRising: true
  140. },
  141. {
  142. flagIcon: '/static/c2.png',
  143. stockName: '深证成指',
  144. stockCode:'noCode',
  145. currentPrice: '45757.90',
  146. changeAmount: '-123.45',
  147. changePercent: '-0.27%',
  148. isRising: false
  149. },
  150. {
  151. flagIcon: '/static/c3.png',
  152. stockName: '创业板指',
  153. stockCode:'noCode',
  154. currentPrice: '6606.08',
  155. changeAmount: '+89.76',
  156. changePercent: '+1.38%',
  157. isRising: true
  158. },
  159. {
  160. flagIcon: '/static/c4.png',
  161. stockName: 'HSI50',
  162. stockCode:'noCode',
  163. currentPrice: '22333.96',
  164. changeAmount: '+156.78',
  165. changePercent: '+0.71%',
  166. isRising: true
  167. },
  168. {
  169. flagIcon: '/static/c5.png',
  170. stockName: '沪深300',
  171. stockCode:'noCode',
  172. currentPrice: '45757.90',
  173. changeAmount: '-89.12',
  174. changePercent: '-0.19%',
  175. isRising: false
  176. },
  177. {
  178. flagIcon: '/static/c6.png',
  179. stockName: '上证50',
  180. stockCode:'noCode',
  181. currentPrice: '45757.90',
  182. changeAmount: '+234.56',
  183. changePercent: '+0.52%',
  184. isRising: true
  185. }
  186. ])
  187. // 亚太指数数据
  188. const asiaIndexes = ref([
  189. {
  190. flagIcon: '/static/c7.png',
  191. stockName: '日经225',
  192. stockCode:'noCode',
  193. currentPrice: '28456.78',
  194. changeAmount: '+234.56',
  195. changePercent: '+0.83%',
  196. isRising: true
  197. },
  198. {
  199. flagIcon: '/static/c8.png',
  200. stockName: '韩国KOSPI',
  201. stockCode:'noCode',
  202. currentPrice: '2567.89',
  203. changeAmount: '-12.34',
  204. changePercent: '-0.48%',
  205. isRising: false
  206. },
  207. {
  208. flagIcon: '/static/c9.png',
  209. stockName: '印度孟买',
  210. stockCode:'noCode',
  211. currentPrice: '65432.10',
  212. changeAmount: '+456.78',
  213. changePercent: '+0.70%',
  214. isRising: true
  215. }
  216. ])
  217. // 美洲指数数据
  218. const americaIndexes = ref([
  219. {
  220. flagIcon: '/static/c7.png',
  221. stockName: '道琼斯指数',
  222. stockCode:'noCode',
  223. currentPrice: '34567.89',
  224. changeAmount: '+123.45',
  225. changePercent: '+0.36%',
  226. isRising: true
  227. },
  228. {
  229. flagIcon: '/static/c8.png',
  230. stockName: '纳斯达克',
  231. stockCode:'noCode',
  232. currentPrice: '13456.78',
  233. changeAmount: '-67.89',
  234. changePercent: '-0.50%',
  235. isRising: false
  236. },
  237. {
  238. flagIcon: '/static/c9.png',
  239. stockName: '标普500',
  240. stockCode:'noCode',
  241. currentPrice: '4234.56',
  242. changeAmount: '+23.45',
  243. changePercent: '+0.56%',
  244. isRising: true
  245. }
  246. ])
  247. // 计算属性:内容区域顶部位置
  248. const contentTopPosition = computed(() => {
  249. const statusBarHeight = iSMT.value || 0
  250. const currentHeaderHeight = headerHeight.value > 0 ? headerHeight.value : 100
  251. return statusBarHeight + currentHeaderHeight
  252. })
  253. // 方法:返回上一页
  254. const goBack = () => {
  255. uni.navigateBack()
  256. }
  257. // 方法:搜索输入
  258. const onSearchInput = (e) => {
  259. searchValue.value = e.detail.value
  260. }
  261. // 方法:清除搜索
  262. const clearSearch = () => {
  263. searchValue.value = ''
  264. }
  265. // 方法:查看更多
  266. const viewMore = (market) => {
  267. console.log('查看更多:', market)
  268. uni.navigateTo({
  269. url: `/pages/marketSituation/marketDetail?market=${market}`
  270. })
  271. }
  272. // 方法:查看指数详情
  273. const viewIndexDetail = (item) => {
  274. console.log('查看指数详情:', item.stockName)
  275. // uni.showToast({
  276. // title: `查看 ${item.stockName} 详情`,
  277. // icon: 'none',
  278. // duration: 2000
  279. // })
  280. // 这里可以跳转到具体的指数详情页面
  281. uni.navigateTo({
  282. url: `/pages/marketSituation/marketCondition?stockInformation=${encodeURIComponent(JSON.stringify(item))}`
  283. })
  284. }
  285. // 生命周期:页面挂载
  286. onMounted(() => {
  287. // 获取系统信息
  288. const systemInfo = uni.getSystemInfoSync()
  289. iSMT.value = systemInfo.statusBarHeight || 0
  290. console.log('全球指数页面加载完成')
  291. // 动态计算header实际高度
  292. uni.createSelectorQuery().select('.header_fixed').boundingClientRect((rect) => {
  293. if (rect) {
  294. headerHeight.value = rect.height
  295. console.log('Header实际高度:', headerHeight.value, 'px')
  296. }
  297. }).exec()
  298. // 检测warn文字是否溢出
  299. checkWarnTextOverflow()
  300. })
  301. // 监听headerHeight变化,重新计算contentHeight
  302. watch(headerHeight, (newHeight) => {
  303. if (newHeight > 0) {
  304. const systemInfo = uni.getSystemInfoSync()
  305. const windowHeight = systemInfo.windowHeight
  306. const statusBarHeight = systemInfo.statusBarHeight || 0
  307. const footerHeight = 100
  308. contentHeight.value = windowHeight - statusBarHeight - newHeight - footerHeight
  309. console.log('重新计算contentHeight:', contentHeight.value)
  310. }
  311. })
  312. </script>
  313. <style lang="scss" scoped>
  314. .main {
  315. position: relative;
  316. height: 100vh;
  317. overflow: hidden;
  318. background-color: #f5f5f5;
  319. }
  320. /* 状态栏占位 */
  321. .top {
  322. position: fixed;
  323. top: 0;
  324. left: 0;
  325. right: 0;
  326. z-index: 1001;
  327. background-color: #ffffff;
  328. }
  329. /* 固定头部样式 */
  330. .header_fixed {
  331. position: fixed;
  332. left: 0;
  333. right: 0;
  334. z-index: 1000;
  335. background-color: #ffffff;
  336. padding: 20rpx 0 0 0;
  337. box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.1);
  338. }
  339. .header_content {
  340. display: flex;
  341. align-items: center;
  342. justify-content: space-between;
  343. height: 80rpx;
  344. padding: 0 20rpx;
  345. margin-bottom: 10rpx;
  346. }
  347. .header_back {
  348. margin-right: 20rpx;
  349. width: 25rpx;
  350. height: 30rpx;
  351. }
  352. .header_back image {
  353. width: 25rpx;
  354. height: 30rpx;
  355. }
  356. .header_input_wrapper {
  357. display: flex;
  358. align-items: center;
  359. width: 100%;
  360. margin: 0 20rpx 0 0;
  361. height: 70rpx;
  362. border-radius: 35rpx;
  363. background-color: #ffffff;
  364. border: 1rpx solid #e9ecef;
  365. padding: 0 80rpx 0 30rpx;
  366. font-size: 28rpx;
  367. color: #5c5c5c;
  368. box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.1);
  369. }
  370. .search_icon {
  371. width: 40rpx;
  372. height: 40rpx;
  373. opacity: 0.6;
  374. }
  375. .header_input {
  376. margin-left: 10rpx;
  377. }
  378. .header_icons {
  379. display: flex;
  380. align-items: center;
  381. gap: 15rpx;
  382. }
  383. .header_icon {
  384. width: 40rpx;
  385. height: 40rpx;
  386. display: flex;
  387. align-items: center;
  388. justify-content: center;
  389. }
  390. .header_icon image {
  391. width: 40rpx;
  392. height: 40rpx;
  393. }
  394. .warn {
  395. display: flex;
  396. align-items: center;
  397. justify-content: flex-start;
  398. gap: 10rpx;
  399. font-size: 28rpx;
  400. color: #666666;
  401. padding: 20rpx;
  402. max-width: 100%;
  403. overflow: hidden;
  404. position: relative;
  405. }
  406. .warn image {
  407. width: 40rpx;
  408. height: 40rpx;
  409. flex-shrink: 0;
  410. /* 防止图片被压缩 */
  411. position: relative;
  412. z-index: 2;
  413. /* 确保图片在最上层 */
  414. }
  415. .warn_text_container {
  416. flex: 1;
  417. overflow: hidden;
  418. position: relative;
  419. min-width: 0;
  420. /* 允许容器收缩 */
  421. }
  422. .warn_text {
  423. display: block;
  424. white-space: nowrap;
  425. will-change: transform;
  426. /* 优化动画性能 */
  427. }
  428. /* 文字滚动动画 */
  429. @keyframes scrollText {
  430. 0% {
  431. transform: translateX(0);
  432. }
  433. 20% {
  434. transform: translateX(0);
  435. }
  436. 80% {
  437. transform: translateX(-85%);
  438. }
  439. 100% {
  440. transform: translateX(-85%);
  441. }
  442. }
  443. /* 当文字超长时启用滚动动画 */
  444. .warn_text.scroll-active {
  445. animation: scrollText 12s linear infinite;
  446. animation-delay: 2s;
  447. /* 延迟2秒开始滚动,让用户先看到开头 */
  448. }
  449. /* 内容区域 */
  450. .content {
  451. position: fixed;
  452. left: 0;
  453. right: 0;
  454. bottom: 120rpx;
  455. background-color: #f5f5f5;
  456. padding: 0;
  457. }
  458. /* 市场分组 */
  459. .market-section {
  460. background-color: white;
  461. border-radius: 20rpx;
  462. }
  463. .market-header {
  464. margin: 20rpx 20rpx 0 20rpx;
  465. display: flex;
  466. align-items: center;
  467. justify-content: space-between;
  468. margin-bottom: 10rpx;
  469. padding-bottom: 10rpx;
  470. border-bottom: 2rpx solid #f0f0f0;
  471. }
  472. .market-title {
  473. font-size: 32rpx;
  474. font-weight: 600;
  475. color: #333;
  476. }
  477. .market-more {
  478. display: flex;
  479. align-items: center;
  480. gap: 8rpx;
  481. }
  482. .more-text {
  483. font-size: 24rpx;
  484. color: #666;
  485. }
  486. .more-arrow {
  487. font-size: 20rpx;
  488. color: #666;
  489. font-weight: bold;
  490. }
  491. /* 三列卡片网格 */
  492. .cards-grid-three {
  493. display: grid;
  494. grid-template-columns: repeat(3, 1fr);
  495. }
  496. .card-item {
  497. background-color: white;
  498. border-radius: 16rpx;
  499. overflow: hidden;
  500. transition: transform 0.2s ease, box-shadow 0.2s ease;
  501. }
  502. .card-item:active {
  503. transform: scale(0.98);
  504. box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.12);
  505. }
  506. /* 底部安全区域 */
  507. .bottom-safe-area {
  508. height: 40rpx;
  509. background-color: transparent;
  510. }
  511. /* 底部导航栏 */
  512. .static-footer {
  513. position: fixed;
  514. bottom: 0;
  515. left: 0;
  516. right: 0;
  517. z-index: 1000;
  518. }
  519. /* 响应式设计 */
  520. @media (max-width: 400rpx) {
  521. .cards-grid-three {
  522. grid-template-columns: repeat(2, 1fr);
  523. }
  524. }
  525. </style>