feat,wip: 토너먼트 베팅 진행

This commit is contained in:
2022-04-25 00:30:31 +09:00
parent 18f2e9ffea
commit 42fc0f6aed
7 changed files with 164 additions and 178 deletions
+13 -23
View File
@@ -4,39 +4,29 @@ import { setAxiosXMLHttpRequest } from '@util/setAxiosXMLHttpRequest';
import type { InvalidResponse } from '@/defs';
import { convertFormData } from '@util/convertFormData';
import { unwrap_any } from '@util/unwrap_any';
import { SammoAPI } from './SammoAPI';
$(function($){
setAxiosXMLHttpRequest();
declare const staticValues: {
bettingID: number;
}
$('.submitBtn').on('click', async function(e){
$(function ($) {
$('.submitBtn').on('click', async function (e) {
e.preventDefault();
const $this = $(this);
const target = parseInt($this.data('target'));
const amount = parseInt(unwrap_any<string>($(`#target_${target}`).val()));
let result: InvalidResponse;
try{
const response = await axios({
url: 'j_betting.php',
responseType: 'json',
method: 'post',
data: convertFormData({
target: target,
amount: amount
})
try {
await SammoAPI.Betting.Bet({
bettingID: staticValues.bettingID,
bettingType: [target],
amount: amount,
});
result = response.data;
}catch(e){
} catch (e) {
console.error(e);
alert(`에러: ${e}`);
location.reload();
return;
}
if(!result.result){
alert(`베팅을 실패했습니다: ${result.reason}`);
alert(`베팅을 실패했습니다: ${e}`);
location.reload();
return;
}