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.

384 lines
9.2 KiB

1 month ago
1 month ago
  1. <template>
  2. <view>
  3. <!-- 第一行白色背景标题和按钮 -->
  4. <view class="market-header">
  5. <text class="section-title">今日市场概览</text>
  6. <text class="more-btn" @click="showMarketSelector">{{ buttonText }}</text>
  7. </view>
  8. <!-- 第二行灰色圆角背景市场数据 -->
  9. <view class="market-content">
  10. <!-- 默认显示图片 -->
  11. <view class="selected-market" v-if="!showForexMarket">
  12. <image class="market-image" src="https://d31zlh4on95l9h.cloudfront.net/images/dee46373b5593d5f315d91675a38fb61.png" mode="widthFix"></image>
  13. </view>
  14. <!-- 外汇市场样式 -->
  15. <view class="selected-market" v-if="showForexMarket">
  16. <view class="forex-market">
  17. <!-- 上部分三个汇率容器 -->
  18. <view class="forex-rates">
  19. <view class="forex-rate-item up">
  20. <text class="forex-pair">美元/日元</text>
  21. <text class="forex-value">151.13</text>
  22. <text class="forex-change">+1.62%</text>
  23. </view>
  24. <view class="forex-rate-item down">
  25. <text class="forex-pair">美元/韩元</text>
  26. <text class="forex-value">1424.900</text>
  27. <text class="forex-change">-2.92%</text>
  28. </view>
  29. <view class="forex-rate-item up">
  30. <text class="forex-pair">美元/英镑</text>
  31. <text class="forex-value">0.730</text>
  32. <text class="forex-change">+2.92%</text>
  33. </view>
  34. </view>
  35. <!-- 中部分智能解读标题 -->
  36. <view class="forex-analysis-title">
  37. <text class="analysis-title">智能解读</text>
  38. </view>
  39. <!-- 下部分智能解读内容 -->
  40. <view class="forex-analysis-content">
  41. <view class="analysis-icon-container">
  42. <image class="analysis-brain-icon" src="https://d31zlh4on95l9h.cloudfront.net/images/8f35e54c52412467101370aa70d8fdb2.png" mode="aspectFit"></image>
  43. </view>
  44. <view class="analysis-items">
  45. <view class="analysis-item">
  46. <text class="analysis-dot orange"></text>
  47. <text class="analysis-text">今日市场情报: 偏乐观</text>
  48. </view>
  49. <view class="analysis-item">
  50. <text class="analysis-dot blue"></text>
  51. <text class="analysis-text">市场风险评级: 需警惕潜在风险</text>
  52. </view>
  53. <view class="analysis-item">
  54. <text class="analysis-dot green"></text>
  55. <text class="analysis-text">早盘解析: 今日高开, 芯片稀土公共</text>
  56. </view>
  57. </view>
  58. </view>
  59. </view>
  60. </view>
  61. </view>
  62. <!-- 市场选择对话框 -->
  63. <uni-popup ref="marketPopup" type="center" :mask-click="true" @change="popupChange">
  64. <view class="market-dialog">
  65. <view class="dialog-title">
  66. <text>选择市场</text>
  67. </view>
  68. <view class="market-list">
  69. <view class="market-option" v-for="(market, index) in marketOptions" :key="index" @click="selectMarket(market.id)">
  70. <view class="market-flag">
  71. <image :src="market.flag" mode="aspectFit" class="flag-image"></image>
  72. </view>
  73. <view class="market-name-container">
  74. <text class="market-option-name">{{ market.name }}</text>
  75. </view>
  76. <view class="market-checkbox">
  77. <radio :checked="selectedMarket === market.id" color="#4080ff" />
  78. </view>
  79. </view>
  80. </view>
  81. <view class="dialog-buttons">
  82. <button class="confirm-btn" @click="confirmMarketSelection">确认</button>
  83. </view>
  84. </view>
  85. </uni-popup>
  86. </view>
  87. </template>
  88. <script>
  89. export default {
  90. name: 'MarketOverview',
  91. data() {
  92. return {
  93. selectedMarket: 'forex',
  94. tempSelectedMarket: 'forex', // 临时选择,确认后才会应用
  95. previousMarket: null,
  96. buttonText: '切换市场',
  97. showSelector: false,
  98. showForexMarket: false, // 默认不显示外汇市场内容
  99. marketOptions: [
  100. { id: 'forex', name: '外汇市场', flag: '/static/c2.png', value: '+1.62%', trend: 'up' }
  101. ],
  102. marketData: {
  103. 'forex': {
  104. name: '外汇市场',
  105. value: '+1.62%',
  106. trend: 'up',
  107. indicators: [
  108. { name: '美元/日元', value: '151.13 +1.62%', trend: 'up' },
  109. { name: '美元/韩元', value: '1424.900 -2.92%', trend: 'down' },
  110. { name: '美元/英镑', value: '0.79 +2.92%', trend: 'up' }
  111. ]
  112. }
  113. }
  114. }
  115. },
  116. methods: {
  117. showMarketSelector() {
  118. // 切换显示外汇市场内容
  119. this.showForexMarket = !this.showForexMarket;
  120. // 更新按钮文本
  121. this.buttonText = this.showForexMarket ? '外汇市场' : '切换市场';
  122. },
  123. popupChange(e) {
  124. // 对话框关闭时,如果没有确认,则恢复原来的选择
  125. if (!e.show && this.tempSelectedMarket !== this.selectedMarket) {
  126. this.tempSelectedMarket = this.selectedMarket;
  127. }
  128. },
  129. selectMarket(marketId) {
  130. // 临时选择市场,不立即应用
  131. this.tempSelectedMarket = marketId;
  132. },
  133. confirmMarketSelection() {
  134. // 确认选择,应用市场选择并关闭对话框
  135. this.selectedMarket = this.tempSelectedMarket;
  136. this.showSelector = false;
  137. this.$refs.marketPopup.close();
  138. },
  139. getSelectedMarketName() {
  140. if (!this.selectedMarket) return '';
  141. return this.marketData[this.selectedMarket].name;
  142. },
  143. getSelectedMarketValue() {
  144. if (!this.selectedMarket) return '';
  145. return this.marketData[this.selectedMarket].value;
  146. },
  147. getSelectedMarketTrend() {
  148. if (!this.selectedMarket) return '';
  149. return this.marketData[this.selectedMarket].trend;
  150. },
  151. getSelectedMarketIndicators() {
  152. if (!this.selectedMarket) return [];
  153. return this.marketData[this.selectedMarket].indicators;
  154. }
  155. }
  156. }
  157. </script>
  158. <style>
  159. /* 市场概览样式 */
  160. .market-header {
  161. display: flex;
  162. justify-content: space-between;
  163. align-items: center;
  164. padding: 10px 15px;
  165. background-color: #ffffff;
  166. }
  167. .section-title {
  168. font-size: 16px;
  169. font-weight: bold;
  170. color: #333;
  171. }
  172. .more-btn {
  173. font-size: 14px;
  174. color: #4080ff;
  175. }
  176. .market-content {
  177. margin: 0 0 15px;
  178. background-color: #f5f7fa;
  179. border-radius: 8px;
  180. overflow: hidden;
  181. }
  182. /* 外汇市场样式 */
  183. .forex-market {
  184. padding: 15px;
  185. }
  186. .forex-rates {
  187. display: flex;
  188. justify-content: space-between;
  189. gap: 10px;
  190. margin-bottom: 15px;
  191. }
  192. .forex-rate-item {
  193. width: 30%;
  194. padding: 10px;
  195. border-radius: 6px;
  196. display: flex;
  197. flex-direction: column;
  198. align-items: center;
  199. }
  200. .forex-rate-item.up {
  201. background-color: rgba(82, 196, 26, 0.1);
  202. border: 1px solid #52c41a;
  203. }
  204. .forex-rate-item.down {
  205. background-color: rgba(245, 34, 45, 0.1);
  206. border: 1px solid #f5222d;
  207. }
  208. .forex-pair {
  209. font-size: 12px;
  210. color: #666;
  211. margin-bottom: 5px;
  212. }
  213. .forex-value {
  214. font-size: 16px;
  215. font-weight: bold;
  216. color: #333;
  217. margin-bottom: 5px;
  218. }
  219. .forex-change {
  220. font-size: 12px;
  221. color: #52c41a;
  222. }
  223. .forex-rate-item.down .forex-change {
  224. color: #f5222d;
  225. }
  226. .forex-analysis-title {
  227. display: flex;
  228. align-items: center;
  229. margin-bottom: 10px;
  230. border-left: 3px solid #f5222d;
  231. padding-left: 8px;
  232. }
  233. .analysis-title {
  234. font-size: 14px;
  235. font-weight: bold;
  236. color: #333;
  237. }
  238. .forex-analysis-content {
  239. display: flex;
  240. background-color: #fff;
  241. border-radius: 6px;
  242. padding: 12px;
  243. }
  244. .analysis-icon-container {
  245. width: 40px;
  246. height: 40px;
  247. margin-right: 10px;
  248. display: flex;
  249. align-items: center;
  250. justify-content: center;
  251. align-self: center;
  252. }
  253. .analysis-brain-icon {
  254. width: 100%;
  255. height: 100%;
  256. }
  257. .analysis-items {
  258. flex: 1;
  259. }
  260. .analysis-item {
  261. display: flex;
  262. align-items: center;
  263. margin-bottom: 8px;
  264. }
  265. .analysis-item:last-child {
  266. margin-bottom: 0;
  267. }
  268. .analysis-dot {
  269. width: 8px;
  270. height: 8px;
  271. border-radius: 50%;
  272. margin-right: 8px;
  273. }
  274. .analysis-dot.orange {
  275. background-color: #fa8c16;
  276. }
  277. .analysis-dot.blue {
  278. background-color: #1890ff;
  279. }
  280. .analysis-dot.green {
  281. background-color: #52c41a;
  282. }
  283. .analysis-text {
  284. font-size: 12px;
  285. color: #333;
  286. line-height: 1.4;
  287. }
  288. /* 市场选择对话框样式 */
  289. .market-dialog {
  290. width: 300px;
  291. background-color: #fff;
  292. border-radius: 10px;
  293. overflow: hidden;
  294. }
  295. .dialog-title {
  296. padding: 15px;
  297. text-align: center;
  298. border-bottom: 1px solid #eee;
  299. }
  300. .market-list {
  301. max-height: 300px;
  302. overflow-y: auto;
  303. }
  304. .market-option {
  305. display: flex;
  306. align-items: center;
  307. padding: 12px 15px;
  308. border-bottom: 1px solid #f5f5f5;
  309. }
  310. .market-flag {
  311. width: 24px;
  312. height: 24px;
  313. margin-right: 10px;
  314. }
  315. .flag-image {
  316. width: 100%;
  317. height: 100%;
  318. border-radius: 50%;
  319. }
  320. .market-name-container {
  321. flex: 1;
  322. }
  323. .market-option-name {
  324. font-size: 14px;
  325. color: #333;
  326. }
  327. .dialog-buttons {
  328. padding: 10px 15px 15px;
  329. display: flex;
  330. justify-content: center;
  331. }
  332. .confirm-btn {
  333. width: 80%;
  334. height: 40px;
  335. line-height: 40px;
  336. text-align: center;
  337. background-color: #4080ff;
  338. color: #fff;
  339. border-radius: 20px;
  340. font-size: 14px;
  341. }
  342. </style>