File tree Expand file tree Collapse file tree 4 files changed +67
-114
lines changed
src/app/shared/components/weather Expand file tree Collapse file tree 4 files changed +67
-114
lines changed Original file line number Diff line number Diff line change 11< div class ="weather-wrap ">
22 < div class ="weather-content ">
3- < i class ="icon iconfont icon-duoyun type "> </ i >
4- < span class ="date "> 03-04</ span >
5- < span class ="low-high "> 29.0℃ ~ 22.0℃</ span >
3+ < i class ="icon iconfont icon-{{today.type}} type "> </ i >
4+ < span class ="low-high "> {{today.low}} ~ {{today.high}}</ span >
65 < span class ="wind ">
76 < i class ="icon iconfont icon-tianqizitiku09 "> </ i >
8- < 3 级 </ span >
7+ {{today.fl}} </ span >
98 </ div >
109 < div class ="weather-bottom ">
11- < div class ="forecast-item-wrap ">
12- < i class ="icon iconfont icon-duoyun "> </ i >
13- < span > 03-04</ span >
14- </ div >
15- < div class ="forecast-item-wrap ">
16- < i class ="icon iconfont icon-duoyun "> </ i >
17- < span > 03-05</ span >
18- </ div >
19- < div class ="forecast-item-wrap ">
20- < i class ="icon iconfont icon-xiaoyu "> </ i >
21- < span > 03-06</ span >
22- </ div >
23- < div class ="forecast-item-wrap ">
24- < i class ="icon iconfont icon-xiaoyu "> </ i >
25- < span > 03-07</ span >
26- </ div >
27- < div class ="forecast-item-wrap ">
28- < i class ="icon iconfont icon-qing "> </ i >
29- < span > 03-08</ span >
30- </ div >
10+ < button class ="switch-btn forecast-item-wrap " [ngClass] ="{'active':item.isSelect} " *ngFor ="let item of data;let i = index "
11+ (click) ="switch(i) ">
12+ < i class ="icon iconfont icon-{{item.type}} "> </ i >
13+ < span > {{item.date}}</ span >
14+ </ button >
3115 </ div >
3216</ div >
Original file line number Diff line number Diff line change 22.weather-wrap {
33 display : flex ;
44 flex-direction : column ;
5+ background : url (https://api.dujin.org/bing/1366.php );
56}
67
78.weather-content {
89 flex : 1 ;
910 height : 200px ;
1011 .type {
12+ display : block ;
1113 font-size : 10em ;
14+ text-align : center ;
15+ }
16+ .low-high {
17+ display : block ;
18+ font-size : 2em ;
19+ text-align : center ;
1220 }
1321}
1422
1725 flex-direction : row ;
1826 flex-wrap : nowrap ;
1927 width : 100% ;
20- height : 70px ;
28+ height : 100px ;
29+ background : rgba ($card-bg , .8 );
2130 border-top : 1px solid $border-color ;
2231 .forecast-item-wrap {
2332 flex : 1 ;
33+ background : transparent ;
34+ border : none ;
2435 border-right : 1px solid $border-color ;
36+ outline : none ;
2537 text-align : center ;
2638 .icon {
2739 font-size : 3em ;
3143 font-size : $sm-text ;
3244 }
3345 & :last-child {
34- border : none ;
46+ border-right : none ;
3547 }
3648 }
49+ .active {
50+ border-top : 2px solid $primary ;
51+ }
3752}
Original file line number Diff line number Diff line change @@ -9,14 +9,23 @@ import { WeatherService } from './weather.service';
99} )
1010export class WeatherComponent implements OnInit {
1111
12+ today ;
1213 data : Array < any > ;
1314 constructor ( private _weatherService : WeatherService ) { }
1415
1516 ngOnInit ( ) {
1617 /* this._weatherService.getJSON().subscribe(data => {
1718 console.log(data);
1819 }); */
19- this . data = this . _weatherService . DATA . data . forecast ;
20+ this . data = this . _weatherService . DATA ;
21+ this . switch ( 0 ) ;
2022 }
2123
24+ switch ( index ) {
25+ this . data . forEach ( item => {
26+ item . isSelect = false ;
27+ } ) ;
28+ this . data [ index ] . isSelect = true ;
29+ this . today = this . data [ index ] ;
30+ }
2231}
Original file line number Diff line number Diff line change @@ -17,91 +17,36 @@ export class WeatherService {
1717 }
1818
1919
20- DATA = {
21- "date" : "20180404" ,
22- "message" : "Success !" ,
23- "status" : 200 ,
24- "city" : "深圳" ,
25- "count" : 410 ,
26- "data" : {
27- "shidu" : "87%" ,
28- "pm25" : 28.0 ,
29- "pm10" : 51.0 ,
30- "quality" : "良" ,
31- "wendu" : "21" ,
32- "ganmao" : "极少数敏感人群应减少户外活动" ,
33- "yesterday" : {
34- "date" : "03日星期二" ,
35- "sunrise" : "06:16" ,
36- "high" : "高温 29.0℃" ,
37- "low" : "低温 21.0℃" ,
38- "sunset" : "18:40" ,
39- "aqi" : 47.0 ,
40- "fx" : "无持续风向" ,
41- "fl" : "<3级" ,
42- "type" : "多云" ,
43- "notice" : "阴晴之间,谨防紫外线侵扰"
44- } ,
45- "forecast" : [ {
46- "date" : "04日星期三" ,
47- "sunrise" : "06:15" ,
48- "high" : "高温 29.0℃" ,
49- "low" : "低温 22.0℃" ,
50- "sunset" : "18:40" ,
51- "aqi" : 31.0 ,
52- "fx" : "无持续风向" ,
53- "fl" : "<3级" ,
54- "type" : "多云" ,
55- "notice" : "阴晴之间,谨防紫外线侵扰"
56- } ,
57- {
58- "date" : "05日星期四" ,
59- "sunrise" : "06:14" ,
60- "high" : "高温 30.0℃" ,
61- "low" : "低温 19.0℃" ,
62- "sunset" : "18:40" ,
63- "aqi" : 26.0 ,
64- "fx" : "无持续风向" ,
65- "fl" : "<3级" ,
66- "type" : "多云" ,
67- "notice" : "阴晴之间,谨防紫外线侵扰"
68- } ,
69- {
70- "date" : "06日星期五" ,
71- "sunrise" : "06:13" ,
72- "high" : "高温 25.0℃" ,
73- "low" : "低温 16.0℃" ,
74- "sunset" : "18:41" ,
75- "aqi" : 36.0 ,
76- "fx" : "北风" ,
77- "fl" : "3-4级" ,
78- "type" : "阵雨" ,
79- "notice" : "阵雨来袭,出门记得带伞"
80- } ,
81- {
82- "date" : "07日星期六" ,
83- "sunrise" : "06:13" ,
84- "high" : "高温 21.0℃" ,
85- "low" : "低温 15.0℃" ,
86- "sunset" : "18:41" ,
87- "aqi" : 74.0 ,
88- "fx" : "无持续风向" ,
89- "fl" : "<3级" ,
90- "type" : "阵雨" ,
91- "notice" : "阵雨来袭,出门记得带伞"
92- } ,
93- {
94- "date" : "08日星期日" ,
95- "sunrise" : "06:12" ,
96- "high" : "高温 25.0℃" ,
97- "low" : "低温 17.0℃" ,
98- "sunset" : "18:42" ,
99- "aqi" : 74.0 ,
100- "fx" : "无持续风向" ,
101- "fl" : "<3级" ,
102- "type" : "晴" ,
103- "notice" : "愿你拥有比阳光明媚的心情"
104- } ]
105- }
106- }
20+ DATA = [
21+ {
22+ "date" : "03-04" ,
23+ "high" : "29.0℃" ,
24+ "low" : "22.0℃" ,
25+ "fl" : "<3级" ,
26+ "type" : "dayu" ,
27+ } , {
28+ "date" : "03-05" ,
29+ "high" : "29.0℃" ,
30+ "low" : "22.0℃" ,
31+ "fl" : "<3级" ,
32+ "type" : "duoyun" ,
33+ } , {
34+ "date" : "03-06" ,
35+ "high" : "29.0℃" ,
36+ "low" : "22.0℃" ,
37+ "fl" : "<3级" ,
38+ "type" : "leidian" ,
39+ } , {
40+ "date" : "03-07" ,
41+ "high" : "29.0℃" ,
42+ "low" : "22.0℃" ,
43+ "fl" : "<3级" ,
44+ "type" : "qing" ,
45+ } , {
46+ "date" : "03-08" ,
47+ "high" : "29.0℃" ,
48+ "low" : "22.0℃" ,
49+ "fl" : "<3级" ,
50+ "type" : "yintian" ,
51+ } ]
10752}
You can’t perform that action at this time.
0 commit comments