entertainment.vue 16 KB

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