-- ios 自动化脚本注册app store账号 init(0) require("TSLib") require("ext_new") require("ext_bakup") require("ios_func") require('page_action') local ts = require("ts") local json = ts.json local ios_config = require("config") toast("TSLib 版本:" .. TSVersions(), 5) function check_internet() local wait_sec = 0 local succuess = 0 while wait_sec < 30 do nettype = ts.getNetType() toast('等待网络恢复正常,当前网络状态:[' .. nettype .. ']已等待' .. wait_sec .. '已恢复' .. succuess,1) if nettype ~= 'NO NETWORK' then succuess = succuess + 1 else succuess = 0 end if succuess >= 3 then break end wait_sec = wait_sec + 1 mSleep(1000) end if succuess > 0 then return true else return false end end function main() -- 与服务器沟通,获取执行任务 return register_task end -- 刷机并请求注册信息 function register_task() -- 准备工作 -- 关闭所有应用 closeApp("*",1) --按下Home键 回归主页 mSleep(500) pressHomeKey(0) mSleep(100) pressHomeKey(1) mSleep(500) -- 执行新机 new_ios_device() -- 重启springboard -- reload_spring() -- 重启vpn切换IP -- restart_vpn() -- mSleep(500) -- 校验sn -- res = check_sn() -- if res == 400 then goto start end -- 等待网络恢复正常 if not check_internet() then return 400 end -- 获取任务 任务json = get_register_task(ios_config.ios_注册信息.device_id) toast("取到注册任务\r\n" .. "email:" .. 任务json.data.email .. "\r\n" .. "phone:" .. 任务json.data.phone, 2) return 200 end function register_task_fail(fail_reason) -- 注册任务失败上报信息 return_task_fail({ task_id = 任务json.data.id, fail_code = res, fail_reason = fail_reason }) end -- -- 刷机 ::start:: res = register_task() if res == 400 then goto start end -- 刷机成功, 调用注册 ::register_start:: -- 第1页,打开app res = step1_open_app() if res == 400 then snapAndSave(0,0,749,1333) goto register_start end -- 第2页,点击创建账户并同意协议 res = step2_aggre_protocol() if res == 400 then snapAndSave(0,0,749,1333) goto register_start end -- 第3页,输入邮箱、密码 res = step3_fill_email() if res == 400 then snapAndSave(0,0,749,1333) return_task_fail({ task_id = 任务json.data.id, fail_code = res, fail_reason = 'step3_fill_email' }) goto register_start end if res == 699 then toast("邮箱已注册", 2) return_task_fail({ task_id = 任务json.data.id, fail_code = res, fail_reason = '邮箱已注册' }) goto start end -- 第4页,输入姓名 res = step4_fill_name() if res == 400 then snapAndSave(0,0,749,1333) return_task_fail({ task_id = 任务json.data.id, fail_code = res, fail_reason = 'step4_fill_name' }) goto register_start end -- 第5页,输入付款信息 res = step5_fill_payment() if res == 400 then snapAndSave(0,0,749,1333) return_task_fail({ task_id = 任务json.data.id, fail_code = res, fail_reason = 'step5_fill_payment' }) goto register_start end -- 第6页,输入手机号 step6_fill_phone() -- 第7页,输入手机验证码 res = step7_fill_phone_code() if res == 400 then snapAndSave(0,0,749,1333) return_task_fail({ task_id = 任务json.data.id, fail_code = res, fail_reason = 'step7_fill_phone_code' }) goto register_start end if res == 500 then toast("获取手机验证码失败", 2) return_task_fail({ task_id = 任务json.data.id, fail_code = res, fail_reason = '获取手机验证码失败' }) change_ip_new() goto start end -- 第8页,输入邮箱验证码 res = step8_email_code() if res == 400 then snapAndSave(0,0,749,1333) return_task_fail({ task_id = 任务json.data.id, fail_code = res, fail_reason = 'step8_email_code' }) goto register_start end if res == 600 then toast("获取邮箱验证码失败", 2) return_task_fail({ task_id = 任务json.data.id, fail_code = res, fail_reason = '获取邮箱验证码失败' }) goto start end -- 第9页,检查注册结果 res = step9_check_register_res() if res == 400 then snapAndSave(0,0,749,1333) return_task_fail({ task_id = 任务json.data.id, fail_code = res, fail_reason = 'step9_check_register_res' }) goto register_start end if res == 240 then toast("激活icloud失败", 2) return_task_fail({ task_id = 任务json.data.id, fail_code = res, fail_reason = '激活icloud失败' }) change_ip_new() goto start end -- -- 校验设置是否登陆成功 ::re_verify_account_status:: res = verify_and_backup() if res == 400 then goto re_verify_account_status end if res == 200 then goto start end ::debug_end:: goto start