entertainment.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713
  1. <template>
  2. <view class="all">
  3. <view class="padding-t-30"></view>
  4. <view class="top-content">
  5. <view class="top-one flex" v-if="history.next">
  6. <view class="action-title">
  7. <text>{{$t('indexenter.第')}}{{history.next.no}}{{$t('indexenter.期')}}</text>
  8. </view>
  9. <view class="end-time">
  10. <text>{{$t('indexenter.距离结束')}}</text>
  11. <text class="time">
  12. <text v-if="time.H<10">0</text>
  13. {{time.H}}:
  14. <text v-if="time.M<10">0</text>
  15. {{time.M}}:
  16. <text v-if="time.S<10">0</text>
  17. {{time.S}}
  18. </text>
  19. </view>
  20. </view>
  21. <view class="top-two flex" v-if="history.list.length>0">
  22. <view class="old-title flex-start">
  23. <text>{{$t('indexenter.第')}}{{history.list[0].no}}{{$t('indexenter.期')}}</text>
  24. <image v-for="ls in history.list[0].result_info" class="dice"
  25. :src="`../../static/img/dice${ls}.png`" mode="scaleToFill"></image>
  26. </view>
  27. <view class="old-num">
  28. <!-- {{$t('indexenter.竞猜数')}}:10 -->
  29. {{$t('indexenter.结果')}}:
  30. <text class="margin-l-10"
  31. v-for="ll in history.list[0].typelist">{{$t(`indexenter.${ll.type}`)}}</text>
  32. </view>
  33. </view>
  34. </view>
  35. <view class="number flex">
  36. <view class="item-num" :class="{action:ind==actiontype}" v-for="(item,ind) in history.base.include_function"
  37. @click="actiontype=ind">
  38. <view class="type">
  39. {{$t(`indexenter.${item.name}`)}}
  40. </view>
  41. <view class="percentage">
  42. {{item.bfb}}%
  43. </view>
  44. </view>
  45. </view>
  46. <view class="money-list flex">
  47. <view class="list-ls flex" @click="upOnBtnData.value=item.value" v-for="(item,ind) in moneyList">
  48. <view class="image">
  49. <image class="img" :src="item.url" mode="widthFix"></image>
  50. </view>
  51. <view class="list">
  52. {{item.value}}
  53. </view>
  54. </view>
  55. </view>
  56. <view class="pay-title padding-l-30">
  57. {{$t('indexenter.竞猜总额')}}(USDT):
  58. </view>
  59. <view class="pay-money-box flex padding-c-30 padding-v-10">
  60. <input class="pay-money" type="number" v-model="upOnBtnData.value" />
  61. <view class="buttom-del" @click="upOnBtnData.value=0">
  62. {{$t('indexenter.清空')}}
  63. </view>
  64. </view>
  65. <view class="pay-title padding-c-30 flex padding-v-20">
  66. <view>
  67. {{$t('indexenter.竞猜总额')}}:
  68. </view>
  69. <view class="font-color-yellow">
  70. 0
  71. USDT
  72. </view>
  73. </view>
  74. <view class="push-buttom" @click="onPayBet">
  75. {{$t('indexenter.确认')}}
  76. </view>
  77. <view class="chz flex" @click="nav('/pages/user/money/recharge')">
  78. <view>
  79. <view class="yue padding-b-10">{{$t('enter.u15')}}</view>
  80. <view class="yes">{{userWallet}}USDT</view>
  81. </view>
  82. <view class="flex-start">
  83. <view class="quc">{{$t('enter.u16')}}</view>
  84. <image class="choz" src="../../static/img/img39.png" mode="scaleToFill"></image>
  85. </view>
  86. </view>
  87. <view class="history-title padding-l-30 margin-t-30">
  88. {{$t('indexenter.近期记录')}}:
  89. </view>
  90. <view class="history-list">
  91. <view class="history-title-type flex">
  92. <view class="history-item">
  93. {{$t('indexenter.期号')}}
  94. </view>
  95. <view class="history-item">
  96. {{$t('indexenter.竞猜值')}}
  97. </view>
  98. <view class="history-item">
  99. {{$t('indexenter.竞猜数')}}
  100. </view>
  101. <view class="history-item">
  102. {{$t('indexenter.结果')}}
  103. </view>
  104. </view>
  105. <view class="history-title-type flex margin-t-30" v-for="(item,ind) in betList.list" :key="ind">
  106. <view class="history-item font-color-yellow" :class="{'font-color-gray':item.result==0,'font-color-red':item.result==1}">
  107. {{item.room.no}}
  108. </view>
  109. <view class="history-item font-color-red">
  110. <text class="margin-l-10"
  111. v-for="(ll,ind) in history.base.include_function" v-if="item.bet==ll.id">{{$t(`indexenter.${ll.name}`)}}</text>
  112. </view>
  113. <view class="history-item font-color-red">
  114. {{item.room.result_info||$t('enter.a2')}}
  115. </view>
  116. <view class="history-item font-color-yellow" v-if="item.typelist.length>0">
  117. <text class="margin-l-10"
  118. v-for="ll in item.typelist">{{$t(`indexenter.${ll.type}`)}}</text>
  119. </view>
  120. <view class="history-item font-color-yellow" v-else>
  121. {{$t('enter.a2')}}
  122. </view>
  123. </view>
  124. </view>
  125. <uni-popup type="bottom" ref="popup" :mask-click="false" @maskClick='colsePayPassword'>
  126. <inputPassword @commit='KeyInfo' @colse='colsePayPassword'></inputPassword>
  127. </uni-popup>
  128. </view>
  129. </template>
  130. <script>
  131. import {} from "@/api/game.js";
  132. import {
  133. mapState,
  134. mapMutations
  135. } from 'vuex';
  136. import {
  137. getGame,
  138. getGameList,
  139. gameWallet,
  140. gameBetList,
  141. gameBetIn,
  142. // gameTest
  143. } from "@/api/game.js";
  144. import {
  145. saveUrl,
  146. interceptor
  147. } from '@/utils/loginUtils.js';
  148. import {
  149. getTime
  150. } from '@/utils/rocessor.js';
  151. import inputPassword from "@/components/input-password/input-password.vue";
  152. export default {
  153. components: {
  154. inputPassword
  155. },
  156. computed: {
  157. ...mapState("user", ["hasLogin"]),
  158. },
  159. data() {
  160. return {
  161. // 当前选中的大小奇偶
  162. actiontype: 0,
  163. id: '',
  164. moneyList: [{
  165. url: '/static/img/money_pay_1.png',
  166. value: 5
  167. }, {
  168. url: '/static/img/money_pay_2.png',
  169. value: 10
  170. },
  171. {
  172. url: '/static/img/money_pay_3.png',
  173. value: 30
  174. },
  175. {
  176. url: '/static/img/money_pay_4.png',
  177. value: 50
  178. }
  179. ],
  180. // 游戏信息
  181. time: {
  182. H: 0,
  183. M: 0,
  184. S: 0,
  185. // 保存倒计时对象
  186. t: ''
  187. },
  188. // 游戏信息
  189. history: {
  190. list: [], //游戏进行记录
  191. page: 1,
  192. limit: 10,
  193. // 基础数据
  194. base: {},
  195. next: "",
  196. now: {}
  197. },
  198. // 游戏押注记录
  199. betList: {
  200. list: [], //游戏进行记录
  201. page: 1,
  202. limit: 5,
  203. },
  204. userWallet: 0,
  205. upOnBtnData: {
  206. type: '',
  207. // 当前输入的密码
  208. passwordArr: '',
  209. value: 0,
  210. },
  211. // 保存获取下次游戏对象
  212. getNextTimeObj: '',
  213. // 判断是否当前页面中
  214. loadPage: false,
  215. };
  216. },
  217. onLoad(option) {
  218. this.id = option.id;
  219. uni.setNavigationBarTitle({
  220. title: option.title
  221. });
  222. },
  223. onShow() {
  224. this.loadPage = true;
  225. if (!this.hasLogin) {
  226. uni.showModal({
  227. title: this.$t('enter.c4'),
  228. content: this.$t('enter.b5'),
  229. cancelText: this.$t('indexenter.取消'),
  230. confirmText: this.$t('indexenter.确定'),
  231. success: (e) => {
  232. // 判断是否点击确认按钮
  233. if (e.confirm) {
  234. // 保存当前页面地址
  235. saveUrl()
  236. // 跳转页面
  237. interceptor()
  238. }
  239. }
  240. })
  241. return
  242. }
  243. this.getUserWallet();
  244. this.gameInit(this.id);
  245. },
  246. // 关闭循环
  247. onHide() {
  248. this.loadPage = false;
  249. // 倒计时清理
  250. this.initData();
  251. },
  252. methods: {
  253. getTime,
  254. // 初始化
  255. async gameInit(id) {
  256. console.log('id', id);
  257. // await gameTest();
  258. // 获取基础信息
  259. await this.getGame(id);
  260. },
  261. // 获取游戏信息
  262. getGame(id) {
  263. const that = this;
  264. return getGame({
  265. page: that.history.page,
  266. limit: that.history.limit
  267. }, id).then(({
  268. data
  269. }) => {
  270. that.history.base = data.game || {};
  271. that.history.base.include_function = that.history.base.include_function.map((res) => {
  272. res.bfb = res.ratio * 1 * that.history.base.success_ratio / 100;
  273. return res
  274. })
  275. that.history.next = data.next_game || '';
  276. that.history.now = data.now_game || '';
  277. if (data.list) {
  278. that.history.list = data.list.map((res) => {
  279. res.result_info = res.result_info.split(",");
  280. res.typelist = that.resultLottery(res.result);
  281. return res
  282. });
  283. console.log(that.history.list, 'that.history.list');
  284. } else {
  285. that.history.list = [];
  286. }
  287. // 判断是否不存在游戏,并且没有倒计时对象,且在当前页面
  288. if (that.loadPage && !that.history.next && !that.getNextTimeObj) {
  289. that.getNextTimeObj = setInterval(() => {
  290. that.getGame(id)
  291. }, 1000)
  292. return
  293. }
  294. if (that.history.next && that.getNextTimeObj) {
  295. clearInterval(that.getNextTimeObj);
  296. // 清空倒计时对象
  297. that.getNextTimeObj = '';
  298. }
  299. // 判断是否有活动并且正在进行中
  300. if (that.history.next && !that.getNextTimeObj) {
  301. that.opTiem();
  302. that.gameBetList()
  303. }
  304. })
  305. },
  306. // 处理中奖信息数据
  307. resultLottery(st) {
  308. const that = this;
  309. let typelist = [];
  310. if(st){
  311. st.split(",").forEach((r) => {
  312. const ar = r.split(':');
  313. if (ar[1] == '1') {
  314. for (let i = 0; i < that.history.base.include_function.length; i++) {
  315. if (that.history.base.include_function[i].id == ar[0] * 1) {
  316. typelist.push({
  317. type: that.history.base.include_function[i].name
  318. })
  319. break
  320. }
  321. }
  322. }
  323. });
  324. }
  325. return typelist
  326. },
  327. // 游戏押注记录
  328. gameBetList() {
  329. const that = this;
  330. const lineNum = that.history.base.decimal;
  331. gameBetList({
  332. page: 1,
  333. limit: 10,
  334. id: that.history.base.id,
  335. }).then(({
  336. data
  337. }) => {
  338. that.betList.list = data.bet_log.map((res) => {
  339. res.typelist = that.resultLottery(res.room.result);
  340. return res
  341. });
  342. })
  343. },
  344. // 开始倒计时
  345. async opTiem() {
  346. const that = this;
  347. try {
  348. // 判斷是否有游戲信息并且有正在進行中游戏
  349. if (that.history.base.id && that.history.next) {
  350. // console.log(that.history.base.id, that.history.next,
  351. // 'that.history.base.id && that.history.next');
  352. that.time.t = setInterval(() => {
  353. that.getOutTime();
  354. }, 1000)
  355. }
  356. } catch (e) {
  357. console.log(e, '定时');
  358. }
  359. },
  360. // 倒计时清理
  361. initData() {
  362. const that = this
  363. // 关闭倒计时
  364. clearInterval(that.getNextTimeObj);
  365. clearInterval(that.time.t);
  366. // 清空倒计时对象
  367. that.getNextTimeObj = '';
  368. that.time = {
  369. H: 0,
  370. M: 0,
  371. S: 0,
  372. t: ''
  373. };
  374. },
  375. // 点击触发支付事件
  376. onPayBet() {
  377. if (!this.upOnBtnData.value) {
  378. uni.showToast({
  379. title: this.$t('enter.a9'),
  380. icon: "error"
  381. })
  382. return
  383. }
  384. if (!this.history.next) {
  385. uni.showModal({
  386. title: this.$t('enter.c4'),
  387. content: this.$t('enter.a3'),
  388. showCancel: false,
  389. confirmText: this.$t('indexenter.确定'),
  390. });
  391. return
  392. }
  393. this.upOnBtnData.type = this.history.base.include_function[this.actiontype].id;
  394. this.openPayPassword();
  395. },
  396. // 打开支付弹窗
  397. openPayPassword() {
  398. this.upOnBtnData.show = true;
  399. this.$refs.popup.open();
  400. },
  401. // 关闭支付弹窗
  402. colsePayPassword() {
  403. this.upOnBtnData.show = false;
  404. this.$refs.popup.close();
  405. },
  406. // 密码输入完成后调用下注
  407. KeyInfo(val) {
  408. const that = this;
  409. that.upOnBtnData.passwordArr = val;
  410. const name = that.$t(`indexenter.${that.history.base.include_function[that.actiontype].name}`)
  411. that.colsePayPassword();
  412. uni.showModal({
  413. title: that.$t('enter.c4'),
  414. content: `${that.$t('enter.a8')}${that.upOnBtnData.value}USDT${that.$t('enter.a10')}${that.history.next.no}${name}`,
  415. cancelText: that.$t('indexenter.取消'),
  416. confirmText: that.$t('indexenter.确定'),
  417. success: res => {
  418. if (res.confirm) {
  419. that.gameBetIn();
  420. }
  421. },
  422. });
  423. },
  424. // 参与压住
  425. gameBetIn(type) {
  426. const that = this;
  427. const upData = {
  428. id: that.history.next.id,
  429. bet: that.upOnBtnData.type,
  430. num: that.upOnBtnData.value,
  431. trade_password: that.upOnBtnData.passwordArr
  432. };
  433. uni.showLoading({
  434. mask: true
  435. })
  436. that.upOnBtnData.value = '';
  437. gameBetIn(upData).then((res) => {
  438. uni.hideLoading()
  439. uni.showToast({
  440. title: res.msg
  441. });
  442. that.gameBetList();
  443. that.getUserWallet();
  444. }).catch((res) => {
  445. uni.hideLoading();
  446. uni.showToast({
  447. title: res.msg
  448. });
  449. })
  450. },
  451. // 获取用户余额信息
  452. getUserWallet() {
  453. gameWallet().then((res) => {
  454. const balance = Number(res.data.back.USDT.money.money);
  455. this.userWallet = balance.toFixed(2);
  456. // this.userWallet = +res.data.back.USDT.money.money
  457. })
  458. },
  459. // 获取倒计时时间
  460. getOutTime() {
  461. const that = this;
  462. const da = (new Date()).getTime();
  463. const timenum = that.history.next.open_time * 1000 - da;
  464. // console.log(timenum, that.history.next.open_time, da, '计算');
  465. if (timenum > 0) {
  466. that.time.H = Math.floor(timenum / 1000 / 60 / 60);
  467. that.time.S = Math.floor(timenum / 1000 % 60)
  468. that.time.M = Math.floor(timenum / 1000 / 60 % 60);
  469. }
  470. if (that.time.H == 0 && that.time.M == 0 && that.time.S == 0) {
  471. console.log('归0');
  472. clearInterval(that.time.t);
  473. // 延时调用防止数据重复加载
  474. setTimeout(() => {
  475. that.getGame(that.history.base.id);
  476. }, 2000)
  477. }
  478. },
  479. // 页面跳转
  480. nav(url) {
  481. console.log('tz');
  482. if (!this.hasLogin) {
  483. uni.showModal({
  484. title: this.$t('enter.c4'),
  485. content: this.$t('enter.b5'),
  486. cancelText: this.$t('indexenter.取消'),
  487. confirmText: this.$t('indexenter.确定'),
  488. success: (e) => {
  489. // 判断是否点击确认按钮
  490. if (e.confirm) {
  491. // 保存当前页面地址
  492. saveUrl()
  493. // 跳转页面
  494. interceptor()
  495. }
  496. }
  497. })
  498. return
  499. }
  500. uni.navigateTo({
  501. url,
  502. fail(err) {
  503. console.log(err);
  504. }
  505. });
  506. },
  507. },
  508. };
  509. </script>
  510. <style lang="scss">
  511. $yellow: #FDAF41;
  512. .all {
  513. width: 750rpx;
  514. /* height: 2500rpx; */
  515. height: 100%;
  516. padding-top: var(--status-bar-height);
  517. padding-bottom: 30rpx;
  518. color: #FFFFFF;
  519. }
  520. .chz {
  521. background: #191a1f;
  522. border-radius: 20rpx;
  523. margin: 0 30rpx;
  524. color: #ffffff;
  525. font-weight: bold;
  526. padding: 20rpx 30rpx;
  527. .yue {
  528. font-size: 28rpx;
  529. }
  530. .yes {
  531. color: $color-yellow;
  532. }
  533. .quc {
  534. font-size: 26rpx;
  535. font-weight: 500;
  536. }
  537. .choz {
  538. width: 22rpx;
  539. height: 14rpx;
  540. }
  541. }
  542. .number {
  543. flex-wrap: wrap;
  544. padding: 70rpx;
  545. padding-bottom: 0;
  546. .item-num {
  547. line-height: 1;
  548. text-align: center;
  549. font-weight: bold;
  550. width: 260rpx;
  551. border-radius: 20rpx;
  552. margin-bottom: 70rpx;
  553. padding: 30rpx;
  554. background: linear-gradient(-74deg, rgba(206, 156, 109, 0.4), rgba(255, 236, 214, 0.4));
  555. &.action {
  556. background: linear-gradient(-74deg, #CE9C6D, #FFECD6);
  557. }
  558. .type {
  559. font-size: 72rpx;
  560. }
  561. .percentage {
  562. padding-top: 20rpx;
  563. font-size: $font-base;
  564. }
  565. }
  566. }
  567. .money-list {
  568. padding: 0 30rpx;
  569. color: #FFF;
  570. text-align: center;
  571. align-items: stretch;
  572. padding-bottom: 50rpx;
  573. .list-ls {
  574. width: 23%;
  575. flex-direction: column;
  576. align-items: stretch;
  577. font-size: 35rpx;
  578. font-weight: bold;
  579. .image {
  580. .img {
  581. width: 100%;
  582. }
  583. }
  584. }
  585. }
  586. .pay-title {
  587. font-size: 26rpx;
  588. }
  589. .pay-money-box {
  590. .pay-money {
  591. flex-grow: 1;
  592. font-size: 38rpx;
  593. font-weight: bold;
  594. color: $yellow;
  595. }
  596. .buttom-del {
  597. background-color: $yellow;
  598. border-radius: 6rpx;
  599. color: #000000;
  600. font-size: 26rpx;
  601. padding: 14rpx 26rpx;
  602. line-height: 1;
  603. }
  604. }
  605. .push-buttom {
  606. text-align: center;
  607. line-height: 1;
  608. color: #000000;
  609. background-color: $yellow;
  610. padding: 30rpx;
  611. margin: 30rpx;
  612. border-radius: 10rpx;
  613. margin-bottom: 40rpx;
  614. }
  615. .history-title {
  616. color: $yellow;
  617. font-size: $font-lg;
  618. }
  619. .history-list {
  620. line-height: 1;
  621. background-color: #1E1E1F;
  622. border-radius: 10rpx;
  623. padding: 30rpx;
  624. margin: 30rpx;
  625. .history-title-type {
  626. font-size: 24rpx;
  627. .history-item {
  628. text-align: center;
  629. width: 25%;
  630. &:nth-child(1) {
  631. text-align: left;
  632. width: 30%;
  633. }
  634. &:nth-child(2) {
  635. width: 30%;
  636. }
  637. &:nth-child(3) {
  638. width: 20%;
  639. }
  640. &:nth-child(4) {
  641. text-align: right;
  642. width: 20%;
  643. }
  644. }
  645. }
  646. }
  647. .top-content {
  648. padding: 30rpx;
  649. color: #FFF;
  650. background-color: #1E1E1F;
  651. line-height: 1;
  652. .top-one {
  653. font-size: $font-lg;
  654. .time {
  655. padding-left: 10rpx;
  656. color: $color-red;
  657. }
  658. }
  659. .top-two {
  660. font-size: 26rpx;
  661. padding-top: 20rpx;
  662. .old-title {
  663. .dice {
  664. width: 54rpx;
  665. height: 54rpx;
  666. margin-left: 10rpx;
  667. }
  668. }
  669. .old-num {
  670. color: $color-yellow;
  671. }
  672. }
  673. }
  674. </style>