1
jhzh
2025-11-02 411edaf3d05d0a7393e4784ff8f3310a0ccb2196
src/page/user/myOrder.vue
@@ -63,6 +63,7 @@
    <van-tabs v-model="active" title-inactive-color="#898a8e">
      <van-tab :title="$t('hj2')" name="0" title-style="font-size:0.4rem;"></van-tab>
      <van-tab :title="$t('hj121')" name="1" title-style="font-size:0.4rem;"></van-tab>
      <van-tab :title="$t('hj109')" name="2" title-style="font-size:0.4rem;"></van-tab>
    </van-tabs>
    <div class="mo_list" v-if="active == '0'">
@@ -78,58 +79,7 @@
            {{ i.orderDirection == "买涨" ? $t("gm") : $t("hj78") }}
          </div>
        </div>
        <!-- <div class="moli_orderTitle">
          <span>{{ $t("订单号") }}</span>
          <span style="margin-left: 1em;">{{ i.buyOrderId }}</span>
        </div> -->
        <div style="display:flex;flex-wrap:wrap;padding:0 .3rem .35rem;">
          <!-- <div class="tui-wrapItem flex-start">
            <div>
              {{ $t("Price") }}
            </div>
            <div style="margin-left: .25rem;font-size: .4rem;">
              {{ i.orderTotalPrice }}
            </div>
          </div>
          <div class="tui-wrapItem flex-start" style="width: 46%;">
            <div>
              {{ $t("盈虧") }}
            </div>
            <div
              style="margin-left: .25rem;font-size: .4rem;"
              :style="
                `color:${
                  i.profitAndLose > 0
                    ? 'green'
                    : i.profitAndLose < 0
                    ? 'red'
                    : ''
                }`
              "
            >
              {{ i.profitAndLose }}
            </div>
          </div>
          <div class="tui-wrapItem flex-start">
            <div>
              {{ $t("持倉價") }}
            </div>
            <div style="margin-left: .25rem;">
              {{ i.buyOrderPrice }}
            </div>
          </div>
          <div class="tui-wrapItem flex-start" style="width:100%">
            <div>
              {{ $t("持倉時間") }}
            </div>
            <div style="margin-left: .25rem;">
              {{ $moment(i.buyOrderTime).format("DD-MM-YYYY hh:mm:ss A") }}
            </div>
          </div> -->
          <div class="tui-wrapItem" style="width: 25%;">
            <div style="font-size: 0.28rem;margin-bottom: .25rem;">
              {{ $t("MingCheng") }}/{{ $t("市值") }}
@@ -293,6 +243,81 @@
        <span>{{ $t("沒有更多了") }}</span>
      </div>
    </div>
    <div class="mo_list" v-if="active == '2'">
      <div class="mol_item" v-for="(i, index) in orderList" :key="i.id" >
        <div class="moli_title flex-between">
          <div>
            {{ i.stockName }}
          </div>
         <div >
          </div>
        </div>
        <div style="display:flex;flex-wrap:wrap;padding-bottom: .35rem;margin: 0 10px;">
          <div class="tui-wrapItem flex-start">
            <div>
              {{ $t("hj125") }}
            </div>
            <div style="margin-left: .25rem;font-size: .4rem;">
              {{ i.nowPrice }}
            </div>
          </div>
          <div class="tui-wrapItem flex-start" style="width: 46%;">
            <div>
              {{ $t("hj101") }}
            </div>
            <div style="margin-left: .25rem;font-size: .4rem;" >
              {{ i.lever }}
            </div>
          </div>
          <div class="tui-wrapItem flex-start">
            <div>
              {{ $t("hj270") }}
            </div>
            <div style="margin-left: .25rem;">
              {{ i.buyNum }}
            </div>
          </div>
          <div class="tui-wrapItem flex-start" style="width: 46%;">
            <div>
              {{ $t("hj271") }}
            </div>
            <div style="margin-left: .25rem;">
              {{ i.targetPrice }}
            </div>
          </div>
          <div class="tui-wrapItem">
            <div>
              {{ $t("操作时间") }}
            </div>
            <div>
              {{ i.addTime }}
            </div>
          </div>
          <div class="tui-wrapItem" style="width: 46%;">
            <div>
              {{ $t("状态") }}
            </div>
            <div v-if="i.status==0">
              {{ $t('已挂单') }}
            </div>
            <div v-if="i.status==2">
              {{ $t('买入失败') }}
            </div>
          </div>
        </div>
      </div>
      <div class="more-news">
        <span>{{ $t("沒有更多了") }}</span>
      </div>
    </div>
  </div>
</template>
@@ -311,6 +336,7 @@
      active: "0",
      pageNum: 1,
      pageSize: 9999,
      orderList:[],//挂单列表
      total: 1,
      list: [], // 持仓数据
      list2: [], // 平仓数据
@@ -322,15 +348,20 @@
  watch: {
    active: {
      handler(state) {
        this.pageNum = 1;
        this.getList(state);
        clearInterval(teimss2);
        // 判断如果是获取平仓数据就不再轮询
        if(state == '1') return
        teimss2 = setInterval(() => {
        console.log(state);
        if(state==2){
          this.getorderList()
        }else{
          this.pageNum = 1;
          this.getList(state);
        }, 3000);
          clearInterval(teimss2);
          // 判断如果是获取平仓数据就不再轮询
          if(state == '1') return
          teimss2 = setInterval(() => {
            this.getList(state);
          }, 3000);
        }
      },
      immediate: true
    }
@@ -353,6 +384,13 @@
    clearInterval(teimss2);
  },
  methods: {
    // 获取 挂单 数据
    async getorderList() {
      let data = await api.getorderList();
      if (data.status === 0) {
        this.orderList = data.data
      }
    },
    // 获取 持仓 数据
    async getList(state = 0) {
      let opt = {
@@ -360,7 +398,7 @@
        pageNum: this.pageNum,
        pageSize: this.pageSize
      };
      let data = await api.getchicang(opt);
      if (data.status === 0) {
        if (this.active == "0") this.list = data.data.list;