84 lines
3.0 KiB
JavaScript
84 lines
3.0 KiB
JavaScript
const express = require("express");
|
|
const axios = require("axios");
|
|
const qs = require("qs");
|
|
|
|
const app = express();
|
|
const port = 25362;
|
|
app.get('/submit', async (req, res) => {
|
|
try {
|
|
let uid = req.query.uid;
|
|
let mile = req.query.mile;
|
|
let ua = req.query.userAgent;
|
|
if (!uid || !mile) {
|
|
res.status(400).send({
|
|
code: 400,
|
|
info: '参数uid或mile不能为空。'
|
|
});
|
|
return;
|
|
}
|
|
const currentTimestamp = new Date().getTime(); // 或者使用 Date.now()
|
|
// console.log("uid => " + uid + ",timestamp => " + currentTimestamp);
|
|
let userInfo = {
|
|
"isBack": 0,
|
|
"mile": mile,
|
|
"userId": uid,
|
|
"timestamp": currentTimestamp
|
|
};
|
|
const param = Buffer.from(JSON.stringify(userInfo)).toString('base64');
|
|
// console.log(param);
|
|
let data = qs.stringify({
|
|
'param': param
|
|
});
|
|
let config = {
|
|
headers: {
|
|
'Host': 'herobox.yingxiong.com:25362',
|
|
'Accept': 'application/json, text/plain, */*',
|
|
'Content-Type': 'application/x-www-form-urlencoded',
|
|
'Source': 'h5',
|
|
'User-Agent': getUA(uid, ua),
|
|
'Version': '2.16.1',
|
|
'Origin': 'https://herobox.yingxiong.com:8022',
|
|
'X-Requested-With': 'com.hero.time',
|
|
'Sec-Fetch-Site': 'same-site',
|
|
'Sec-Fetch-Mode': 'cors',
|
|
'Sec-Fetch-Dest': 'empty',
|
|
'Referer': 'https://herobox.yingxiong.com:8022/',
|
|
'Accept-Encoding': 'gzip, deflate',
|
|
'Accept-Language': 'zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7'
|
|
}
|
|
};
|
|
let response = await axios.post('https://herobox.yingxiong.com:25362/encourage/flappy/calc', data, config);
|
|
console.log(JSON.stringify(response.data));
|
|
if (response.status === 200 && response.data.code === 200 && response.data.data) {
|
|
res.send({
|
|
code: 200,
|
|
high: response.data.data.highMile,
|
|
total: response.data.data.totalMile
|
|
});
|
|
return;
|
|
}
|
|
res.send({
|
|
code: 500,
|
|
info: response.data.msg
|
|
});
|
|
} catch (e) {
|
|
console.log("发生错误,原因:" + e.message);
|
|
res.status(500).send({
|
|
code: 501,
|
|
info: e.message
|
|
});
|
|
}
|
|
});
|
|
|
|
function getUA(uid, ua) {
|
|
if (ua) {
|
|
return ua;
|
|
} else {
|
|
let mode = ["NX569J", "RMX1991", "RMX3561", "NX569H", "NX569J", "RMX1991", "PD2208", "NX569H", "NX569J", "RMX3561"]
|
|
return `Mozilla/5.0 (Linux; Android 13; ${mode[uid.charAt(5)]}} Build/AC1A.220${uid.charAt(3)}0${uid.charAt(6)}.0${uid.slice(7, 9)}; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/103.0.5060.129 Mobile Safari/537.36CP6.TgzO Hero/2.18.0`;
|
|
}
|
|
}
|
|
|
|
app.listen(port, () => {
|
|
console.log(`Server is running on port ${port}`);
|
|
}); |