forked from DarrickBM/robFood-1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
executable file
·52 lines (51 loc) · 1.12 KB
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
const appName = "盒马";
launchApp(appName);
sleep(3000);
auto.waitFor()
// 点击按钮
const clickSettle = () => {
id('button_cart_charge').findOne().click()
}
const hasText = (text) => {
return textStartsWith(text).exists() // 是否存在指定文本
}
const musicNotify = () => {
const m = '/storage/emulated/0/netease/cloudmusic/Music/Hanser - 勾指起誓.mp3'
media.playMusic(m);
sleep(media.getMusicDuration());
}
const start = () => {
// 是否有结算按钮
if (hasText("结算")) {
// 点击结算
clickSettle()
sleep(1000)
start()
} else if (hasText('非常抱歉,当前商品运力不足(063)') || hasText('很抱歉,下单失败')) {
// 返回上一页
back()
sleep(1000)
start()
} else if (hasText('提交订单')) {
className("android.widget.TextView").text("提交订单").findOne().parent().click()
musicNotify()
sleep(1000)
start()
} else {
/*
toast('停止活动了')
musicNotify()
*/
// 返回上一页
back()
sleep(1000)
start()
}
}
start()
// const appName = "盒马";
// launchApp(appName);
// sleep(3000);
// media.pauseMusic()
// sleep(7000)
// media.stopMusic()