|
@@ -32,12 +32,22 @@ class Base extends Controller
|
|
|
}
|
|
|
//end---------------------------------------------------------
|
|
|
|
|
|
-
|
|
|
-
|
|
|
+ $getip = getIp();//获取ip
|
|
|
+ // $getip = "218.70.26.255"; //重庆IP地址
|
|
|
+ if($getip == ''||$getip=='127.0.0.1'){
|
|
|
+ $getip="210.51.167.169";//默认为北京ip地址
|
|
|
+ }
|
|
|
+ $content = json_decode(file_get_contents("https://api.seniverse.com/v3/weather/now.json?key=S3OSd1xyPevThEbnB&location=$getip"),true);
|
|
|
+ $city=array();
|
|
|
+ $city['name'] = $content['results'][0]['location']['name'];//获取城市
|
|
|
+ $tq = tianqi($city['name']);//获取当前城市天气
|
|
|
$this->assign([
|
|
|
'data'=>$data,
|
|
|
'tags'=>$tags,
|
|
|
'good'=>$good,
|
|
|
+ 'getip'=>$getip,//ip
|
|
|
+ 'city'=>$city,//城市
|
|
|
+ 'tq'=>$tq,//天气
|
|
|
]);
|
|
|
|
|
|
return view();
|