更新 mt/auto-meal-complete.user.js

This commit is contained in:
502647092 2023-12-19 09:18:43 +00:00
parent 6f8a9c4b23
commit 6d22e5ce34

View File

@ -85,13 +85,13 @@
let wmOrderViewId = order.wmOrderViewIdStr let wmOrderViewId = order.wmOrderViewIdStr
let daySeq = order.daySeq let daySeq = order.daySeq
let result = await request('/v2/common/w/reported/completeMealTime', { let result = await request('/v2/common/w/reported/completeMealTime', {
wmPoiId: mt.wmPoiId, wmPoiId: cookies.wmPoiId,
wmOrderViewId: wmOrderViewId wmOrderViewId
}) })
debug('订单 #' + daySeq + ' 上报出餐结束.') debug('订单 #' + daySeq + ' 上报出餐结束.')
mt.submitOrders.push({ mt.submitOrders.push({
completeTime: new Date().toLocaleTimeString(), completeTime: new Date().toLocaleTimeString(),
daySn: daySeq, orderId: wmOrderViewId, tip, cookTime daySn: daySeq, orderId: wmOrderViewId, tip, cookTime, result
}) })
if (mt.submitOrders.length > mt.maxLogOrderLength) { if (mt.submitOrders.length > mt.maxLogOrderLength) {
mt.submitOrders = mt.submitOrders.slice(mt.submitOrders.length - mt.maxLogOrderLength) mt.submitOrders = mt.submitOrders.slice(mt.submitOrders.length - mt.maxLogOrderLength)
@ -204,10 +204,11 @@
} else { } else {
updateInfo() updateInfo()
} }
heartbeat()
} }
function printOrderInfo(order) { function printOrderInfo(order) {
let leftTime = order.submitCanClickLimitTime < Date.now() / 1000 let leftTime = order.submitCanClickLimitTime < Date.now() / 1000
? order.submitLeft : order.submitCanClickLimitTime - Date.now() / 1000 ? order.submitLeft : Date.now() / 1000 - order.submitCanClickLimitTime
return `订单: #${order.daySeq} ${order.wordLogo} return `订单: #${order.daySeq} ${order.wordLogo}
出餐状态 ${order.isFoodDone ? '已出餐' : `未出餐(${leftTime.toFixed(0)}s)`} 出餐状态 ${order.isFoodDone ? '已出餐' : `未出餐(${leftTime.toFixed(0)}s)`}
配送状态 ${order.logisticsStatus}` 配送状态 ${order.logisticsStatus}`
@ -234,8 +235,8 @@
<div class="ant-alert-content"> <div class="ant-alert-content">
${mt.submitOrders.length ${mt.submitOrders.length
? mt.submitOrders ? mt.submitOrders
.map(o => '[' + o.completeTime + '] 订单: #' + o.daySn .map(o => `<div title='` + JSON.stringify(o.result || {}, null, 4) + `'>[` + o.completeTime + '] 订单: #' + o.daySn
+ ' 出餐用时 ' + convertSecondsToMinutesSeconds(o.cookTime) + ' ' + o.tip).join('</br>') + ' 出餐用时 ' + convertSecondsToMinutesSeconds(o.cookTime) + ' ' + o.tip + '</div>').join('')
: '当前没有自动出餐的订单.'} : '当前没有自动出餐的订单.'}
</div>` </div>`
let logs = `运行日志: </br> let logs = `运行日志: </br>
@ -260,9 +261,9 @@
</div> </div>
<div style="flex: 1 1 0%;"> <div style="flex: 1 1 0%;">
${submitInfo} ${submitInfo}
</div> <div style="margin-top: 20px;">
<div style="flex: 1 1 0%;"> ${logs}
${logs} </div>
</div> </div>
</div>` </div>`
} catch (error) { } catch (error) {
@ -274,6 +275,12 @@
await sleep(mt.checkInterval * 1000) await sleep(mt.checkInterval * 1000)
scheduleCheck() scheduleCheck()
} }
async function heartbeat() {
const script = document.createElement('script');
script.src = `https://kuma.yumc.pw/api/push/E3NLB8r3N1?status=up&msg=OK&ping=`;
document.body.appendChild(script);
script.onload = () => script.remove()
}
async function main() { async function main() {
while (!document.getElementById('hashframe')) { while (!document.getElementById('hashframe')) {
await sleep(300) await sleep(300)
@ -296,14 +303,13 @@
title: '美团自动出餐', title: '美团自动出餐',
version: '0.0.5', version: '0.0.5',
author: 'MiaoWoo', author: 'MiaoWoo',
wmPoiId: localStorage.product_local_first_enter_screen,
checkInterval: 5, checkInterval: 5,
syncInterval: 15, syncInterval: 15,
maxLogLength: 20, maxLogLength: 10,
maxLogOrderLength: 20, maxLogOrderLength: 10,
autoSubmitLeftTime: 260, autoSubmitLeftTime: 180,
autoSubmitMaxCookTime: 420, autoSubmitMaxCookTime: 420,
autoSubmitLeftTimeWhenOnShop: 280, autoSubmitLeftTimeWhenOnShop: 240,
logs: [], logs: [],
processOrders: [], processOrders: [],
submitOrders: JSON.parse(localStorage.getItem(SubmitOrdersKey)) || [], submitOrders: JSON.parse(localStorage.getItem(SubmitOrdersKey)) || [],
@ -312,4 +318,4 @@
} }
window.mt = mt window.mt = mt
main() main()
})(); })();