5cb256fc22683455190b0a0b22895ffa489caa5a.svn-base 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  1. <template>
  2. <div>
  3. <div v-if="obj.a">
  4. <div class="tit">
  5. <span>总进球数</span>
  6. </div>
  7. <div class="playCode">
  8. <div
  9. class="item flex"
  10. v-for="(item,index) in data"
  11. v-if="item.odds_code.startsWith('tg') && !item.odds_code.endsWith('_h')"
  12. >
  13. <span class="teamName">{{item.condition}}</span>
  14. <div @click="betMethod(index,item.id,'','总进球数')">
  15. <span
  16. class="odds"
  17. :class="{chooseStyle:item.isTrue,rising:item.change == 'rising',falling:item.change == 'falling'}"
  18. >{{item.odds}}</span>
  19. </div>
  20. </div>
  21. </div>
  22. </div>
  23. <div v-if="obj.b">
  24. <div class="tit">
  25. <span>总进球数-上半场</span>
  26. </div>
  27. <div class="playCode">
  28. <div
  29. class="item flex"
  30. v-for="(item,index) in data"
  31. v-if="item.odds_code.endsWith('_h')"
  32. >
  33. <span class="teamName">{{item.condition}}</span>
  34. <div @click="betMethod(index,item.id,'','总进球数-上半场')">
  35. <span
  36. class="odds"
  37. :class="{chooseStyle:item.isTrue,rising:item.change == 'rising',falling:item.change == 'falling'}"
  38. >{{item.odds}}</span>
  39. </div>
  40. </div>
  41. </div>
  42. </div>
  43. </div>
  44. </template>
  45. <script>
  46. export default {
  47. data() {
  48. return {
  49. title: "TG",
  50. data: [], //数据源
  51. guest_team: "", //客队名
  52. home_team: "", //主队名
  53. obj: "", //
  54. match_id: "",
  55. limit: "", //投注数量
  56. lg_id:'',
  57. };
  58. },
  59. /***
  60. * 方法
  61. */
  62. methods: {
  63. //玩法分类
  64. playGrouping(data) {
  65. let obj = {};
  66. let betting = this.$store.getters.getBetting;
  67. data.forEach(e => {
  68. if(betting.length > 0){
  69. for(let i= 0; i< betting.length; i++){
  70. if(betting[i].title =="TG" && betting[i].data.length >0){
  71. for(let j = 0 ; j < betting[i].data.length ; j++ ){
  72. if(betting[i].data[j].id == e.id){
  73. this.$set(e,'isTrue',true);
  74. //betting[i].data.splice(j,1);
  75. }
  76. }
  77. break;
  78. }
  79. }
  80. }
  81. e.lg_id = this.lg_id;
  82. if (e.odds_code.startsWith("tg") && !e.odds_code.endsWith("_h")) {
  83. obj.a = true;
  84. } else if (e.odds_code.endsWith("_h")) {
  85. obj.b = true;
  86. }
  87. });
  88. data.sort((a, z) => {
  89. console.log(a.condition[0]);
  90. if(a.condition[0] == 0){
  91. return -100;
  92. }else{
  93. return -a.condition[0];
  94. }
  95. });
  96. this.obj = obj;
  97. },
  98. /*---------------------------------- */
  99. //玩法投注
  100. betMethod(index, id, name, playName) {
  101. if (this.data[index].isTrue) {
  102. this.$set(this.data[index], "isTrue", false);
  103. } else {
  104. this.$set(this.data[index], "isTrue", true);
  105. }
  106. //调用投注公共方法
  107. let betting = this.$store.getters.getBetting;
  108. let ballId = this.$store.getters.getBallCode;
  109. let _this = this;
  110. //console.log(this.home_team,this.guest_team)
  111. let teamName = {
  112. home:this.home_team,
  113. guest:this.guest_team
  114. };
  115. this.$public.publicBetMethod(this.data,this.title,id,index,betting,teamName,playName,name,this.match_id,ballId,this.limit,
  116. function(data, type) {
  117. if (type) {
  118. _this.$dialog.toast({ mes: "亲,超出表格上限啦。", timeout: 2000 });
  119. }
  120. _this.$store.dispatch("SET_BETTING", []);
  121. _this.$store.dispatch("SET_BETTING", data);
  122. }
  123. );
  124. }
  125. },
  126. /**
  127. * 计算属性
  128. */
  129. computed: {
  130. getGameRatio() {
  131. //console.log(this.$store.getters.getGameRatio)
  132. return this.$store.getters.getGameRatio;
  133. },
  134. //获取投注数据
  135. getBetting() {
  136. return this.$store.getters.getBetting;
  137. },
  138. //获取投注数据数量
  139. getLimit() {
  140. return this.$store.getters.getLimit;
  141. }
  142. },
  143. /**
  144. * 监听器
  145. */
  146. watch: {
  147. getGameRatio(val) {
  148. // console.log(val,'我的')
  149. this.lg_id = val.lg_id
  150. this.match_id = val.match_id;
  151. this.guest_team = val.guest_team;
  152. this.home_team = val.home_team;
  153. val.oddsData.forEach(e => {
  154. if (e[0].p_code == this.title) {
  155. this.data = e;
  156. this.playGrouping(this.data);
  157. }
  158. });
  159. //console.log(this.data);
  160. },
  161. //投注数据监听和处理
  162. getBetting(val) {
  163. if (val.length > 0) {
  164. let id = this.$store.getters.getDeleteType;
  165. for (let i = 0; i < val.length; i++) {
  166. if (val[i].title == this.title) {
  167. for (let j = 0; j < this.data.length; j++) {
  168. if (this.data[j].id == id) {
  169. this.$set(this.data[j], "isTrue", false);
  170. break;
  171. }
  172. }
  173. break;
  174. }
  175. }
  176. } else {
  177. for (let j = 0; j < this.data.length; j++) {
  178. if (this.data[j].isTrue) {
  179. this.$set(this.data[j], "isTrue", false);
  180. }
  181. }
  182. }
  183. },
  184. //投注数量
  185. getLimit(val) {
  186. this.limit = val;
  187. }
  188. }
  189. };
  190. </script>
  191. <style scoped>
  192. .flex {
  193. display: flex;
  194. justify-content: space-between;
  195. align-items: center;
  196. }
  197. .tit {
  198. background: #cdcdcd;
  199. font-size: 0.14rem;
  200. padding: 0 0.1rem;
  201. height: 0.4rem;
  202. line-height: 0.4rem;
  203. color: #333;
  204. }
  205. .playCode {
  206. display: flex;
  207. }
  208. .playCode .item,
  209. .playCode .guest {
  210. height: 0.4rem;
  211. line-height: 0.4rem;
  212. width: 25%;
  213. background: #fff;
  214. padding: 0 0 0 0.1rem;
  215. }
  216. .playCode .item {
  217. width: calc(25% - 1px);
  218. padding: 0 0.1rem;
  219. font-size: 0.14rem;
  220. border-right: 1px solid #e4e4e4;
  221. }
  222. .playCode .item:nth-last-child(1) {
  223. border-right: none;
  224. }
  225. .oddsBox {
  226. margin-right: 0.1rem;
  227. }
  228. .odds {
  229. display: inline-block;
  230. width: 0.48rem;
  231. height: 0.3rem;
  232. border: 0.01rem solid #ccc;
  233. line-height: 0.3rem;
  234. text-align: center;
  235. border-radius: 0.05rem;
  236. cursor: pointer;
  237. }
  238. .odds:hover {
  239. background: #ddd;
  240. color: #f76649;
  241. }
  242. .guest {
  243. padding-right: 0.1rem;
  244. }
  245. .item:hover,
  246. .guest:hover {
  247. background: #fff5e9;
  248. }
  249. .draw {
  250. width: 20%;
  251. background: #fff;
  252. padding: 0 0.1rem;
  253. border-right: 1px solid #e4e4e4;
  254. }
  255. .teamName {
  256. color: #f76649;
  257. font-weight: bold;
  258. }
  259. </style>