Skip to content

Commit

Permalink
fix weather
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangyuhan committed May 31, 2019
1 parent 8a5aab4 commit 539a3ca
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
4 changes: 2 additions & 2 deletions lua/weather/info.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"name": "天气",
"icon": "http://ww1.sinaimg.cn/large/8c9b876fly1fh10p6tgqtj2046046jr5.jpg",
"main": "main.lua",
"versionName": "1.0.1",
"versionCode": 3,
"versionName": "1.0.2",
"versionCode": 4,
"private": false,
"desc": "简洁的看天气的插件"
}
20 changes: 14 additions & 6 deletions lua/weather/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ local uihelper = require("uihelper")
local JSON = require("cjson")
local filehelper = require("filehelper")
local weather = require("weather.weather")
local log = require("log")

local item_hour = {
LinearLayout,
Expand Down Expand Up @@ -210,7 +211,8 @@ local function fillWeekInfo(body)
end

local function fill24HInfo(body)
local json = JSON.decode(string.match(body, 'fc1h_24 =(.*)'))
print(body)
local json = JSON.decode(string.match(body, 'fc1h_24%s+=(.*);'))
local j = 0
for i = 1, #json.jh, 3 do
local child = layout_24h.getChildAt(j)
Expand All @@ -227,10 +229,11 @@ end


local function getData(url, successFunc)
print(url)
local options = {
url = url,
headers = {
"Referer:http://e.weather.com.cn"
"Referer:http://m.weather.com.cn"
}
}
LuaHttp.request(options, function(error, code, body)
Expand Down Expand Up @@ -324,19 +327,23 @@ function onDestroy()
end

local function findCityCode(province, city)
local id = '101010100'
local China = require("weather.city")
for k, v in pairs(China) do
if province == k then
for k2, v2 in pairs(v) do
if k2 == city then
id = v2[1][1]:sub(2)
return id
print(city)
log.print_r(v2)
for k3,v3 in pairs(v2) do
if(v3 == city) then
return k3:sub(2)
end
end
end
end
end
end
return id
return '101010100'
end

local function locateMe()
Expand All @@ -349,6 +356,7 @@ local function locateMe()
}
}
LuaHttp.request(options, function(error, code, body)
print(body)
if error or code ~= 200 then
print('locate failure')
return
Expand Down

0 comments on commit 539a3ca

Please sign in to comment.