1 Star 0 Fork 16

cat_zhuang / autojs-demo

forked from lin_bo / autojs-demo 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
京东取消店铺关注.js 2.06 KB
AI 代码解读
一键复制 编辑 原始数据 按行查看 历史
lin_bo 提交于 2020-09-02 13:04 . update
let uiWaitTime = 1000;
function clickUI(item, waitTime) {
if (item) {
if (item.clickable()) {
item.click();
} else {
click(item.bounds().centerX(), item.bounds().centerY());
}
if (waitTime && waitTime > 0) {
// console.log('睡眠' + waitTime)
sleep(waitTime);
}
} else {
console.warn("UI控件为空,无法点击");
}
}
function __openApp__() {
// 启动app
app.startActivity({
action: "android.intent.action.MAIN",
packageName: "com.jingdong.app.mall",
className: "com.jingdong.app.mall.main.MainActivity",
category: ["android.intent.category.LAUNCHER"],
flags: ["activity_new_task"]
});
sleep(uiWaitTime * 3);
}
// 打开关注店铺页面
function __openConcernedShopPage__() {
// 打开【我的】标签页
let btn = text('我的').find()[0];
clickUI(btn, uiWaitTime);
console.log('打开【我的】标签页');
btn = text('店铺关注').find()[0];
clickUI(btn, uiWaitTime);
console.log('打开【店铺关注】页面');
}
// 取消店铺关注,返回是否还有关注店铺
function __cancleAttention__() {
// 进入编辑模式
let btn = text('编辑').find()[0];
if (!btn) {
console.log('没有关注的店铺');
return false;
}
clickUI(btn, uiWaitTime);
console.log('点击【编辑】按钮');
// 全选已展示的店铺
btn = text('全选').find()[0];
clickUI(btn, uiWaitTime);
console.log('点击【全选】按钮');
// 取消关注
btn = text('取消关注').depth(13).find()[0];
clickUI(btn, uiWaitTime);
console.log('点击【取消关注】按钮');
// 确定
btn = text('确定').find()[0];
clickUI(btn, uiWaitTime);
console.log('点击【确定】按钮');
sleep(uiWaitTime);
return true;
}
function run() {
__openApp__();
__openConcernedShopPage__();
let count = 0;
while(__cancleAttention__()) {
console.log('' + ++count + '次取消关注');
}
}
run()
JavaScript
1
https://gitee.com/cat_zhuang/autojs-demo.git
git@gitee.com:cat_zhuang/autojs-demo.git
cat_zhuang
autojs-demo
autojs-demo
master

搜索帮助