entertainment.vue 17 KB

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