TriggerPrice.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. <template>
  2. <Teleport to="body">
  3. <div v-if="visible" class="modal-mask" @click="close">
  4. <div class="modal-content" @click.stop>
  5. <div class="handle-bar"></div>
  6. <div class="trigger fs18 fc333333 pf600">选择触发类型</div>
  7. <div class="options-list">
  8. <div
  9. v-for="item in options"
  10. :key="item.id"
  11. class="option-card"
  12. :class="{ 'active': selectedId === item.id }"
  13. @click="handleSelect(item)"
  14. >
  15. <div class="card-header">
  16. <span class="title">{{ item.label }}</span>
  17. <div v-if="selectedId === item.id" class="check-icon">
  18. <svg viewBox="0 0 24 24" width="16" height="16" stroke="currentColor"
  19. stroke-width="3" fill="none" stroke-linecap="round" stroke-linejoin="round"
  20. class="css-i6dzq1"><polyline points="20 6 9 17 4 12"></polyline></svg>
  21. </div>
  22. </div>
  23. <div class="description">
  24. {{ item.desc }}
  25. </div>
  26. </div>
  27. </div>
  28. </div>
  29. </div>
  30. </Teleport>
  31. </template>
  32. <script setup>
  33. import { defineProps, defineEmits } from 'vue';
  34. // 接收父组件传来的 modelValue (控制显示) 和 当前选中的ID
  35. const props = defineProps({
  36. visible: {
  37. type: Boolean,
  38. default: false
  39. },
  40. selectedId: {
  41. type: [String, Number],
  42. default: 1
  43. }
  44. });
  45. const emit = defineEmits(['update:visible', 'confirm']);
  46. // 静态数据源 (保持不变)
  47. const options = [
  48. {
  49. id: 1,
  50. label: '标记价格',
  51. desc: '标记价格为合约的预计公允价值'
  52. },
  53. {
  54. id: 2,
  55. label: '最新价格',
  56. desc: '最新价格为该合约的最新成交价格'
  57. }
  58. ];
  59. const close = () => {
  60. emit('update:visible', false);
  61. };
  62. const handleSelect = (item) => {
  63. // 1. 触发 confirm 事件,把整个对象带回去
  64. emit('confirm', item);
  65. // 2. 关闭弹窗
  66. close();
  67. };
  68. </script>
  69. <style lang="less" scoped>
  70. .modal-mask {
  71. position: fixed;
  72. top: 0; left: 0; width: 100%; height: 100%;
  73. background: rgba(0, 0, 0, 0.5);
  74. display: flex;
  75. align-items: flex-end; /* 底部对齐 */
  76. z-index: 1000; /* 极高的 Z-index */
  77. }
  78. .modal-content {
  79. width: 100%;
  80. background: white;
  81. border-radius: 16px 16px 0 0;
  82. padding: 20px;
  83. padding-bottom: 40px;
  84. max-height: 80vh;
  85. overflow-y: auto;
  86. animation: slideUp 0.3s ease-out;
  87. .trigger{margin-bottom: 15px}
  88. }
  89. .handle-bar {
  90. width: 40px;
  91. height: 4px;
  92. background: #E0E0E0;
  93. border-radius: 2px;
  94. margin: 0 auto 20px auto;
  95. }
  96. .option-card {
  97. border: 1px solid #E0E0E0;
  98. border-radius: 12px;
  99. padding: 16px;
  100. margin-bottom: 16px;
  101. cursor: pointer;
  102. transition: all 0.2s;
  103. position: relative;
  104. }
  105. .card-header {
  106. display: flex;
  107. justify-content: space-between;
  108. align-items: center;
  109. margin-bottom: 8px;
  110. }
  111. .title {
  112. font-size: 16px;
  113. font-weight: bold;
  114. color: #333;
  115. }
  116. .description {
  117. font-size: 13px;
  118. color: #666;
  119. line-height: 1.5;
  120. }
  121. /* 选中状态样式 */
  122. .option-card.active {
  123. border-color: #F53F3F; /* 红色边框 */
  124. background-color: #FFF9F9; /* 极淡的红色背景可选 */
  125. }
  126. .option-card.active .title {
  127. color: #D92828; /* 红色标题 */
  128. }
  129. .option-card.active .description {
  130. color: #D92828; /* 红色描述 */
  131. }
  132. .check-icon {
  133. width: 24px;
  134. height: 24px;
  135. background: #D92828;
  136. border-radius: 50%;
  137. display: flex;
  138. align-items: center;
  139. justify-content: center;
  140. color: white;
  141. }
  142. @keyframes slideUp {
  143. from { transform: translateY(100%); }
  144. to { transform: translateY(0); }
  145. }
  146. </style>