123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417 |
- <template>
- <uni-popup ref="popupRef" type="bottom">
- <view class="popups-box" :rise-fall="stocksColor">
- <view class="popups-title">
- {{ content ? '持仓止盈止损修改' : '设置止盈止损' }}
- <text class="close-icon iconfont" @click.stop="close()"></text>
- </view>
- <view class="popups-content">
- <template v-if="content">
- <view class="content-item">
- <text class="content-lable">合约名称</text>
- <view class="content-val">
- <text class="val-name">{{ content.symbol }}</text>
- <text class="val-lever">{{ content.multiple }}倍杠杆</text>
- <text class="val-tag">{{ content.type_name }}</text>
- </view>
- </view>
- <view class="content-item">
- <text class="content-lable">开仓价格(USDT)</text>
- <view class="content-val">
- {{ content.origin_price }}
- </view>
- </view>
- <view class="content-item">
- <text class="content-lable">标记价格(USDT)</text>
- <view class="content-val">
- {{ content.update_price }}
- </view>
- </view>
- </template>
- <view class="content-restrict">
- <view class="restrict-item">
- <text class="restrict-lable">止盈</text>
- <view class="restrict-btn" v-if="content">
- <text class="iconfont"></text>
- <text>按比例设置</text>
- </view>
- </view>
- <view class="restrict-input-box">
- <input class="restrict-input" v-model="target_profit_price" type="number"
- placeholder-class="placeholder-class" placeholder="请输入触发价">
- <text class="restrict-tag">USDT</text>
- <text class="restrict-btn" @click.stop="target_profit_price = ''">清空</text>
- </view>
- <view class="restrict-input-box input-type">
- <text class="restrict-input">市价</text>
- <text class="restrict-tag">USDT</text>
- <text class="restrict-btn">市价</text>
- </view>
- <view class="restrict-hint">
- <text class="iconfont"></text>
- <text>市价单的成交价格可能偏离用户下单时看到的成交价格</text>
- </view>
- <view class="restrict-hint2" v-if="content" :class="$setColor(profitPrice)">
- <text>当标价价格触达{{ target_profit_price || '--'}}时,将会触发市价委托平仓</text>
- <text>预计盈亏 <text class="color">{{ profitPrice || '--'}}</text> </text>
- </view>
- <view class="restrict-item">
- <text class="restrict-lable">止损</text>
- <view class="restrict-btn" v-if="content">
- <text class="iconfont"></text>
- <text>按比例设置</text>
- </view>
- </view>
- <view class="restrict-input-box">
- <input class="restrict-input" v-model="stop_loss_price" type="number"
- placeholder-class="placeholder-class" placeholder="请输入触发价">
- <text class="restrict-tag">USDT</text>
- <text class="restrict-btn" @click.stop="stop_loss_price = ''">清空</text>
- </view>
- <view class="restrict-input-box input-type">
- <text class="restrict-input">市价</text>
- <text class="restrict-tag">USDT</text>
- <text class="restrict-btn">市价</text>
- </view>
- <view class="restrict-hint">
- <text class="iconfont"></text>
- <text>市价单的成交价格可能偏离用户下单时看到的成交价格</text>
- </view>
- <view class="restrict-hint2" v-if="content" :class="$setColor(lossPrice)">
- <text>当标价价格触达{{ stop_loss_price || '--'}}时,将会触发市价委托平仓</text>
- <text>预计盈亏 <text class="color">{{ lossPrice || '--'}}</text></text>
- </view>
- <view class="content-btns">
- <view class="content-btn cancel-btn" @click.stop="close()">
- 取消
- </view>
- <view class="content-btn" @click.stop="setLeverStop()">
- 确定
- </view>
- </view>
- </view>
- </view>
- </view>
- </uni-popup>
- </template>
- <script>
- import {
- Api_setLeverStop
- } from "@/api/index.js"
- import {
- mapGetters
- } from 'vuex'
- export default {
- data() {
- return {
- content: null, // null : 下单时设置 , 否则为但是仓位设置
- target_profit_price: '',
- stop_loss_price: '',
- profitPrice:"",
- lossPrice:''
- };
- },
- watch:{
- target_profit_price:{
- handler(newPrice){
- if(newPrice && newPrice > Number(this.content.origin_price)){
- this.profitPrice = ((newPrice - this.content.origin_price) * 100 / this.content.origin_price *this.content.caution_money).toFixed(2);
- }else{
- this.profitPrice = ''
- }
-
- },
- immediate:true
- },
- stop_loss_price:{
- handler(newPrice){
- if(newPrice && newPrice < Number(this.content.origin_price)){
- this.lossPrice = ((newPrice - this.content.origin_price) * 100 / this.content.origin_price *this.content.caution_money).toFixed(2);
- }else{
- this.lossPrice = ''
- }
- },
- immediate:true
- },
-
- },
- computed: {
- ...mapGetters([
- "stocksColor"
- ])
- },
- mounted() {
- // this.open()
- },
- methods: {
- open(item = null) {
- this.target_profit_price = '';
- this.stop_loss_price = '';
- this.content = item;
- this.$nextTick(() => {
- this.$refs.popupRef.open();
- })
- },
- close() {
- this.$refs.popupRef.close()
- },
- // confirm() {
- // this.close();
- // this.$emit('confirm')
- // },
- //
- setLeverStop() {
- if (this.content) {
- // 单个持仓修改
- Api_setLeverStop({
- id: this.content.id,
- target_profit_price: this.target_profit_price,
- stop_loss_price: this.stop_loss_price
- }).then(res => {
- this.close();
- this.$emit('setSuccess')
- })
- } else {
- // 全局下单设置
- this.close();
- this.$eventBus.$emit('placeOrder', {
- target_profit_price: this.target_profit_price,
- stop_loss_price: this.stop_loss_price
- });
- }
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .popups-box {
- width: 100%;
- .popups-title {
- text-align: center;
- width: 100%;
- height: 100rpx;
- line-height: 100rpx;
- background-color: $box-bg;
- position: relative;
- font-size: 30rpx;
- font-weight: bold;
- border-radius: 40rpx 40rpx 0 0;
- .close-icon {
- position: absolute;
- right: 30rpx;
- top: 50%;
- transform: translateY(-50%);
- }
- }
- }
- .popups-content {
- width: 100%;
- background-color: #fff;
- .content-item {
- width: 100%;
- display: flex;
- justify-content: space-between;
- align-items: center;
- padding: 20rpx $pages-padding;
- font-size: 22rpx;
- .content-lable {
- color: $SizeColor;
- }
- .content-val {
- color: #000;
- font-weight: bold;
- // <text class="val-name">LTC/USDT</text>
- // <text class="val-lever">100倍杠杆</text>
- // <text class="val-tag">逐仓做多</text>
- .val-name {}
- .val-tag,
- .val-lever {
- padding: 5rpx 4rpx;
- color: #fff;
- font-size: 20rpx;
- border-radius: 4rpx;
- margin-left: 6rpx;
- }
- .val-lever {
- background-color: $Theme-Color;
- }
- .val-tag {
- background-color: $Theme-Color1;
- }
- }
- &:last-child {
- border-bottom: 10rpx solid $border-color;
- }
- }
- .content-restrict {
- width: 100%;
- padding: 0 $pages-padding;
- .restrict-item {
- width: 100%;
- padding-top: 30rpx;
- display: flex;
- justify-content: space-between;
- align-items: center;
- font-size: 26rpx;
- font-weight: bold;
- .restrict-btn {
- .iconfont {
- font-size: 28rpx;
- color: $Theme-Color;
- margin-right: 10rpx;
- }
- }
- }
- .restrict-input-box {
- margin-top: 20rpx;
- width: 100%;
- display: flex;
- align-items: center;
- font-size: 26rpx;
- height: 80rpx;
- border: 1rpx solid $border-color;
- border-radius: 10rpx;
- padding-right: 20rpx;
- text {
- flex-shrink: 0;
- }
- .restrict-input {
- flex: 1;
- height: 100%;
- border: none;
- padding: 0 20rpx;
- }
- .placeholder-class {
- font-size: 26rpx;
- font-weight: bold;
- }
- .restrict-tag {
- color: $SizeColor2;
- }
- .restrict-btn {
- color: $Theme-Color;
- padding-left: 20rpx;
- }
- }
- .input-type {
- background-color: $box-bg;
- .restrict-input {
- flex: 1;
- height: auto;
- padding: 0 20rpx;
- color: #000;
- font-weight: bold;
- }
- .restrict-btn {
- line-height: 1;
- border-left: 1px solid $Theme-Color;
- margin-left: 10rpx;
- padding-left: 10rpx;
- }
- }
- // <view class="restrict-hint">
- // <text class="iconfont"></text>
- // <text>市价单的成交价格可能偏离用户下单时看到的成交价格</text>
- // </view>
- // <view class="restrict-hint2">
- // <text>当标价价格触达{{ target_profit_price || '--'}}时,将会触发市价委托平仓</text>
- // <text>预计盈亏--</text>
- // </view>
- .restrict-hint {
- width: 100%;
- display: flex;
- align-items: center;
- padding-top: 10rpx;
- text {
- font-size: 22rpx;
- }
- .iconfont {
- font-size: 26rpx;
- margin-right: 6rpx;
- color: #000;
- }
- }
- .restrict-hint2 {
- width: 100%;
- display: flex;
- align-items: center;
- justify-content: space-between;
- font-size: 20rpx;
- color: $SizeColor;
- padding-top: 10rpx;
- text + text{
- flex-shrink: 0;
- padding-left: 10px;
- }
- }
- }
- }
- .content-btns {
- width: 100%;
- display: flex;
- justify-content: space-between;
- align-items: stretch;
- padding-top: 60rpx;
- .content-btn {
- flex: 1;
- height: 80rpx;
- line-height: 80rpx;
- background-color: $Theme-Color;
- margin-bottom: 40rpx;
- color: #fff;
- text-align: center;
- font-size: 30rpx;
- letter-spacing: 1px;
- border-radius: 6rpx;
- }
- .cancel-btn {
- margin-right: 20rpx;
- border: 1rpx solid $Theme-Color;
- background-color: #fff;
- color: $Theme-Color;
- }
- }
- </style>
|