| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286 |
- <template>
- <div class="sports">
- <div class="title">
- <span style="font-size:.3rem;color:#fff; font-weight: bold;">体育</span>
- <i></i>
- </div>
- <div class="box-active row average item-center">
- <div class="row center" :class="{active:issurvey==true}" @click="survey(true)">显示</div>
- <div class="row center" :class="{active:issurvey==false}" @click="survey(false)">即将开赛</div>
- </div>
- <!-- 显示 -->
- <div v-if="issurvey" v-for="(item,idx) in list" class="sportName" :key="item.id">
- <!-- <div v-for="item in list" class="sportName" :key="item.id" v-if="list[0].match.length != 0"> -->
- <!-- <div class="sportName" v-if="list.match.length != 0"> -->
- <!-- <h3>{{item.title}}</h3> -->
- <h3 class="row item-center allAlignment">
- {{item.name}}
- <img v-if="list.name=='足球'" src="../assets/st-imges/footballimg.png">
- <img v-if="list.name=='篮球'" src="../assets/st-imges/basketballimg.png">
- <img v-if="list.name=='棒球'" src="../assets/st-imges/baseballimg.png">
- <img v-if="list.name=='网球'" src="../assets/st-imges/tennisimg.png">
- </h3>
- <div
- class="list"
- v-for="(items,index) in item.match"
- :key="index"
- @click="leagueBetting(item.game_code,item.name,items.match_id)"
- >
- <div class="teamName">
- <span>{{items.home_team}}</span>
- <div>vs</div>
- <span>{{items.guest_team}}</span>
- </div>
- <div class="timer">
- <span>{{items.match_date}}</span>
- <div>
- <i :style="field"></i>
- </div>
- <span>{{items.match_time}}</span>
- </div>
- </div>
- <rollingBall
- :ballName="item.all.name"
- :index="item.all.count"
- :bm ='bm'
- :today ='today'
- :name='item.name'
- :code ="item.all.code"
- :gameCode='item.game_code'
- style="margin-top:0.47rem;margin-bottom:0.16rem;"
- ></rollingBall>
- <div v-for=" item_a in item.league" :key="item_a.id">
- <rollingBall :ballName="item_a.name_chinese" :homeShow='homeShow' :name='item.name' :code ="item_a.code" :bm ='bm' :gameCode='item.game_code' :lgId ='item_a.lg_id' :index="item_a.count" style="margin-bottom:0.16rem;"></rollingBall>
- </div>
- </div>
- <!-- 即将开赛 -->
- <div v-if="!issurvey" v-for="item in list" :key="item.id" class="sportName">
- <!-- <div v-for="item in list" class="sportName" :key="item.id" v-if="item.match.length != 0"> -->
- <!-- <div class="sportName" v-if="list.match.length != 0"> -->
- <!-- <h3>{{item.title}}</h3> -->
- <h3 class="row item-center allAlignment">{{item.gameName}}</h3>
- <div
- class="list"
- v-for="(items,index) in item.matchData"
- :key="index"
- @click="leagueBetting(item.gameCode,item.gameName,items.match_id)"
- >
- <div class="teamName">
- <span>{{items.home_team}}</span>
- <div>vs</div>
- <span>{{items.guest_team}}</span>
- </div>
- <div class="timer minute">
- <span>{{items.wait_time}}分钟</span>
- </div>
- </div>
- <rollingBall
- :ballName="issurvey?ball.name:'所有' + item.gameName + '即将开赛' "
- :index="issurvey?ball.index:item.matchNum"
- :bm ='bm'
- style="margin-top:0.47rem;margin-bottom:0.16rem;"
- ></rollingBall>
- <!-- <div v-for=" item_a in list.league" :key="item_a.id">
- <rollingBall :ballName="item_a.name" :index="item_a.count" style="margin-bottom:0.16rem;"></rollingBall>
- </div>-->
- </div>
- </div>
- </template>
- <script>
- import rollingBall from "@/components/StRollingBall";
- import "../css/index.css";
- export default {
- name:'StSports',
- data() {
- return {
- issurvey: true,
- bm:'ty',
- homeShow:'0', //区分显示与即将开赛的btn
- field: {
- backgroundImage:
- "url(" + require("../assets/st-imges/stadium.png") + ")",
- backgroundRepeat: "no-repeat",
- backgroundSize: "100% 100%"
- },
- list: "",
- ball: {
- name: "今日",
- index: 0
- },
- matchNum: "", //btn数量
- gameCode: "", //传入betting的值
- timers:true,
- today : '1',
- getIsShow:true,
- };
- },
- methods: {
- // leagueBetting: function(pId, id) {
- // this.$router.push({ path: "/StBallBettingPage", query: { pId, id } });
- // }
- leagueBetting: function(game_code,name, id) {
- this.$store.dispatch("GETACTIVITY", '')
- //console.log(game_code,id);
- this.$router.push({
- path: "/StRollBallBettingPage",
- query: { gameCode:game_code,name:name}
- });
- this.$store.dispatch("MACTH_ID", id);
-
- },
- // 体育概览激活样式
- survey(val) {
- this.issurvey = val;
- },
- getAjax(url) {
- //this.$store.dispatch("GETSHOW", true);
- this.$http.get(url).then(res => {
- if (res.data.status == 1 && res.data != [] && res.data != null) {
- //console.log('sports',res.data.data)
- if (this.issurvey == true) {
- this.list = res.data.data;
- //console.log("体育", this.list);
- this.list.forEach(res => {
- res.league.forEach(val => {
- this.ball.index += Number(val.count);
- });
- });
- } else {
- let arr = Object.values(res.data.data);
- this.list = arr;
- //console.log('thisList',this.list)
- }
- }
- let _this=this;
- setTimeout(()=>{
- _this.$store.dispatch('GETSHOW',false);
- },1000)
- });
- }
- },
- components: { rollingBall },
- mounted() {
- if (this.getIsShow) {
- this.$store.dispatch("GETSHOW", true);
- this.getIsShow = false;
- }
- let _this =this;
- this.$public.ajaxTimerFun(function(timing){
- if (_this.timers){
- if(_this.issurvey == true){
-
- _this.getAjax(_this.$ports.home.sports);
- }else{
- _this.getAjax(_this.$ports.home.getSon);
- }
- }else{
- clearInterval(timing);
- }
- },(1000*10))
- this.getAjax(this.$ports.home.sports);
- },
- computed: {
- getInfo: function() {
- return this.issurvey;
- }
- },
- watch: {
- getInfo(val) {
- this.$store.dispatch('GETSHOW',true)
- // 切换数据置空,不是会报错。。。。
- this.list = '';
- if (val == true) {
- this.getAjax(this.$ports.home.sports);
- } else {
- this.getAjax(this.$ports.home.getSon);
- }
- }
- },
- beforeDestroy(){
- this.timers = false;
- }
- };
- </script>
- <style scoped>
- .box-active {
- height: 1.1rem;
- }
- .box-active div {
- width: 1.84rem;
- height: 0.68rem;
- background: #a0a0a0;
- color: #dcdcdc;
- font-size: 0.28rem;
- border-radius: 8px;
- }
- .box-active div.active {
- background: #dcdcdc;
- color: #363636;
- }
- .sports {
- background: #f8f8f8;
- /* padding: 0.28rem 0.3rem 0.34rem 0.45rem; */
- text-align: left;
- /* padding-bottom: 0.68rem; */
- }
- .sports .title {
- color: #000000;
- font-size: 0.32rem;
- display: flex;
- background: #a0a0a0;
- height: 0.88rem;
- line-height: 0.88rem;
- padding: 0 0.32rem 0;
- justify-content: space-between;
- }
- .sportName {
- padding: 0.1rem 0rem 0.4rem;
- background: #f8f8f8;
- width: 92%;
- margin: 0 auto;
- border-bottom: 1px solid #dfdfdf;
- }
- .sportName h3 {
- color: #f76649;
- font-size: 0.28rem;
- font-weight: 400;
- margin-bottom: 0.25rem;
- }
- .sportName h3 img {
- width: 0.44rem;
- height: 0.44rem;
- margin-right: 0.3rem;
- }
- .sportName .list {
- background: #dcdcdc;
- border-radius: 0.08rem;
- padding: 0.28rem 0.5rem 0.28rem 0.3rem;
- display: flex;
- justify-content: space-between;
- margin-bottom: 0.2rem;
- }
- .sportName .list .teamName {
- font-size: 0.28rem;
- color: #333333;
- max-width: 50%;
- }
- .sportName .list .teamName div {
- margin: 0.05rem 0;
- }
- .sportName .timer {
- text-align: center;
- display: flex;
- flex-direction: column;
- justify-content: space-between;
- }
- .sportName .minute {
- align-items: center;
- flex-direction: row;
- }
- .timer div i {
- display: inline-block;
- width: 0.34rem;
- height: 0.24rem;
- }
- </style>
|