close-out.vue 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419
  1. <template>
  2. <uni-popup ref="popupRef" type="bottom">
  3. <view class="popups-box">
  4. <view class="popups-title">
  5. 平仓
  6. <text class="close-icon iconfont" @click.stop="close()">&#xeca0;</text>
  7. </view>
  8. <view class="popups-content">
  9. <view class="content-item">
  10. <text class="content-lable">合约名称</text>
  11. <view class="content-val">
  12. <text class="val-name">{{ content.symbol }}</text>
  13. <text class="val-lever">{{ content.multiple }}倍杠杆</text>
  14. <text class="val-tag">{{ content.type_name }}</text>
  15. </view>
  16. </view>
  17. <view class="content-item">
  18. <text class="content-lable">开仓价格(USDT)</text>
  19. <view class="content-val">
  20. {{ content.price }}
  21. </view>
  22. </view>
  23. <view class="content-item">
  24. <text class="content-lable">标记价格(USDT)</text>
  25. <view class="content-val">
  26. {{ content.origin_price }}
  27. </view>
  28. </view>
  29. <view class="content-restrict">
  30. <view class="restrict-item">
  31. <text class="restrict-lable">平仓价格(USDT)</text>
  32. <!-- <view class="restrict-btn" v-if="content">
  33. <text class="iconfont">&#xe672;</text>
  34. <text>按比例设置</text>
  35. </view> -->
  36. </view>
  37. <view class="restrict-input-box input-type">
  38. <text class="restrict-input" v-show="priceType === 1">市价</text>
  39. <input class="restrict-input" type="number" v-show="priceType === 2" placeholder-class="placeholder-class" placeholder="请输入委托价">
  40. <text class="restrict-tag">USDT</text>
  41. <view class="restrict-switch" @click.stop="priceType === 1 ? priceType = 2 : priceType = 1">
  42. <text class="restrict-btn">{{ priceType === 1 ? '市价' : '限价' }}</text>
  43. <text class=" iconfont">&#xe672;</text>
  44. </view>
  45. </view>
  46. <view class="restrict-item">
  47. <text class="restrict-lable">平仓数量(USDT)</text>
  48. <view class="restrict-btn">
  49. <text class="restrict-nums-text">可平仓位数量(张):</text>
  50. <text class="restrict-nums">{{ numss }}</text>
  51. </view>
  52. </view>
  53. <view class="restrict-input-box">
  54. <input class="restrict-input" v-model="numsk" @focus="numsFocus" type="number">
  55. <text class="restrict-tag">张</text>
  56. </view>
  57. <view class="step-content">
  58. <step :percent.sync="percent" />
  59. </view>
  60. <view class="content-btns">
  61. <view class="content-btn cancel-btn" @click.stop="close()">
  62. 市价全平
  63. </view>
  64. <view class="content-btn" @click.stop="setLeverStop()">
  65. 确定
  66. </view>
  67. </view>
  68. </view>
  69. </view>
  70. </view>
  71. </uni-popup>
  72. </template>
  73. <script>
  74. import {
  75. Api_setLeverStop
  76. } from "@/api/index.js"
  77. export default {
  78. data() {
  79. return {
  80. content: {},
  81. percent: 0,
  82. numss: 196,
  83. numsk: '',
  84. priceType: 1, // 1 : 市价 2: 限价
  85. // target_profit_price: '',
  86. // stop_loss_price: '',
  87. };
  88. },
  89. watch: {
  90. percent: {
  91. handler(newNum) {
  92. if (newNum) {
  93. let num = Math.ceil(this.numss * newNum / 100)
  94. this.numsk = num > this.numss ? this.numss : num
  95. } else {
  96. this.numsk = ''
  97. }
  98. }
  99. }
  100. },
  101. mounted() {
  102. // this.open()
  103. },
  104. methods: {
  105. open(item = {}) {
  106. this.content = item;
  107. this.$nextTick(() => {
  108. this.$refs.popupRef.open();
  109. })
  110. },
  111. close() {
  112. this.$refs.popupRef.close()
  113. },
  114. // 平仓数量获取焦点时,根据情况复原百分比进度条
  115. numsFocus() {
  116. if (this.percent) {
  117. this.percent = 0;
  118. this.numsk = ''
  119. }
  120. },
  121. // confirm() {
  122. // this.close();
  123. // this.$emit('confirm')
  124. // },
  125. //
  126. setLeverStop() {
  127. if (this.content) {
  128. // 单个持仓修改
  129. Api_setLeverStop({
  130. id: this.content.id,
  131. target_profit_price: this.target_profit_price,
  132. stop_loss_price: this.stop_loss_price
  133. }).then(res => {
  134. this.close();
  135. this.$emit('setSuccess')
  136. })
  137. } else {
  138. // 全局下单设置
  139. this.close();
  140. this.$eventBus.$emit('placeOrder', {
  141. target_profit_price: this.target_profit_price,
  142. stop_loss_price: this.stop_loss_price
  143. });
  144. }
  145. }
  146. }
  147. }
  148. </script>
  149. <style lang="scss" scoped>
  150. .popups-box {
  151. width: 100%;
  152. .popups-title {
  153. text-align: center;
  154. width: 100%;
  155. height: 100rpx;
  156. line-height: 100rpx;
  157. background-color: $box-bg;
  158. position: relative;
  159. font-size: 30rpx;
  160. font-weight: bold;
  161. border-radius: 40rpx 40rpx 0 0;
  162. .close-icon {
  163. position: absolute;
  164. right: 30rpx;
  165. top: 50%;
  166. transform: translateY(-50%);
  167. }
  168. }
  169. }
  170. .popups-content {
  171. width: 100%;
  172. background-color: #fff;
  173. .content-item {
  174. width: 100%;
  175. display: flex;
  176. justify-content: space-between;
  177. align-items: center;
  178. padding: 20rpx $pages-padding;
  179. font-size: 22rpx;
  180. .content-lable {
  181. color: $SizeColor;
  182. font-size: 24rpx;
  183. }
  184. .content-val {
  185. color: #000;
  186. font-weight: bold;
  187. // <text class="val-name">LTC/USDT</text>
  188. // <text class="val-lever">100倍杠杆</text>
  189. // <text class="val-tag">逐仓做多</text>
  190. .val-name {}
  191. .val-tag,
  192. .val-lever {
  193. padding: 5rpx 4rpx;
  194. color: #fff;
  195. font-size: 20rpx;
  196. border-radius: 4rpx;
  197. margin-left: 6rpx;
  198. }
  199. .val-lever {
  200. background-color: $Theme-Color;
  201. }
  202. .val-tag {
  203. background-color: $Theme-Color1;
  204. }
  205. }
  206. &:last-child {
  207. border-bottom: 10rpx solid $border-color;
  208. }
  209. }
  210. .content-restrict {
  211. width: 100%;
  212. padding: 0 $pages-padding;
  213. border-top: 1rpx solid $border-color2;
  214. .restrict-item {
  215. width: 100%;
  216. padding-top: 30rpx;
  217. display: flex;
  218. justify-content: space-between;
  219. align-items: center;
  220. font-size: 26rpx;
  221. font-weight: bold;
  222. .restrict-btn {
  223. .iconfont {
  224. font-size: 28rpx;
  225. color: $Theme-Color;
  226. margin-right: 10rpx;
  227. }
  228. .restrict-nums-text {
  229. font-size: 26rpx;
  230. color: $SizeColor3;
  231. border-bottom: 1rpx dashed $border-color12;
  232. }
  233. .restrict-nums {
  234. font-size: 24rpx;
  235. color: $Theme-Color;
  236. }
  237. }
  238. }
  239. .restrict-input-box {
  240. margin-top: 20rpx;
  241. width: 100%;
  242. display: flex;
  243. align-items: center;
  244. font-size: 26rpx;
  245. height: 80rpx;
  246. border: 1rpx solid $border-color;
  247. border-radius: 10rpx;
  248. padding-right: 20rpx;
  249. text {
  250. flex-shrink: 0;
  251. }
  252. .restrict-input {
  253. flex: 1;
  254. height: 100%;
  255. border: none;
  256. padding: 0 20rpx;
  257. }
  258. .placeholder-class {
  259. font-size: 26rpx;
  260. font-weight: bold;
  261. }
  262. .restrict-tag {
  263. color: $SizeColor2;
  264. }
  265. .restrict-btn {
  266. color: $Theme-Color;
  267. padding-left: 20rpx;
  268. }
  269. .restrict-switch {
  270. flex-shrink: 0;
  271. .iconfont {
  272. font-size: 22rpx;
  273. color: #c29032;
  274. padding-left: 10rpx;
  275. }
  276. }
  277. }
  278. .input-type {
  279. background-color: $box-bg;
  280. .restrict-input {
  281. flex: 1;
  282. height: auto;
  283. padding: 0 20rpx;
  284. color: #000;
  285. font-weight: bold;
  286. }
  287. .restrict-btn {
  288. line-height: 1;
  289. border-left: 1px solid $Theme-Color;
  290. margin-left: 10rpx;
  291. padding-left: 10rpx;
  292. }
  293. }
  294. // <view class="restrict-hint">
  295. // <text class="iconfont">&#xe8ec;</text>
  296. // <text>市价单的成交价格可能偏离用户下单时看到的成交价格</text>
  297. // </view>
  298. // <view class="restrict-hint2">
  299. // <text>当标价价格触达{{ target_profit_price || '--'}}时,将会触发市价委托平仓</text>
  300. // <text>预计盈亏--</text>
  301. // </view>
  302. .restrict-hint {
  303. width: 100%;
  304. display: flex;
  305. align-items: center;
  306. padding-top: 10rpx;
  307. text {
  308. font-size: 22rpx;
  309. }
  310. .iconfont {
  311. font-size: 26rpx;
  312. margin-right: 6rpx;
  313. color: #000;
  314. }
  315. }
  316. .restrict-hint2 {
  317. width: 100%;
  318. display: flex;
  319. align-items: center;
  320. justify-content: space-between;
  321. font-size: 20rpx;
  322. color: $SizeColor;
  323. padding-top: 10rpx;
  324. }
  325. }
  326. }
  327. .step-content {
  328. padding-top: 40rpx;
  329. }
  330. .content-btns {
  331. width: 100%;
  332. display: flex;
  333. justify-content: space-between;
  334. align-items: stretch;
  335. padding-top: 60rpx;
  336. .content-btn {
  337. flex: 1;
  338. height: 80rpx;
  339. line-height: 80rpx;
  340. background-color: $Theme-Color;
  341. margin-bottom: 40rpx;
  342. color: #fff;
  343. text-align: center;
  344. font-size: 30rpx;
  345. letter-spacing: 1px;
  346. border-radius: 6rpx;
  347. }
  348. .cancel-btn {
  349. margin-right: 20rpx;
  350. border: 1rpx solid $Theme-Color;
  351. background-color: #fff;
  352. color: $Theme-Color;
  353. }
  354. }
  355. </style>