sellOrder1.vue 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369
  1. <script setup>
  2. import {defineAsyncComponent, ref} from 'vue';
  3. //状态组件
  4. // const assetlessState = defineAsyncComponent(() => import("./assetlessState.vue"));
  5. import AccountPopup from './AccountPopup.vue'; // 引入组件
  6. const showAccountPopup = ref(false);
  7. //持有仓位组件
  8. const position = defineAsyncComponent(() => import("@/views/bitcoin/components/position.vue"));
  9. // 1. 模拟数据:为了还原图片,我们创建两个不同的订单对象
  10. const orders = ref([
  11. {
  12. id: 1,
  13. symbol: 'BTC/USDT',
  14. contractType: '永续',
  15. side: 'buy', // 'buy' | 'sell'
  16. leverage: '20X',
  17. orderType: '市价',
  18. amount: '0.215 USDT',
  19. price: '0.215 USDT',
  20. statusText: '止损',
  21. triggerPrice: '标记价格>20',
  22. time: '2025-11-04,16:30',
  23. stateText: '未触发',
  24. canCancel: true // 显示红色撤单按钮
  25. },
  26. {
  27. id: 2,
  28. symbol: 'BTC/USDT',
  29. contractType: '永续',
  30. side: 'sell',
  31. leverage: '20X',
  32. orderType: '市价',
  33. amount: '0.215 USDT',
  34. price: '0.215 USDT',
  35. statusText: '止盈',
  36. triggerPrice: '标记价格>20',
  37. time: '2025-11-04,16:30',
  38. stateText: '未触发',
  39. canCancel: false // 显示灰色已完成/不可操作按钮
  40. }
  41. ]);
  42. // 当前选中的 Tab,默认选中 index 1 (当前委托)
  43. const currentTab = ref(0);
  44. const tabs = ['持有仓位(2)', '当前委托(2)'];
  45. // 按钮操作
  46. const handleCancel = (id) => {
  47. console.log('撤单 ID:', id);
  48. // 这里写撤单逻辑
  49. };
  50. //平仓平空
  51. const showModal3 = ref(false);
  52. </script>
  53. <template>
  54. <div class="page-container">
  55. <div class="tabs-header">
  56. <div class="tabs-left">
  57. <div
  58. v-for="(tab, index) in tabs"
  59. :key="index"
  60. class="tab-item"
  61. :class="{ active: currentTab === index }"
  62. @click="currentTab = index"
  63. >
  64. {{ tab }}
  65. <div class="active-line" v-if="currentTab === index"></div>
  66. </div>
  67. </div>
  68. <div class="fc999999 fs14" @click="showAccountPopup = true">我的</div>
  69. <div class="tabs-right">
  70. <span class="history-icon" style="align-content: center; display: flex; gap: 5px; align-items: center">
  71. <img src="@/assets/icon/bitcoin/shizhong.svg" alt=""> 全部</span>
  72. </div>
  73. </div>
  74. <position v-if="currentTab==0"></position>
  75. <div >
  76. <!-- <assetlessState v-if="isassetlessState"></assetlessState>-->
  77. </div>
  78. <div v-show="currentTab==1" class="order-list">
  79. <div
  80. v-for="item in orders"
  81. :key="item.id"
  82. class="order-card"
  83. >
  84. <div class="card-top">
  85. <div class="coin-info">
  86. <div class="coin-icon">₿</div>
  87. <div class="coin-details">
  88. <div class="coin-name">
  89. {{ item.symbol }} <span class="contract-tag">{{ item.contractType }}</span>
  90. </div>
  91. <div class="tags-row">
  92. <span class="tag" :class="item.side === 'buy' ? 'tag-buy' : 'tag-sell'">
  93. {{ item.side === 'buy' ? '买入' : '卖出' }}
  94. </span>
  95. <span class="tag tag-gray">逐仓 {{ item.leverage }}</span>
  96. <span class="tag tag-gray">{{ item.orderType }}</span>
  97. </div>
  98. </div>
  99. </div>
  100. <button
  101. v-if="item.canCancel"
  102. class="btn-cancel"
  103. @click="handleCancel(item.id)"
  104. >
  105. 撤单
  106. </button>
  107. <div v-else class="badge-completed">
  108. 已完成
  109. </div>
  110. </div>
  111. <div class="divider"></div>
  112. <div class="card-body-grid">
  113. <div class="grid-item align-left">
  114. <div class="label">数量</div>
  115. <div class="value">{{ item.amount }}</div>
  116. </div>
  117. <div class="grid-item align-center">
  118. <div class="label">价格</div>
  119. <div class="value">{{ item.price }}</div>
  120. </div>
  121. <div class="grid-item align-right">
  122. <div class="label">状态</div>
  123. <div class="value bold-text">{{ item.statusText }}</div>
  124. </div>
  125. <div class="grid-item align-left">
  126. <div class="label">触发价格</div>
  127. <div class="value">{{ item.triggerPrice }}</div>
  128. </div>
  129. <div class="grid-item align-center">
  130. <div class="label">下单时间</div>
  131. <div class="value">{{ item.time }}</div>
  132. </div>
  133. <div class="grid-item align-right">
  134. <div class="label">状态</div>
  135. <div class="value bold-text">{{ item.stateText }}</div>
  136. </div>
  137. </div>
  138. </div>
  139. </div>
  140. <AccountPopup v-model:visible="showAccountPopup" />
  141. </div>
  142. </template>
  143. <style lang="less" scoped>
  144. /* 基础设置 */
  145. .page-container {
  146. width: 100%;
  147. height: auto;
  148. //background-color: #FAFAFA; /* 浅灰背景 */
  149. font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", Arial, sans-serif;
  150. }
  151. /* --- Tabs 样式 --- */
  152. .tabs-header {
  153. display: flex;
  154. justify-content: space-between;
  155. align-items: center;
  156. padding: 0 16px;
  157. background-color: #fff;
  158. height: 44px;
  159. position: sticky;
  160. top: 0;
  161. z-index: 10;
  162. }
  163. .tabs-left {
  164. display: flex;
  165. gap: 24px;
  166. }
  167. .tab-item {
  168. font-size: 15px;
  169. color: #999;
  170. position: relative;
  171. cursor: pointer;
  172. padding: 10px 0;
  173. }
  174. .tab-item.active {
  175. color: #333;
  176. font-weight: 600;
  177. font-size: 16px;
  178. }
  179. .active-line {
  180. position: absolute;
  181. bottom: 0;
  182. left: 50%;
  183. transform: translateX(-50%);
  184. width: 20px;
  185. height: 3px;
  186. background-color: #121212; /* 选中时的蓝色 */
  187. border-radius: 2px;
  188. }
  189. .tabs-right {
  190. color: #999;
  191. font-size: 14px;
  192. align-content: center;
  193. }
  194. /* --- 列表卡片样式 --- */
  195. .order-list {
  196. padding: 15px;
  197. }
  198. .order-card {
  199. background-color: #fff;
  200. border-radius: 8px;
  201. padding: 16px;
  202. margin-bottom: 12px;
  203. //box-shadow: 0 2px 8px rgba(0,0,0,0.02); /* 轻微阴影 */
  204. border: 1px solid #f0f0f0;
  205. }
  206. /* 卡片头部 */
  207. .card-top {
  208. display: flex;
  209. justify-content: space-between;
  210. align-items: flex-start;
  211. margin-bottom: 12px;
  212. }
  213. .coin-info {
  214. display: flex;
  215. gap: 10px;
  216. }
  217. .coin-icon {
  218. width: 36px;
  219. height: 36px;
  220. background-color: #F7931A; /* BTC 橙色 */
  221. color: white;
  222. border-radius: 50%;
  223. display: flex;
  224. align-items: center;
  225. justify-content: center;
  226. font-weight: bold;
  227. font-size: 20px;
  228. }
  229. .coin-name {
  230. font-size: 16px;
  231. font-weight: 600;
  232. color: #333;
  233. margin-bottom: 4px;
  234. }
  235. .contract-tag {
  236. font-size: 12px;
  237. font-weight: normal;
  238. color: #333;
  239. }
  240. .tags-row {
  241. display: flex;
  242. gap: 6px;
  243. }
  244. /* 标签体系 */
  245. .tag {
  246. font-size: 11px;
  247. padding: 1px 4px;
  248. border-radius: 2px;
  249. color: #fff;
  250. }
  251. .tag-buy {
  252. background-color: #2EBD85; /* 涨/买入绿 */
  253. }
  254. .tag-sell {
  255. background-color: #DF294A; /* 跌/卖出红 */
  256. }
  257. .tag-gray {
  258. background-color: #F0F0F0;
  259. color: #999;
  260. }
  261. /* 按钮体系 */
  262. .btn-cancel {
  263. background-color: #DF294A;
  264. color: white;
  265. border: none;
  266. padding: 6px 16px;
  267. border-radius: 4px;
  268. font-size: 13px;
  269. cursor: pointer;
  270. }
  271. .badge-completed {
  272. background-color: #aaa;
  273. color: white;
  274. padding: 6px 12px;
  275. border-radius: 4px;
  276. font-size: 13px;
  277. }
  278. .divider {
  279. height: 1px;
  280. background-color: #F5F5F5;
  281. margin-bottom: 12px;
  282. }
  283. /* --- 数据网格 Grid --- */
  284. .card-body-grid {
  285. display: grid;
  286. /* 定义三列,左侧和中间自动,右侧靠边 */
  287. grid-template-columns: 1fr 2fr 1fr;
  288. row-gap: 12px; /* 行间距 */
  289. }
  290. .grid-item {
  291. display: flex;
  292. flex-direction: column;
  293. gap: 4px;
  294. }
  295. /* 对齐方式 */
  296. .align-left {
  297. align-items: flex-start;
  298. }
  299. .align-center {
  300. align-items: center;
  301. .value:nth-child(2){
  302. margin-top: 2px;
  303. }
  304. }
  305. .align-right {
  306. align-items: flex-end;
  307. }
  308. .label {
  309. font-size: 12px;
  310. color: #999; /* 灰色标签 */
  311. }
  312. .value {
  313. font-size: 13px;
  314. color: #333;
  315. font-family: Helvetica, Arial, sans-serif; /* 数字字体优化 */
  316. font-weight: 500;
  317. }
  318. .bold-text {
  319. font-weight: 500;
  320. }
  321. </style>