123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212 |
- <template>
- <div class="game-main-wrap">
- <game-header></game-header>
- <div class="game-desktop">
- <div class="game-cell-wrap">
- <div class="game-desk-bg" :class="`${$i18n.locale}-lang-bg`"></div>
- <div class="game-cell-item"
- v-for="(item, key) in typeMap"
- :key="key"
- :class="[`game-cell-${key}`, {'checked': typeMap[key]['amount'].length, 'opened': openArray.includes(key)}]"
- @click="betSelect(key, $event)"
- >
- <div class="cell-counter"
- :class="`counter-${getColor(item.sum)}`"
- v-if="item.sum">
- {{item.sum}}
- </div>
- </div>
- <div class="moblie-rule-cell" @click="showRules">
- <i class="game-question-icon"></i>
- </div>
- </div>
- <game-bet
- @update:betNum="updateBetNum"
- @update:counter="changeCounter"
- @update:newgame="openGame"
- @clearbet="clearBet"
- :betArray="betArray"
- :betSum="betSum"
- ref="gamebet"
- ></game-bet>
- <div class="m-bet-sum">
- {{$t('gtTips')}} {{gtRate}}GT
- <i class="gt-times-icon" v-if="gtRate > 1">X{{gtRate}}</i>
- <i class="gt-help-icon" @click="showGtRules"></i>
- <div class="right">
- {{$t('game.confirmTip')}}:{{betSum}}<i class="game-eos-icon"></i>,{{$t('game.winGt')}} {{gtGet}}<i class="game-gt-icon"></i>
- </div>
- </div>
- </div>
- <div class="bet-sum">{{$t('game.confirmTip')}}:{{betSum}}<i class="game-eos-icon"></i>,{{$t('game.winGt')}} {{gtGet}}<i class="game-gt-icon"></i></div>
- </div>
- </template>
- <script>
- import gameHeader from './gameHeader'
- import gameBet from './gameBet'
- import typeMap from './typeMap.js'
- import NP from 'number-precision'
- import Rules from '@/components/popup/rules'
- import $ from 'jquery'
- import { funParabola } from '@/util/util'
- import { mapState } from 'vuex'
- export default {
- name: 'gameDeskTop',
- data () {
- return {
- typeMap,
- openArray: [],
- betArray: [],
- betNum: 1,
- gtGet: 0,
- isCounter: false,
- tenBetShow: false,
- isOpening: false // 开奖中禁止点击
- }
- },
- components: {
- gameHeader,
- gameBet
- },
- computed: {
- ...mapState({
- account: state => state.account,
- gtRate: state => state.gtRate,
- newOpen: state => state.newOpen,
- newOffer: state => state.newOffer
- }),
- betSum () {
- if (this.betArray.length) {
- let sum = 0
- this.betArray.forEach(x => {
- sum = NP.plus(sum, x.bet)
- })
- return sum / 10000
- } else {
- return 0
- }
- }
- },
- watch: {
- newOpen (to, from) {
- this.openArray.splice(0, this.openArray.length)
- if (to.player === this.account.name) {
- this.openArray = to.result.split('|')
- }
- },
- newOffer (to, from) {
- if (to.player === this.account.name) {
- this.gtGet = NP.times(this.betSum, this.gtRate)
- // 开奖禁止点击
- this.isOpening = true
- }
- }
- },
- methods: {
- // 下注
- betSelect (code, event) {
- if (this.$refs['gamebet'].tenBeting || this.isOpening) {
- return
- }
- if (this.betSum + this.betNum > 100) {
- this.$showTips(this.$t('moreBet'))
- return
- }
- this.betArray.push({
- code,
- bet: this.betNum * 10000
- })
- let target = event.currentTarget
- let flyEl, $cloneEl
- if (this.isCounter) {
- let id = `counter${this.betNum * 10}`
- let dom = document.getElementById(id)
- $cloneEl = $(dom).clone().attr('style', '')
- $('.counter-target-wrap').append($cloneEl)
- } else {
- let id = `counter${this.getColor(this.betNum)}`
- let dom = document.getElementById(id)
- $cloneEl = $(dom).clone().attr('style', '')
- $('.animate-counter-wrap').append($cloneEl)
- }
- flyEl = $cloneEl[0]
- flyEl.style.visibility = 'visible'
- let self = this
- funParabola(flyEl, target, {
- speed: 1200,
- curvature: 0.001,
- complete () {
- $(flyEl).remove()
- // 计算总数
- let arr = self.typeMap[code]['amount']
- arr.push(self.betNum)
- let sum = arr.reduce((prev, next) => {
- return NP.plus(prev, next)
- })
- self.$set(self.typeMap, code, {
- amount: arr,
- sum
- })
- }
- }).position().move()
- },
- getColor (betNum) {
- var color
- if (betNum < 0.5) {
- color = 'red'
- } else if (betNum >= 0.5 && betNum < 1) {
- color = 'blue'
- } else if (betNum >= 1 && betNum < 5) {
- color = 'pur'
- } else if (betNum >= 5 && betNum < 10) {
- color = 'green'
- } else if (betNum >= 10 && betNum < 20) {
- color = 'yellow'
- } else if (betNum >= 20) {
- color = 'orange'
- }
- return color
- },
- updateBetNum (newval) {
- this.betNum = newval
- },
- changeCounter (flag) {
- this.isCounter = flag
- },
- // 清除按钮
- clearBet () {
- for (let k in this.typeMap) {
- this.$set(this.typeMap, k, {
- amount: [],
- sum: 0
- })
- }
- this.betArray.splice(0, this.betArray.length)
- },
- showGtRules () {
- Rules.showGTRules()
- },
- showRules () {
- Rules.showRules()
- },
- openGame () {
- this.gtGet = 0
- this.clearBet()
- this.openArray.splice(0, this.openArray.length)
- this.isOpening = false
- }
- },
- mounted () {
- }
- }
- </script>
- <style lang="scss">
- @import 'style.scss';
- </style>
|