-- ios 自动化脚本注册app store账号 -- 触动企业源 -- https://apt-ent.touchsprite.com/ init(0) require("TSLib") require("ext_new") require("ext_bakup") require("ios_func") require('page_action') require('api') local ts = require("ts") local json = ts.json local ios_config = require("config") local config_action = require("config_action") local config_map = require("config_map") -- new_ios_device() -- reload_spring() -- wolf_log(tostring(deviceIsLock())) -- tap(388 ,1168) -- if find_multi_color(ios_config.ios_多色判断.注册_欢迎按钮, 1) then -- check_tap(374, 1168) -- end -- if not find_multi_color(ios_config.ios_多色判断.注册_邮箱验证码_输入框, 15) then -- wolf_log("未找到页面定位,等待重新启动应用", 2) -- return 400 -- end -- while true do -- reload_spring() -- mSleep(2000) -- end -- wolf_log("222") -- if find_multi_color(ios_config.ios_多色判断.重登_设置_登录_登录成功, 1) then -- wolf_log("111") -- -- end -- wolf_log("222") -- if find_str(ios_config.ios_查找文字.app_store_底部游戏, false, 10) then -- wolf_log("111") -- end -- -- check_alert() -- -- new_ios_device() -- -- mSleep(5000) -- openURL("https://itunes.apple.com/WebObjects/MZStore.woa/Wwa/resetAndRedirect?dsf=143465&mt=8&url=/WebObjects/MZStore.woa/wa/viewSoftware?mt=8&id=1108187390&cc=cn&urlDesc=") -- open_app(ios_config.ios_app_bid.设置) -- find_table = ios_config.ios_查找文字.设置_用户_媒体与购买项目_打开成功登录判断 -- wolf_log("222") -- if findTextUntil(find_table[1], find_table[2], find_table[3], find_table[4], find_table[5], find_table[6], "", find_table[7], 1) then -- wolf_log("111") -- end -- local a ="wolf_config.dat" -- config_json = { -- ["aaa"] = 111 -- } -- writeUIConfigFile(a, config_json) -- config_json = readUIConfigFile(a) -- wolf_log(ts.json.encode(config_json)) -- wolf_log(tostring(config_json["isspringboard"])) -- -- config_json.aaa = "1" -- -- wolf_log(ts.json.encode(config_json)) -- -- wolf_log(type(config_json)) -- -- writeUIConfigFile(a, config_json) -- -- if config_json.springboard_boolea == "1" then -- -- wolf_log("11") -- -- end -- openURL("https://itunes.apple.com/WebObjects/MZStore.woa/wa/resetAndRedirect?dsf=143465&mt=8&url=/WebObjects/MZStore.woa/wa/viewSoftware?mt=8&id=1108187390&cc=cn&urlDesc=") -- wolf_log("111") -- if find_str(ios_config.ios_查找文字.测试, false, 1) then -- wolf_log("1111") -- end -- if find_multi_color(ios_config.ios_多色判断.登录_双重验证_设备验证码界面, 1) then -- wolf_log("222") -- end -- if find_str(ios_config.ios_查找文字.设置_登录_媒体与购买项目_继续, false, 1) then -- wolf_log("1111") -- else -- wolf_log("222") -- end -- luaExit() -- find_str(ios_config.ios_查找文字.设置_登录_媒体与购买项目_继续, false, 1) local now_action = 'main' local fail_dic = {} local res = 0 local func_map = { main = main } -- reload_spring() os.execute("rm -rf /var/mobile/Media/TouchSprite/log/lua_log.log") while (true) do wolf_log('开始处理,当前方法' .. now_action) if now_action == 'main' then func_success, res = pcall(func_map[now_action]) else res = func_map[now_action]() func_success = 1 end if not func_success then wolf_log('常规程序'.. now_action ..'执行异常,跳转重试 err:' .. res) res = 400 mSleep(10000) -- goto continue end if now_action == 'main' then ios_config.ios_任务信息 = res func_map = config_map[ios_config.ios_任务信息.task_type] now_action = ios_config[ios_config.ios_任务信息.task_type][2] goto continue end -- 连续3次失败 重启springBoard 切换IP 新机 -- 如果处于备份步骤则只重启springBoard if res == 400 then find_table = ios_config.ios_查找文字.弹窗_验证ID if findTextUntil(find_table[1], find_table[2], find_table[3], find_table[4], find_table[5], find_table[6], "", find_table[7], 1) then toast("异常弹窗_文字", 2) tap(238, 763) -- return_task_fail(config_map[ios_config.ios_任务信息.task_type].url, { -- task_id = ios_config.ios_任务信息.task_id, -- fail_code = 400, -- fail_reason = now_action .. ' 异常弹窗,进行重载' -- }, ios_config.ios_任务信息.task_data.email) os.execute("rm -rf /var/mobile/a.lock") -- reload_spring() -- return_device_error(ios_config.ios_任务信息.device_id) -- lua_exit() end if find_str(ios_config.ios_查找文字.设置_激活_iCloud, false, 1) then if ios_config.ios_任务信息.task_type ~= "appstore_relogin_task_func" then task_fail(config_map[ios_config.ios_任务信息.task_type].url, { code=499, reason='账号被封禁...' }, ios_config.ios_任务信息.task_data.id) reload_spring() lua_restart() -- return_device_error(ios_config.ios_任务信息.device_id) -- lua_exit() end end if fail_dic[now_action] == nil then fail_dic[now_action] = 0 end fail_dic[now_action] = fail_dic[now_action] + 1 toast('机器在'.. now_action ..'连续失败次数:' .. fail_dic[now_action] ,2) wolf_log('机器在'.. now_action ..'连续失败次数:' .. fail_dic[now_action]) if fail_dic[now_action] > 3 then toast('机器执行错误3次, 检测设备异常情况, 放弃当前执行任务',2) wolf_log('机器执行错误3次, 检测设备异常情况, 放弃当前执行任务') return_task_fail(config_map[ios_config.ios_任务信息.task_type].url, { task_id = ios_config.ios_任务信息.task_id, fail_code = 400, fail_reason = now_action .. '执行失败,放弃当前任务' }, ios_config.ios_任务信息.task_data.email) reload_spring() lua_restart() -- if not reload_spring() then -- return_device_error(ios_config.ios_任务信息.device_id) -- lua_exit() -- else -- return_device_error(ios_config.ios_任务信息.device_id) -- lua_exit() -- end -- if not verify_lua_tap() then -- wolf_log("检测触动触摸失效,反馈异常状态") -- return_device_error(ios_config.ios_任务信息.device_id) -- lua_exit() -- end fail_dic = {} -- 尝试取异常后的处理方法,取不到默认回到主方法 if config_action[ios_config.ios_任务信息.task_type][now_action][device_err] == nil then now_action = 'main' else now_action = config_action[ios_config.ios_任务信息.task_type][now_action][device_err][func] end wolf_log('检测设备异常完毕, 下一步执行:' .. now_action) goto continue end else fail_dic[now_action] = 0 end if not config_action[ios_config.ios_任务信息.task_type][now_action] then toast('当前函数[' .. now_action .. ']无处理后续',2) mSleep(2000) break end if not config_action[ios_config.ios_任务信息.task_type][now_action][res] then toast('当前函数[' .. now_action .. ']的返回结果['.. res .. ']无处理后续',2) mSleep(2000) break end -- 执行后续处理流程前的处理 pre_handle = config_action[ios_config.ios_任务信息.task_type][now_action][res]["pre_handle"] if pre_handle then wolf_log('进入预处理,当前方法:' .. now_action) pre_handle_func = config_action[ios_config.ios_任务信息.task_type][now_action][res]["pre_handle"]['func'] pre_handle_param = config_action[ios_config.ios_任务信息.task_type][now_action][res]["pre_handle"]['param'] func_success, ress = pcall(func_map[pre_handle_func], func_map.url, pre_handle_param) if not func_success then wolf_log('前置处理程序'.. pre_handle_func ..'执行异常,跳转重试 err:' .. ress) end end now_action = config_action[ios_config.ios_任务信息.task_type][now_action][res]["func"] ::continue:: end