2aafe88bafa095529523d7cf469e3a87b2d51c62.svn-base 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459
  1. <template>
  2. <div>
  3. <div class="Serch row item-center">
  4. <div class="Soccer-game row item-center">
  5. <div
  6. style=" display:flex;align-items:center;justify-content:center;"
  7. class="Soccer-game-title"
  8. @click="isreturn()"
  9. >
  10. <img class="box-img" src="../assets/st-imges/returnbox.png">
  11. {{this.title}}
  12. </div>
  13. </div>
  14. </div>
  15. <div class="champion">
  16. <div v-for="item in ChampionData" :key="item.id">
  17. <div class="title">
  18. <span>{{item.name}}</span>
  19. <div class="time">
  20. <span>{{item.last_time}}</span>
  21. </div>
  22. </div>
  23. <div v-for="(items) in item.data" :key="items.id">
  24. <div class="chmpTit">{{items.title}}</div>
  25. <div v-for="itemList in items.datas" :key="itemList.id">
  26. <div class="list">
  27. <span class="chmName">{{itemList.team}}</span>
  28. <div
  29. v-if="itemList.odds >0 "
  30. class="num"
  31. @click="championBetting(itemList.id,itemList.odds,itemList.odds_only,itemList.p_code,itemList.match_id,itemList.odds_code,items.title,itemList.lg_id,itemList.team)"
  32. :class="{active:itemList.isTrue,increased_color:itemList.change == 'add',reduce_color:itemList.change == 'red'}"
  33. >{{itemList.odds}}</div>
  34. <div v-else class="ratio column center">
  35. <img style="width: 0.7rem;height: 0.5rem;" src="@/assets/st-imges/mima.png"><img>
  36. </div>
  37. </div>
  38. </div>
  39. </div>
  40. </div>
  41. </div>
  42. <div class="BettingWindow" v-if="isBettingWindow =='100'">
  43. <BettingWindow/>
  44. </div>
  45. </div>
  46. </template>
  47. <script>
  48. import BettingWindow from "./StBettingWindow.vue";
  49. import Loading from "@/components/StLoading";
  50. export default {
  51. name: "champion",
  52. data() {
  53. return {
  54. title: this.$route.query.name, //标题
  55. data: "", // 冠军盘口数据
  56. ChampionData: "",
  57. isBettingShow: "0", //投注显示关闭默认false
  58. // 冠军盘新增
  59. match_id: "", //赛事ID
  60. betting: 10000, //vuex里面玩法投注数据
  61. thisNum: 10000, //vuex里面
  62. lg_id: "",
  63. scorll: "", //背景滚动
  64. isBettingWindow: "-1",
  65. getIsShow:true,
  66. // 存储变色数据
  67. previousStorage:[],
  68. timers : true
  69. };
  70. },
  71. components: {
  72. BettingWindow,
  73. Loading
  74. },
  75. methods: {
  76. /*--------------------------------------------------------------------------------*/
  77. // 冠军盘玩法投注
  78. //冠军盘口投注
  79. championBetting(
  80. id,
  81. odds,
  82. odds_only,
  83. p_code,
  84. match_id,
  85. odds_code,
  86. play_name,
  87. lg_id,
  88. name
  89. ) {
  90. if (this.$store.getters.getLimit * 1 >= 10) {
  91. this.$dialog.alert({ mes: "你的注单已达到上限啦!" });
  92. }
  93. // 导入数据
  94. let _this = this;
  95. let isAdd = true;
  96. let bettingInfo = {
  97. id,
  98. home_team: "",
  99. guest_team: "",
  100. name,
  101. odds,
  102. match_id,
  103. condition: "",
  104. ballId: this.$store.getters.getBallId,
  105. odds_code: odds_code,
  106. p_code: "gj",
  107. play_name,
  108. score: "",
  109. bettingTime: "",
  110. odds_only,
  111. lg_id
  112. };
  113. console.log(bettingInfo);
  114. let matchList = this.$store.getters.getBetting;
  115. if (this.thisNum != 10000) {
  116. //删除vuex投注数据
  117. matchList[this.thisNum].data.forEach((res, index) => {
  118. if (res.id == id) {
  119. console.log(res.id, id);
  120. this.modifyChampionStyle(id);
  121. matchList[this.thisNum].data.splice(index, 1);
  122. this.$store.dispatch("SET_LIMIT", false);
  123. this.$store.dispatch("BETTING", []);
  124. this.$store.dispatch("BETTING", matchList);
  125. isAdd = false;
  126. }
  127. });
  128. //添加vuex投注数据
  129. if (isAdd) {
  130. if (this.$store.getters.getLimit * 1 >= 10) return false;
  131. this.modifyChampionStyle(id);
  132. matchList[this.thisNum].data.push(bettingInfo);
  133. this.$store.dispatch("BETTING", []);
  134. this.$store.dispatch("BETTING", matchList);
  135. if (this.$store.getters.getIsBetting == "100") return false;
  136. this.$store.dispatch("ISBETTING", 100);
  137. }
  138. } else {
  139. //添加新的玩法赔率数据
  140. let obj = {
  141. title: "gj",
  142. data: [bettingInfo]
  143. };
  144. //console.log(obj);
  145. //判断vuex有误其它玩法数据
  146. if (matchList) {
  147. matchList.push(obj);
  148. } else {
  149. this.$store.dispatch("BETTING", [obj]);
  150. }
  151. this.modifyChampionStyle(id);
  152. if (this.$store.getters.getIsBetting == "100") return false;
  153. this.$store.dispatch("ISBETTING", "100");
  154. }
  155. },
  156. /*-----------------------------------------------------*/
  157. /*-----------------------------------------------------*/
  158. //修改当前页面样式公共方法
  159. modifyChampionStyle: function(id) {
  160. this.ChampionData.forEach(a => {
  161. a.data.forEach(b => {
  162. b.datas.every((res, index) => {
  163. if (res.id == id) {
  164. this.$set(res, "isTrue", res.isTrue ? false : true);
  165. this.$forceUpdate();
  166. console.log(res.isTrue);
  167. return false;
  168. }
  169. return true;
  170. });
  171. return true;
  172. });
  173. });
  174. },
  175. /*--------------------------------------------------------------------------------*/
  176. // 返回上一页
  177. isreturn() {
  178. history.go(-1);
  179. },
  180. getAjax() {
  181. this.$http
  182. .get(this.$ports.match.matchState, {
  183. game_code: this.$route.query.game_code,
  184. lg_id: this.$route.query.leagueID,
  185. type_code: "StChampion"
  186. })
  187. .then(res => {
  188. this.championGroup(res.data.data);
  189. });
  190. let _this = this;
  191. setTimeout(() => {
  192. _this.$store.dispatch("GETSHOW", false);
  193. }, 1000);
  194. },
  195. /*--------------------------------------------------- */
  196. //冠军
  197. championGroup(data) {
  198. // console.log("data", data);
  199. let champion = {},
  200. stiTime = "",
  201. chamData = [];
  202. let title = Object.keys(data);
  203. let val = Object.values(data);
  204. let championBet = this.getTypeBetting("gj");
  205. title.forEach((e, index) => {
  206. chamData.push({
  207. name: e,
  208. data: val[index]
  209. });
  210. });
  211. chamData.forEach(res => {
  212. res.last_time = res.data.last_time;
  213. let resData = Object.values(res.data);
  214. let resTitle = Object.keys(res.data);
  215. res.data = [];
  216. resTitle.forEach((e, index) => {
  217. if (e !== "last_time") {
  218. if (championBet != "-1") {
  219. championBet.forEach(bet => {
  220. resData[index].forEach(val => {
  221. //
  222. if (bet.id == val.id) {
  223. //console.log('冠军',val)
  224. val.isTrue = true;
  225. }
  226. });
  227. });
  228. }
  229. res.data.push({
  230. title: e,
  231. datas: resData[index]
  232. });
  233. }
  234. });
  235. });
  236. this.ChampionData = chamData;
  237. let storage = this.previousStorage;
  238. if(storage && storage != null && storage.length >0){
  239. this.ChampionData.forEach(e =>{
  240. e.data.forEach(k =>{
  241. k.datas.forEach(item =>{
  242. storage.forEach(a =>{
  243. a.forEach(b =>{
  244. if(item.id == b.id){
  245. if(item.odds > b.odds){
  246. item.change = 'add'
  247. }else if(item.odds <b.odds){
  248. item.change = 'red'
  249. }else{
  250. item.change = ''
  251. }
  252. }
  253. })
  254. })
  255. })
  256. })
  257. })
  258. }
  259. this.previousStorage = [];
  260. this.ChampionData.forEach(e =>{
  261. e.data.forEach(k =>{
  262. this.previousStorage.push(k.datas)
  263. })
  264. })
  265. // console.log('123123123',this.previousStorage)
  266. console.log("冠军", this.ChampionData);
  267. },
  268. //获取vueX相对应投注信息
  269. getTypeBetting: function(type) {
  270. let data = "-1";
  271. if (this.betting.length > 0) {
  272. this.betting.forEach((e, index) => {
  273. if (e.title == type) {
  274. data = e.data;
  275. this.thisNum = index;
  276. }
  277. });
  278. } else {
  279. data = "-1";
  280. }
  281. return data;
  282. }
  283. },
  284. mounted() {
  285. if (this.getIsShow) {
  286. this.$store.dispatch("GETSHOW", true);
  287. this.getIsShow = false;
  288. }
  289. if (this.$store.getters.getIsBetting == "100") {
  290. this.isBettingShow = 100;
  291. }
  292. //获取vuex玩法已投注相对应的数据
  293. //是否展示投注框
  294. if (this.$store.getters.getIsBetting == "100") {
  295. this.isBettingWindow = "100";
  296. }
  297. //获取vuex玩法已投注相对应的数据
  298. if (this.$store.getters.getBetting) {
  299. this.betting = this.$store.getters.getBetting;
  300. }
  301. // 调用
  302. this.getAjax();
  303. let _this = this;
  304. this.$public.ajaxTimerFun(function(timing) {
  305. if (_this.timers) {
  306. _this.getAjax("");
  307. }else{
  308. clearInterval(timing);
  309. }
  310. },(1000*10));
  311. },
  312. computed: {
  313. getBetting() {
  314. return this.$store.getters.getBetting;
  315. },
  316. getIsBetting() {
  317. return this.$store.getters.getIsBetting;
  318. },
  319. //获取投注框删除的投注信息
  320. getDeleteType() {
  321. return this.$store.getters.getDeleteType;
  322. }
  323. },
  324. watch: {
  325. // 监听滚动状态变化赋值滚动
  326. getscorllcode(val) {
  327. this.scorll = val;
  328. },
  329. getDeleteType(val) {
  330. let flag = true;
  331. this.ChampionData.forEach(e => {
  332. if (val == "all") {
  333. e.data.forEach(k => {
  334. k.datas.forEach(i => {
  335. this.$set(i, "isTrue", false);
  336. });
  337. });
  338. } else {
  339. let showData = true;
  340. e.data.forEach(k => {
  341. k.datas.forEach(i => {
  342. if (i.id == val) {
  343. this.$set(i, "isTrue", false);
  344. showData = false;
  345. }
  346. });
  347. });
  348. if (showData) {
  349. e.data.forEach(k => {
  350. k.datas.forEach(i => {
  351. if (i.id == val) {
  352. this.$set(i, "isTrue", false);
  353. }
  354. });
  355. });
  356. }
  357. }
  358. });
  359. },
  360. getBetting(val) {
  361. //获取vuex玩法已投注相对应的数据
  362. if (val) {
  363. val.forEach((e, index) => {
  364. if ("gj" == e.title) {
  365. this.thisNum = index;
  366. this.betting = e.data;
  367. // console.log('betting', this.betting)
  368. }
  369. });
  370. }
  371. },
  372. // 监听投注框开关
  373. getIsBetting(val) {
  374. this.isBettingWindow = val;
  375. }
  376. },
  377. beforeDestroy(){
  378. this.timers = false;
  379. }
  380. };
  381. </script>
  382. <style scoped>
  383. .Serch {
  384. height: 0.75rem;
  385. display: flex;
  386. justify-content: space-between;
  387. align-items: center;
  388. background-color: #363636;
  389. color: #f76649;
  390. font-family: "PingFang-SC-Regular";
  391. padding: 0 0.32rem;
  392. }
  393. .box-img {
  394. width: 0.37rem;
  395. height: 0.3rem;
  396. margin-right: 0.18rem;
  397. }
  398. .champion .title {
  399. padding: 0.15rem 0.2rem;
  400. background-color: #626262;
  401. }
  402. .champion .title span {
  403. font-size: 0.28rem;
  404. font-weight: bold;
  405. color: #e1e1df;
  406. }
  407. .champion .title .time span:nth-child(2) {
  408. color: #f76649;
  409. }
  410. .chmpTit {
  411. height: 0.7rem;
  412. line-height: 0.7rem;
  413. padding: 0 0.2rem;
  414. background: #e4e4e4;
  415. }
  416. .champion .list {
  417. height: 1rem;
  418. line-height: 0.6rem;
  419. padding: 0.1rem 0.2rem;
  420. width: 100%;
  421. display: -webkit-box;
  422. display: -ms-flexbox;
  423. display: flex;
  424. -webkit-box-pack: justify;
  425. -ms-flex-pack: justify;
  426. justify-content: space-between;
  427. border-bottom: 1px solid #aaa;
  428. font-size: 0.28rem;
  429. background: #f4f4f4;
  430. }
  431. .champion .list span:nth-child(1) {
  432. margin-top: 0.1rem;
  433. }
  434. .champion .list .num {
  435. width: 1.07rem;
  436. height: 0.76rem;
  437. border: 1px solid #e4e4e4;
  438. border-radius: 0.1rem;
  439. padding: 0.1rem;
  440. text-align: center;
  441. }
  442. .col {
  443. background: #f76649;
  444. border: 2px solid #f76649 !important;
  445. }
  446. .col span {
  447. color: #f4f4f4 !important;
  448. }
  449. .ratio {
  450. width: 1rem;
  451. height: 0.76rem;
  452. border: 1px solid #cecece;
  453. margin-right: 0.14rem;
  454. border-radius: 0.1rem;
  455. margin: 0.06rem;
  456. }
  457. </style>