🧪 -3001,参数错误☹

This commit is contained in:
目棃
2024-07-25 19:40:07 +08:00
parent 20ad79f08b
commit 289620922d
2 changed files with 60 additions and 10 deletions

View File

@@ -13,9 +13,46 @@
</div>
</div>
</div>
<h1>验证码登录测试</h1>
<div class="test-item">
<div class="btn-list">
<button class="test-btn" @click="tryCaptchaLogin()">获取验证码</button>
</div>
</div>
</div>
</template>
<script lang="ts" setup></script>
<script lang="ts" setup>
import showConfirm from "../../components/func/confirm.js";
import showSnackbar from "../../components/func/snackbar.js";
import Mys from "../../plugins/Mys/index.js";
async function tryCaptchaLogin(): Promise<void> {
const phone = await showConfirm({
mode: "input",
title: "请输入手机号",
text: "+86",
});
if (!phone) return;
const captchaResp = await Mys.User.getCaptcha(phone);
console.log("[captchaResp]", captchaResp);
if ("retcode" in captchaResp) {
showSnackbar({
text: `[${captchaResp.retcode}] ${captchaResp.message}`,
color: "error",
});
return;
}
const action_type = captchaResp.action_type;
const captcha = await showConfirm({
mode: "input",
title: "请输入验证码",
text: "验证码:",
});
if (!captcha) return;
const loginResp = await Mys.User.login(phone, captcha, action_type);
console.log("[loginResp]", loginResp);
}
</script>
<style lang="css" scoped>
.test-box {
display: flex;
@@ -36,6 +73,11 @@
}
.test-btn {
display: flex;
align-items: center;
justify-content: center;
padding: 10px;
border-radius: 5px;
background: var(--tgc-btn-1);
color: var(--btn-text);
}

View File

@@ -11,11 +11,10 @@ import { getDeviceInfo } from "../../../utils/toolFunc.js";
import TGConstant from "../../../web/constant/TGConstant.js";
const PUB_KEY = `-----BEGIN PUBLIC KEY-----
MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDDvekdPMHN3AYhm/vktJT+YJr7cI5DcsNK
qdsx5DZX0gDuWFuIjzdwButrIYPNmRJ1G8ybDIF7oDW2eEpm5sMbL9zs9ExXCdvqrn51qELb
qj0XxtMTIpaCHFSI50PfPpTFV9Xt/hmyVwokoOXFlAEgCn+QCgGs52bFoYMtyi+xEQIDAQAB
MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDDvekdPMHN3AYhm/vktJT+YJr7cI5DcsNKqdsx5DZX0gDuWFuIjzdwButrIYPNmRJ1G8ybDIF7oDW2eEpm5sMbL9zs
9ExXCdvqrn51qELbqj0XxtMTIpaCHFSI50PfPpTFV9Xt/hmyVwokoOXFlAEgCn+Q
CgGs52bFoYMtyi+xEQIDAQAB
-----END PUBLIC KEY-----`;
const EncryptAreaCode = rsaEncrypt("+86");
/**
* @description rsa 加密
@@ -43,7 +42,7 @@ export async function getCaptcha(
const device_name = getDeviceInfo("device_name");
const device_id = getDeviceInfo("device_id");
const device_model = getDeviceInfo("product");
const body = { area: EncryptAreaCode, phone: rsaEncrypt(phone) };
const body = { area_code: rsaEncrypt("+86"), mobile: rsaEncrypt(phone) };
const header = {
"x-rpc-aigis": "",
"x-rpc-app_version": TGConstant.BBS.VERSION,
@@ -53,7 +52,13 @@ export async function getCaptcha(
"x-rpc-device_name": device_name,
"x-rpc-device_id": device_id,
"x-rpc-device_model": device_model,
"user-agent": TGConstant.BBS.UA_MOBILE,
"content-type": "application/json",
referer: "https://user.miyoushe.com/",
"x-rpc-game_biz": TGConstant.Utils.GAME_BIZ,
};
console.log("getCaptcha header: ", header);
console.log("getCaptcha body: ", body);
const resp = await TGHttp<
TGApp.Plugins.Mys.CaptchaLogin.CaptchaResponse | TGApp.BBS.Response.Base
>(url, {
@@ -69,14 +74,14 @@ export async function getCaptcha(
* @description 通过短信验证码登录
* @since Beta v0.5.1
* @param {string} phone - 手机号
* @param {string} action_type - 操作类型
* @param {string} captcha - 验证码
* @param {string} action_type - 操作类型
* @returns {Promise<TGApp.Plugins.Mys.CaptchaLogin.LoginData | TGApp.BBS.Response.Base>}
*/
export async function doCaptchaLogin(
phone: string,
action_type: string,
captcha: string,
action_type: string,
): Promise<TGApp.Plugins.Mys.CaptchaLogin.LoginData | TGApp.BBS.Response.Base> {
const url = "https://passport-api.mihoyo.com/account/ma-cn-passport/app/loginByMobileCaptcha";
const device_fp = getDeviceInfo("device_fp");
@@ -84,8 +89,8 @@ export async function doCaptchaLogin(
const device_id = getDeviceInfo("device_id");
const device_model = getDeviceInfo("product");
const body = {
area: EncryptAreaCode,
phone: rsaEncrypt(phone),
area_code: rsaEncrypt("+86"),
mobile: rsaEncrypt(phone),
action_type,
captcha,
};
@@ -98,7 +103,10 @@ export async function doCaptchaLogin(
"x-rpc-device_name": device_name,
"x-rpc-device_id": device_id,
"x-rpc-device_model": device_model,
"user-agent": TGConstant.BBS.UA_MOBILE,
};
console.log("doCaptchaLogin header: ", header);
console.log("doCaptchaLogin body: ", body);
const resp = await TGHttp<TGApp.Plugins.Mys.CaptchaLogin.LoginResponse | TGApp.BBS.Response.Base>(
url,
{