3b0dd2135172ac065999490b646d47d8ed53cb31.svn-base 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434
  1. <template>
  2. <div>
  3. <div v-if="data.length >0 ">
  4. <div class="bettingTable" :class="data?'':'dataNo row center'">
  5. <div class="list" v-for="(item,index) in data" :key="item.id">
  6. <div style="padding-bottom:.1rem;">
  7. <div class="list-header row item-center allAlignment">
  8. <p
  9. class="br05 row center"
  10. style="height:.24rem;background:#F00;padding:0 .1rem;"
  11. >{{item.playName}}</p>
  12. <p
  13. @click="deleteList(index,item.id,item.p_code)"
  14. class="row center"
  15. style="width:.26rem;height:.26rem; border-radius:50%;background:#F76649;"
  16. >
  17. <img src="@/assets/st-imges/del.png">
  18. </p>
  19. </div>
  20. <div class="list-body">
  21. <div class="condition row item-center">
  22. <span>{{item.name}}</span>
  23. <p style="padding-left:.1rem;">
  24. @
  25. <span style="color:#F76649">{{item.odds}}</span>
  26. </p>
  27. </div>
  28. <div class="duel row item-center">
  29. <p>{{item.home_team}}</p>
  30. <span style="color:#F76649;font-size:.12rem;">&emsp;vs&emsp;</span>
  31. <p>{{item.guest_team}}</p>&nbsp;
  32. </div>
  33. </div>
  34. </div>
  35. </div>
  36. <!-- <div v-if="(i+1)>2"> -->
  37. <div v-for="(item,index) in ThroughPlay" :key="index">
  38. <div style="width:100%;height:.4rem;padding:0 .2rem;"
  39. class="row item-center" >
  40. <span>{{item.title}}</span>
  41. <span>X{{item.index}}</span>
  42. </div>
  43. <div class="list-input row item-center allAlignment" style="padding:0 .2rem;">
  44. <div
  45. class="br05"
  46. style="border:.01rem solid #F76649;position: relative;"
  47. @click="getKeys(index)"
  48. >
  49. <input type="text" placeholder="投注额" class="bettingall" oncopy="return false" v-model="item.money"
  50. onpaste="return false" @keyup="keyMatch($event,index)"
  51. >
  52. <img
  53. @click="clearBettingMoney(index)"
  54. style="position: absolute;width:.2rem;height:.2rem;right:.1rem;top:.05rem;"
  55. src="@/assets/st-imges/delbetting.png"
  56. >
  57. </div>
  58. <div
  59. class="br05 row item-center"
  60. style="border:.01rem solid #BFE2B3;background:#E7FFDA;padding-left: .05rem;"
  61. > {{item.money ? (item.money * item.odds).toFixed(2) : '可赢额'}}</div>
  62. </div>
  63. <div class="key" :style="keys == index?'':'display:none;'">
  64. <div>
  65. <div class="row average item-center">
  66. <p @click="moneyClick(100,index)">+100</p>
  67. <p @click="moneyClick(500,index)">+500</p>
  68. <p @click="moneyClick(1000,index)">+1000</p>
  69. </div>
  70. <div class="row average item-center">
  71. <p @click="moneyClick(5000,index)">+5000</p>
  72. <p @click="moneyClick(10000,index)">+10000</p>
  73. <p @click="moneyClick(50000,index)">+50000</p>
  74. </div>
  75. </div>
  76. </div>
  77. </div>
  78. <!-- </div> -->
  79. <div class="statistics">
  80. <div>
  81. <div class="statistics-list">
  82. <p class="row allAlignment">
  83. <span>
  84. <i style="color:#F76649">{{ThroughPlay.length > 0 ? ThroughPlay.length :0}}</i>&emsp;所有投注:
  85. </span>
  86. <span>{{bettingMoney ? bettingMoney :'0.00'}} RMB</span>
  87. </p>
  88. <p class="row allAlignment">
  89. <span>可赢金额:</span>
  90. <span style="color:#F76649;font-size:.16rem;">{{canWin ? canWin :'0.00'}}RMB</span>
  91. </p>
  92. </div>
  93. <!-- <div
  94. style="height:.5rem;background:#A83131;padding-left:.2rem;margin-top:.2rem;"
  95. class="row item-center"
  96. >
  97. <img style="width:.17rem;height:.15rem;" src="@/assets/st-imges/warning.png">&nbsp;
  98. <p style="color:#fff;font-size:.14rem;">您的余额不足。 请您先进行存款</p>
  99. </div>
  100. <div
  101. class="row center"
  102. style="height:.5rem;background:rgb(247, 102, 73);color:#fff;margin-top:.2rem;font-size:.14rem;"
  103. >赔率信息已更改,请重新投注</div> -->
  104. <div class="statistics-btn">
  105. <div class="row center" style="font-size:.16rem;'color:#666'" v-if="!logins">请先登录再进去投注</div>
  106. <div class="row center submit" style="background:#F76649;color:#fff;" v-else @click="submit()">投注</div>
  107. <div class="row center" style="background:#CCC;color:#666;" @click="cancel()">取消</div>
  108. </div>
  109. </div>
  110. </div>
  111. </div>
  112. </div>
  113. </div>
  114. </template>
  115. <script>
  116. import "@/css/index.css";
  117. export default {
  118. name: "eventBettingTable",
  119. data() {
  120. return {
  121. keys: "",
  122. logins: false,
  123. bettingMoney: 0,//投注金额
  124. canWin:0,//可赢金额
  125. ThroughPlay:[],
  126. data: "",
  127. };
  128. },
  129. methods: {
  130. /*----------------------------------*/
  131. // 数据提交
  132. submit(){
  133. let dataList=[];
  134. let money = 0,isMoney=false;
  135. this.ThroughPlay.forEach(e =>{
  136. if(e.money*1 >= 1){
  137. isMoney = true;
  138. money += e.money;
  139. dataList.push({
  140. type:e.title,
  141. bet_amount:e.money,
  142. })
  143. }
  144. })
  145. dataList.push(this.data);
  146. //onsole.log(dataList)
  147. if (isMoney) {
  148. let token = localStorage.getItem("token");
  149. this.$http
  150. .post(this.$ports.betOrder.Bet, {
  151. data: dataList,
  152. token,
  153. bet_money:money
  154. })
  155. .then(res => {
  156. //console.log('数据',res.data);
  157. if (res.data.status == 1) {
  158. // this.alldel();
  159. this.$store.dispatch("SET_PASSBETTING",[]);
  160. this.cash = (this.cash - this.dataNumbe * 1).toFixed(2);
  161. this.$dialog.alert({ mes: "亲!你已经投注成功啦。" });
  162. } else if (res.data.status == "-4001") {
  163. this.isLogin = false;
  164. this.$dialog.alert({ mes: "亲!你的登陆已过期。" });
  165. } else if (res.data.status == "4204") {
  166. this.$dialog.alert({ mes: "亲!你的余额不足。" });
  167. }else if(res.data.status == '7027' ){
  168. this.$dialog.alert({ mes: "亲!赔率发生变法,请重新选择。" });
  169. // this.alldel();
  170. this.$store.dispatch("SET_PASSBETTING",[]);
  171. }else{
  172. this.$dialog.alert({ mes: "错误代码:"+res.data.status});
  173. }
  174. this.isSubmit = false;
  175. });
  176. } else {
  177. this.$dialog.alert({ mes: "亲!你还未输入投注金额啦。" });
  178. this.isSubmit = false;
  179. }
  180. },
  181. /*----------------------------------*/
  182. //激活键盘
  183. getKeys(index) {
  184. this.keys = index;
  185. },
  186. /*----------------------------------*/
  187. //投注金额处理
  188. moneyClick(num, index) {
  189. let money = this.ThroughPlay[index].money ? this.ThroughPlay[index].money *1 : 0;
  190. this.$set(this.ThroughPlay[index],'money',money+num > 999999999 ? 999999999: money+num );
  191. this.calculationAmount()
  192. //console.log(money+num);
  193. },
  194. /*----------------------------------*/
  195. //计算投注金额
  196. calculationAmount(){
  197. let money = 0,profit = 0;
  198. this.ThroughPlay.forEach(e=>{
  199. if(e.money){
  200. money += e.money * e.index;
  201. profit += e.money * e.odds;
  202. }
  203. })
  204. this.bettingMoney =money.toFixed(2);
  205. this.canWin = profit.toFixed(2);
  206. },
  207. /*------------------------------------*/
  208. //输入验证
  209. keyMatch(e, i) {
  210. e.currentTarget.value = e.currentTarget.value.replace(/[^0-9]/g, "");
  211. if(e.currentTarget.value.length > 9){
  212. e.currentTarget.value = 999999999
  213. }
  214. this.$set(this.ThroughPlay[i],'money',e.currentTarget.value)
  215. this.calculationAmount()
  216. //console.log(this.bettingMoney);
  217. },
  218. /*----------------------------------*/
  219. // 清除投注金额
  220. clearBettingMoney(index) {
  221. this.$set(this.ThroughPlay[index],'money','')
  222. this.calculationAmount()
  223. },
  224. /*----------------------------------*/
  225. //删除一条数据
  226. deleteList(index, id, code) {
  227. let betting = this.$store.getters.getPassBetting;
  228. for (let i = 0; i < betting.length; i++) {
  229. if (code == betting[i].title) {
  230. for (let j = 0; j < betting[i].data.length; j++) {
  231. if (id == betting[i].data[j].id) {
  232. this.data[index].money = "";
  233. betting[i].data.splice(j, 1);
  234. break;
  235. }
  236. }
  237. break;
  238. }
  239. }
  240. this.$store.dispatch("DEL_TYPE", id);
  241. this.$store.dispatch("SET_PASSBETTING", []);
  242. this.$store.dispatch("SET_PASSBETTING", betting);
  243. },
  244. /*----------------------------------*/
  245. // 取消
  246. cancel(){
  247. this.$store.dispatch("SET_PASSBETTING", []);
  248. }
  249. },
  250. computed: {
  251. getIsLogin() {
  252. return this.$public.getItem("token");
  253. },
  254. getPassBetting() {
  255. return this.$store.getters.getPassBetting;
  256. },
  257. // //计算可赢金额
  258. // canWin(){
  259. // this.ThroughPlay
  260. // }
  261. },
  262. watch: {
  263. getIsLogin(val) {
  264. if (val) {
  265. this.logins = true;
  266. } else {
  267. this.logins = false;
  268. }
  269. //console.log(this.$public.getItem("token"), "token");
  270. },
  271. getPassBetting(val) {
  272. this.data = [];
  273. if (this.$store.getters.getPassLimit > 0) {
  274. val.forEach(e => {
  275. e.data.home_team =
  276. this.data = this.data.concat(e.data);
  277. // if(this.$store.getters.getPassLimit > 10){
  278. // this.$dialog.toast({ mes: "亲,超出表格上限啦。", timeout: 2000 });
  279. // this.deleteList(this.data.length - 1,this.data[this.data.length-1].id,this.data[this.data.length-1].p_code);
  280. // console.log(this.$store.getters.getBetting,'我的')
  281. // }
  282. });
  283. this.ThroughPlay =[];
  284. if(this.data.length >2){
  285. for(let i=3 ; i <= this.data.length ;i++ ){
  286. this.ThroughPlay.push(this.$public.betPlay(i,this.data));
  287. }
  288. }
  289. console.log( this.ThroughPlay);
  290. this.calculationAmount();
  291. //console.log('数据更新',this.data);
  292. }
  293. }
  294. },
  295. mounted() {
  296. if (this.$public.getItem("token")) {
  297. this.logins = true;
  298. }
  299. //
  300. }
  301. };
  302. </script>
  303. <style scoped>
  304. img {
  305. cursor: pointer;
  306. }
  307. .br05 {
  308. border-radius: 0.05rem;
  309. }
  310. .bettingTable {
  311. width: 100%;
  312. background: #e5e5e5;
  313. }
  314. .dataNo {
  315. background: #777;
  316. }
  317. .list {
  318. padding: 0 0.2rem;
  319. border-bottom: 0.02rem solid #999;
  320. }
  321. .list img {
  322. width: 0.15rem;
  323. height: 0.15rem;
  324. }
  325. .list-header {
  326. min-height: 0.5rem;
  327. }
  328. .list-header p {
  329. font-size: 0.14rem;
  330. color: #fff;
  331. }
  332. .list-body {
  333. min-height: 0.6rem;
  334. }
  335. .list-body > div {
  336. min-height: 0.3rem;
  337. }
  338. .condition {
  339. font-size: 0.16rem;
  340. font-weight: bold;
  341. color: #666;
  342. }
  343. .duel {
  344. font-size: 0.14rem;
  345. color: #666;
  346. }
  347. .list-input {
  348. min-height: 0.6rem;
  349. }
  350. .list-input > div {
  351. width: 48%;
  352. height: 0.34rem;
  353. color: #999;
  354. font-size: 0.14rem;
  355. }
  356. .list-input > div input {
  357. width: 100%;
  358. height: 100%;
  359. border: none;
  360. border-radius: 0.05rem;
  361. background: #fff;
  362. padding-left: 0.05rem;
  363. }
  364. .key {
  365. min-height: 1rem;
  366. background: #ccc;
  367. }
  368. .key > div {
  369. width: 90%;
  370. margin: 0 auto;
  371. }
  372. .key > div > div {
  373. min-height: 0.5rem;
  374. }
  375. .key p {
  376. width: 30%;
  377. height: 0.34rem;
  378. background: #fff;
  379. border-radius: 0.05rem;
  380. display: flex;
  381. justify-content: center;
  382. align-items: center;
  383. color: #f76649;
  384. font-size: 0.14rem;
  385. cursor: pointer;
  386. box-shadow: .05rem .05rem .05rem rgba(0, 0, 0, .1)
  387. }
  388. .key p:active{
  389. background: #e9e9e9;
  390. }
  391. .statistics {
  392. width: 100%;
  393. background: #fff;
  394. }
  395. .statistics > div {
  396. width: 90%;
  397. margin: 0 auto;
  398. padding: 0.2rem 0;
  399. }
  400. .statistics-list {
  401. min-height: 0.6rem;
  402. font-size: 0.14rem;
  403. }
  404. .statistics-list > p {
  405. line-height: 0.3rem;
  406. }
  407. .statistics-btn > div {
  408. height: 0.35rem;
  409. border-radius: 0.05rem;
  410. margin-top: 0.1rem;
  411. cursor: pointer;
  412. }
  413. .submit:active{
  414. background: #F77649 !important;
  415. box-shadow: -2px 0px 5px 1px rgba(0, 0, 0, 0.05),
  416. 0px -2px 5px 1px rgba(0, 0, 0, 0.05), 2px 0px 5px 1px rgba(0, 0, 0, 0.05),
  417. 0px 2px 5px 1px rgba(0, 0, 0, 0.05);
  418. }
  419. </style>