123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759 |
- <template>
- <view class="all">
- <view class="padding-t-30"></view>
- <view class="top-content">
- <view class="top-one flex">
- <view class="action-title">
- <text v-if="history.next">{{$t('indexenter.第')}}{{history.next.no}}{{$t('indexenter.期')}}</text>
- <text v-else>loading...</text>
- </view>
- <view class="end-time">
- <text>{{$t('indexenter.距离结束')}}</text>
- <text class="time">
- <text v-if="time.H<10">0</text>
- {{time.H}}:
- <text v-if="time.M<10">0</text>
- {{time.M}}:
- <text v-if="time.S<10">0</text>
- {{time.S}}
- </text>
- </view>
- </view>
- <view class="top-two flex" v-if="history.list.length>0">
- <view class="old-title flex-start">
- <text>{{$t('indexenter.第')}}{{history.list[0].no}}{{$t('indexenter.期')}}</text>
- <image v-for="ls in history.list[0].result_info" class="dice"
- :src="`../../static/img/dice${ls}.png`" mode="scaleToFill"></image>
- </view>
- <view class="old-num">
- <!-- {{$t('indexenter.竞猜数')}}:10 -->
- {{$t('indexenter.结果')}}:
- <text class="margin-l-10"
- v-for="ll in history.list[0].typelist">{{$t(`indexenter.${ll.type}`)}}</text>
- </view>
- </view>
- </view>
- <view class="number flex">
- <view class="item-num" :class="{action:ind==actiontype}" v-for="(item,ind) in history.base.include_function"
- @click="actiontype=ind">
- <view class="type">
- {{$t(`indexenter.${item.name}`)}}
- </view>
- <view class="percentage">
- {{item.bfb}}%
- </view>
- </view>
- </view>
- <view class="money-list flex">
- <view class="list-ls flex" @click="upOnBtnData.value=item.value" v-for="(item,ind) in moneyList">
- <view class="image">
- <image class="img" :src="item.url" mode="widthFix"></image>
- </view>
- <view class="list">
- {{item.value}}
- </view>
- </view>
- </view>
- <view class="pay-title padding-l-30">
- {{$t('indexenter.竞猜总额')}}(USDT):
- </view>
- <view class="pay-money-box flex padding-c-30 padding-v-10">
- <input class="pay-money" type="number" v-model="upOnBtnData.value" />
- <view class="buttom-del" @click="upOnBtnData.value=0">
- {{$t('indexenter.清空')}}
- </view>
- </view>
- <view class="pay-title padding-c-30 flex padding-v-20">
- <view>
- {{$t('indexenter.竞猜总额')}}:
- </view>
- <view class="font-color-yellow">
- 0
- USDT
- </view>
- </view>
- <view class="push-buttom" @click="onPayBet">
- {{$t('indexenter.确认')}}
- </view>
- <view class="chz flex" @click="nav('/pages/user/money/recharge')">
- <view>
- <view class="yue padding-b-10">{{$t('enter.u15')}}</view>
- <view class="yes">{{userWallet}}USDT</view>
- </view>
- <view class="flex-start">
- <view class="quc">{{$t('enter.u16')}}</view>
- <image class="choz" src="../../static/img/img39.png" mode="scaleToFill"></image>
- </view>
- </view>
- <view class="history-title padding-l-30 margin-t-30 flex-start">
- <view :class="{action:historyType==0}" @click="historyType=0">
- {{$t('indexenter.押注记录')}}
- </view>
- <view class="margin-l-30" :class="{action:historyType==1}" @click="historyType=1">
- {{$t('indexenter.近期记录')}}
- </view>
- </view>
- <view class="history-list">
- <view class="history-title-type flex">
- <view class="history-item">
- {{$t('indexenter.期号')}}
- </view>
- <view class="history-item" v-if="historyType==0">
- {{$t('indexenter.竞猜值')}}
- </view>
- <view class="history-item">
- {{$t('indexenter.竞猜数')}}
- </view>
- <view class="history-item">
- {{$t('indexenter.结果')}}
- </view>
- </view>
- <view class="history-title-type flex margin-t-30" v-for="(item,ind) in betList.list" :key="ind"
- v-if="historyType==0">
- <view class="history-item font-color-yellow"
- :class="{'font-color-gray':item.result==0,'font-color-red':item.result==1}">
- {{item.room.no}}
- </view>
- <view class="history-item font-color-red">
- <text class="margin-l-10" v-for="(ll,ind) in history.base.include_function"
- v-if="item.bet==ll.id">{{$t(`indexenter.${ll.name}`)}}</text>
- </view>
- <view class="history-item font-color-red">
- {{item.room.result_info||$t('enter.a2')}}
- </view>
- <view class="history-item font-color-yellow" v-if="item.typelist.length>0">
- <text class="margin-l-10" v-for="ll in item.typelist">{{$t(`indexenter.${ll.type}`)}}</text>
- </view>
- <view class="history-item font-color-yellow" v-else>
- {{$t('enter.a2')}}
- </view>
- </view>
- <view class="history-title-type flex margin-t-30" v-for="(item,ind) in history.list" :key="ind"
- v-if="historyType==1">
- <view class="history-item font-color-yellow"
- :class="{'font-color-gray':item.result==0,'font-color-red':item.result==1}">
- {{item.no}}
- </view>
- <!-- <view class="history-item font-color-red">
- <text class="margin-l-10"
- v-for="(ll,ind) in history.base.include_function" v-if="item.bet==ll.id">{{$t(`indexenter.${ll.name}`)}}</text>
- </view> -->
- <view class="history-item font-color-red flex">
- <image v-for="ls in item.result_info" class="dice-number" :src="`../../static/img/dice${ls}.png`"
- mode="scaleToFill"></image>
- </view>
- <view class="history-item font-color-yellow" v-if="item.typelist.length>0">
- <text class="margin-l-10" v-for="ll in item.typelist">{{$t(`indexenter.${ll.type}`)}}</text>
- </view>
- <view class="history-item font-color-yellow" v-else>
- {{$t('enter.a2')}}
- </view>
- </view>
- </view>
- <uni-popup type="bottom" ref="popup" :mask-click="false" @maskClick='colsePayPassword'>
- <inputPassword @commit='KeyInfo' @colse='colsePayPassword'></inputPassword>
- </uni-popup>
- </view>
- </template>
- <script>
- import {} from "@/api/game.js";
- import {
- mapState,
- mapMutations
- } from 'vuex';
- import {
- getGame,
- getGameList,
- gameWallet,
- gameBetList,
- gameBetIn,
- // gameTest
- } from "@/api/game.js";
- import {
- saveUrl,
- interceptor
- } from '@/utils/loginUtils.js';
- import {
- getTime
- } from '@/utils/rocessor.js';
- import inputPassword from "@/components/input-password/input-password.vue";
- export default {
- components: {
- inputPassword
- },
- computed: {
- ...mapState("user", ["hasLogin"]),
- },
- data() {
- return {
- historyType: 0, //记录类型
- // 当前选中的大小奇偶
- actiontype: 0,
- id: '',
- moneyList: [{
- url: '/static/img/money_pay_1.png',
- value: 5
- }, {
- url: '/static/img/money_pay_2.png',
- value: 10
- },
- {
- url: '/static/img/money_pay_3.png',
- value: 30
- },
- {
- url: '/static/img/money_pay_4.png',
- value: 50
- }
- ],
- // 游戏信息
- time: {
- H: 0,
- M: 0,
- S: 0,
- // 保存倒计时对象
- t: ''
- },
- // 游戏信息
- history: {
- list: [], //游戏进行记录
- page: 1,
- limit: 10,
- // 基础数据
- base: {},
- next: "",
- now: {}
- },
- // 游戏押注记录
- betList: {
- list: [], //游戏进行记录
- page: 1,
- limit: 5,
- },
- userWallet: 0,
- upOnBtnData: {
- type: '',
- // 当前输入的密码
- passwordArr: '',
- value: 0,
- },
- // 保存获取下次游戏对象
- getNextTimeObj: '',
- loadPage:true,
- };
- },
- onLoad(option) {
- this.id = option.id;
- uni.setNavigationBarTitle({
- title: option.title
- });
- },
- onShow() {
- if (!this.hasLogin) {
- uni.showModal({
- title: this.$t('enter.c4'),
- content: this.$t('enter.b5'),
- cancelText: this.$t('indexenter.取消'),
- confirmText: this.$t('indexenter.确定'),
- success: (e) => {
- // 判断是否点击确认按钮
- if (e.confirm) {
- // 保存当前页面地址
- saveUrl()
- // 跳转页面
- interceptor()
- }
- }
- })
- return
- }
- this.getUserWallet();
- this.gameInit(this.id);
- },
- // 关闭循环
- onHide() {
- const that = this;
- // 倒计时清理
- that.initData();
- },
- onUnload() {
- const that = this;
- that.initData();
- },
- methods: {
- getTime,
- // 初始化
- gameInit(id) {
- console.log('id', id);
- // await gameTest();
- // 获取基础信息
- this.getGame(id);
- },
- // 获取游戏信息
- getGame(id) {
- const that = this;
- getGame({
- page: that.history.page,
- limit: that.history.limit
- }, id).then(({
- data
- }) => {
- that.history.base = data.game || {};
- that.history.base.include_function = that.history.base.include_function.map((res) => {
- res.bfb = res.ratio * 1 * that.history.base.success_ratio / 100;
- return res
- })
- that.history.next = data.now_game || '';
- that.history.now = data.now_game || '';
- if (data.list) {
- that.history.list = data.list.map((res) => {
- res.result_info = res.result_info.split(",");
- res.typelist = that.resultLottery(res.result);
- return res
- });
- console.log(that.history.list, 'that.history.list');
- } else {
- that.history.list = [];
- }
- // 判断是否不存在游戏,并且没有倒计时对象,且在当前页面
- if (that.loadPage && !that.history.next) {
- that.getNextTimeObj = setTimeout(() => {
- that.getGame(id)
- }, 1000)
- return
- }
- if (that.history.next && that.getNextTimeObj) {
- clearTimeout(that.getNextTimeObj);
- // 清空倒计时对象
- that.getNextTimeObj = '';
- }
- // 判断是否有活动并且正在进行中
- if (that.history.next && !that.getNextTimeObj) {
- that.opTiem();
- that.gameBetList()
- }
- })
- },
- // 处理中奖信息数据
- resultLottery(st) {
- const that = this;
- let typelist = [];
- if (st) {
- st.split(",").forEach((r) => {
- const ar = r.split(':');
- if (ar[1] == '1') {
- for (let i = 0; i < that.history.base.include_function.length; i++) {
- if (that.history.base.include_function[i].id == ar[0] * 1) {
- typelist.push({
- type: that.history.base.include_function[i].name
- })
- break
- }
- }
- }
- });
- }
- return typelist
- },
- // 游戏押注记录
- gameBetList() {
- const that = this;
- if (that.historyType == 0) {
- const lineNum = that.history.base.decimal;
- gameBetList({
- page: 1,
- limit: 10,
- id: that.history.base.id,
- }).then(({
- data
- }) => {
- that.betList.list = data.bet_log.map((res) => {
- res.typelist = that.resultLottery(res.room.result);
- return res
- });
- })
- }
- },
- // 开始倒计时
- async opTiem() {
- const that = this;
- try {
- // 判斷是否有游戲信息并且有正在進行中游戏
- if (that.history.base.id && that.history.next) {
- // console.log(that.history.base.id, that.history.next,
- // 'that.history.base.id && that.history.next');
- that.time.t = setInterval(() => {
- that.getOutTime();
- }, 1000)
- }
- } catch (e) {
- console.log(e, '定时');
- }
- },
- // 清除加载
- initData() {
- const that = this;
- that.loadPage = false;
- // 关闭倒计时
- clearTimeout(that.getNextTimeObj);
- clearInterval(that.time.t);
- // 清空倒计时对象
- that.getNextTimeObj = '';
- that.time = {
- H: 0,
- M: 0,
- S: 0,
- t: ''
- };
- },
- // 点击触发支付事件
- onPayBet() {
- if (!this.upOnBtnData.value) {
- uni.showToast({
- title: this.$t('enter.a9'),
- icon: "error"
- })
- return
- }
- if (!this.history.next) {
- uni.showModal({
- title: this.$t('enter.c4'),
- content: this.$t('enter.a3'),
- showCancel: false,
- confirmText: this.$t('indexenter.确定'),
- });
- return
- }
- this.upOnBtnData.type = this.history.base.include_function[this.actiontype].id;
- this.openPayPassword();
- },
- // 打开支付弹窗
- openPayPassword() {
- this.upOnBtnData.show = true;
- this.$refs.popup.open();
- },
- // 关闭支付弹窗
- colsePayPassword() {
- this.upOnBtnData.show = false;
- this.$refs.popup.close();
- },
- // 密码输入完成后调用下注
- KeyInfo(val) {
- const that = this;
- that.upOnBtnData.passwordArr = val;
- const name = that.$t(`indexenter.${that.history.base.include_function[that.actiontype].name}`)
- that.colsePayPassword();
- uni.showModal({
- title: that.$t('enter.c4'),
- content: `${that.$t('enter.a8')}${that.upOnBtnData.value}USDT${that.$t('enter.a10')}${that.history.next.no}${name}`,
- cancelText: that.$t('indexenter.取消'),
- confirmText: that.$t('indexenter.确定'),
- success: res => {
- if (res.confirm) {
- that.gameBetIn();
- }
- },
- });
- },
- // 参与压住
- gameBetIn(type) {
- const that = this;
- const upData = {
- id: that.history.next.id,
- bet: that.upOnBtnData.type,
- num: that.upOnBtnData.value,
- trade_password: that.upOnBtnData.passwordArr
- };
- uni.showLoading({
- mask: true
- })
- that.upOnBtnData.value = '';
- gameBetIn(upData).then((res) => {
- uni.hideLoading()
- uni.showToast({
- title: res.msg
- });
- that.gameBetList();
- that.getUserWallet();
- }).catch((res) => {
- uni.hideLoading();
- uni.showToast({
- title: res.msg
- });
- })
- },
- // 获取用户余额信息
- getUserWallet() {
- gameWallet().then((res) => {
- const balance = Number(res.data.back.USDT.money.money);
- this.userWallet = balance.toFixed(2);
- // this.userWallet = +res.data.back.USDT.money.money
- })
- },
- // 获取倒计时时间
- getOutTime() {
- const that = this;
- const da = (new Date()).getTime();
- const timenum = that.history.next.close_time * 1000 - da;
- // console.log(timenum, that.history.next.open_time, da, '计算');
- if (timenum > 0) {
- that.time.H = Math.floor(timenum / 1000 / 60 / 60);
- that.time.S = Math.floor(timenum / 1000 % 60)
- that.time.M = Math.floor(timenum / 1000 / 60 % 60);
- }
- if (that.time.H == 0 && that.time.M == 0 && that.time.S == 0) {
- console.log('归0');
- clearInterval(that.time.t);
- // 延时调用防止数据重复加载
- setTimeout(() => {
- that.getGame(that.history.base.id);
- }, 2000)
- }
- },
- // 页面跳转
- nav(url) {
- console.log('tz');
- if (!this.hasLogin) {
- uni.showModal({
- title: this.$t('enter.c4'),
- content: this.$t('enter.b5'),
- cancelText: this.$t('indexenter.取消'),
- confirmText: this.$t('indexenter.确定'),
- success: (e) => {
- // 判断是否点击确认按钮
- if (e.confirm) {
- // 保存当前页面地址
- saveUrl()
- // 跳转页面
- interceptor()
- }
- }
- })
- return
- }
- uni.navigateTo({
- url,
- fail(err) {
- console.log(err);
- }
- });
- },
- },
- };
- </script>
- <style lang="scss">
- $yellow: #FDAF41;
- .all {
- width: 750rpx;
- /* height: 2500rpx; */
- height: 100%;
- padding-top: var(--status-bar-height);
- padding-bottom: 30rpx;
- color: #FFFFFF;
- }
- .chz {
- background: #191a1f;
- border-radius: 20rpx;
- margin: 0 30rpx;
- color: #ffffff;
- font-weight: bold;
- padding: 20rpx 30rpx;
- .yue {
- font-size: 28rpx;
- }
- .yes {
- color: $color-yellow;
- }
- .quc {
- font-size: 26rpx;
- font-weight: 500;
- }
- .choz {
- width: 22rpx;
- height: 14rpx;
- }
- }
- .number {
- flex-wrap: wrap;
- padding: 70rpx;
- padding-bottom: 0;
- .item-num {
- line-height: 1;
- text-align: center;
- font-weight: bold;
- width: 260rpx;
- border-radius: 20rpx;
- margin-bottom: 70rpx;
- padding: 30rpx;
- background: linear-gradient(-74deg, rgba(206, 156, 109, 0.4), rgba(255, 236, 214, 0.4));
- &.action {
- background: linear-gradient(-74deg, #CE9C6D, #FFECD6);
- }
- .type {
- font-size: 72rpx;
- }
- .percentage {
- padding-top: 20rpx;
- font-size: $font-base;
- }
- }
- }
- .money-list {
- padding: 0 30rpx;
- color: #FFF;
- text-align: center;
- align-items: stretch;
- padding-bottom: 50rpx;
- .list-ls {
- width: 23%;
- flex-direction: column;
- align-items: stretch;
- font-size: 35rpx;
- font-weight: bold;
- .image {
- .img {
- width: 100%;
- }
- }
- }
- }
- .pay-title {
- font-size: 26rpx;
- }
- .pay-money-box {
- .pay-money {
- flex-grow: 1;
- font-size: 38rpx;
- font-weight: bold;
- color: $yellow;
- }
- .buttom-del {
- background-color: $yellow;
- border-radius: 6rpx;
- color: #000000;
- font-size: 26rpx;
- padding: 14rpx 26rpx;
- line-height: 1;
- }
- }
- .push-buttom {
- text-align: center;
- line-height: 1;
- color: #000000;
- background-color: $yellow;
- padding: 30rpx;
- margin: 30rpx;
- border-radius: 10rpx;
- margin-bottom: 40rpx;
- }
- .history-title {
- font-size: $font-lg;
- .action {
- color: $yellow;
- }
- }
- .history-list {
- line-height: 1;
- background-color: #1E1E1F;
- border-radius: 10rpx;
- padding: 30rpx;
- margin: 30rpx;
- .history-title-type {
- font-size: 24rpx;
- .history-item {
- text-align: center;
- width: 25%;
- .dice-number {
- width: 40rpx;
- height: 40rpx;
- }
- &:nth-child(1) {
- text-align: left;
- width: 30%;
- }
- &:nth-child(2) {
- width: 30%;
- }
- &:nth-child(3) {
- width: 20%;
- }
- &:nth-child(4) {
- text-align: right;
- width: 20%;
- }
- }
- }
- }
- .top-content {
- padding: 30rpx;
- color: #FFF;
- background-color: #1E1E1F;
- line-height: 1;
- .top-one {
- font-size: $font-lg;
- .time {
- padding-left: 10rpx;
- color: $color-red;
- }
- }
- .top-two {
- font-size: 26rpx;
- padding-top: 20rpx;
- .old-title {
- .dice {
- width: 54rpx;
- height: 54rpx;
- margin-left: 10rpx;
- }
- }
- .old-num {
- color: $color-yellow;
- }
- }
- }
- </style>
|