<template>
  <div>
    <div class="serch row item-center allAlignment">
      <div class="row item-center">
        <div class="row item-center">
          <input
            class="fz14"
            type="text"
            placeholder="请输入球队名称"
            v-model="serchTxt"
            onkeyup="this.value=this.value.replace(/\s+/g,'')"
            color="#AAA"
          />
          <div class="row center serch-img pointer hover" @click="Serch()">
            <img src="@/assets/st-imges/serch.png" alt />
          </div>
        </div>
        <div class="row item-center">
          <div class="row center clear pointer hover br05 fz14" @click="clearSerchTxt()">清除</div>
        </div>
      </div>
      <div class="row center redraw pointer hover br05" @click="red()">
        <img src="@/assets/st-imges/redraw.png" alt />
      </div>
    </div>
    <!-- 标题 -->
    <div style="height:.5rem;background:#888;" class="pdg20 row allAlignment">
      <div  class="row item-center"
        style="height:100%;color:#FFF;font-size:.16rem;font-weight:bold;"
      >网球滚球</div>
      <div class="row item-center">
        <!-- <p style="font-size:.14rem;">显示</p>
        <div
          style="width:.5rem;height:.3rem;background:#AAA;color:#FFF;margin-left:.13rem;font-size:.14rem;"
          class="row center br05"
        >盘数</div> -->
      </div>
    </div>
    <div class="tennisRollBall" v-for="(item,index) in data" :key="item.id">
      <!-- 联赛名 -->
      <div class="tennisRollBall-title row item-center pdg20">{{item.leagueName}}</div>
      <div class="tennisRollBall-title-list" v-for="(items,i) in item.matchData" :key="items.id">
        <div class="tennisRollBall-title-list-title pdg20 row">
          <div style="width:30%;height:100%" class="row allAlignment item-center">
            <span
              style="color:#F76649"
              v-if="items.home_player_score != null"
            >{{items.home_player_score}}</span>
            <span style="color:#F76649" v-else>0</span>
            <span>-</span>
            <span
              style="color:#F76649"
              v-if="items.guest_player_score != null"
            >{{items.guest_player_score}}</span>
            <span style="color:#F76649" v-else>0</span>
            <div
              class="row center triangle tennisRollBall-title-list-title-num"
              style="background:#BBB;width:.6rem;height:.5rem;color:#fff;"
              @click="getTournamentPlay(items.match_id)"
            >{{items.tag}} ></div>
          </div>
          <div style="color:#666;width:70%" class="pdg20 row allAlignment item-center">
            <p>全场</p>
            <p>让盘</p>
            <p>让局</p>
            <p>局-大/小盘</p>
          </div>
        </div>
        <div class="row" style="border-bottom:.01rem solid #EDEDED;height:100%;">
          <!-- 全场 -->
          <div
            style="width:30%;height:100%;margin-left:.1rem;padding:.1rem 0;"
            class="tennisRollBall-list-name"
          >
            <p style="padding-left:0.2rem;line-height: .4rem;">
              <span style="margin-right:.1rem;background:#AFE13B;"></span>
              {{items.home_team}}
            </p>
            <p style="padding-left:0.2rem;line-height: .4rem;">
              <span style="margin-right:.1rem;background:#AFE13B;"></span>
              {{items.guest_team}}
            </p>
          </div>
          <div style="position: relative;width:70%">
            <div
              style="height:100%;"
              class="row allAlignment item-center"
              v-for="(itemList,idx) in items.full_oddsData"
              :key="itemList.id"
            >
              <!-- 独赢 -->
              <!-- <div v-if="itemList.odds_code == 'ch' || itemList.odds_code == 'cg'">
                <p
                  class="singleAndDouble-list-btn hover home dishes"
                  :class="{col:itemList.isTrue,rising:itemList.change == 'rising',falling:itemList.change == 'falling'}"
                  v-if="itemList.odds_code == 'ch'"
                  @click="selection(index,i,idx,itemList.id,itemList.p_code,items.match_id,items.home_team,items.guest_team,items.home_team,'滚球','all')"
                >{{itemList.odds}}</p>
                <p
                  class="singleAndDouble-list-btn hover guest dishes"
                  :class="{col:itemList.isTrue,rising:itemList.change == 'rising',falling:itemList.change == 'falling'}"
                  v-if="itemList.odds_code == 'cg'"
                  @click="selection(index,i,idx,itemList.id,itemList.p_code,items.match_id,items.home_team,items.guest_team,items.guest_team,'滚球','all')"
                >{{itemList.odds}}</p>
              </div> -->

              <!-- 让盘 -->
                <div v-if="itemList.odds_code.startsWith('ld')">
              
                  <div  v-if="itemList.odds_code == 'ldh'">
                    <p v-if="itemList.odds <=0" class="singleAndDouble-list-btn guest dishes">
                        <img style="vertical-align:middle" src="@/assets/st-imges/mima.png" alt="">
                    </p>
                    <div v-else>
                      <!-- <span>{{itemList.condition}}</span> -->
                      <p class="singleAndDouble-list-btn hover home dishes"
                        :class="{col:itemList.isTrue,rising:itemList.change == 'rising',falling:itemList.change == 'falling'}"
                        @click="selection(index,i,idx,itemList.id,itemList.p_code,items.match_id,items.home_team,items.guest_team,items.home_team,'滚球','all')"
                      >{{itemList.odds}}</p>
                    </div>
                  </div>
                  <div v-if="itemList.odds_code == 'ldg'">
                    <p v-if="itemList.odds<=0" class="singleAndDouble-list-btn guest dishes">
                        <img style="vertical-align:middle" src="@/assets/st-imges/mima.png" alt="">
                    </p>
                    <div v-else>
                      <!-- <span>{{itemList.condition}}</span> -->
                      <p class="singleAndDouble-list-btn hover guest dishes"
                        :class="{col:itemList.isTrue,rising:itemList.change == 'rising',falling:itemList.change == 'falling'}"
                        @click="selection(index,i,idx,itemList.id,itemList.p_code,items.match_id,items.home_team,items.guest_team,items.guest_team,'滚球','all')"
                      >{{itemList.odds}}</p>
                    </div>
                  </div>
                </div>

              <!-- 让局 -->
                <div v-if="itemList.odds_code.startsWith('lb')">
               
                
                  <div v-if="itemList.odds_code == 'lbh' ">
                    <p v-if="itemList.odds <=0" class="singleAndDouble-list-btn guest concede">
                      <img style="vertical-align:middle" src="@/assets/st-imges/mima.png" alt="">
                    </p>
                    <div v-else>
                      <p class="singleAndDouble-list-btn hover home concede"
                        :class="{col:itemList.isTrue,rising:itemList.change == 'rising',falling:itemList.change == 'falling'}"
                        @click="selection(index,i,idx,itemList.id,itemList.p_code,items.match_id,items.home_team,items.guest_team,items.home_team,'滚球','all')"
                      >{{itemList.odds}}</p>
                    </div>
                  </div>
                  <div  v-if="itemList.odds_code == 'lbg' ">
                      <p v-if="itemList.odds <=0" class="singleAndDouble-list-btn guest concede">
                      <img style="vertical-align:middle" src="@/assets/st-imges/mima.png" alt="">
                    </p>
                    <div v-else>
                      <p class="singleAndDouble-list-btn hover guest concede"
                        :class="{col:itemList.isTrue,rising:itemList.change == 'rising',falling:itemList.change == 'falling'}" 
                        @click="selection(index,i,idx,itemList.id,itemList.p_code,items.match_id,items.home_team,items.guest_team,items.guest_team,'滚球','all')"
                      >{{itemList.odds}}</p>
                    </div>
                  </div>
                </div>

              <!-- 大小 -->
                <div v-if="itemList.odds_code.startsWith('tn')">
                 
                  <div v-if="itemList.odds_code == 'tnb'">
                    <p v-if="itemList.odds <=0" class="singleAndDouble-list-btn home total">
                      <img style="vertical-align:middle" src="@/assets/st-imges/mima.png" alt="">
                    </p>
                    <div v-else>
                      <p
                        class="singleAndDouble-list-btn hover home total"
                        :class="{col:itemList.isTrue,rising:itemList.change == 'rising',falling:itemList.change == 'falling'}"
                        
                        @click="selection(index,i,idx,itemList.id,itemList.p_code,items.match_id,items.home_team,items.guest_team,items.home_team,'滚球','all')"
                      >{{itemList.odds}}</p>
                    </div>
                  </div>
            
                  <div v-if="itemList.odds_code == 'tns'">
                    <p v-if="itemList.odds <=0" class="singleAndDouble-list-btn guest total">
                        <img style="vertical-align:middle" src="@/assets/st-imges/mima.png" alt="">
                    </p>
                    <div v-else>
                      <p
                        class="singleAndDouble-list-btn hover guest total"
                        :class="{col:itemList.isTrue,rising:itemList.change == 'rising',falling:itemList.change == 'falling'}"
                      
                        @click="selection(index,i,idx,itemList.id,itemList.p_code,items.match_id,items.home_team,items.guest_team,items.guest_team,'滚球','all')"
                      >{{itemList.odds}}</p>
                    </div>
                  </div>
                </div>
              </div>
          </div>
        </div>



        <div
          class="row"
          style="border-bottom:.01rem solid #EDEDED;height:100%;"
          v-if="items.one_oddsData"
        >
          <!-- 第一局 -->
          <div
            style="width:30%;height:100%;margin-left:.1rem;padding:.1rem 0;"
            class="tennisRollBall-list-name"
          >
            <p style="color:#2D8320">第一盘</p>
            <p style="padding-left:0.2rem;line-height: .4rem;">
              <span style="margin-right:.1rem;background:#AFE13B;"></span>
              {{items.home_team}}
            </p>
            <p style="padding-left:0.2rem;line-height: .4rem;">
              <span style="margin-right:.1rem;background:#AFE13B;"></span>
              {{items.guest_team}}
            </p>
          </div>
          <div style="position: relative;width:70%">
            <div
              style="height:100%;"
              class="row allAlignment item-center"
              v-for="(itemList,idx) in items.one_oddsData"
              :key="itemList.id"
            >
              <!-- 独赢 -->
              <!-- <div v-if="itemList.odds_code == 'ch' || itemList.odds_code == 'cg'">
                <p
                  class="singleAndDouble-list-btn hover home dishes"
                  :class="{col:itemList.isTrue,rising:itemList.change == 'rising',falling:itemList.change == 'falling'}"
                  v-if="itemList.odds_code == 'ch'"
                  @click="selection(index,i,idx,itemList.id,itemList.p_code,items.match_id,items.home_team,items.guest_team,items.home_team,'滚球','all')"
                >{{itemList.odds}}</p>
                <p
                  class="singleAndDouble-list-btn hover guest dishes"
                  :class="{col:itemList.isTrue,rising:itemList.change == 'rising',falling:itemList.change == 'falling'}"
                  v-if="itemList.odds_code == 'cg'"
                  @click="selection(index,i,idx,itemList.id,itemList.p_code,items.match_id,items.home_team,items.guest_team,items.guest_team,'滚球','all')"
                >{{itemList.odds}}</p>
              </div> -->

              <!-- 让盘 -->
              <div v-if="itemList.odds_code.startsWith('ld')">
                <p
                  class="singleAndDouble-list-btn hover home dishes"
                  :class="{col:itemList.isTrue,rising:itemList.change == 'rising',falling:itemList.change == 'falling'}"
                  v-if="itemList.odds_code == 'ldh'"
                  @click="selection(index,i,idx,itemList.id,itemList.p_code,items.match_id,items.home_team,items.guest_team,items.home_team,'滚球','one')"
                >{{itemList.odds}}</p>
                <p
                  class="singleAndDouble-list-btn hover guest dishes"
                  :class="{col:itemList.isTrue,rising:itemList.change == 'rising',falling:itemList.change == 'falling'}"
                  v-if="itemList.odds_code == 'ldg'"
                  @click="selection(index,i,idx,itemList.id,itemList.p_code,items.match_id,items.home_team,items.guest_team,items.guest_team,'滚球','one')"
                >{{itemList.odds}}</p>
              </div>
              <!-- 让局 -->
              <div v-if="itemList.odds_code.startsWith('lb')">
                <p
                  class="singleAndDouble-list-btn hover home concede"
                  :class="{col:itemList.isTrue,rising:itemList.change == 'rising',falling:itemList.change == 'falling'}"
                  v-if="itemList.odds_code == 'lbh'"
                  @click="selection(index,i,idx,itemList.id,itemList.p_code,items.match_id,items.home_team,items.guest_team,items.home_team,'滚球','one')"
                >{{itemList.odds}}</p>
                <p
                  class="singleAndDouble-list-btn hover guest concede"
                  :class="{col:itemList.isTrue,rising:itemList.change == 'rising',falling:itemList.change == 'falling'}"
                  v-if="itemList.odds_code == 'lbg'"
                  @click="selection(index,i,idx,itemList.id,itemList.p_code,items.match_id,items.home_team,items.guest_team,items.guest_team,'滚球','one')"
                >{{itemList.odds}}</p>
              </div>
              <!-- 大小 -->
              <div v-if="itemList.odds_code.startsWith('tn')">
                <p
                  class="singleAndDouble-list-btn hover home total"
                  :class="{col:itemList.isTrue,rising:itemList.change == 'rising',falling:itemList.change == 'falling'}"
                  v-if="itemList.odds_code == ' tnb'"
                  @click="selection(index,i,idx,itemList.id,itemList.p_code,items.match_id,items.home_team,items.guest_team,items.home_team,'滚球','one')"
                >{{itemList.odds}}</p>
                <p
                  class="singleAndDouble-list-btn hover guest total"
                  :class="{col:itemList.isTrue,rising:itemList.change == 'rising',falling:itemList.change == 'falling'}"
                  v-if="itemList.odds_code == 'tns'"
                  @click="selection(index,i,idx,itemList.id,itemList.p_code,items.match_id,items.home_team,items.guest_team,items.guest_team,'滚球','one')"
                >{{itemList.odds}}</p>
              </div>
            </div>
          </div>
        </div>
        <div
          class="row"
          style="border-bottom:.01rem solid #EDEDED;height:100%;"
          v-if="items.two_oddsData"
        >
          <!-- 第二局 -->
          <div
            style="width:30%;height:100%;margin-left:.1rem;padding:.1rem 0;"
            class="tennisRollBall-list-name"
          >
            <p style="color:#2D8320">第二盘</p>
            <p style="padding-left:0.2rem;line-height: .4rem;">
              <span style="margin-right:.1rem;background:#AFE13B;"></span>
              {{items.home_team}}
            </p>
            <p style="padding-left:0.2rem;line-height: .4rem;">
              <span style="margin-right:.1rem;background:#AFE13B;"></span>
              {{items.guest_team}}
            </p>
          </div>
          <div style="position: relative;width:70%">
            <div
              style="height:100%;"
              class="row allAlignment item-center"
              v-for="(itemList,idx) in items.two_oddsData"
              :key="itemList.id"
            >
                 <!-- 独赢 -->
              <!-- <div v-if="itemList.odds_code == 'ch' || itemList.odds_code == 'cg'">
                <p
                  class="singleAndDouble-list-btn hover home dishes"
                  :class="{col:itemList.isTrue,rising:itemList.change == 'rising',falling:itemList.change == 'falling'}"
                  v-if="itemList.odds_code == 'ch'"
                  @click="selection(index,i,idx,itemList.id,itemList.p_code,items.match_id,items.home_team,items.guest_team,items.home_team,'滚球','all')"
                >{{itemList.odds}}</p>
                <p
                  class="singleAndDouble-list-btn hover guest dishes"
                  :class="{col:itemList.isTrue,rising:itemList.change == 'rising',falling:itemList.change == 'falling'}"
                  v-if="itemList.odds_code == 'cg'"
                  @click="selection(index,i,idx,itemList.id,itemList.p_code,items.match_id,items.home_team,items.guest_team,items.guest_team,'滚球','all')"
                >{{itemList.odds}}</p>
              </div> -->

              <!-- 让盘 -->
              <div v-if="itemList.odds_code.startsWith('ld')">
                <p
                  class="singleAndDouble-list-btn hover home dishes"
                  :class="{col:itemList.isTrue,rising:itemList.change == 'rising',falling:itemList.change == 'falling'}"
                  v-if="itemList.odds_code == 'ldh'"
                  @click="selection(index,i,idx,itemList.id,itemList.p_code,items.match_id,items.home_team,items.guest_team,items.home_team,'滚球','two')"
                >{{itemList.odds}}</p>
                <p
                  class="singleAndDouble-list-btn hover guest dishes"
                  :class="{col:itemList.isTrue,rising:itemList.change == 'rising',falling:itemList.change == 'falling'}"
                  v-if="itemList.odds_code == 'ldg'"
                  @click="selection(index,i,idx,itemList.id,itemList.p_code,items.match_id,items.home_team,items.guest_team,items.guest_team,'滚球','two')"
                >{{itemList.odds}}</p>
              </div>
              <!-- 让局 -->
              <div v-if="itemList.odds_code.startsWith('lb')">
                <p
                  class="singleAndDouble-list-btn hover home concede"
                  :class="{col:itemList.isTrue,rising:itemList.change == 'rising',falling:itemList.change == 'falling'}"
                  v-if="itemList.odds_code == 'ldh'"
                  @click="selection(index,i,idx,itemList.id,itemList.p_code,items.match_id,items.home_team,items.guest_team,items.home_team,'滚球','two')"
                >{{itemList.odds}}</p>
                <p
                  class="singleAndDouble-list-btn hover guest concede"
                  :class="{col:itemList.isTrue,rising:itemList.change == 'rising',falling:itemList.change == 'falling'}"
                  v-if="itemList.odds_code == 'ldh'"
                  @click="selection(index,i,idx,itemList.id,itemList.p_code,items.match_id,items.home_team,items.guest_team,items.guest_team,'滚球','two')"
                >{{itemList.odds}}</p>
              </div>
              <!-- 大小 -->
              <div v-if="itemList.odds_code.startsWith('tn')">
                <p
                  class="singleAndDouble-list-btn hover home total"
                  :class="{col:itemList.isTrue,rising:itemList.change == 'rising',falling:itemList.change == 'falling'}"
                  v-if="itemList.odds_code == 'tnb'"
                  @click="selection(index,i,idx,itemList.id,itemList.p_code,items.match_id,items.home_team,items.guest_team,items.home_team,'滚球','two')"
                >{{itemList.odds}}</p>
                <p
                  class="singleAndDouble-list-btn hover guest total"
                  :class="{col:itemList.isTrue,rising:itemList.change == 'rising',falling:itemList.change == 'falling'}"
                  v-if="itemList.odds_code == 'tns'"
                  @click="selection(index,i,idx,itemList.id,itemList.p_code,items.match_id,items.home_team,items.guest_team,items.guest_team,'滚球','two')"
                >{{itemList.odds}}</p>
              </div>
            </div>
          </div>
        </div>
        <div v-if="items.result_mark" style="height:.5rem;" class="row item-center pdg20 allAlignment">
          <div style="font-size:.14rem; color:#666;" class="tennisRollBall-list-footer-num">
            <span :class="{chageColor :items.result_mark.schedule[items.result_mark.schedule.length-1] == 1}" >{{items.result_mark.sc_1th_H}}-{{items.result_mark.sc_1th_C}}</span>
            <span :class="{chageColor :items.result_mark.schedule[items.result_mark.schedule.length-1]== 2 }" >{{items.result_mark.sc_2th_H}}-{{items.result_mark.sc_2th_C}}</span>
            <span :class="{chageColor :items.result_mark.schedule[items.result_mark.schedule.length-1]== 3 }" >{{items.result_mark.sc_3th_H}}-{{items.result_mark.sc_3th_C}}</span>
            <span :class="{chageColor :items.result_mark.schedule[items.result_mark.schedule.length-1]== 4 }" v-if="items.result_mark.best == 5" style="color:#F76649">{{items.result_mark.sc_4th_H}}-{{items.result_mark.sc_4th_C}}</span>
            <span :class="{chageColor :items.result_mark.schedule[items.result_mark.schedule.length-1]== 5 }" v-if="items.result_mark.best == 5" style="color:#F76649">{{items.result_mark.c_5th_H}}-{{items.result_mark.sc_5th_C}}</span>
          </div>
          <div style="color:#666;">
            <span v-if="items.result_mark.best == 3">三盘两胜</span>
            <span v-else="items.result_mark.best == 5">五盘三胜</span>
            |
            <span>总局数</span>
            <span style="color:#F76649">{{items.result_mark.game_num_H}} - {{items.result_mark.game_num_C}}({{items.result_mark.game_num_H*1 + items.result_mark.game_num_C*1}})</span>
          </div>
        </div>
      </div>
    </div>
    <div v-if="noData">
      <noData />
    </div>
  </div>
