//插入代码
toastLog("此脚本用于支付宝小号步数同步");
work()
//启动支付宝
shell("am start com.eg.android.AlipayGphone/.AlipayLogin",true)
//////函数部分
function work() {
    console.show()
    console.setPosition(0,device.height/2);
    syn_steps_accounts();
    app.startActivity("console");
}

function syn_steps_accounts() {
    var Accounts =[]
    var Passwords=[]
    Accounts[0]=""
    Passwords[0]=""

    Accounts[1]=""
    Passwords[1]=""

    Accounts[2]=""
    Passwords[2]=""

    //有多少写多少

    for (let k = 0; k <Accounts.length; k++) {
        account = Accounts[k]
        password = Passwords[k]
        if(account){
            switchAccount(account, password);
        }else{
            console.error("当前账号为空,已跳过")
            log("------------------")
            sleep(200)
            continue         
        }
        log("= = = = = = = = = =")
        accountOrder=k+1
        log("当前为第" + accountOrder +"//总" + Accounts.length +"个账号")
        log("= = = = = = = = = =")
        log("当前账号:" + account + "")
        log("当前密码:" + password + "")
        log("- - - - - - - - -")
        sleep(3000)
        if (text("首页").exists()){
            log("登录成功,开始同步步数…")
            log("- - - - - - - - - -")
            sleep(500)
        }else{
            console.error("账号登不上,切换")
            log("- - - - - - - - - -")
            sleep(2000)
            continue
        }
        syncToAlipay();
    }
}


function syncToAlipay() {
    go_sports()
    for (var i = 0; i < 3; i++) {
        desc("今日步数").findOne(3000)   
        //确保步数内容加载出来,即出现”今日步数“字样,但是有超时风险,设置3秒上限
        sleep(1000)
        w = descMatches(/^\d+(,\d{3})*$/).findOne(3000);
        var steps_alipay = w.contentDescription
        let steps_real = steps_alipay.replace(/,/g, '');
        if(steps_real > 20000 ){
            log("当前步数为:" + steps_real + ",已达标")
            continue
        }else{
            console.error("当前步数为:" + steps_real + ",未达标")
        }
        sleep(500)
        back();
        text("首页").findOne(2000)  //设置2秒 超时 返回null
        sleep(1000)
        go_sports() 
        sleep(3000)
    }
    back()
}

//打开支付宝运动
function go_sports(){
    shell("am start alipayqr://platformapi/startapp?saId=20000869",true)
    sleep(1000)
}


function switchAccount(account, key) {
    this.logIn = function (account, key) {
        idContains("loginButton").waitFor()
        setText(0, account);
        sleep(100);
        setText(1, key);
        sleep(100);
        setText(0, account);
        idContains("loginButton").findOne().click()
        //textMatches(/首页|关闭/).findOne() //如果登陆被限制,会卡在这里,所以注释掉,或者加时间限制
    }
    //切换账号
    shell("am start alipayqr://platformapi/startapp?appId=20000008",true)
    threads.start(function () {
        obj = textMatches("换个账号|换个验证方式|密码登录|换个方式登录").findOne(2000)
        click("换个账号")
        click("换个验证方式")
        click("密码登录")
        click("换个方式登录")
    })
    this.logIn(account, key)
    log("- - -开始登陆- - -")
}
Last modification:January 16th, 2020 at 09:44 pm
如果觉得我的文章对你有用,请随意赞赏