11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
# File 'lib/fastlane/plugin/zhuixi_build_app/actions/login_action.rb', line 11
def self.login_and_get_user_id_and_token(account, password, packet_os)
uri = URI.parse("http://xg.yutennet.com/issuesy/pack/user_login")
request = Net::HTTP::Post.new(uri)
request.content_type = "application/json"
request.body = JSON.dump({
"account" => account,
"password" => password,
"packet_os" => packet_os,
})
response = Net::HTTP.start(uri.hostname, uri.port) do |http|
http.request(request)
end
if response.code == "200"
result = JSON.parse(response.body)
if result["code"] == 200
user_id = result["data"]["user_id"]
token = result["data"]["token"]
lane_context[:user_id] = user_id
lane_context[:token] = token
platforms = result["data"]["platform_lists"]
puts "ZHUIXI---登陆成功!platform:\n" + platforms.to_s
for platform in platforms
if lane_context[:selectPlatformName] == platform["platform_name"]
lane_context[:platform_id] = platform["platform_id"]
return { user_id: user_id, token: token, platform_id: lane_context[:platform_id] }
end
end
else
puts "ZHUIXI---登录失败:#{result["msg"]}"
end
else
puts "ZHUIXI---登录失败:HTTP #{response.code}"
end
return nil, nil
end
|