Fly 2 years ago
parent
commit
c5bce251da
2 changed files with 34 additions and 17 deletions
  1. 31 14
      pages/contract/modules/restrict.vue
  2. 3 3
      pages/contract/shortcut/index.vue

+ 31 - 14
pages/contract/modules/restrict.vue

@@ -118,12 +118,18 @@
 		},
 		watch: {
 			restrictOrder: {
-				handler(newOrder) {
-					console.log('this.stop_loss_price  restrictOrder ' , newOrder)
+				handler(newOrder, oldOrder) {
 					if (newOrder) {
 						this.calculateProfitPrice(this.target_profit_price)
 						this.calculateLossPrice(this.stop_loss_price)
 					}
+					if (!oldOrder || (newOrder && newOrder.stop_loss_price !== oldOrder.stop_loss_price)) {
+						console.log('this.stop_loss_price  restrictOrder ' ,1)
+						this.stop_loss_price = newOrder?.stop_loss_price || '';
+					}
+					if (!oldOrder || (newOrder && newOrder.target_profit_price !== oldOrder.target_profit_price)) {
+						this.target_profit_price = newOrder?.target_profit_price || '';
+					}
 				},
 				immediate: true,
 				deep: true
@@ -153,27 +159,36 @@
 		},
 		methods: {
 			calculateProfitPrice(newPrice) {
-				if (newPrice && this.restrictOrder && newPrice > Number(this.restrictOrder
-						.update_price)) {
-					this.profitPrice = ((newPrice - this.restrictOrder.update_price) * 100 / this
-						.restrictOrder.update_price * this.restrictOrder.caution_money).toFixed(2);
-				} else {
+				// if (newPrice && this.restrictOrder && newPrice > Number(this.restrictOrder.update_price)) {
+				try {
+					if (newPrice && this.restrictOrder) {
+						this.profitPrice = ((newPrice - this.restrictOrder.update_price) * 100 / this
+							.restrictOrder.update_price * this.restrictOrder.caution_money).toFixed(2);
+					} else {
+						this.profitPrice = ''
+					}
+				} catch {
 					this.profitPrice = ''
 				}
 			},
 
 			calculateLossPrice(newPrice) {
-				if (newPrice && this.restrictOrder && newPrice < Number(this.restrictOrder.update_price)) {
-					// console.log('this.calculateLossPrice = ' , newPrice , this.restrictOrder.update_price)
-					this.lossPrice = ((newPrice - this.restrictOrder.update_price) * 100 / this
-						.restrictOrder.update_price * this.restrictOrder.caution_money).toFixed(2);
-				} else {
+				// if (newPrice && this.restrictOrder && newPrice < Number(this.restrictOrder.update_price)) {
+				try {
+					if (newPrice && this.restrictOrder) {
+						// console.log('this.calculateLossPrice = ' , newPrice , this.restrictOrder.update_price)
+						this.lossPrice = ((newPrice - this.restrictOrder.update_price) * 100 / this
+							.restrictOrder.update_price * this.restrictOrder.caution_money).toFixed(2);
+					} else {
+						this.lossPrice = ''
+					}
+				} catch {
 					this.lossPrice = ''
 				}
+
 			},
 			open(item = null) {
-				this.target_profit_price = '';
-				this.stop_loss_price = '';
+
 				// this.content = item;
 				this.$nextTick(() => {
 					this.$refs.popupRef.open();
@@ -181,6 +196,8 @@
 			},
 			close() {
 				this.$refs.popupRef.close()
+				this.target_profit_price = '';
+				this.stop_loss_price = '';
 			},
 			change(e) {
 				if (!e.show) {

+ 3 - 3
pages/contract/shortcut/index.vue

@@ -193,7 +193,7 @@
 										<view class="top-right" :class="[$setColor(item.profits || '0.00')]">
 											<text class="color">{{ item.profits }}</text>
 											<text
-												class="top-right-float color"><text>浮动盈亏</text>{{ $getChange(item , 1) }}%</text>
+												class="top-right-float color"><text>浮动盈亏</text>{{ $getChange(item , 4) }}%</text>
 										</view>
 									</view>
 									<view class="content-info">
@@ -244,9 +244,9 @@
 										<view class="content-btn-item">
 											反向开仓
 										</view>
-										<view class="content-btn-item">
+									<!-- 	<view class="content-btn-item">
 											加仓
-										</view>
+										</view> -->
 									</view>
 									<view class="set-stop">
 										<view class="stop-left" @click.stop="setRestrict(item)">