Skip to content

Commit

Permalink
今天日期(js)
Browse files Browse the repository at this point in the history
  • Loading branch information
Evelyn2017 committed Mar 15, 2019
1 parent 70e3c45 commit 0917477
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 2 deletions.
Binary file added icons/arrow-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 11 additions & 1 deletion pages/index/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ Page({
nowTemp: 14,
nowWeather: "多云",
nowWeatherBackground: '',
forecast:[]
forecast:[],
todayTemp:"",
todayDate:""
},
onPullDownRefresh(){
this.getNow(()=>{
Expand All @@ -40,6 +42,7 @@ Page({
let result = res.data.result
this.setNow(result)
this.setHourlyWeather(result)
this.setToday(result)
},
complete: ()=>{
callback && callback()
Expand Down Expand Up @@ -80,5 +83,12 @@ Page({
this.setData({
hourlyWeather: hourlyWeather
})
},
setToday(result){
let date = new Date()
this.setData({
todayTemp: `${result.today.minTemp}˚ - ${result.today.maxTemp}˚`,
todayDate: `${date.getFullYear()} - ${date.getMonth() + 1} - ${date.getDate()} 今天`
})
}
})
7 changes: 6 additions & 1 deletion pages/index/index.wxml
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
<view class='weather-wrapper'>
<view class="temp">{{nowTemp}}</view>
<view class="weather">{{nowWeather}}</view>

<image class="weather-bg"
src="{{nowWeatherBackground}}"
mode="scaleToFill"></image>
<view class='day-weather'>
<view class='day-text'>{{todayDate}}</view>
<view class='temp-text'>{{todayTemp}}</view>
<image class='arrow-icon'
src='/icons/arrow-icon.png'></image>
</view>
</view>

<view class="timetips">
Expand Down
22 changes: 22 additions & 0 deletions pages/index/index.wxss
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,26 @@
margin-top: 46rpx;
font-size: 40rpx;
line-height: 56rpx;
}
.day-weather{
display: flex;
align-items: center;
position: absolute;
bottom: 0;
left: 40rpx;
right: 40rpx;
height: 90rpx;
border-top: 1px solid rgba(0,0, 0, 0.1);
font-size: 30rpx;
line-height: 42rpx;
opacity: 0.5;
}
.temp-text{
flex-grow: 1;
padding-right: 30rpx;
text-align: right;
}
.arrow-icon{
width: 13rpx;
height: 24rpx;
}

0 comments on commit 0917477

Please sign in to comment.