|
@@ -276,8 +276,8 @@
|
|
import { ref, onMounted,computed, reactive } from "vue";
|
|
import { ref, onMounted,computed, reactive } from "vue";
|
|
import Header from "@/components/Header";
|
|
import Header from "@/components/Header";
|
|
import { sendSingleReward,WGTForToken,STTForToken,getBalance } from "@/utils/web.js";
|
|
import { sendSingleReward,WGTForToken,STTForToken,getBalance } from "@/utils/web.js";
|
|
-import { matchList, matchRank, matchInfo,verifyEnroll,matchEnroll,userPrize,claimPrize,sysSetting } from "@/api/game";
|
|
|
|
-import { getreportlogger } from "@/utils/utils.js";
|
|
|
|
|
|
+import { matchList, matchRank, matchInfo,verifyEnroll,matchEnroll,userPrize,claimPrize,sysSetting,enrollGameMatch,receiveGamePrize } from "@/api/game";
|
|
|
|
+import { getreportlogger,AES_CBC_ENCRYPT } from "@/utils/utils.js";
|
|
import dayjs from "dayjs";
|
|
import dayjs from "dayjs";
|
|
const timeData = ref({});
|
|
const timeData = ref({});
|
|
const onChange = (e) => {
|
|
const onChange = (e) => {
|
|
@@ -293,12 +293,12 @@ const WGTbalance = ref(0);
|
|
const STTbalance = ref(0);
|
|
const STTbalance = ref(0);
|
|
const entry_fee = ref(0);
|
|
const entry_fee = ref(0);
|
|
const wgt_price = ref(0);
|
|
const wgt_price = ref(0);
|
|
-const privateKey = ref('');
|
|
|
|
const triggered = ref(false);
|
|
const triggered = ref(false);
|
|
const received = ref(false);
|
|
const received = ref(false);
|
|
const receivedItem = ref({});
|
|
const receivedItem = ref({});
|
|
const GasRate = ref(1);
|
|
const GasRate = ref(1);
|
|
-// const privateKey = ref("4d8d38c6433c9552a11181b64a234814cd83f5b0d2c7306545ee097da9c0e4b2");//H5
|
|
|
|
|
|
+// const privateKey = ref('');
|
|
|
|
+const privateKey = ref("4d8d38c6433c9552a11181b64a234814cd83f5b0d2c7306545ee097da9c0e4b2");//H5
|
|
|
|
|
|
const bgClass = computed(() => {
|
|
const bgClass = computed(() => {
|
|
if (gameCheck.value === 0) return 'bg1';
|
|
if (gameCheck.value === 0) return 'bg1';
|
|
@@ -306,7 +306,7 @@ const bgClass = computed(() => {
|
|
return 'bg3';
|
|
return 'bg3';
|
|
});
|
|
});
|
|
const handleAddressUpdate = (addr) => {
|
|
const handleAddressUpdate = (addr) => {
|
|
- privateKey.value = window.android.getPrivateKey();//app
|
|
|
|
|
|
+ // privateKey.value = window.android.getPrivateKey();//app
|
|
walletAddress.value = addr;
|
|
walletAddress.value = addr;
|
|
getSysSetting();
|
|
getSysSetting();
|
|
getGameMatchList();
|
|
getGameMatchList();
|
|
@@ -389,27 +389,27 @@ const changeSign = async () =>{
|
|
}
|
|
}
|
|
}
|
|
}
|
|
// 报名
|
|
// 报名
|
|
-const getMatchEnroll = async (hash) =>{
|
|
|
|
- let res = await matchEnroll({
|
|
|
|
- dapp_id:15,
|
|
|
|
- match_id:gameList.value[gameCheck.value]?.id,
|
|
|
|
- address:walletAddress.value,
|
|
|
|
- entry_hash:hash
|
|
|
|
- });
|
|
|
|
- if (res.status == 200) {
|
|
|
|
- uni.hideLoading()
|
|
|
|
- uni.showToast({
|
|
|
|
- title: '报名成功',
|
|
|
|
- icon: 'none',
|
|
|
|
- duration: 1000
|
|
|
|
- })
|
|
|
|
- setTimeout(() => {
|
|
|
|
- getGameMatchList(false);
|
|
|
|
- }, 1500);
|
|
|
|
- }else{
|
|
|
|
- uni.hideLoading()
|
|
|
|
- }
|
|
|
|
-}
|
|
|
|
|
|
+// const getMatchEnroll = async (hash) =>{
|
|
|
|
+// let res = await matchEnroll({
|
|
|
|
+// dapp_id:15,
|
|
|
|
+// match_id:gameList.value[gameCheck.value]?.id,
|
|
|
|
+// address:walletAddress.value,
|
|
|
|
+// entry_hash:hash
|
|
|
|
+// });
|
|
|
|
+// if (res.status == 200) {
|
|
|
|
+// uni.hideLoading()
|
|
|
|
+// uni.showToast({
|
|
|
|
+// title: '报名成功',
|
|
|
|
+// icon: 'none',
|
|
|
|
+// duration: 1000
|
|
|
|
+// })
|
|
|
|
+// setTimeout(() => {
|
|
|
|
+// getGameMatchList(false);
|
|
|
|
+// }, 1500);
|
|
|
|
+// }else{
|
|
|
|
+// uni.hideLoading()
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
|
|
const changeWGT = async () => {
|
|
const changeWGT = async () => {
|
|
if(WGTbalance.value < wgt_price.value){
|
|
if(WGTbalance.value < wgt_price.value){
|
|
@@ -420,7 +420,8 @@ const changeWGT = async () => {
|
|
});
|
|
});
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
- await handleTokenSignUp(WGTForToken, wgt_price.value);
|
|
|
|
|
|
+ // await handleTokenSignUp(WGTForToken, wgt_price.value);
|
|
|
|
+ await handleTokenSignUp('wgt', wgt_price.value);
|
|
};
|
|
};
|
|
|
|
|
|
const changeSTT = async () => {
|
|
const changeSTT = async () => {
|
|
@@ -432,7 +433,8 @@ const changeSTT = async () => {
|
|
});
|
|
});
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
- await handleTokenSignUp(STTForToken, entry_fee.value);
|
|
|
|
|
|
+ // await handleTokenSignUp(STTForToken, entry_fee.value);
|
|
|
|
+ await handleTokenSignUp('stt', entry_fee.value);
|
|
};
|
|
};
|
|
|
|
|
|
const handleTokenSignUp = async (signUpFn, price) => {
|
|
const handleTokenSignUp = async (signUpFn, price) => {
|
|
@@ -442,18 +444,45 @@ const handleTokenSignUp = async (signUpFn, price) => {
|
|
mask: true
|
|
mask: true
|
|
});
|
|
});
|
|
try {
|
|
try {
|
|
- const result = await signUpFn(privateKey.value, price,GasRate.value);
|
|
|
|
- if (result.status === "success") {
|
|
|
|
- await getMatchEnroll(result.hash);
|
|
|
|
- } else {
|
|
|
|
- uni.hideLoading();
|
|
|
|
|
|
+ // 加密
|
|
|
|
+ let {ciphertext, iv} = await AES_CBC_ENCRYPT(privateKey.value);
|
|
|
|
+ // console.log(signUpFn, ciphertext, iv);
|
|
|
|
+ let res = await enrollGameMatch({
|
|
|
|
+ dapp_id:15,match_id:gameDetail.value?.id,address:walletAddress.value,
|
|
|
|
+ key: ciphertext, _m: iv, type: signUpFn
|
|
|
|
+ });
|
|
|
|
+ // console.log(res);
|
|
|
|
+ if (res.status == 200) {
|
|
|
|
+ uni.hideLoading()
|
|
uni.showToast({
|
|
uni.showToast({
|
|
- title: result.message || "报名失败",
|
|
|
|
|
|
+ title: '报名成功',
|
|
|
|
+ icon: 'none',
|
|
|
|
+ duration: 1000
|
|
|
|
+ })
|
|
|
|
+ setTimeout(() => {
|
|
|
|
+ getGameMatchList(false);
|
|
|
|
+ }, 1000);
|
|
|
|
+ }else{
|
|
|
|
+ uni.hideLoading()
|
|
|
|
+ uni.showToast({
|
|
|
|
+ title: res.message || "领取失败",
|
|
icon: 'none',
|
|
icon: 'none',
|
|
duration: 5000
|
|
duration: 5000
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
+ // const result = await signUpFn(privateKey.value, price,GasRate.value);
|
|
|
|
+ // if (result.status === "success") {
|
|
|
|
+ // await getMatchEnroll(result.hash);
|
|
|
|
+ // } else {
|
|
|
|
+ // uni.hideLoading();
|
|
|
|
+ // uni.showToast({
|
|
|
|
+ // title: result.message || "报名失败",
|
|
|
|
+ // icon: 'none',
|
|
|
|
+ // duration: 5000
|
|
|
|
+ // });
|
|
|
|
+ // }
|
|
} catch (error) {
|
|
} catch (error) {
|
|
|
|
+ console.log(error)
|
|
uni.hideLoading();
|
|
uni.hideLoading();
|
|
uni.showToast({
|
|
uni.showToast({
|
|
title: error.message || "报名失败",
|
|
title: error.message || "报名失败",
|
|
@@ -481,24 +510,24 @@ const awardFun = async (item) => {
|
|
}
|
|
}
|
|
};
|
|
};
|
|
// 领取用户奖金
|
|
// 领取用户奖金
|
|
-const getClaimPrize = async (hash) =>{
|
|
|
|
- let res = await claimPrize({
|
|
|
|
- dapp_id:15,
|
|
|
|
- match_id:gameDetail.value?.id,
|
|
|
|
- address:walletAddress.value,
|
|
|
|
- receive_hash:hash
|
|
|
|
- });
|
|
|
|
- if (res.status == 200) {
|
|
|
|
- uni.showToast({
|
|
|
|
- title: '领取成功',
|
|
|
|
- icon: 'none',
|
|
|
|
- duration: 1000
|
|
|
|
- })
|
|
|
|
- setTimeout(() => {
|
|
|
|
- getGameRank(gameDetail.value?.id)
|
|
|
|
- }, 500);
|
|
|
|
- }
|
|
|
|
-}
|
|
|
|
|
|
+// const getClaimPrize = async (hash) =>{
|
|
|
|
+// let res = await claimPrize({
|
|
|
|
+// dapp_id:15,
|
|
|
|
+// match_id:gameDetail.value?.id,
|
|
|
|
+// address:walletAddress.value,
|
|
|
|
+// receive_hash:hash
|
|
|
|
+// });
|
|
|
|
+// if (res.status == 200) {
|
|
|
|
+// uni.showToast({
|
|
|
|
+// title: '领取成功',
|
|
|
|
+// icon: 'none',
|
|
|
|
+// duration: 1000
|
|
|
|
+// })
|
|
|
|
+// setTimeout(() => {
|
|
|
|
+// getGameRank(gameDetail.value?.id)
|
|
|
|
+// }, 500);
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
|
|
const getsendSingleReward = async (prize_money) =>{
|
|
const getsendSingleReward = async (prize_money) =>{
|
|
uni.showLoading({
|
|
uni.showLoading({
|
|
@@ -506,16 +535,42 @@ const getsendSingleReward = async (prize_money) =>{
|
|
mask: true
|
|
mask: true
|
|
});
|
|
});
|
|
try {
|
|
try {
|
|
- const result = await sendSingleReward(privateKey.value,prize_money,GasRate.value);
|
|
|
|
- if (result.status === "success") {
|
|
|
|
- await getClaimPrize(result.hash);
|
|
|
|
- }else{
|
|
|
|
|
|
+ // 加密
|
|
|
|
+ let {ciphertext, iv} = await AES_CBC_ENCRYPT(privateKey.value);
|
|
|
|
+ // console.log(ciphertext, iv);
|
|
|
|
+ let res = await receiveGamePrize({
|
|
|
|
+ dapp_id:15,match_id:gameDetail.value?.id,address:walletAddress.value,
|
|
|
|
+ key: ciphertext, _m: iv,
|
|
|
|
+ });
|
|
|
|
+ console.log(res);
|
|
|
|
+ if (res.status == 200) {
|
|
|
|
+ uni.hideLoading()
|
|
uni.showToast({
|
|
uni.showToast({
|
|
- title: result.message || "领取失败",
|
|
|
|
|
|
+ title: '领取成功',
|
|
|
|
+ icon: 'none',
|
|
|
|
+ duration: 1000
|
|
|
|
+ })
|
|
|
|
+ setTimeout(() => {
|
|
|
|
+ getGameRank(gameDetail.value?.id)
|
|
|
|
+ }, 1000);
|
|
|
|
+ } else {
|
|
|
|
+ uni.hideLoading()
|
|
|
|
+ uni.showToast({
|
|
|
|
+ title: res.message || "领取失败",
|
|
icon: 'none',
|
|
icon: 'none',
|
|
duration: 5000
|
|
duration: 5000
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
+ // const result = await sendSingleReward(privateKey.value,prize_money,GasRate.value);
|
|
|
|
+ // if (result.status === "success") {
|
|
|
|
+ // await getClaimPrize(result.hash);
|
|
|
|
+ // }else{
|
|
|
|
+ // uni.showToast({
|
|
|
|
+ // title: result.message || "领取失败",
|
|
|
|
+ // icon: 'none',
|
|
|
|
+ // duration: 5000
|
|
|
|
+ // });
|
|
|
|
+ // }
|
|
} catch (error) {
|
|
} catch (error) {
|
|
uni.showToast({
|
|
uni.showToast({
|
|
title: error.message || "领取失败",
|
|
title: error.message || "领取失败",
|