mirror of
https://github.com/BTMuli/TeyvatGuide.git
synced 2026-03-15 03:53:16 +08:00
✨ 千星奇域抽卡记录获取
This commit is contained in:
@@ -20,20 +20,41 @@
|
||||
</template>
|
||||
<script lang="ts" setup>
|
||||
import showSnackbar from "@comp/func/snackbar.js";
|
||||
import recordReq from "@req/recordReq.js";
|
||||
import hk4eReq from "@req/hk4eReq.js";
|
||||
import takumiReq from "@req/takumiReq.js";
|
||||
import useUserStore from "@store/user.js";
|
||||
import { storeToRefs } from "pinia";
|
||||
import { ref } from "vue";
|
||||
|
||||
const { cookie, account } = storeToRefs(useUserStore());
|
||||
|
||||
const authkey = ref<string>("");
|
||||
|
||||
async function test(): Promise<void> {
|
||||
if (!cookie.value) return;
|
||||
const resp = await recordReq.actCalendar(cookie.value, account.value);
|
||||
console.log(resp);
|
||||
if ("retcode" in resp) {
|
||||
showSnackbar.warn(`[${resp.retcode}] ${resp.message}`);
|
||||
if (!cookie.value || !account.value) {
|
||||
showSnackbar.warn("请先登录账号");
|
||||
return;
|
||||
}
|
||||
const authkeyRes = await takumiReq.bind.authKey(cookie.value, account.value);
|
||||
if (typeof authkeyRes === "string") {
|
||||
authkey.value = authkeyRes;
|
||||
} else {
|
||||
showSnackbar.error("获取authkey失败");
|
||||
return;
|
||||
}
|
||||
const list: Array<TGApp.Game.Gacha.GachaBItem> = [];
|
||||
let endId = "0";
|
||||
while (true) {
|
||||
const res = await hk4eReq.gachaB(authkey.value, "1000", endId);
|
||||
if (Array.isArray(res)) {
|
||||
if (res.length === 0) break;
|
||||
list.push(...res);
|
||||
endId = res[res.length - 1].id;
|
||||
} else {
|
||||
showSnackbar.warn(`[${res.retcode}] 获取祈愿记录失败:${res.message}`);
|
||||
}
|
||||
}
|
||||
console.log(list);
|
||||
}
|
||||
</script>
|
||||
<style lang="css" scoped>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file request/hk4eReq.ts
|
||||
* @description Hk4eApi 请求模块
|
||||
* @since Beta v0.8.0
|
||||
* @since Beta v0.8.4
|
||||
*/
|
||||
|
||||
import { AnnoLangEnum } from "@enum/anno.js";
|
||||
@@ -122,7 +122,7 @@ async function getGachaLog(
|
||||
size: "20",
|
||||
end_id: endId,
|
||||
};
|
||||
const resp = await TGHttp<TGApp.Game.Gacha.GachaLogResponse | TGApp.BBS.Response.Base>(
|
||||
const resp = await TGHttp<TGApp.Game.Gacha.GachaLogResp | TGApp.BBS.Response.Base>(
|
||||
"https://public-operation-hk4e.mihoyo.com/gacha_info/api/getGachaLog",
|
||||
{ method: "GET", query: params },
|
||||
);
|
||||
@@ -130,6 +130,42 @@ async function getGachaLog(
|
||||
return resp.data.list;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 获取千星奇域抽卡记录
|
||||
* @since Beta v0.8.4
|
||||
* @param {string} authKey authKey
|
||||
* @param {string} gachaType 抽卡类型
|
||||
* @param {string} endId 结束 id,默认为 0
|
||||
* @returns {Promise<Array<TGApp.Game.Gacha.GachaBItem>|TGApp.BBS.Response.Base>} 抽卡记录
|
||||
*/
|
||||
async function getBeyondGachaLog(
|
||||
authKey: string,
|
||||
gachaType: string,
|
||||
endId: string = "0",
|
||||
): Promise<Array<TGApp.Game.Gacha.GachaBItem> | TGApp.BBS.Response.Base> {
|
||||
const gachaIdMap: Record<string, string> = {
|
||||
"1000": "f3f5090a8ec0b28f15805c9969aa6c4ec357",
|
||||
"2000": "57016dec6b768231ba1342c01935417a799b",
|
||||
};
|
||||
const params = {
|
||||
lang: "zh-cn",
|
||||
auth_appid: "webview_gacha",
|
||||
authkey: authKey,
|
||||
authkey_ver: "1",
|
||||
sign_type: "2",
|
||||
gacha_type: gachaType,
|
||||
gacha_id: gachaIdMap[gachaType],
|
||||
size: "20",
|
||||
end_id: endId,
|
||||
};
|
||||
const resp = await TGHttp<TGApp.Game.Gacha.GachaBLogResp | TGApp.BBS.Response.Base>(
|
||||
"https://public-operation-hk4e.mihoyo.com/gacha_info/api/getBeyondGachaLog",
|
||||
{ method: "GET", query: params },
|
||||
);
|
||||
if (resp.retcode !== 0) return <TGApp.BBS.Response.Base>resp;
|
||||
return resp.data.list;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 获取登录二维码
|
||||
* @since Beta v0.7.2
|
||||
@@ -171,6 +207,7 @@ async function queryPandaQr(
|
||||
const hk4eReq = {
|
||||
anno: { list: getAnnoList, detail: getAnnoDetail },
|
||||
gacha: getGachaLog,
|
||||
gachaB: getBeyondGachaLog,
|
||||
loginQr: { create: fetchPandaQr, state: queryPandaQr },
|
||||
};
|
||||
|
||||
|
||||
@@ -78,7 +78,7 @@ async function genAuthKey(
|
||||
game_uid: account.gameUid,
|
||||
region: account.region,
|
||||
};
|
||||
const resp = await TGHttp<TGApp.Game.Gacha.AuthkeyResponse | TGApp.BBS.Response.Base>(
|
||||
const resp = await TGHttp<TGApp.Game.Gacha.AuthkeyResp | TGApp.BBS.Response.Base>(
|
||||
`${taBu}binding/api/genAuthKey`,
|
||||
{
|
||||
method: "POST",
|
||||
|
||||
119
src/types/Game/Gacha.d.ts
vendored
119
src/types/Game/Gacha.d.ts
vendored
@@ -1,53 +1,59 @@
|
||||
/**
|
||||
* @file types/Game/Gacha.d.ts
|
||||
* @description 游戏抽卡相关类型定义文件
|
||||
* @since Beta v0.3.0
|
||||
* @since Beta v0.8.4
|
||||
*/
|
||||
|
||||
/**
|
||||
* @description 游戏抽卡相关类型定义命名空间
|
||||
* @since Beta v0.3.0
|
||||
* @namespace TGApp.Game.Gacha
|
||||
* @memberof TGApp.Game
|
||||
*/
|
||||
declare namespace TGApp.Game.Gacha {
|
||||
/**
|
||||
* @description 获取 authkey 返回类型
|
||||
* @interface AuthkeyResponse
|
||||
* @since Beta v0.3.0
|
||||
* @interface AuthkeyResp
|
||||
* @since Beta v0.8.4
|
||||
* @extends TGApp.BBS.Response.BaseWithData
|
||||
* @property {number} data.sign_type - 签名类型
|
||||
* @property {number} data.authkey_ver - authkey 版本
|
||||
* @property {string} data.authkey - authkey
|
||||
* @return AuthkeyResponse
|
||||
*/
|
||||
interface AuthkeyResponse extends TGApp.BBS.Response.BaseWithData {
|
||||
data: {
|
||||
sign_type: number;
|
||||
authkey_ver: number;
|
||||
authkey: string;
|
||||
};
|
||||
}
|
||||
type AuthkeyResp = TGApp.BBS.Response.BaseWithData<AuthkeyRes>;
|
||||
|
||||
/**
|
||||
* @description 获取 authkey 数据类型
|
||||
* @interface AuthkeyRes
|
||||
* @since Beta v0.8.4
|
||||
* @property {number} sign_type - 签名类型
|
||||
* @property {number} authkey_ver - authkey 版本
|
||||
* @property {string} authkey - authkey
|
||||
*/
|
||||
type AuthkeyRes = { sign_type: number; authkey_ver: number; authkey: string };
|
||||
|
||||
/**
|
||||
* @description 获取抽卡记录返回类型
|
||||
* @interface GachaLogResponse
|
||||
* @since Beta v0.3.0
|
||||
* @interface GachaLogResp
|
||||
* @since Beta v0.8.4
|
||||
* @extends TGApp.BBS.Response.BaseWithData
|
||||
* @property {number} data.page - 页码
|
||||
* @property {number} data.size - 每页大小
|
||||
* @property {number} data.total - 总数
|
||||
* @property {GachaItem[]} data.list - 抽卡记录列表
|
||||
* @return GachaLogResponse
|
||||
*/
|
||||
interface GachaLogResponse extends TGApp.BBS.Response.BaseWithData {
|
||||
data: {
|
||||
page: number;
|
||||
size: number;
|
||||
total: number;
|
||||
list: GachaItem[];
|
||||
};
|
||||
}
|
||||
type GachaLogResp = TGApp.BBS.Response.BaseWithData<GachaLogRes>;
|
||||
|
||||
/**
|
||||
* @description 获取千星奇域抽卡记录返回类型
|
||||
* @interface GachaBLogResp
|
||||
* @since Beta v0.8.4
|
||||
* @extends TGApp.BBS.Response.BaseWithData
|
||||
*/
|
||||
type GachaBLogResp = TGApp.BBS.Response.BaseWithData<GachaBLogRes>;
|
||||
|
||||
/**
|
||||
* @description 抽卡记录返回数据类型
|
||||
* @interface GachaLogRes
|
||||
* @since Beta v0.8.4
|
||||
* @property {number} page - 页码
|
||||
* @property {number} size - 每页大小
|
||||
* @property {number} total - 总数
|
||||
* @property {Array<GachaItem>} list - 抽卡记录列表
|
||||
*/
|
||||
type GachaLogRes = {
|
||||
page: number;
|
||||
size: number;
|
||||
total: number;
|
||||
list: Array<GachaItem>;
|
||||
};
|
||||
|
||||
/**
|
||||
* @description 抽卡记录类型
|
||||
@@ -65,7 +71,7 @@ declare namespace TGApp.Game.Gacha {
|
||||
* @property {string} id - 抽卡记录 id
|
||||
* @return GachaItem
|
||||
*/
|
||||
interface GachaItem {
|
||||
type GachaItem = {
|
||||
uid: string;
|
||||
gacha_type: string;
|
||||
item_id: string;
|
||||
@@ -76,5 +82,44 @@ declare namespace TGApp.Game.Gacha {
|
||||
item_type: string;
|
||||
rank_type: string;
|
||||
id: number;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @description 千星奇域抽卡记录返回数据类型
|
||||
* @interface GachaBLogRes
|
||||
* @since Beta v0.8.4
|
||||
* @property {Array<GachaBItem>} list - 页码
|
||||
* @property {number} total - 总数
|
||||
*/
|
||||
type GachaBLogRes = { list: Array<GachaBItem>; total: number };
|
||||
|
||||
/**
|
||||
* @description 千星奇域抽卡记录类型
|
||||
* @interface GachaBItem
|
||||
* @since Beta v0.8.4
|
||||
* @property {string} id - 抽卡记录 id
|
||||
* @property {string} is_up - 是否为UP池,0-否,1-是
|
||||
* @property {string} item_id - 物品 id
|
||||
* @property {string} item_name - 物品名称
|
||||
* @property {string} item_type - 物品类型
|
||||
* @property {string} op_gacha_type - 抽卡类型,用于接口请求
|
||||
* @property {string} rank_type - 星级
|
||||
* @property {string} region - 区域
|
||||
* @property {string} schedule_id - 排期ID
|
||||
* @property {string} time - 抽卡时间,格式:yyyy-MM-dd HH:mm:ss
|
||||
* @property {string} uid - 用户 uid
|
||||
*/
|
||||
type GachaBItem = {
|
||||
id: string;
|
||||
is_up: string;
|
||||
item_id: string;
|
||||
item_name: string;
|
||||
item_type: string;
|
||||
op_gacha_type: string;
|
||||
rank_type: string;
|
||||
region: string;
|
||||
schedule_id: string;
|
||||
time: string;
|
||||
uid: string;
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user