JD_Summer

start();

function start() {

    auto.waitFor();

    //app.launch("com.jingdong.app.mall");

    console.log(currentPackage())

    app.startActivity({data:"openApp.jdMobile://virtual?params=%7B%22category%22%3A%22jump%22%2C%22action%22%3A%22to%22%2C%22des%22%3A%22m%22%2C%22url%22%3A%22https%3A%2F%2Fwbbny.m.jd.com%2FbabelDiy%2FZeus%2F2rtpffK8wqNyPBH6wyUDuBKoAbCt%2Findex.html%22%7D"});

    while (className("android.widget.Image").text("c143642ad0850f7a").findOnce() == null) {

        toast("请进入活动界面");

        sleep(3000);

    }

    if (className("android.widget.Image").text("c143642ad0850f7a").exists()) {

        toast("成功进入活动界面");

        sleep(3000);

        while (textContains("运动+").exists()) {

            textContains("运动+").findOnce().click();

            toast("收集运动卡币");sleep(3000);

        }

        while (textContains("任务+").exists()) {

            textContains("任务+").findOnce().click();

            toast("收集任务卡币");sleep(3000);

        }

    }

    doTask();

}

function doTask() {

    className("android.widget.Image").text("c143642ad0850f7a").findOne().parent().click()

    toast("打开任务界面");

    sleep(3000);



    //关键字作为任务类型

    var hasTask = true;

    while (hasTask) {

        if (textMatches(/.*[0-9]秒.*/).exists() && textMatches(/.*[0-9]秒.*/).findOnce().parent().child(8).text() == "去完成") {

            textMatches(/.*[0-9]秒.*/).findOnce().parent().child(8).click();

            sleep(10000);

            //跳小程序后,停留3秒返回

            while (currentPackage() != 'com.jingdong.app.mall' ){

                sleep(3000);

                back();

            }

        } else if (textContains("浏览加购").exists() && textContains("浏览加购").findOnce().parent().child(8).text() == "去完成") {

            textContains("浏览加购").findOnce().parent().child(8).click();

            sleep(3000);

            for (var i = 0; i < 5; i++) {

                className("android.view.View").scrollable(true).depth(15).findOne().child(i).child(0).child(4).click();

                toast("加购第" + (i+1) + "个商品");

                sleep(5000);

                back();

                sleep(3000);

            }

            toast("浏览加购完成,返回");

        }  else if (textContains("浏览").exists() && textContains("浏览").findOnce().parent().child(8).text() == "去完成") {

            textContains("浏览").findOnce().parent().child(8).click();

            sleep(3000);

            //跳小程序后,停留3秒返回

            while (currentPackage() != 'com.jingdong.app.mall' ){

                sleep(3000);

                back();

            }

            toast("浏览完成,返回");

        } else if (textStartsWith("参与可得").exists() && textStartsWith("参与可得").findOnce().parent().child(8).text() == "去完成") {

            textStartsWith("参与可得").findOnce().parent().child(8).click();

            sleep(3000);

            toast("浏览完成,返回");

        }else if (textContains("成功入会").exists() && textContains("成功入会").findOnce().parent().child(8).text() == "去完成") {

            textContains("成功入会").findOnce().parent().child(8).click();

            sleep(3000);

            if(textContains("加入店铺会员").exists()){

                toast("脚本结束(涉及个人隐私,请手动加入店铺会员或者忽略加入会员任务)");

                break;

            }

            toast("浏览入会界面,获取金币");

        }

        else {

            toast("所有任务已完成,若有剩余可再启动一次脚本或手动完成");

            break;

        }

        sleep(1000);//给提示一个显示的时间

        back();

        sleep(3000);

        for(var i=0;!className("android.widget.Image").text("c143642ad0850f7a").exists()&&i<5;i++){

            toast("返回");

            sleep(1000);

            back();

            sleep(3000);

            if(i==5){

                toast("无法返回任务界面,请重新执行脚本");

                exit();

            }

        }//避免弹窗,返回任务界面

    }

}
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。