close-out.vue 9.6 KB

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