c969ac48245cb7b81ec3de2d1a7546ab61bfeb39.svn-base 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286
  1. <template>
  2. <div class="sports">
  3. <div class="title">
  4. <span style="font-size:.3rem;color:#fff; font-weight: bold;">体育</span>
  5. <i></i>
  6. </div>
  7. <div class="box-active row average item-center">
  8. <div class="row center" :class="{active:issurvey==true}" @click="survey(true)">显示</div>
  9. <div class="row center" :class="{active:issurvey==false}" @click="survey(false)">即将开赛</div>
  10. </div>
  11. <!-- 显示 -->
  12. <div v-if="issurvey" v-for="(item,idx) in list" class="sportName" :key="item.id">
  13. <!-- <div v-for="item in list" class="sportName" :key="item.id" v-if="list[0].match.length != 0"> -->
  14. <!-- <div class="sportName" v-if="list.match.length != 0"> -->
  15. <!-- <h3>{{item.title}}</h3> -->
  16. <h3 class="row item-center allAlignment">
  17. {{item.name}}
  18. <img v-if="list.name=='足球'" src="../assets/st-imges/footballimg.png">
  19. <img v-if="list.name=='篮球'" src="../assets/st-imges/basketballimg.png">
  20. <img v-if="list.name=='棒球'" src="../assets/st-imges/baseballimg.png">
  21. <img v-if="list.name=='网球'" src="../assets/st-imges/tennisimg.png">
  22. </h3>
  23. <div
  24. class="list"
  25. v-for="(items,index) in item.match"
  26. :key="index"
  27. @click="leagueBetting(item.game_code,item.name,items.match_id)"
  28. >
  29. <div class="teamName">
  30. <span>{{items.home_team}}</span>
  31. <div>vs</div>
  32. <span>{{items.guest_team}}</span>
  33. </div>
  34. <div class="timer">
  35. <span>{{items.match_date}}</span>
  36. <div>
  37. <i :style="field"></i>
  38. </div>
  39. <span>{{items.match_time}}</span>
  40. </div>
  41. </div>
  42. <rollingBall
  43. :ballName="item.all.name"
  44. :index="item.all.count"
  45. :bm ='bm'
  46. :today ='today'
  47. :name='item.name'
  48. :code ="item.all.code"
  49. :gameCode='item.game_code'
  50. style="margin-top:0.47rem;margin-bottom:0.16rem;"
  51. ></rollingBall>
  52. <div v-for=" item_a in item.league" :key="item_a.id">
  53. <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>
  54. </div>
  55. </div>
  56. <!-- 即将开赛 -->
  57. <div v-if="!issurvey" v-for="item in list" :key="item.id" class="sportName">
  58. <!-- <div v-for="item in list" class="sportName" :key="item.id" v-if="item.match.length != 0"> -->
  59. <!-- <div class="sportName" v-if="list.match.length != 0"> -->
  60. <!-- <h3>{{item.title}}</h3> -->
  61. <h3 class="row item-center allAlignment">{{item.gameName}}</h3>
  62. <div
  63. class="list"
  64. v-for="(items,index) in item.matchData"
  65. :key="index"
  66. @click="leagueBetting(item.gameCode,item.gameName,items.match_id)"
  67. >
  68. <div class="teamName">
  69. <span>{{items.home_team}}</span>
  70. <div>vs</div>
  71. <span>{{items.guest_team}}</span>
  72. </div>
  73. <div class="timer minute">
  74. <span>{{items.wait_time}}分钟</span>
  75. </div>
  76. </div>
  77. <rollingBall
  78. :ballName="issurvey?ball.name:'所有' + item.gameName + '即将开赛' "
  79. :index="issurvey?ball.index:item.matchNum"
  80. :bm ='bm'
  81. style="margin-top:0.47rem;margin-bottom:0.16rem;"
  82. ></rollingBall>
  83. <!-- <div v-for=" item_a in list.league" :key="item_a.id">
  84. <rollingBall :ballName="item_a.name" :index="item_a.count" style="margin-bottom:0.16rem;"></rollingBall>
  85. </div>-->
  86. </div>
  87. </div>
  88. </template>
  89. <script>
  90. import rollingBall from "@/components/StRollingBall";
  91. import "../css/index.css";
  92. export default {
  93. name:'StSports',
  94. data() {
  95. return {
  96. issurvey: true,
  97. bm:'ty',
  98. homeShow:'0', //区分显示与即将开赛的btn
  99. field: {
  100. backgroundImage:
  101. "url(" + require("../assets/st-imges/stadium.png") + ")",
  102. backgroundRepeat: "no-repeat",
  103. backgroundSize: "100% 100%"
  104. },
  105. list: "",
  106. ball: {
  107. name: "今日",
  108. index: 0
  109. },
  110. matchNum: "", //btn数量
  111. gameCode: "", //传入betting的值
  112. timers:true,
  113. today : '1',
  114. getIsShow:true,
  115. };
  116. },
  117. methods: {
  118. // leagueBetting: function(pId, id) {
  119. // this.$router.push({ path: "/StBallBettingPage", query: { pId, id } });
  120. // }
  121. leagueBetting: function(game_code,name, id) {
  122. this.$store.dispatch("GETACTIVITY", '')
  123. //console.log(game_code,id);
  124. this.$router.push({
  125. path: "/StRollBallBettingPage",
  126. query: { gameCode:game_code,name:name}
  127. });
  128. this.$store.dispatch("MACTH_ID", id);
  129. },
  130. // 体育概览激活样式
  131. survey(val) {
  132. this.issurvey = val;
  133. },
  134. getAjax(url) {
  135. //this.$store.dispatch("GETSHOW", true);
  136. this.$http.get(url).then(res => {
  137. if (res.data.status == 1 && res.data != [] && res.data != null) {
  138. //console.log('sports',res.data.data)
  139. if (this.issurvey == true) {
  140. this.list = res.data.data;
  141. //console.log("体育", this.list);
  142. this.list.forEach(res => {
  143. res.league.forEach(val => {
  144. this.ball.index += Number(val.count);
  145. });
  146. });
  147. } else {
  148. let arr = Object.values(res.data.data);
  149. this.list = arr;
  150. //console.log('thisList',this.list)
  151. }
  152. }
  153. let _this=this;
  154. setTimeout(()=>{
  155. _this.$store.dispatch('GETSHOW',false);
  156. },1000)
  157. });
  158. }
  159. },
  160. components: { rollingBall },
  161. mounted() {
  162. if (this.getIsShow) {
  163. this.$store.dispatch("GETSHOW", true);
  164. this.getIsShow = false;
  165. }
  166. let _this =this;
  167. this.$public.ajaxTimerFun(function(timing){
  168. if (_this.timers){
  169. if(_this.issurvey == true){
  170. _this.getAjax(_this.$ports.home.sports);
  171. }else{
  172. _this.getAjax(_this.$ports.home.getSon);
  173. }
  174. }else{
  175. clearInterval(timing);
  176. }
  177. },(1000*10))
  178. this.getAjax(this.$ports.home.sports);
  179. },
  180. computed: {
  181. getInfo: function() {
  182. return this.issurvey;
  183. }
  184. },
  185. watch: {
  186. getInfo(val) {
  187. this.$store.dispatch('GETSHOW',true)
  188. // 切换数据置空,不是会报错。。。。
  189. this.list = '';
  190. if (val == true) {
  191. this.getAjax(this.$ports.home.sports);
  192. } else {
  193. this.getAjax(this.$ports.home.getSon);
  194. }
  195. }
  196. },
  197. beforeDestroy(){
  198. this.timers = false;
  199. }
  200. };
  201. </script>
  202. <style scoped>
  203. .box-active {
  204. height: 1.1rem;
  205. }
  206. .box-active div {
  207. width: 1.84rem;
  208. height: 0.68rem;
  209. background: #a0a0a0;
  210. color: #dcdcdc;
  211. font-size: 0.28rem;
  212. border-radius: 8px;
  213. }
  214. .box-active div.active {
  215. background: #dcdcdc;
  216. color: #363636;
  217. }
  218. .sports {
  219. background: #f8f8f8;
  220. /* padding: 0.28rem 0.3rem 0.34rem 0.45rem; */
  221. text-align: left;
  222. /* padding-bottom: 0.68rem; */
  223. }
  224. .sports .title {
  225. color: #000000;
  226. font-size: 0.32rem;
  227. display: flex;
  228. background: #a0a0a0;
  229. height: 0.88rem;
  230. line-height: 0.88rem;
  231. padding: 0 0.32rem 0;
  232. justify-content: space-between;
  233. }
  234. .sportName {
  235. padding: 0.1rem 0rem 0.4rem;
  236. background: #f8f8f8;
  237. width: 92%;
  238. margin: 0 auto;
  239. border-bottom: 1px solid #dfdfdf;
  240. }
  241. .sportName h3 {
  242. color: #f76649;
  243. font-size: 0.28rem;
  244. font-weight: 400;
  245. margin-bottom: 0.25rem;
  246. }
  247. .sportName h3 img {
  248. width: 0.44rem;
  249. height: 0.44rem;
  250. margin-right: 0.3rem;
  251. }
  252. .sportName .list {
  253. background: #dcdcdc;
  254. border-radius: 0.08rem;
  255. padding: 0.28rem 0.5rem 0.28rem 0.3rem;
  256. display: flex;
  257. justify-content: space-between;
  258. margin-bottom: 0.2rem;
  259. }
  260. .sportName .list .teamName {
  261. font-size: 0.28rem;
  262. color: #333333;
  263. max-width: 50%;
  264. }
  265. .sportName .list .teamName div {
  266. margin: 0.05rem 0;
  267. }
  268. .sportName .timer {
  269. text-align: center;
  270. display: flex;
  271. flex-direction: column;
  272. justify-content: space-between;
  273. }
  274. .sportName .minute {
  275. align-items: center;
  276. flex-direction: row;
  277. }
  278. .timer div i {
  279. display: inline-block;
  280. width: 0.34rem;
  281. height: 0.24rem;
  282. }
  283. </style>