ThermometerCard.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555
  1. <template>
  2. <div>
  3. <div class="thermometerContainer" :style="{'width':width,'height':height}">
  4. <!-- <div class="container" :style="{'width':width,'height':height}"> -->
  5. <div class="time" v-if="module">
  6. 0 实况
  7. </div>
  8. <div class="time" v-if="module==false">
  9. {{nowTime}} 实况
  10. </div>
  11. <div class="thermometerAndTemperature">
  12. <div class="temperature" v-if="module">
  13. 0<span>℃</span>
  14. </div>
  15. <div class="temperature" v-if="module==false">
  16. {{weatherProphetData_17Hour[0].temperature}}<span>℃</span>
  17. </div>
  18. <div :class="[thermometerClassName,totalClassName]" style="transform: scale(0.80);margin-left: 28%;margin-top: -14%;">
  19. </div>
  20. </div>
  21. <div class="realFeelWindDirectionSpeed">
  22. <div class="realFeel" v-if="module">
  23. <div class="realFeelIcon"></div>&nbsp;体感温度:0℃
  24. </div>
  25. <div class="realFeel" v-if="module==false">
  26. <div class="realFeelIcon"></div>&nbsp;体感温度:{{weatherProphetData_17Hour[0].realfeel}}℃
  27. </div>
  28. <div class="windDirection" v-if="module">
  29. <div class="windDirectionIcon"></div>&nbsp;风向:0风
  30. </div>
  31. <div class="windDirection" v-if="module==false">
  32. <div class="windDirectionIcon"></div>&nbsp;风向:{{weatherProphetData_17Hour[0].winddirection}}风
  33. </div>
  34. <div class="speed" v-if="module">
  35. <div class="speedIcon"></div>&nbsp;风速:0km/h
  36. </div>
  37. <div class="speed" v-if="module==false">
  38. <div class="speedIcon"></div>&nbsp;风速:{{weatherProphetData_17Hour[0].speed}}km/h
  39. </div>
  40. </div>
  41. <div class="weatherDayTemperatureSunrise" v-show="weatherSwitch==true">
  42. <div class="dayTemperature">
  43. <div class="dayTemperatureIcon"></div>&nbsp;温度:{{weatherProphetData_1[0].temperature1}}℃
  44. </div>
  45. <div class="daySunrise">
  46. <div class="daySunriseIcon"></div>&nbsp;日出:{{weatherProphetData_1[0].sunrise}}
  47. </div>
  48. <div class="weatherDayAndNightButton">
  49. <div :class="[weatherSwitch==true?'dayButtonWhite':'dayButtonBlack']" @click="weatherDaySwitch()">白天</div>
  50. <div :class="[weatherSwitch==false?'nightButtonWhite':'nightButtonBlack']" @click="weatherNightSwitch()">夜间</div>
  51. </div>
  52. </div>
  53. <div class="weatherNightTemperatureSunrise" v-show="weatherSwitch==false">
  54. <div class="nightTemperature">
  55. <div class="nightTemperatureIcon"></div>&nbsp;温度:{{weatherProphetData_1[0].temperature2}}℃
  56. </div>
  57. <div class="nightSunrise">
  58. <div class="nightSunriseIcon"></div>&nbsp;日落:{{weatherProphetData_1[0].sunset}}
  59. </div>
  60. <div class="weatherDayAndNightButton">
  61. <div :class="[weatherSwitch==true?'dayButtonWhite':'dayButtonBlack']" @click="weatherDaySwitch()">白天</div>
  62. <div :class="[weatherSwitch==false?'nightButtonWhite':'nightButtonBlack']" @click="weatherNightSwitch()">夜间</div>
  63. </div>
  64. </div>
  65. <!-- </div> -->
  66. </div>
  67. </div>
  68. </template>
  69. <script>
  70. Date.prototype.Format = function(fmt) {
  71. var o = {
  72. "M+": this.getMonth() + 1, //月份
  73. "d+": this.getDate(), //日
  74. "h+": this.getHours(), //小时
  75. "m+": this.getMinutes(), //分
  76. "s+": this.getSeconds(), //秒
  77. "q+": Math.floor((this.getMonth() + 3) / 3), //季度
  78. "S": this.getMilliseconds() //毫秒
  79. };
  80. if (/(y+)/.test(fmt))
  81. fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
  82. for (var k in o)
  83. if (new RegExp("(" + k + ")").test(fmt))
  84. fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
  85. return fmt;
  86. };
  87. //调用--
  88. // var mytime=new Date(后台传来的毫秒格式的时间);
  89. // var newtime=mytime.Format("需转化的时间格式比如--yyyy-MM-hh");
  90. export default {
  91. data: function() {
  92. return {
  93. nowTime: "",
  94. weatherProphetData_17Hour: [{
  95. realfeel:'',
  96. speed:'',
  97. temperature:'',
  98. winddirection:'',
  99. }],
  100. weatherProphetData_1: [{
  101. speed:'',
  102. temperature1:'',
  103. sunrise:'',
  104. temperature2:'',
  105. sunset:''
  106. }],
  107. thermometerClassName: "",
  108. totalClassName: "thermometer",
  109. width: "",
  110. height: "",
  111. weatherSwitch:true,
  112. module:true
  113. }
  114. },
  115. created: function() {
  116. let that = this;
  117. setInterval(function() {
  118. that.getNowTime();
  119. }, 1000);
  120. // this.getHourWeatherData("90", "360", this.weatherProphetData_17Hour,this.weatherProphetData_1)
  121. },
  122. methods: {
  123. weatherDaySwitch:function(){
  124. this.weatherSwitch=true;
  125. this.$emit("listenEven","day");
  126. },
  127. weatherNightSwitch:function(){
  128. this.weatherSwitch=false;
  129. this.$emit("listenEven","night");
  130. },
  131. getNowTime: function() {
  132. var nowTime = new Date(new Date().getTime()).Format("hh:mm");
  133. this.nowTime = nowTime;
  134. },
  135. // getDayWeatherData:function(weatherProphetData_1){
  136. // this.weatherProphetData_1 = weatherProphetData_1;
  137. // console.log(this.weatherProphetData_1)
  138. // },
  139. getHourWeatherData: function(width, height, weatherProphetData_17Hour,weatherProphetData_1) {
  140. this.module = false;
  141. this.weatherProphetData_1=weatherProphetData_1;
  142. this.weatherProphetData_17Hour = weatherProphetData_17Hour;
  143. this.width = width + "%";
  144. this.height = height + "px";
  145. //判断温度计的度数,list[0].maximumtem%5后 1、2取0 , 3、4取5
  146. if (parseInt(weatherProphetData_17Hour[0].temperature) % 5 == 0) {
  147. this.thermometerClassName = "thermometer_" + parseInt(weatherProphetData_17Hour[0].temperature);
  148. } else if (parseInt(weatherProphetData_17Hour[0].temperature) % 5 == 1 || parseInt(weatherProphetData_17Hour[0].temperature) %
  149. 5 == 2) {
  150. this.thermometerClassName = "thermometer_" + (parseInt(weatherProphetData_17Hour[0].temperature / 5) * 5);
  151. } else if (parseInt(weatherProphetData_17Hour[0].temperature) % 5 == 3 || parseInt(weatherProphetData_17Hour[0].temperature) %
  152. 5 == 4) {
  153. this.thermometerClassName = "thermometer_" + ((parseInt(weatherProphetData_17Hour[0].temperature / 5) + 1) * 5);
  154. } else if (parseInt(weatherProphetData_17Hour[0].temperature) % 5 == -1 || parseInt(weatherProphetData_17Hour[0].temperature) %
  155. 5 == -2) {
  156. this.thermometerClassName = "thermometer_" + (parseInt(weatherProphetData_17Hour[0].temperature / 5) * -5);
  157. } else if (parseInt(weatherProphetData_17Hour[0].temperature) % 5 == -3 || parseInt(weatherProphetData_17Hour[0].temperature) %
  158. 5 == -4) {
  159. this.thermometerClassName = "thermometer_" + ((parseInt(weatherProphetData_17Hour[0].temperature / 5) + 1) * -5);
  160. }
  161. }
  162. }
  163. }
  164. </script>
  165. <style scoped="scoped">
  166. .thermometerContainer {
  167. width: 90%;
  168. height: 260px;
  169. /* background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#024F93), color-stop(1.5, #cccccc), to(#437193));
  170. background: rgba(0, 0, 0, 0.1); */
  171. background-color: #535252;
  172. float: left;
  173. margin: 0px auto;
  174. border-radius: 20px;
  175. margin-top: 1%;
  176. margin-left: 5%;
  177. }
  178. .container {
  179. width: 370px;
  180. height: 370px;
  181. margin: 0px auto;
  182. }
  183. .time {
  184. width: 100px;
  185. height: 30px;
  186. color: white;
  187. font-size: 16px;
  188. margin-left: 7%;
  189. margin-top: 3%;
  190. font-family: "microsoft yahei";
  191. }
  192. .thermometerAndTemperature {
  193. width: 100%;
  194. height: 150px;
  195. }
  196. .temperature {
  197. width: 100px;
  198. height: 100px;
  199. float: left;
  200. margin-top: 4.5%;
  201. margin-left: 5%;
  202. font-size: 68px;
  203. font-family: "microsoft yahei";
  204. text-align: center;
  205. line-height: 140px;
  206. color: white;
  207. }
  208. .temperature span {
  209. font-size: 37px;
  210. font-family: "microsoft yahei";
  211. }
  212. .thermometer {
  213. width: 104px;
  214. height: 186px;
  215. margin-left: 85px;
  216. float: left;
  217. margin-top: -30px;
  218. }
  219. .realFeelWindDirectionSpeed {
  220. width: 100%;
  221. height: 80px;
  222. font-size: 15px;
  223. margin-top: -6%;
  224. margin-left: 15px;
  225. }
  226. .realFeel {
  227. width: 150px;
  228. height: 40px;
  229. float: left;
  230. margin-left: 1.5%;
  231. margin-top: -5%;
  232. line-height: 40px;
  233. font-size: 14px;
  234. font-family: "microsoft yahei";
  235. color: white;
  236. }
  237. .realFeelIcon {
  238. width: 20px;
  239. height: 20px;
  240. margin-top: 10px;
  241. float: left;
  242. background: url(../../../../static/picture/thermometerCard/pic_tu_01.png) no-repeat;
  243. }
  244. .windDirection {
  245. width: 150px;
  246. height: 40px;
  247. float: right;
  248. margin-right: 6%;
  249. margin-top: 4.5%;
  250. line-height: 40px;
  251. font-size: 14px;
  252. font-family: "microsoft yahei";
  253. color: white;
  254. }
  255. .windDirectionIcon {
  256. width: 20px;
  257. height: 20px;
  258. margin-top: 10px;
  259. margin-left: 10%;
  260. float: left;
  261. background: url(../../../../static/picture/thermometerCard/pic_tu_02.png) no-repeat;
  262. }
  263. .weatherDayTemperatureSunrise {
  264. width: 100%;
  265. height: 30px;
  266. font-size: 15px;
  267. margin-top: -5%;
  268. float: left;
  269. }
  270. .weatherDayAndNightButton{
  271. width: 35%;
  272. height: 20px;
  273. font-size: 14px;
  274. float: left;
  275. margin-left: 1%;
  276. }
  277. .dayButtonWhite{
  278. margin-left: 25%;
  279. text-align: center;
  280. line-height: 20px;
  281. width: 29%;
  282. height: 20px;
  283. color: white;
  284. font-size: 14px;
  285. border-style: solid;
  286. border-top-width: 0px;
  287. border-right-width: 0px;
  288. border-bottom-width: 3px;
  289. border-bottom-color: #FFEE35;
  290. border-left-width: 0px;
  291. font-family: "microsoft yahei";
  292. float: left;
  293. }
  294. .dayButtonBlack{
  295. margin-left: 25%;
  296. line-height: 20px;
  297. text-align: center;
  298. width: 29%;
  299. height: 20px;
  300. color: #DEDEDE;
  301. font-size: 14px;
  302. font-family: "microsoft yahei";
  303. float: left;
  304. }
  305. .nightButtonWhite{
  306. margin-left: 5%;
  307. text-align: center;
  308. line-height: 20px;
  309. width: 29%;
  310. height: 20px;
  311. color: white;
  312. font-size: 14px;
  313. border-style: solid;
  314. border-top-width: 0px;
  315. border-right-width: 0px;
  316. border-bottom-width: 3px;
  317. border-bottom-color: #FFEE35;
  318. border-left-width: 0px;
  319. font-family: "microsoft yahei";
  320. float: left;
  321. }
  322. .nightButtonBlack{
  323. margin-left: 5%;
  324. line-height: 20px;
  325. text-align: center;
  326. width: 29%;
  327. height: 20px;
  328. color: #DEDEDE;
  329. font-size: 14px;
  330. font-family: "microsoft yahei";
  331. float: left;
  332. }
  333. .dayTemperature {
  334. width: 26%;
  335. height: 40px;
  336. float: left;
  337. margin-left: 5.5%;
  338. margin-top: -10px;
  339. line-height: 40px;
  340. font-size: 14px;
  341. font-family: "microsoft yahei";
  342. color: white;
  343. }
  344. .daySunrise {
  345. width: 26%;
  346. height: 40px;
  347. float: left;
  348. margin-top: -10px;
  349. /* margin-left: -60px; */
  350. line-height: 40px;
  351. font-size: 14px;
  352. font-family: "microsoft yahei";
  353. color: white;
  354. }
  355. .weatherNightTemperatureSunrise {
  356. width: 100%;
  357. height: 30px;
  358. font-size: 15px;
  359. margin-top: -5%;
  360. float: left;
  361. }
  362. .nightTemperature {
  363. width: 26%;
  364. height: 40px;
  365. float: left;
  366. margin-left: 5.5%;
  367. margin-top: -10px;
  368. line-height: 40px;
  369. font-size: 14px;
  370. font-family: "microsoft yahei";
  371. color: white;
  372. }
  373. .nightSunrise {
  374. width: 26%;
  375. height: 40px;
  376. float: left;
  377. margin-top: -10px;
  378. /* margin-left: -60px; */
  379. line-height: 40px;
  380. font-size: 14px;
  381. font-family: "microsoft yahei";
  382. color: white;
  383. }
  384. .speed {
  385. width: 150px;
  386. height: 40px;
  387. float: left;
  388. margin-top: -2%;
  389. margin-left: 1.5%;
  390. line-height: 40px;
  391. font-size: 14px;
  392. font-family: "microsoft yahei";
  393. color: white;
  394. }
  395. .speedIcon {
  396. width: 20px;
  397. height: 20px;
  398. margin-top: 10px;
  399. float: left;
  400. background: url(../../../../static/picture/thermometerCard/pic_tu_03.png) no-repeat;
  401. }
  402. /*0℃*/
  403. .thermometer_0 {
  404. background: url(../../../../static/picture/thermometerCard/thermometer/0C.png) no-repeat 0px 0px;
  405. }
  406. /*5℃*/
  407. .thermometer_5 {
  408. background: url(../../../../static/picture/thermometerCard/thermometer/5C.png) no-repeat 0px 0px;
  409. }
  410. /*-5℃*/
  411. .thermometer_-5 {
  412. background: url(../../../../static/picture/thermometerCard/thermometer/-5C.png) no-repeat 0px 0px;
  413. }
  414. /*10℃*/
  415. .thermometer_10 {
  416. background: url(../../../../static/picture/thermometerCard/thermometer/10C.png) no-repeat 0px 0px;
  417. }
  418. /*-10℃*/
  419. .thermometer_-10 {
  420. background: url(../../../../static/picture/thermometerCard/thermometer/-10C.png) no-repeat 0px 0px;
  421. }
  422. /*15℃*/
  423. .thermometer_15 {
  424. background: url(../../../../static/picture/thermometerCard/thermometer/15C.png) no-repeat 0px 0px;
  425. }
  426. /*-15℃*/
  427. .thermometer_-15 {
  428. background: url(../../../../static/picture/thermometerCard/thermometer/-15C.png) no-repeat 0px 0px;
  429. }
  430. /*20℃*/
  431. .thermometer_20 {
  432. background: url(../../../../static/picture/thermometerCard/thermometer/20C.png) no-repeat 0px 0px;
  433. }
  434. /*-20℃*/
  435. .thermometer_-20 {
  436. background: url(../../../../static/picture/thermometerCard/thermometer/-20C.png) no-repeat 0px 0px;
  437. }
  438. /* 25℃*/
  439. .thermometer_25 {
  440. background: url(../../../../static/picture/thermometerCard/thermometer/25C.png) no-repeat 0px 0px;
  441. }
  442. /* -25℃*/
  443. .thermometer_-25 {
  444. background: url(../../../../static/picture/thermometerCard/thermometer/-25C.png) no-repeat 0px 0px;
  445. }
  446. /*30℃*/
  447. .thermometer_30 {
  448. background: url(../../../../static/picture/thermometerCard/thermometer/30C.png) no-repeat 0px 0px;
  449. }
  450. /*-30℃*/
  451. .thermometer_-30 {
  452. background: url(../../../../static/picture/thermometerCard/thermometer/-30C.png) no-repeat 0px 0px;
  453. }
  454. /*40℃*/
  455. .thermometer_40 {
  456. background: url(../../../../static/picture/thermometerCard/thermometer/40C.png) no-repeat 0px 0px;
  457. }
  458. /*-40℃*/
  459. .thermometer_-40 {
  460. background: url(../../../../static/picture/thermometerCard/thermometer/-40C.png) no-repeat 0px 0px;
  461. }
  462. /*45℃*/
  463. .thermometer_45 {
  464. background: url(../../../../static/picture/thermometerCard/thermometer/45C.png) no-repeat 0px 0px;
  465. }
  466. /*-45℃*/
  467. .thermometer_-45 {
  468. background: url(../../../../static/picture/thermometerCard/thermometer/-45C.png) no-repeat 0px 0px;
  469. }
  470. /*50℃*/
  471. .thermometer_50 {
  472. background: url(../../../../static/picture/thermometerCard/thermometer/50C.png) no-repeat 0px 0px;
  473. }
  474. /*-50℃*/
  475. .thermometer_-50 {
  476. background: url(../../../../static/picture/thermometerCard/thermometer/-50C.png) no-repeat 0px 0px;
  477. }
  478. </style>