123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537 |
- <template>
- <div>
- <div class="thermometerContainer" :style="{'width':width,'height':height}">
- <!-- <div class="container" :style="{'width':width,'height':height}"> -->
- <div class="time">
- {{nowTime}} 实况
- </div>
- <div class="thermometerAndTemperature">
- <div class="temperature">
- {{weatherProphetData_17Hour[0].temperature}}<span>℃</span>
- </div>
- <div :class="[thermometerClassName,totalClassName]" style="transform: scale(0.80);margin-left: 28%;margin-top: -14%;">
- </div>
- </div>
- <div class="realFeelWindDirectionSpeed">
- <div class="realFeel">
- <div class="realFeelIcon"></div> 体感温度:{{weatherProphetData_17Hour[0].realfeel}}℃
- </div>
- <div class="windDirection">
- <div class="windDirectionIcon"></div> 风向:{{weatherProphetData_17Hour[0].winddirection}}风
- </div>
- <div class="speed">
- <div class="speedIcon"></div> 风速:{{weatherProphetData_17Hour[0].speed}}km/h
- </div>
- </div>
- <div class="weatherDayTemperatureSunrise" v-show="weatherSwitch==true">
- <div class="dayTemperature">
- <div class="dayTemperatureIcon"></div> 温度:{{weatherProphetData_1[0].temperature1}}℃
- </div>
- <div class="daySunrise">
- <div class="daySunriseIcon"></div> 日出:{{weatherProphetData_1[0].sunrise}}
- </div>
- <div class="weatherDayAndNightButton">
- <div :class="[weatherSwitch==true?'dayButtonWhite':'dayButtonBlack']" @click="weatherDaySwitch()">白天</div>
- <div :class="[weatherSwitch==false?'nightButtonWhite':'nightButtonBlack']" @click="weatherNightSwitch()">夜间</div>
- </div>
- </div>
- <div class="weatherNightTemperatureSunrise" v-show="weatherSwitch==false">
- <div class="nightTemperature">
- <div class="nightTemperatureIcon"></div> 温度:{{weatherProphetData_1[0].temperature2}}℃
- </div>
- <div class="nightSunrise">
- <div class="nightSunriseIcon"></div> 日落:{{weatherProphetData_1[0].sunset}}
- </div>
- <div class="weatherDayAndNightButton">
- <div :class="[weatherSwitch==true?'dayButtonWhite':'dayButtonBlack']" @click="weatherDaySwitch()">白天</div>
- <div :class="[weatherSwitch==false?'nightButtonWhite':'nightButtonBlack']" @click="weatherNightSwitch()">夜间</div>
- </div>
- </div>
-
- <!-- </div> -->
- </div>
- </div>
- </template>
- <script>
- Date.prototype.Format = function(fmt) {
- var o = {
- "M+": this.getMonth() + 1, //月份
- "d+": this.getDate(), //日
- "h+": this.getHours(), //小时
- "m+": this.getMinutes(), //分
- "s+": this.getSeconds(), //秒
- "q+": Math.floor((this.getMonth() + 3) / 3), //季度
- "S": this.getMilliseconds() //毫秒
- };
- if (/(y+)/.test(fmt))
- fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
- for (var k in o)
- if (new RegExp("(" + k + ")").test(fmt))
- fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
- return fmt;
- };
- //调用--
- // var mytime=new Date(后台传来的毫秒格式的时间);
- // var newtime=mytime.Format("需转化的时间格式比如--yyyy-MM-hh");
- export default {
- data: function() {
- return {
- nowTime: "",
- weatherProphetData_17Hour: [{
- realfeel:'',
- speed:'',
- temperature:'',
- winddirection:'',
- }],
- weatherProphetData_1: [{
- speed:'',
- temperature1:'',
- sunrise:'',
- temperature2:'',
- sunset:''
- }],
- thermometerClassName: "",
- totalClassName: "thermometer",
- width: "",
- height: "",
- weatherSwitch:true
- }
- },
- created: function() {
- let that = this;
- setInterval(function() {
- that.getNowTime();
- }, 1000);
- // this.getHourWeatherData("90", "360", this.weatherProphetData_17Hour,this.weatherProphetData_1)
- },
- methods: {
- weatherDaySwitch:function(){
- this.weatherSwitch=true;
- this.$emit("listenEven","day");
- },
- weatherNightSwitch:function(){
- this.weatherSwitch=false;
- this.$emit("listenEven","night");
- },
- getNowTime: function() {
- var nowTime = new Date(new Date().getTime()).Format("hh:mm");
- this.nowTime = nowTime;
- },
- // getDayWeatherData:function(weatherProphetData_1){
- // this.weatherProphetData_1 = weatherProphetData_1;
- // console.log(this.weatherProphetData_1)
- // },
- getHourWeatherData: function(width, height, weatherProphetData_17Hour,weatherProphetData_1) {
- this.weatherProphetData_1=weatherProphetData_1;
- this.weatherProphetData_17Hour = weatherProphetData_17Hour;
- this.width = width + "%";
- this.height = height + "px";
- //判断温度计的度数,list[0].maximumtem%5后 1、2取0 , 3、4取5
- if (parseInt(weatherProphetData_17Hour[0].temperature) % 5 == 0) {
- this.thermometerClassName = "thermometer_" + parseInt(weatherProphetData_17Hour[0].temperature);
- } else if (parseInt(weatherProphetData_17Hour[0].temperature) % 5 == 1 || parseInt(weatherProphetData_17Hour[0].temperature) %
- 5 == 2) {
- this.thermometerClassName = "thermometer_" + (parseInt(weatherProphetData_17Hour[0].temperature / 5) * 5);
- } else if (parseInt(weatherProphetData_17Hour[0].temperature) % 5 == 3 || parseInt(weatherProphetData_17Hour[0].temperature) %
- 5 == 4) {
- this.thermometerClassName = "thermometer_" + ((parseInt(weatherProphetData_17Hour[0].temperature / 5) + 1) * 5);
- } else if (parseInt(weatherProphetData_17Hour[0].temperature) % 5 == -1 || parseInt(weatherProphetData_17Hour[0].temperature) %
- 5 == -2) {
- this.thermometerClassName = "thermometer_" + (parseInt(weatherProphetData_17Hour[0].temperature / 5) * -5);
- } else if (parseInt(weatherProphetData_17Hour[0].temperature) % 5 == -3 || parseInt(weatherProphetData_17Hour[0].temperature) %
- 5 == -4) {
- this.thermometerClassName = "thermometer_" + ((parseInt(weatherProphetData_17Hour[0].temperature / 5) + 1) * -5);
- }
- }
- }
- }
- </script>
- <style scoped="scoped">
- .thermometerContainer {
- width: 65%;
- height: 100%;
- /* background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#024F93), color-stop(1.5, #cccccc), to(#437193));
- background: rgba(0, 0, 0, 0.1); */
- background-color: #535252;
- float: left;
- margin: 0px auto;
- border-radius: 20px;
- margin-top: 1%;
- margin-left: 5%;
- }
- .container {
- width: 370px;
- height: 370px;
- margin: 0px auto;
- }
- .time {
- width: 100px;
- height: 30px;
- color: white;
- font-size: 16px;
- margin-left: 7%;
- margin-top: 3%;
-
- font-family: "microsoft yahei";
- }
- .thermometerAndTemperature {
- width: 100%;
- height: 150px;
- }
- .temperature {
- width: 100px;
- height: 100px;
- float: left;
- margin-top: 4.5%;
- margin-left: 5%;
- font-size: 68px;
- font-family: "microsoft yahei";
- text-align: center;
- line-height: 140px;
- color: white;
- }
- .temperature span {
- font-size: 37px;
- font-family: "microsoft yahei";
- }
- .thermometer {
- width: 104px;
- height: 186px;
- margin-left: 85px;
- float: left;
- margin-top: -30px;
- }
- .realFeelWindDirectionSpeed {
- width: 100%;
- height: 80px;
- font-size: 15px;
- margin-top: -6%;
- margin-left: 15px;
- }
- .realFeel {
- width: 150px;
- height: 40px;
- float: left;
- margin-left: 1.5%;
- margin-top: -5%;
- line-height: 40px;
- font-size: 14px;
- font-family: "microsoft yahei";
- color: white;
- }
- .realFeelIcon {
- width: 20px;
- height: 20px;
- margin-top: 10px;
- float: left;
- background: url(../../../../static/picture/thermometerCard/pic_tu_01.png) no-repeat;
- }
- .windDirection {
- width: 150px;
- height: 40px;
- float: right;
- margin-right: 6%;
- margin-top: 4.5%;
- line-height: 40px;
- font-size: 14px;
- font-family: "microsoft yahei";
- color: white;
- }
- .windDirectionIcon {
- width: 20px;
- height: 20px;
- margin-top: 10px;
- margin-left: 10%;
- float: left;
- background: url(../../../../static/picture/thermometerCard/pic_tu_02.png) no-repeat;
- }
- .weatherDayTemperatureSunrise {
- width: 100%;
- height: 30px;
- font-size: 15px;
- margin-top: -5%;
- float: left;
- }
-
-
- .weatherDayAndNightButton{
- width: 35%;
- height: 20px;
- font-size: 14px;
- float: left;
- margin-left: 1%;
- }
-
- .dayButtonWhite{
- margin-left: 25%;
- text-align: center;
- line-height: 20px;
- width: 29%;
- height: 20px;
- color: white;
- font-size: 14px;
- border-style: solid;
- border-top-width: 0px;
- border-right-width: 0px;
- border-bottom-width: 3px;
- border-bottom-color: #FFEE35;
- border-left-width: 0px;
- font-family: "microsoft yahei";
- float: left;
- }
- .dayButtonBlack{
- margin-left: 25%;
- line-height: 20px;
- text-align: center;
- width: 29%;
- height: 20px;
- color: #DEDEDE;
- font-size: 14px;
- font-family: "microsoft yahei";
- float: left;
- }
- .nightButtonWhite{
- margin-left: 5%;
- text-align: center;
- line-height: 20px;
- width: 29%;
- height: 20px;
- color: white;
- font-size: 14px;
- border-style: solid;
- border-top-width: 0px;
- border-right-width: 0px;
- border-bottom-width: 3px;
- border-bottom-color: #FFEE35;
- border-left-width: 0px;
- font-family: "microsoft yahei";
- float: left;
- }
- .nightButtonBlack{
- margin-left: 5%;
- line-height: 20px;
- text-align: center;
- width: 29%;
- height: 20px;
- color: #DEDEDE;
- font-size: 14px;
- font-family: "microsoft yahei";
- float: left;
- }
- .dayTemperature {
- width: 26%;
- height: 40px;
- float: left;
- margin-left: 5.5%;
- margin-top: -10px;
- line-height: 40px;
- font-size: 14px;
- font-family: "microsoft yahei";
- color: white;
- }
- .daySunrise {
- width: 26%;
- height: 40px;
- float: left;
- margin-top: -10px;
- /* margin-left: -60px; */
- line-height: 40px;
- font-size: 14px;
- font-family: "microsoft yahei";
- color: white;
- }
- .weatherNightTemperatureSunrise {
- width: 100%;
- height: 30px;
- font-size: 15px;
- margin-top: -5%;
- float: left;
- }
- .nightTemperature {
- width: 26%;
- height: 40px;
- float: left;
- margin-left: 5.5%;
- margin-top: -10px;
- line-height: 40px;
- font-size: 14px;
- font-family: "microsoft yahei";
- color: white;
- }
- .nightSunrise {
- width: 26%;
- height: 40px;
- float: left;
- margin-top: -10px;
- /* margin-left: -60px; */
- line-height: 40px;
- font-size: 14px;
- font-family: "microsoft yahei";
- color: white;
- }
- .speed {
- width: 150px;
- height: 40px;
- float: left;
- margin-top: -2%;
- margin-left: 1.5%;
- line-height: 40px;
- font-size: 14px;
- font-family: "microsoft yahei";
- color: white;
- }
- .speedIcon {
- width: 20px;
- height: 20px;
- margin-top: 10px;
- float: left;
- background: url(../../../../static/picture/thermometerCard/pic_tu_03.png) no-repeat;
- }
- /*0℃*/
- .thermometer_0 {
- background: url(../../../../static/picture/thermometerCard/thermometer/0C.png) no-repeat 0px 0px;
- }
- /*5℃*/
- .thermometer_5 {
- background: url(../../../../static/picture/thermometerCard/thermometer/5C.png) no-repeat 0px 0px;
- }
- /*-5℃*/
- .thermometer_-5 {
- background: url(../../../../static/picture/thermometerCard/thermometer/-5C.png) no-repeat 0px 0px;
- }
- /*10℃*/
- .thermometer_10 {
- background: url(../../../../static/picture/thermometerCard/thermometer/10C.png) no-repeat 0px 0px;
- }
- /*-10℃*/
- .thermometer_-10 {
- background: url(../../../../static/picture/thermometerCard/thermometer/-10C.png) no-repeat 0px 0px;
- }
- /*15℃*/
- .thermometer_15 {
- background: url(../../../../static/picture/thermometerCard/thermometer/15C.png) no-repeat 0px 0px;
- }
- /*-15℃*/
- .thermometer_-15 {
- background: url(../../../../static/picture/thermometerCard/thermometer/-15C.png) no-repeat 0px 0px;
- }
- /*20℃*/
- .thermometer_20 {
- background: url(../../../../static/picture/thermometerCard/thermometer/20C.png) no-repeat 0px 0px;
- }
- /*-20℃*/
- .thermometer_-20 {
- background: url(../../../../static/picture/thermometerCard/thermometer/-20C.png) no-repeat 0px 0px;
- }
- /* 25℃*/
-
- .thermometer_25 {
- background: url(../../../../static/picture/thermometerCard/thermometer/25C.png) no-repeat 0px 0px;
- }
-
- /* -25℃*/
-
- .thermometer_-25 {
- background: url(../../../../static/picture/thermometerCard/thermometer/-25C.png) no-repeat 0px 0px;
- }
-
- /*30℃*/
- .thermometer_30 {
- background: url(../../../../static/picture/thermometerCard/thermometer/30C.png) no-repeat 0px 0px;
- }
- /*-30℃*/
- .thermometer_-30 {
- background: url(../../../../static/picture/thermometerCard/thermometer/-30C.png) no-repeat 0px 0px;
- }
- /*40℃*/
- .thermometer_40 {
- background: url(../../../../static/picture/thermometerCard/thermometer/40C.png) no-repeat 0px 0px;
- }
- /*-40℃*/
- .thermometer_-40 {
- background: url(../../../../static/picture/thermometerCard/thermometer/-40C.png) no-repeat 0px 0px;
- }
- /*45℃*/
- .thermometer_45 {
- background: url(../../../../static/picture/thermometerCard/thermometer/45C.png) no-repeat 0px 0px;
- }
- /*-45℃*/
- .thermometer_-45 {
- background: url(../../../../static/picture/thermometerCard/thermometer/-45C.png) no-repeat 0px 0px;
- }
- /*50℃*/
- .thermometer_50 {
- background: url(../../../../static/picture/thermometerCard/thermometer/50C.png) no-repeat 0px 0px;
- }
- /*-50℃*/
- .thermometer_-50 {
- background: url(../../../../static/picture/thermometerCard/thermometer/-50C.png) no-repeat 0px 0px;
- }
- </style>
|