freight-space.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318
  1. <template>
  2. <view class="">
  3. <template v-if="leverTransaction && leverTransaction.length > 0">
  4. <view class="lable-title">
  5. <text class="lable-title-text">仓位信息</text>
  6. <text class="lable-title-btn" @click.stop="setCloseLeverAll()">全部平仓</text>
  7. </view>
  8. <template v-for="item in leverTransaction">
  9. <view :rise-fall="stocksColor">
  10. <view class="content-top">
  11. <view class="top-left">
  12. <view class="top-left-title">
  13. <text>{{ item.symbol }}</text>
  14. <text>{{ item.type_name }}</text>
  15. <text class="icon-size iconfont">&#xe8b0;</text>
  16. <text class="icon-size">分享</text>
  17. </view>
  18. <view class="top-left-b">
  19. <text>{{ item.multiple }}倍杠杆</text>
  20. <text class="top-left-b-tag">逐仓做多</text>
  21. </view>
  22. </view>
  23. <view class="top-right">
  24. <text>{{ item.profits }}</text>
  25. <text class="top-right-float"><text>浮动盈亏</text>{{ item.fact_profits }}%</text>
  26. </view>
  27. </view>
  28. <view class="content-info">
  29. <view class="info-item">
  30. <text class="info-item-lable">保证金(USDT)</text>
  31. <text class="info-item-val">{{ item.caution_money }}</text>
  32. </view>
  33. <view class="info-item">
  34. <text class="info-item-lable">开仓价格(USDT)</text>
  35. <text class="info-item-val">{{ item.price }}</text>
  36. </view>
  37. <view class="info-item">
  38. <text class="info-item-lable">标记价格(USDT)</text>
  39. <text class="info-item-val">{{ item.origin_price }}</text>
  40. </view>
  41. <view class="info-item">
  42. <text class="info-item-lable">持仓数量(张)</text>
  43. <text class="info-item-val">{{ item.number }}</text>
  44. </view>
  45. <view class="info-item">
  46. <text class="info-item-lable">风险率(%)</text>
  47. <text class="info-item-val"></text>
  48. <!-- {{ item.caution_money }} -->
  49. </view>
  50. <view class="info-item">
  51. <text class="info-item-lable">预计强平价(USDT)</text>
  52. <text class="info-item-val"></text>
  53. <!-- {{ item.caution_money }} -->
  54. </view>
  55. <view class="info-item">
  56. <text class="info-item-lable">预计止损(USDT)</text>
  57. <text class="info-item-val"
  58. @click.stop="setRestrict(item)">{{ item.stop_loss_price || '--' }} <text
  59. class="iconfont">&#xe610;</text></text>
  60. </view>
  61. <view class="info-item">
  62. <text class="info-item-lable">预计止盈(USDT)</text>
  63. <text class="info-item-val"
  64. @click.stop="setRestrict(item)">{{ item.target_profit_price || '--' }} <text
  65. class="iconfont">&#xe610;</text> </text>
  66. </view>
  67. <view class="info-item">
  68. <text class="info-item-lable">预计创建时间(USDT)</text>
  69. <text class="info-item-val">{{ $getData_(item.create_time , false) }}</text>
  70. </view>
  71. </view>
  72. <view class="content-btns">
  73. <view class="content-btn-item" @click.stop="setCloseLever(item)">
  74. 平仓
  75. </view>
  76. <view class="content-btn-item">
  77. 反向开仓
  78. </view>
  79. <view class="content-btn-item">
  80. 加仓
  81. </view>
  82. </view>
  83. </view>
  84. <gap />
  85. </template>
  86. </template>
  87. <template v-else>
  88. 暂无数据
  89. </template>
  90. <unopen ref="unopenRef" @confirm="confirm" textAlign="left" title="平仓" cancelBtn :content="closeLeverContent" />
  91. <restrictPopup ref="restrictRef" @setSuccess="setSuccess" />
  92. </view>
  93. </template>
  94. <script>
  95. import {
  96. Api_setCloseLever
  97. } from "@/api/index.js"
  98. import {
  99. mapGetters
  100. } from 'vuex'
  101. import restrictPopup from "./../modules/restrict.vue"
  102. export default {
  103. name: 'freight-space',
  104. props: {
  105. closeLeverContent: {
  106. type: String,
  107. default: ''
  108. },
  109. leverTransaction: {
  110. type: Array,
  111. default: () => {
  112. return []
  113. }
  114. }
  115. },
  116. components: {
  117. restrictPopup
  118. },
  119. computed: {
  120. ...mapGetters([
  121. "stocksColor"
  122. ])
  123. },
  124. data() {
  125. return {
  126. title: '平仓',
  127. closeLeverItem: null,
  128. restrict: ''
  129. };
  130. },
  131. mounted() {
  132. },
  133. methods: {
  134. setCloseLever(item) {
  135. this.title = '平仓';
  136. this.closeLeverItem = item;
  137. this.$refs.unopenRef.open();
  138. },
  139. setCloseLeverAll() {
  140. this.title = '全部平仓';
  141. this.closeLeverItem = null;
  142. this.$refs.unopenRef.open();
  143. },
  144. confirm() {
  145. if (this.leverTransaction.length > 0) {
  146. if (this.closeLeverItem) {
  147. // 平仓
  148. Api_setCloseLever({
  149. id: this.closeLeverItem.id
  150. }).then(res => {
  151. this.$emit('closeLeverSuccess')
  152. })
  153. } else {
  154. // 全部平仓
  155. }
  156. }
  157. },
  158. setRestrict(item) {
  159. this.$nextTick(() => {
  160. this.$refs.restrictRef.open(item)
  161. })
  162. },
  163. setSuccess() {
  164. this.$emit('closeLeverSuccess')
  165. }
  166. }
  167. }
  168. </script>
  169. <style lang="scss" scoped>
  170. // <view class="lable-title">
  171. // <text class="lable-title-text">仓位信息</text>
  172. // <text class="lable-title-btn">全部平仓</text>
  173. // </view>
  174. .lable-title {
  175. width: 100%;
  176. height: 80rpx;
  177. display: flex;
  178. justify-content: space-between;
  179. align-items: center;
  180. border-bottom: 1rpx solid $border-color;
  181. padding: 0 $pages-padding;
  182. font-size: 24rpx;
  183. color: #000;
  184. font-weight: bold;
  185. .lable-title-btn {
  186. color: $Theme-Color;
  187. }
  188. }
  189. .content-top {
  190. padding: 30rpx $pages-padding;
  191. display: flex;
  192. justify-content: space-between;
  193. align-items: stretch;
  194. width: 100%;
  195. border-bottom: 1rpx solid $border-color;
  196. .top-left,
  197. .top-right {
  198. display: flex;
  199. flex-direction: column;
  200. justify-content: space-between;
  201. }
  202. .top-left-title {
  203. font-size: 34rpx;
  204. font-weight: bold;
  205. .iconfont {
  206. margin: 0 10rpx 0 20rpx;
  207. }
  208. .icon-size {
  209. font-size: 24rpx;
  210. color: $Theme-Color;
  211. }
  212. }
  213. .top-left-b {
  214. font-size: 24rpx;
  215. }
  216. .top-left-b-tag {
  217. padding: 4rpx 6rpx;
  218. border-radius: 3rpx;
  219. background-color: $Theme-Color;
  220. color: #fff;
  221. margin-left: 20rpx;
  222. }
  223. .top-right {
  224. flex-shrink: 0;
  225. text-align: right;
  226. color: $Theme-Color;
  227. font-size: 28rpx;
  228. font-weight: bold;
  229. .top-right-float {
  230. padding-top: 20rpx;
  231. font-weight: normal;
  232. font-size: 22rpx;
  233. text {
  234. border-bottom: 1rpx dashed $Theme-Color;
  235. }
  236. }
  237. }
  238. }
  239. .content-info {
  240. padding: 0 $pages-padding;
  241. width: 100%;
  242. display: flex;
  243. flex-wrap: wrap;
  244. align-items: stretch;
  245. .info-item {
  246. width: 30%;
  247. display: flex;
  248. flex-direction: column;
  249. font-size: 24rpx;
  250. &:nth-child(3n) {
  251. width: 40%;
  252. text-align: right;
  253. }
  254. .info-item-lable {
  255. padding: 30rpx 0 20rpx;
  256. color: $SizeColor;
  257. }
  258. .info-item-val {
  259. color: #000;
  260. .iconfont {
  261. font-size: 24rpx;
  262. color: $Theme-Color;
  263. margin-left: 20rpx;
  264. }
  265. }
  266. }
  267. }
  268. .content-btns {
  269. width: 100%;
  270. padding: 40rpx $pages-padding 30rpx;
  271. width: 100%;
  272. display: flex;
  273. justify-content: space-between;
  274. .content-btn-item {
  275. width: calc((100% - 40rpx) / 3);
  276. height: 70rpx;
  277. line-height: 70rpx;
  278. background-color: $Theme-Color;
  279. text-align: center;
  280. color: #fff;
  281. border-radius: 6rpx;
  282. font-size: 28rpx;
  283. &:nth-child(n + 2) {
  284. background-color: $Theme-Color04;
  285. color: $Theme-Color;
  286. }
  287. }
  288. }
  289. </style>