Created
November 12, 2019 12:51
-
-
Save vitorvargasdev/3a348fac77fd9006afe4826d45cd5c95 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
<span> | |
<span v-if="!$isMobile"> | |
<v-btn | |
color="green" | |
@click="isLogged == true | |
? criarBilhete(prematch.id, prematch.home_name, prematch.away_name, prematch.home_od, 'full_time_result', '1') | |
: alertNoLogged = true" | |
>{{ prematch.home_od | odds }}</v-btn> | |
<v-btn | |
color="green" | |
@click="isLogged == true | |
? criarBilhete(prematch.id, prematch.home_name, prematch.away_name, prematch.draw_od, 'full_time_result', 'X') | |
: alertNoLogged = true" | |
>{{ prematch.draw_od | odds }}</v-btn> | |
<v-btn | |
color="green" | |
@click="isLogged == true | |
? criarBilhete(prematch.id, prematch.home_name, prematch.away_name, prematch.away_od, 'full_time_result', '2') | |
: alertNoLogged = true" | |
>{{ prematch.away_od | odds }}</v-btn> | |
<slot name="mais" /> | |
</span> | |
<span v-else> | |
<slot name="mais" /> | |
</span> | |
<v-snackbar v-model="alertNoLogged" :timeout="2000"> | |
É necessário estar logado para fazer apostas! | |
<v-btn color="blue" text @click="alertNoLogged = false">Fechar</v-btn> | |
</v-snackbar> | |
</span> | |
</template> | |
<script> | |
import axios from "axios"; | |
import { mapState, mapActions, mapGetters } from "vuex"; | |
axios.defaults.headers.common = { | |
'X-Requested-With': 'XMLHttpRequest', | |
"X-CSRF-TOKEN": window.csrf_token | |
}; | |
export default { | |
props: ["id", "bet365_id", "home", "away"], | |
data() { | |
return { | |
prematch: {}, | |
alertNoLogged: false | |
}; | |
}, | |
computed: mapGetters('user', ['isLogged']), | |
methods: { | |
...mapActions("boletim", ["adicionarBilhete"]), | |
prematch_odds(id, state) { | |
async function getData() { | |
return axios.post("/api/upComingPrematch_odds", { id, state }); | |
} | |
getData().then(res => { | |
if (res.data) { | |
this.prematch = { | |
id: this.bet365_id, | |
home_name: this.home, | |
away_name: this.away, | |
home_od: res.data.home_od, | |
draw_od: res.data.draw_od, | |
away_od: res.data.away_od, | |
add_time: res.data.add_time | |
}; | |
} else { | |
this.prematch = { | |
id: null, | |
home_name: null, | |
away_name: null, | |
home_od: "1.00", | |
draw_od: "1.00", | |
away_od: "1.00", | |
add_time: 0 | |
}; | |
} | |
}); | |
}, | |
criarBilhete(id, home, away, odds, NA1, NA2) { | |
let aposta = null; | |
switch (NA2) { | |
case "1": | |
aposta = "Resultado final: " + home; | |
break; | |
case "X": | |
aposta = "Resultado final: Empate"; | |
break; | |
case "2": | |
aposta = "Resultado final: " + away; | |
break; | |
} | |
let bilhete = { | |
id: this.bet365_id, | |
nome_do_jogo: home + " X " + away, | |
nome_da_aposta: aposta, | |
NA1: NA1, | |
NA2: NA2, | |
cotacao: odds | |
}; | |
this.adicionarBilhete(bilhete); | |
} | |
}, | |
mounted() { | |
this.prematch_odds(this.id, "end"); | |
} | |
}; | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment