lxf
2025-07-07 93f9b248dd0eecbaa77006e5146c58c831d89d8e
src/components/Transform/contract-futrue/index.vue
@@ -3,13 +3,17 @@
    <div class="contact-futrue">
      <div class="font-24 text-grey mb-24">{{ $t('交割时间') }}</div>
      <ul class="flex flex-wrap w-full">
        <li v-for="(item, index) in initFutrue.para" v-if="initFutrue.para" :key="item.uuid"
        <!-- v-if="initFutrue.para" -->
        <!-- initFutrue: {{ initFutrue.para }} -->
        <li v-for="(item, index) in initFutrue.para"  v-if="initFutrue.para" :key="item.uuid"
          class="h-92 flex items-center mb-22" @click="onSelect(item, index)">
          <p class="w-95 h-full flex justify-center items-center font-22 flex-1"
            :class="active === item.para_id ? 'bg-light-blue text-white' : 'delivery_left_tab_background textColor'">{{ item.time_num +
            :class="active === item.para_id ? 'bg-light-blue text-white' : 'delivery_left_tab_background textColor'"
            >{{ item.time_num +
              item.time_unit.substr(0, 1) }}</p>
          <p class="w-125 h-full flex justify-center items-center font-22 flex-1"
            :class="active === item.para_id ? 'bg-dark-blue text-white' : 'delivery_tab_background textColor'">{{
            :class="active === item.para_id ? 'bg-dark-blue text-white' : 'delivery_tab_background textColor'"
            >{{
              item.profit_ratio }}%</p>
        </li>
      </ul>
@@ -18,6 +22,9 @@
</template>
<script>
import { _futrueOrderInit } from "@/service/trade.api.js";
import { getStorage } from '@/utils'
export default {
  name: 'ContractFutrue',
  props: {
@@ -31,20 +38,43 @@
  data() {
    return {
      active: '',
      // initFutrue: {},
      m_initFutrue: {},
      initParam: [] // 初始化参数
    }
  },
  created() {
    if (this.initFutrue.para.length > 0) {
      this.active = this.initFutrue.para[0].para_id || ''
      this.$emit('paraId', { id: this.active, index: 0 })
        console.log('this.initFutrue', this.initFutrue)
        // this._initParam();
        if (this.initFutrue.para.length > 0) {
          this.active = this.initFutrue.para[0].para_id || ''
          this.$emit('paraId', { id: this.active, index: 0 })
        }
  },
  watch: {
    '$route.query.symbol'(newVal, oldVal) {
      if (newVal !== oldVal) {
        this._initParam();
      }
    }
  },
  methods: {
    onSelect(item, index) { // 选中
      this.active = item.para_id
      this.$emit('paraId', { id: this.active, index })
    }
    },
    _initParam(){ // 初始化参数
    // if (type === 'futrue' || !type) {
      // const symbol = getStorage('symbol')
      _futrueOrderInit('USDSGD').then(data => {
            // this.m_initFutrue = data
            if (this.initFutrue.para.length < 0) {
              this.initFutrue = data
            }
          console.log('this.initFutrue', this.initFutrue)
        })
    // }
    },
  }
}
</script>
@@ -54,8 +84,7 @@
.bgDark {
  background: 242424
  background: #242424;
}
.bg-light-blue {
@@ -65,4 +94,8 @@
.bg-dark-blue {
  background: #1255A3;
}
ul li p{
    color: #fff;
}
</style>