restrict.vue 8.5 KB

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