Skip to content

Commit

Permalink
调试
Browse files Browse the repository at this point in the history
  • Loading branch information
GilHogan committed Jan 8, 2024
1 parent c10f5f3 commit 87c2acf
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
23 changes: 16 additions & 7 deletions server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ let isLogin = false;
// 出价加价幅度
let Markup = 2;
// 最后出价倒数时间(毫秒)
let LastBidCountdownTime = 300;
let LastBidCountdownTime = 350;
// 出价方式
let BiddingMethod = Constants.BiddingMethod.ON_OTHERS_BID;
const noticeTitle = "京东夺宝岛助手提示";
Expand Down Expand Up @@ -274,8 +274,12 @@ async function handleGoToTargetPage() {
return;
}

// 查询当前的价格和剩余时间
await getBatchInfo();
try {
// 查询当前的价格和剩余时间
await getBatchInfo();
} catch (error) {
consoleUtil.log("handleGoToTargetPage getBatchInfo error: ", error);
}

// 启用拦截器
await page.setRequestInterception(true).catch();
Expand Down Expand Up @@ -342,7 +346,7 @@ async function waitForProductStart() {
}, waitMilliseconds)
});
if (page) {
consoleUtil.log("page start reload");
consoleUtil.log("page start reload.", dayjs().format('YYYY-MM-DD HH:mm:ss'));
// 商品开始抢购时刷新页面,解决页面倒计时不准确,导致出价按钮更新不及时的问题
await page.reload();
}
Expand Down Expand Up @@ -393,6 +397,7 @@ function getBatchInfo(isLastQuery = false) {
const offsetTime = endTime - startTime;
// consoleUtil.log("getBatchInfo end endTime = ", endTime, " , offsetTime = ", offsetTime);
try {
consoleUtil.log("getBatchInfo on end rawData : ", rawData);
const parsedData = JSON.parse(rawData);
if (parsedData.result && parsedData.result.data && parsedData.result.data[Item_ID]) {
NowPrice = parsedData.result.data[Item_ID].currentPrice;
Expand All @@ -412,7 +417,7 @@ function getBatchInfo(isLastQuery = false) {
}
}
} catch (e) {
consoleUtil.error(e.message);
consoleUtil.error("getBatchInfo error: ", e.message);
}
resolve();
});
Expand Down Expand Up @@ -442,7 +447,11 @@ function refreshBatchInfo() {
return;
}
fetching = true;
await getBatchInfo();
try {
await getBatchInfo();
} catch (error) {
consoleUtil.log("refreshBatchInfo error: ", error);
}
fetching = false;
}, 10);
}
Expand Down Expand Up @@ -586,7 +595,7 @@ function handlePriceAndTime(isFirstHandlePrice = false) {
try {
await getBatchInfo();
} catch (error) {
consoleUtil.log(error);
consoleUtil.log("cycleTimer error: ", error);
}
handlePriceAndTime();
}, NextRefreshTime)
Expand Down
2 changes: 1 addition & 1 deletion src/components/ItemInfo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ export default defineComponent({
price: undefined,
bidder: "",
markup: 2,
lastBidCountdownTime: 300,
lastBidCountdownTime: 350,
biddingMethod: Constants.BiddingMethod.ON_OTHERS_BID,
minPrice: undefined,
},
Expand Down

0 comments on commit 87c2acf

Please sign in to comment.