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.

300 lines
5.8 KiB

4 weeks ago
  1. <template>
  2. <view class="content">
  3. <view class="section" v-if="type === 'forex'">
  4. <view class="section_title">
  5. <text class="title_icon">💱</text>
  6. <text>外汇市场</text>
  7. </view>
  8. <view class="forex_grid">
  9. <view v-for="(item, index) in forexData" :key="index" class="forex_item">
  10. <view class="forex_pair">
  11. <text class="base_currency">{{ item.base }}</text>
  12. <text class="separator">/</text>
  13. <text class="quote_currency">{{ item.quote }}</text>
  14. </view>
  15. <view class="forex_price">
  16. <text class="price">{{ item.price }}</text>
  17. <text :class="['change', item.isRising ? 'rising' : 'falling']">
  18. {{ item.change }}
  19. </text>
  20. </view>
  21. </view>
  22. </view>
  23. </view>
  24. <view class="section" v-if="type === 'metals'">
  25. <view class="section_title">
  26. <text class="title_icon">🥇</text>
  27. <text>贵金属</text>
  28. </view>
  29. <view class="metals_grid">
  30. <view v-for="(item, index) in metalsData" :key="index" class="metal_item">
  31. <view class="metal_info">
  32. <text class="metal_icon">{{ item.icon }}</text>
  33. <text class="metal_name">{{ item.name }}</text>
  34. </view>
  35. <view class="metal_price">
  36. <text class="price">{{ item.price }}</text>
  37. <text class="unit">{{ item.unit }}</text>
  38. <text :class="['change', item.isRising ? 'rising' : 'falling']">
  39. {{ item.change }}
  40. </text>
  41. </view>
  42. </view>
  43. </view>
  44. </view>
  45. <!-- 市场动态 -->
  46. <view class="market_news">
  47. <view class="section_title">
  48. <text class="title_icon">📰</text>
  49. <text>市场动态</text>
  50. </view>
  51. <view class="news_list">
  52. <view v-for="(news, index) in newsData" :key="index" class="news_item">
  53. <view class="news_content">
  54. <text class="news_title">{{ news.title }}</text>
  55. <text class="news_time">{{ news.time }}</text>
  56. </view>
  57. <view class="news_impact" :class="news.impact">
  58. <text>{{ news.impactText }}</text>
  59. </view>
  60. </view>
  61. </view>
  62. </view>
  63. <!-- 底部安全区域 -->
  64. <view class="bottom_safe_area"></view>
  65. </view>
  66. </template>
  67. <script setup>
  68. import { ref, computed } from 'vue'
  69. // Props
  70. const props = defineProps({
  71. countryId: {
  72. type: Number,
  73. required: true
  74. }
  75. })
  76. // 判断类型
  77. const type = computed(() => {
  78. return props.countryId === 11 ? 'forex' : 'metals'
  79. })
  80. // 外汇数据
  81. const forexData = ref([
  82. { base: 'USD', quote: 'CNY', price: '7.2456', change: '+0.0123', isRising: true },
  83. { base: 'EUR', quote: 'USD', price: '1.0876', change: '-0.0034', isRising: false },
  84. { base: 'GBP', quote: 'USD', price: '1.2654', change: '+0.0087', isRising: true },
  85. { base: 'USD', quote: 'JPY', price: '149.87', change: '+0.45', isRising: true },
  86. { base: 'AUD', quote: 'USD', price: '0.6543', change: '-0.0021', isRising: false },
  87. { base: 'USD', quote: 'SGD', price: '1.3456', change: '+0.0012', isRising: true }
  88. ])
  89. // 贵金属数据
  90. const metalsData = ref([
  91. { icon: '🥇', name: '黄金', price: '2,034.56', unit: 'USD/盎司', change: '+12.34', isRising: true },
  92. { icon: '🥈', name: '白银', price: '24.87', unit: 'USD/盎司', change: '-0.23', isRising: false },
  93. { icon: '⚪', name: '铂金', price: '987.65', unit: 'USD/盎司', change: '+5.67', isRising: true },
  94. { icon: '⚫', name: '钯金', price: '1,234.56', unit: 'USD/盎司', change: '-8.90', isRising: false }
  95. ])
  96. // 新闻数据
  97. const newsData = ref([
  98. {
  99. title: '美联储暗示可能暂停加息',
  100. time: '2小时前',
  101. impact: 'high',
  102. impactText: '高影响'
  103. },
  104. {
  105. title: '欧洲央行维持利率不变',
  106. time: '4小时前',
  107. impact: 'medium',
  108. impactText: '中影响'
  109. },
  110. {
  111. title: '黄金价格创新高',
  112. time: '6小时前',
  113. impact: 'medium',
  114. impactText: '中影响'
  115. },
  116. {
  117. title: '美元指数小幅下跌',
  118. time: '8小时前',
  119. impact: 'low',
  120. impactText: '低影响'
  121. }
  122. ])
  123. </script>
  124. <style scoped>
  125. .content {
  126. padding: 20rpx;
  127. }
  128. .section {
  129. margin-bottom: 40rpx;
  130. }
  131. .section_title {
  132. display: flex;
  133. align-items: center;
  134. font-size: 28rpx;
  135. font-weight: bold;
  136. color: #333;
  137. margin-bottom: 20rpx;
  138. }
  139. .title_icon {
  140. font-size: 32rpx;
  141. margin-right: 12rpx;
  142. }
  143. .forex_grid, .metals_grid {
  144. background: #fff;
  145. border-radius: 12rpx;
  146. overflow: hidden;
  147. }
  148. .forex_item, .metal_item {
  149. display: flex;
  150. justify-content: space-between;
  151. align-items: center;
  152. padding: 24rpx 20rpx;
  153. border-bottom: 1rpx solid #f0f0f0;
  154. }
  155. .forex_item:last-child, .metal_item:last-child {
  156. border-bottom: none;
  157. }
  158. .forex_pair {
  159. display: flex;
  160. align-items: center;
  161. }
  162. .base_currency {
  163. font-size: 28rpx;
  164. font-weight: bold;
  165. color: #333;
  166. }
  167. .separator {
  168. font-size: 24rpx;
  169. color: #999;
  170. margin: 0 8rpx;
  171. }
  172. .quote_currency {
  173. font-size: 28rpx;
  174. color: #666;
  175. }
  176. .forex_price, .metal_price {
  177. text-align: right;
  178. }
  179. .price {
  180. font-size: 28rpx;
  181. color: #333;
  182. display: block;
  183. margin-bottom: 8rpx;
  184. }
  185. .unit {
  186. font-size: 20rpx;
  187. color: #999;
  188. margin-left: 8rpx;
  189. }
  190. .change {
  191. font-size: 24rpx;
  192. }
  193. .change.rising {
  194. color: #e74c3c;
  195. }
  196. .change.falling {
  197. color: #27ae60;
  198. }
  199. .metal_info {
  200. display: flex;
  201. align-items: center;
  202. }
  203. .metal_icon {
  204. font-size: 32rpx;
  205. margin-right: 16rpx;
  206. }
  207. .metal_name {
  208. font-size: 28rpx;
  209. color: #333;
  210. }
  211. .market_news {
  212. margin-bottom: 30rpx;
  213. }
  214. .news_list {
  215. background: #fff;
  216. border-radius: 12rpx;
  217. overflow: hidden;
  218. }
  219. .news_item {
  220. display: flex;
  221. justify-content: space-between;
  222. align-items: center;
  223. padding: 24rpx 20rpx;
  224. border-bottom: 1rpx solid #f0f0f0;
  225. }
  226. .news_item:last-child {
  227. border-bottom: none;
  228. }
  229. .news_content {
  230. flex: 1;
  231. }
  232. .news_title {
  233. font-size: 28rpx;
  234. color: #333;
  235. display: block;
  236. margin-bottom: 8rpx;
  237. }
  238. .news_time {
  239. font-size: 24rpx;
  240. color: #999;
  241. }
  242. .news_impact {
  243. padding: 6rpx 12rpx;
  244. border-radius: 16rpx;
  245. font-size: 20rpx;
  246. color: #fff;
  247. }
  248. .news_impact.high {
  249. background: #e74c3c;
  250. }
  251. .news_impact.medium {
  252. background: #f39c12;
  253. }
  254. .news_impact.low {
  255. background: #95a5a6;
  256. }
  257. .bottom_safe_area {
  258. height: 120rpx;
  259. }
  260. </style>