11
jhzh
2024-08-28 31fa18ded9967c99869fb5b118b1313e112c7b00
src/page/trade/index.vue
@@ -5,16 +5,16 @@
            v-for="(item,index) in typelist" :key="index">{{item}}</div>
      </div>
      <div v-if="typeindex==0">
         <!-- <trade-head :backFunc="() => $router.push('/')" :symbol="symbol" :newname="newname" :price="price" :range="range"
            :isTrade="true" @update-coin="onUpdate" @data="quote = $event" /> -->
         <trade-head :backFunc="() => $router.push('/')" :symbol="symbol" :newname="newname" :price="price" :range="range"
            :isTrade="true" @update-coin="onUpdate" @data="quote = $event" />
         <div class="trade-buy-sell flex justify-between px-30 py-30">
            <keep-alive>
               <trade-deep-data :selectValue="selectValue" @getList="getList" :showType="showType" :symbol="symbol"
                  v-if="symbol" :price="price" class="w-290 mr-30" />
            </keep-alive>
            <trade-order-area :key="newzuj" :symbol="symbol" :init-open="initOpena" :newname="newname" :init-close="initClose"
               :price="price" @ordered="onOrdereda" />
            <trade-order-area :symbol="symbol" :init-open="initOpena" :newname="newname" :init-close="initClose" :price="price"
               @ordered="onOrdereda" />
         </div>
         <div class="list-data">
@@ -258,7 +258,6 @@
            range: "",
            stop_price_profit: "",
            stop_price_loss: "",
            newzuj:0,
            initClose: {},
            asks: initArr, // 卖单
            bids: initArr, // 买单
@@ -292,6 +291,7 @@
            timeout: null,
            timer: null, // 底部持仓等的公用定时器
            timer2: null, // 交割合约底部持仓等的公用定时器
            symbol: "",
            price: "",
            range: "",
            initOpena: {},
@@ -349,9 +349,7 @@
         }
         _getBalance().then((data) => {
            // 获取用户余额
            this.$store.commit("user/SET_USERINFO", {
               balance: data.money
            });
           this.$store.commit("user/SET_USERINFO", { balance: data.money });
            // const { money } = data
            // this.balance = money
         });
@@ -370,15 +368,11 @@
            this.curTab = "fetchOrderListHold";
         }
         this.symbol = symbol;
         // if(this.symbol == 'ORBITAL'){
         //    this.symbol = 'mother'
         // }
         if (this.typeindex == 0) {
            this.inita(symbol);
         } else {
            this.init(symbol);
         }
         // this.handleQoutes()
      },
      methods: {
         ...mapActions("home", [SET_COIN_LIST]),
@@ -388,7 +382,7 @@
            if (e == 0) {
               this.initParama(this.symbol)
            } else {
               // this.symbol = 'wld'
               this.symbol = 'wld'
               this.initParam(this.symbol)
            }
            this.$forceUpdate()
@@ -454,7 +448,6 @@
            this[this.curTab](this.symbol);
         },
         getCoinPrce(val) {
            _getHomeList(val).then((res) => {
               this.coinPrice = res[0].close;
            });
@@ -587,7 +580,7 @@
            _getHomeList(symbol).then((data) => {
               // 获取行情
               this.handleQoutes(data);
               // this.startQuoteSocket(); // socket
             this.startQuoteSocket(); // socket
               if (this.typeindex == 0) {
                  this.startQuoteSocketa(); // socket
               } else {
@@ -607,7 +600,6 @@
         },
         fetchDeepData(symbol) {
            console.log("sd");
            this.newzuj += 1
            _getDeepData(symbol).then((data) => {
               // 获取深度
               console.log(data);
@@ -620,10 +612,7 @@
               return;
            }
            this.deepData = data;
            const {
               asks,
               bids
            } = data;
           const { asks, bids } = data;
            this.asks = asks.sort((a, b) => a.price - b.price).slice(0, showLength);
            this.bids = bids.sort((a, b) => a.price - b.price).slice(-showLength);
         },
@@ -663,13 +652,8 @@
            };
            this.socket.onmessage = (evt) => {
               const {
                  data
               } = evt;
               const {
                  code,
                  data: _data
               } = JSON.parse(data);
             const { data } = evt;
             const { code, data: _data } = JSON.parse(data);
               if (code / 1 === 0) {
                  this.handleDeep(_data);
               }
@@ -712,7 +696,7 @@
               //console.log('开仓数据')
               Axios.tradeBuyToken({}).then((res) => {
                  this.initOpena = res.data;
                  console.log(this.initOpena.volume, res.data.volume, type,111111);
                  console.log(this.initOpen.volume, res.data.volume, type);
               });
            }
            if (type === "close" || !type) {
@@ -732,8 +716,7 @@
            if (type === "open" || type === "long" || type === "short" || !type) {
               let initFunTimer = null;
               let initFun = () => {
                  _initOpen(symbol.toLowerCase())
               _initOpen(symbol)
                     .then((data) => {
                        this.initOpen = data;
                        clearTimeout(initFunTimer);
@@ -805,7 +788,7 @@
               this.initParam(symbol); // 'open'
            }
            this.clearTimer();
            // this.getCoinPrce(symbol);
            this.getCoinPrce(symbol);
         },
         closeSocketa() {
            this.socket && this.socket.close();
@@ -914,13 +897,8 @@
         //     socket.send('hello')
         // }
         this.sockets.quotes.onmessage = (evt) => {
            const {
               data
            } = evt;
            const {
               code,
               data: _data
            } = JSON.parse(data);
          const { data } = evt;
          const { code, data: _data } = JSON.parse(data);
            if (code / 1 === 0) {
               this.handleQoutes(_data);
            }
@@ -946,10 +924,6 @@
            //       vm.inita(symbol);
            //    });
            // }else{
                  // next((vm) => {
                  //    vm.symbol = symbol;
                  //    vm.inita(symbol);
                  // });
            next((vm) => {
               vm.symbol = symbol;
               vm.init(symbol);
@@ -979,9 +953,9 @@
         }
      },
      activated() {
         this.currentType = this.$route.query.currentType ?
            this.$route.query.currentType :
            "long";
         this.currentType = this.$route.query.currentType
           ? this.$route.query.currentType
           : "long";
      },
      deactivated() {
         if (this.typeindex == 0) {
@@ -1254,7 +1228,8 @@
      width: 100%;
   }
   .my-swipe .van-swipe-item {}
   .my-swipe .van-swipe-item {
   }
   .line {
      height: 13px;