</template>

<script>
import noData from "@/components/noData";
export default {
  name: "tennisRollBall",
  components: {
    noData
  },
  data() {
    return {
      serchTxt: "",
      pCode: this.$store.getters.getPaly_code,
      activity: this.$store.getters.getActivity, //传入接口的值
      ballCode: this.$store.getters.getBallCode,
      noData: false, //暂无数据显示
      timers: true, //轮询开关
      lg_id: "", //联赛
      data: [],
      limit: "" //投注数据长度
    };
  },
  /**
   * 组件内函数方法
   */
  methods: {
    getTournamentPlay(match_id) {
      this.$store.dispatch("MACTH_ID", match_id);
      this.$store.dispatch("SET_CONTROLROUTING", 10014);
    },
    getAjax(lg_id, search) {
      if (this.$store.getters.getActivity == "StStringScene") {
        this.$store.dispatch("SET_BETTINGTYPE", 2);
      } else {
        this.$store.dispatch("SET_BETTINGTYPE", 1);
      }
      this.$http
        .get(this.$ports.home.gameList, {
          type: this.activity,
          game_code: this.ballCode,
          lg_id,                                        //需要拷贝
          search
        })
        .then(res => {
          // console.log('res',res)
          if (res.data.data.length > 0 && res.data.status == 1) {
            this.data = res.data.data[0];
            //console.log('滚球数据',this.data);
            this.noData = false;
            this.dataJosn(this.data);
            this.dataGroup(this.data);
          } else {
            this.noData = true;
            this.noShow = false;
          }
          this.$store.dispatch("GETLOADING", false);
        });
    },
    //
    dataJosn(data){
      data.forEach(e=>{
        e.matchData.forEach(res=>{
          res.result_mark  = JSON.parse(res.result_mark);
          console.log(res.result_mark)
        })
      })
    },
    // 轮询之后添加数据选中效果
    dataGroup(data) {
      let betting = this.$store.getters.getBetting;
      if (betting != null && betting.length > 0) {
        data.forEach(e => {
          e.matchData.forEach(k => {
            if (
              k.full_oddsData != null &&
              k.full_oddsData != undefined &&
              k.full_oddsData.length > 0
            ) {
              k.full_oddsData.forEach(item => {
                betting.forEach(i => {
                  i.data.forEach(j => {
                    if (item.mark == j.mark) {
                      item.isTrue = true;
                    }
                  });
                });
              });
            }
            if (
              k.one_oddsData != null &&
              k.one_oddsData != undefined &&
              k.one_oddsData.length > 0
            ) {
              k.one_oddsData.forEach(item => {
                betting.forEach(i => {
                  i.data.forEach(j => {
                    if (item.mark == j.mark) {
                      item.isTrue = true;
                    }
                  });
                });
              });
            }
            if (
              k.two_oddsData != null &&
              k.two_oddsData != undefined &&
              k.two_oddsData.length > 0
            ) {
              k.two_oddsData.forEach(item => {
                betting.forEach(i => {
                  i.data.forEach(j => {
                    if (item.mark == j.mark) {
                      item.isTrue = true;
                    }
                  });
                });
              });
            }
          });
        });
      }
    },
    //
    /**
     * 处理选中样式
     * index data下标
     * i 第二层下标
     * id 玩法ID
     * status all 为全场 one 为第一场 two 为第二场
     */
    selChange(index, i, mark, status) {
      if (this.limit < 10) {
        if (status == "all") {
          this.data[index].matchData[i].full_oddsData.forEach(res => {
            if (res.mark == mark) {
              this.$forceUpdate();
              this.$set(res, "isTrue", res.isTrue ? false : true);
            }
          });
        } else if (status == "one") {
          this.data[index].matchData[i].one_oddsData.forEach(res => {
            if (res.mark == mark) {
              this.$forceUpdate();
              this.$set(res, "isTrue", res.isTrue ? false : true);
            }
          });
        } else if (status == "two") {
          this.data[index].matchData[i].two_oddsData.forEach(res => {
            if (res.mark == mark) {
              this.$forceUpdate();
              this.$set(res, "isTrue", res.isTrue ? false : true);
            }
          });
        }
      } else {
        if (status == "all") {
          this.data[index].matchData[i].full_oddsData.forEach(item => {
            if (item.mark == mark) {
              this.$set(item, "isTrue", false);
            }
          });
        } else if (status == "one") {
          this.data[index].matchData[i].one_oddsData.forEach(item => {
            if (item.mark == mark) {
              this.$set(item, "isTrue", false);
            }
          });
        } else if (status == "two") {
          this.data[index].matchData[i].two_oddsData.forEach(item => {
            if (item.mark == mark) {
              this.$set(item, "isTrue", false);
            }
          });
        }
      }
    },

    



    // 选中添加投注数据
    selection(
      index,
      i,
      idx,
      id,
      p_code,
      match_id,
      homeName,
      guestName,
      name,
      playName,
      status
    ) {
      // console.log(idx,i,index,id,p_code,match_id,homeName,guestName,name,playName,status)
      let ballId = this.$store.getters.getBallCode;
      let acty = this.$store.getters.getActivity;
      let betting = this.$store.getters.getBetting;
      let data = this.data;
      let isAre = true;
      let isAdd = true,
        isAlert = false;
      let obj = {
        title: p_code,
        data: ""
      };
      let mark ;
      let process  = data[index].matchData[i].match_process;
      let newProcess =  process.substr(process.length-1,1)
      let processData =  newProcess == 1 ?'第一盘':newProcess == 2 ? "第二盘" : newProcess == 3 ? "第三盘" :newProcess == 4? '第四盘':'第五盘'  ;
      if (status == "all") {
        data[index].matchData[i].full_oddsData[idx].home_team = homeName;
        data[index].matchData[i].full_oddsData[idx].guest_team = guestName;
        data[index].matchData[i].full_oddsData[idx].playName = playName;
        data[index].matchData[i].full_oddsData[idx].name = name;
        data[index].matchData[i].full_oddsData[idx].ballId = ballId;
        data[index].matchData[i].full_oddsData[idx].home_score = data[index].matchData[i].home_player_score;
        data[index].matchData[i].full_oddsData[idx].guest_score = data[index].matchData[i].guest_player_score;
        data[index].matchData[i].full_oddsData[idx].roll_time = processData;
        obj.data = [this.data[index].matchData[i].full_oddsData[idx]];
        mark = data[index].matchData[i].full_oddsData[idx].mark;
      } else if (status == "one") {
        data[index].matchData[i].one_oddsData[idx].home_team = homeName;
        data[index].matchData[i].one_oddsData[idx].guest_team = guestName;
        data[index].matchData[i].one_oddsData[idx].playName = playName;
        data[index].matchData[i].one_oddsData[idx].name = name;
        data[index].matchData[i].one_oddsData[idx].ballId = ballId;
        data[index].matchData[i].one_oddsData[idx].home_score = data[index].matchData[i].home_player_score;
        data[index].matchData[i].one_oddsData[idx].guest_score = data[index].matchData[i].guest_player_score;
        data[index].matchData[i].one_oddsData[idx].roll_time = processData;
        obj.data = [this.data[index].matchData[i].one_oddsData[idx]];
        mark = data[index].matchData[i].full_oddsData[idx].mark;
      } else if (status == "two") {
        data[index].matchData[i].two_oddsData[idx].home_team = homeName;
        data[index].matchData[i].two_oddsData[idx].guest_team = guestName;
        data[index].matchData[i].two_oddsData[idx].playName = playName;
        data[index].matchData[i].two_oddsData[idx].name = name;
        data[index].matchData[i].two_oddsData[idx].ballId = ballId;
        data[index].matchData[i].two_oddsData[idx].home_score = data[index].matchData[i].home_player_score;
        data[index].matchData[i].two_oddsData[idx].guest_score = data[index].matchData[i].guest_player_score;
        data[index].matchData[i].two_oddsData[idx].roll_time = processData;
        obj.data = [this.data[index].matchData[i].two_oddsData[idx]];
        mark = data[index].matchData[i].full_oddsData[idx].mark;
      }
      
      console.log(obj)
      if (betting.length > 0) {
        betting.forEach(e => {
          if (e.title == p_code) {
            e.data.forEach((res, num) => {
              if (res.mark == mark) {
                e.data.splice(num, 1);
                isAdd = false;
              }
            });
            if (isAdd) {
              if (this.limit >= 10) {
                this.$dialog.toast({
                  mes: "亲，超出表格上限啦。",
                  timeout: 2000
                });
              } else {
                if (status == "all") {
                  e.data.push(this.data[index].matchData[i].full_oddsData[idx]);
                } else if (status == "one") {
                  e.data.push(this.data[index].matchData[i].one_oddsData[idx]);
                } else if (status == "two") {
                  e.data.push(this.data[index].matchData[i].two_oddsData[idx]);
                }
              }
            }
            isAre = false;
          }
        });
        if (isAre) {
          if (this.limit >= 10) {
            this.$dialog.toast({ mes: "亲，超出表格上限啦。", timeout: 2000 });
          } else {
            betting.push(obj);
          }
        }
      } else {
        betting.push(obj);
      }
      this.selChange(index, i, mark, status);
      this.$store.dispatch("SET_BETTING", []);
      this.$store.dispatch("SET_BETTING", betting);
      // console.log(this.$store.getters.getBetting)

      // }
      // else{

      // this.$dialog.toast({ mes: "亲，超出表格上限啦。", timeout: 2000 });
      // }
    },
    //搜索按钮被点击
    Serch() {
        this.data = [];
        this.$store.dispatch("SET_LEAGUEDATA",[]); //需要拷贝
        this.getAjax("", this.serchTxt); //需要拷贝
    },
    // 删除搜索框内容
    clearSerchTxt() {
      if (this.serchTxt != "") {
        this.data = [];
        this.serchTxt = "";
        this.$store.dispatch("SET_LEAGUEDATA", []); //需要拷贝
        this.getAjax();
      }
    },
    // 刷新
    red() {
      this.$store.dispatch("SET_LEAGUEDATA", []); //需要拷贝
      if (this.serchTxt.length > 0) {
        this.Serch();
      } else {
        this.data = "";
        this.getAjax();
      }
    },
    //跳转到联赛选择页
    elasticFrame() {
      this.$store.dispatch("SET_CONTROLROUTING", 10014);
    }
  },
  mounted() {
    this.$store.dispatch("SET_BETTING", []);
    //获取选择的联赛id
    if (this.$store.getters.getLeagueData.length > 0) {
      if (this.$store.getters.getLeagueData.length == 1) {
        this.lg_id = this.$store.getters.getLeagueData[0];
      } else {
        this.lg_id = this.$store.getters.getLeagueData.join(",");
      }
    }

    this.getAjax(this.lg_id);
    let _this = this;
    this.$public.ajaxTimerFun(timing => {
      if (_this.timers) {
        _this.getAjax(_this.lg_id, _this.serchTxt);
      } else {
        clearInterval(timing);
      }
    });
  },
  computed: {
    getActy() {
      return this.$store.getters.getActivity;
    },
    // 单个删除
    getDeleteType() {
      return this.$store.getters.getDeleteType;
    },
    // 获取投注数量
    getLimit() {
      return this.$store.getters.getLimit;
    }
  },
  watch: {
    getActy(val) {
      // this.activity = val;
      this.getAJAX();
      this.$store.dispatch("SET_BETTING", []);
    },
    getDeleteType(val) {
      let jumpOut = false;
      for (var i = 0; i < this.data.length; i++) {
        for (var k = 0; k < this.data[i].matchData.length; k++) {
          if (
            this.data[i].matchData[k].one_oddsData &&
            this.data[i].matchData[k].one_oddsData.length > 0
          ) {
            for (
              var j = 0;
              j < this.data[i].matchData[k].one_oddsData.length;
              j++
            ) {
              if (this.data[i].matchData[k].one_oddsData[j].mark == val) {
                this.$forceUpdate();
                this.data[i].matchData[k].one_oddsData[j].isTrue = false;
                jumpOut = true;
                break;
              }
            }
          }

          for (
            var j = 0;
            j < this.data[i].matchData[k].full_oddsData.length;
            j++
          ) {
            if (this.data[i].matchData[k].full_oddsData[j].mark == val) {
              this.$forceUpdate();
              this.data[i].matchData[k].full_oddsData[j].isTrue = false;
              jumpOut = true;
              break;
            }
          }
          if (
            this.data[i].matchData[k].two_oddsData &&
            this.data[i].matchData[k].two_oddsData.length > 0
          ) {
            for (
              var j = 0;
              j < this.data[i].matchData[k].two_oddsData.length;
              j++
            ) {
              if (this.data[i].matchData[k].two_oddsData[j].mark == val) {
                this.$forceUpdate();
                this.data[i].matchData[k].two_oddsData[j].isTrue = false;
                jumpOut = true;
                break;
              }
            }
          }
          if (jumpOut == true) {
            break;
          }
        }
        if (jumpOut == true) {
          break;
        }
      }
    },
    getLimit(val) {
      // console.log("val", val);
      this.limit = val;
      if (val == 0) {
        this.data.forEach(e => {
          e.matchData.forEach(k => {
            if (
              k.full_oddsData != null &&
              k.full_oddsData != undefined &&
              k.full_oddsData.length > 0
            ) {
              k.full_oddsData.forEach(item => {
                this.$forceUpdate();
                item.isTrue = false;
              });
            }
            if (
              k.one_oddsData != null &&
              k.one_oddsData != undefined &&
              k.one_oddsData.length > 0
            ) {
              k.one_oddsData.forEach(item => {
                this.$forceUpdate();
                item.isTrue = false;
              });
            }
            if (
              k.two_oddsData != null &&
              k.two_oddsData != undefined &&
              k.two_oddsData.length > 0
            ) {
              k.two_oddsData.forEach(item => {
                this.$forceUpdate();
                item.isTrue = false;
              });
            }
          });
        });
      }
    }
  },
  beforeDestroy() {
    this.timers = false;
  }
};
</script>

