entertainment.vue 17 KB

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