autojs-03-支付宝-福气店-抢购

2022-01-28  本文已影响0人  不会看源码

【重要说明】

本案例只做学习用途!!!
本案例只做学习用途!!!
本案例只做学习用途!!!



【应用场景】

1. 2022支付宝福卡,福气店的福卡兑换抢购
测试-红包封面.png

【思路分析】

1. 通过首页一步步进入福气店的抢购页面
搞的有点复杂了,其实只要在选定好的抢购页面,定时前几分钟,开启循环刷就行了。

【UI代码】

"ui";

//停止其他脚本
engines.all().map((ScriptEngine) => {
    if (engines.myEngine().toString() !== ScriptEngine.toString()) {
        ScriptEngine.forceStop();
    }
});

//画界面
ui.statusBarColor("#FF4FB3FF");
ui.layout(
    <scroll id='scroll' fillViewport="true">
        <vertical>
            <text id="t_tltie" text="支付宝-福气店" h="48" bg="#FF4FB3FF" gravity="center_vertical" paddingLeft="16" textColor="#ffffff" textSize="16" />

            <vertical padding="10 8" h="*" w="*" layout_weight="1">
                <text textSize="16sp" textColor="black" text="请输入抢购关键字" marginLeft="24dp" marginTop="24dp" />
                <input id="play_number" text="" marginLeft="24dp" marginTop="8dp" />


                <text textSize="16sp" textColor="black" text="请输入支付的福卡" marginLeft="24dp" marginTop="24dp" />
                <text textSize="16sp" textColor="black" text="友善福" marginLeft="24dp" marginTop="12dp" />
                <input id="play_01" text="" marginLeft="24dp" marginTop="8dp" />

                <text textSize="16sp" textColor="black" text="和谐福" marginLeft="24dp" marginTop="24dp" />
                <input id="play_02" text="" marginLeft="24dp" marginTop="8dp" />


                <text textSize="16sp" textColor="black" text="富强福" marginLeft="24dp" marginTop="24dp" />
                <input id="play_03" text="" marginLeft="24dp" marginTop="8dp" />

                <text textSize="16sp" textColor="black" text="爱国福" marginLeft="24dp" marginTop="24dp" />
                <input id="play_04" text="" marginLeft="24dp" marginTop="8dp" />

                <text textSize="16sp" textColor="black" text="敬业福" marginLeft="24dp" marginTop="24dp" />
                <input id="play_05" text="" marginLeft="24dp" marginTop="8dp" />

                <Switch id="autoService" h="auto" w="auto" text="无障碍服务:" checked="{{auto.service != null}}" w="auto" textStyle="bold" marginLeft="24dp" marginTop="24dp" />

            </vertical>

            <button id="bt_start" h="auto" w="*" text="开始运行" tag="ScriptTag" color="#ffffff" bg="#FF4FB3FF" foreground="?selectableItemBackground" />

        </vertical>
    </scroll>

);


ui.autoService.on("check", function (checked) {
    // 用户勾选无障碍服务的选项时,跳转到页面让用户去开启
    if (checked && auto.service == null) {
        app.startActivity({
            action: "android.settings.ACCESSIBILITY_SETTINGS"
        });
    }
    if (!checked && auto.service != null) {
        auto.service.disableSelf();
    }
});

// 当用户回到本界面时,resume事件会被触发
ui.emitter.on("resume", function () {
    // 此时根据无障碍服务的开启情况,同步开关的状态
    ui.autoService.checked = auto.service != null;
});




var clcikTimer = 0;
ui.bt_start.click((v) => {
    var timestamp = (new Date()).getTime();
    if (timestamp - clcikTimer >= 500) {
        clcikTimer = timestamp;
        var autoCheck = auto.service != null;
        if (autoCheck) {
            saveAndStart();
        } else {
            toastLog("请先开启无障碍服务!");
        }

    }
});



function saveAndStart() {
    var ketWord = ui.play_number.getText();

    var number01 = ui.play_01.getText();
    var number02 = ui.play_02.getText();
    var number03 = ui.play_03.getText();
    var number04 = ui.play_04.getText();
    var number05 = ui.play_05.getText();

    var number = "";
    var numberWay = "";
    if (number01 != null && number01 != "") {
        number = number + number01;
        numberWay = numberWay + "0";
    }

    if (number02 != null && number02 != "") {
        number = number + "," + number02;
        numberWay = numberWay + ",1";
    }

    if (number03 != null && number03 != "") {
        number = number + "," + number03;
        numberWay = numberWay + ",2";
    }

    if (number04 != null && number04 != "") {
        number = number + "," + number04;
        numberWay = numberWay + ",3";
    }

    if (number05 != null && number05 != "") {
        number = number + "," + number05;
        numberWay = numberWay + ",4";
    }


    log("保存成功");
    var ali = require('ali.js');
    ali.main(ketWord, numberWay, number);
}




【下载地址】
学习完整源码和Apk地址:

上一篇下一篇

猜你喜欢

热点阅读