<style scoped>
.pdg20 {
  padding: 0 0.2rem;
}
.tennisRollBall-title {
  height: 0.5rem;
  color: #fff;
  background: #aaa;
}
.tennisRollBall-title-list {
  background: #fff;
  font-size: 0.14rem;
}
.tennisRollBall-title-list-title {
  height: 0.5rem;
  background: #e5e5e5;
  color: #666;
  cursor: pointer;
}
.tennisRollBall-title-list-title-num::after {
  border-width: 0.05rem;
  border-left-color: #e5e5e5;
  border-top-color: #e5e5e5;
  left: 42%;
  bottom: -0.05rem;
  transform: rotate(45deg);
}

.serch {
  width: 100%;
  height: 0.5rem;
  background: #aaa;
  padding: 0 0.2rem;
}
input {
  border: none;
  background: #efefef;
  padding-left: 0.2rem;
  width: 4.6rem;
  height: 0.3rem;
  border-radius: 0.05rem 0 0 0.05rem;
}
.serch-img {
  width: 0.5rem;
  height: 0.3rem;
  background: #666;
  border-radius: 0 0.05rem 0.05rem 0;
  margin-right: 0.3rem;
}
.all {
  width: 1.2rem;
  height: 0.3rem;
  background: #ddd;
  color: #333;
}
.chageColor{
  color:#f76649 !important;
}
.clear {
  width: 0.6rem;
  height: 0.3rem;
  background: #666;
  color: #ccc;
  margin-right: 0.1rem;
}
.redraw {
  width: 0.3rem;
  height: 0.3rem;
  background: #666;
}
img {
  width: 0.2rem;
  height: 0.2rem;
}
.br05 {
  border-radius: 0.05rem;
}
.fz14 {
  font-size: 0.14rem;
}
.hover:hover {
  background: #bbb;
  color: #fff;
}
.pointer {
  cursor: pointer;
}
.tennisRollBall-list-name p {
  width: 100%;
}
.tennisRollBall-list-name p span {
  display: inline-block;
  width: 0.08rem;
  height: 0.08rem;
  border-radius: 50%;
}
.right-img {
  width: 0.15rem;
  position: absolute;
  right: 0rem;
  bottom: 0.1rem;
}
.right-img img {
  width: 0.22rem;
  height: 0.2rem;
}
.singleAndDouble-list-btn {
  width: 0.48rem;
  height: 0.3rem;
  border: 0.01rem solid #ccc;
  line-height: 0.3rem;
  text-align: center;
  border-radius: 0.05rem;
  cursor: pointer;
}
.tennisRollBall-list-footer-num span {
  margin-right: 0.1rem;
}
.hover:hover {
  background: #bbb;
  color: #fff;
}
.home {
  position: absolute;
  bottom: 55%;
}
.guest {
  position: absolute;
  bottom: 12%;
}
.dishes {
  left: 28%;
}
.concede {
  left: 55%;
}
.total {
  left: 85%;
}
.col {
  border-radius: 2px;
  background: #f76649;
  color: #fff;
}
</style>