Skip to content

Commit c0f82ba

Browse files
committed
将天气预报模块,迁移到留言页面
1 parent 77df6bf commit c0f82ba

File tree

2 files changed

+139
-196
lines changed

2 files changed

+139
-196
lines changed

src/components/MainPage/AboutMe.vue

Lines changed: 2 additions & 127 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@
211211
</div>
212212
</div>
213213
</div>
214-
<!-- <div class="BigBlock AboutMeMarginTop">
214+
<div class="BigBlock AboutMeMarginTop">
215215
<div class="TitleFontLine">Contacts</div>
216216
<div
217217
class="BlogStatistic"
@@ -260,28 +260,6 @@
260260
></a>
261261
</div>
262262
</div>
263-
</div> -->
264-
<div class="BigBlock AboutMeMarginTop weathDev">
265-
<div class="TitleFontLine weathTitle">
266-
<span class="citySpan">{{ city }}</span>天气
267-
</div>
268-
<div
269-
class="BlogStatistic weathContent"
270-
>
271-
<div class="BlogStatisticItem borderRight" v-for="(item,i) in weathArray" v-bind:key="i">
272-
<div class="weathWeek" v-html="item.week"></div>
273-
<!-- <div class="weathDay">11月23日</div> -->
274-
<div class="weathDay">{{ item.date }}</div>
275-
<div class="weathIcon">
276-
<!-- <i :class="`iconfont ${item.dayweatherIcon} AboutMeIcon`" style="font-size:1.8rem"></i> -->
277-
<svg class="icon" aria-hidden="true">
278-
<use :xlink:href="`#${item.dayweatherIcon}`"></use>
279-
</svg>
280-
</div>
281-
<div class="weathChinese">{{ item.dayweather }}</div>
282-
<div class="temperature">{{ item.nighttemp }} ~ {{ item.daytemp }}°C</div>
283-
</div>
284-
</div>
285263
</div>
286264
</div>
287265
</div>
@@ -293,17 +271,12 @@
293271
<script>
294272
import Heartfelt from "../SonCompnent/Heartfelt";
295273
import Store from "../../store";
296-
import axios from 'axios';
297-
import weathJson from '../../static/map/weath.json';
298-
import weekJson from '../../static/map/week.json';
299274
300275
export default {
301276
name: "AboutMe",
302277
data: function () {
303278
return {
304279
buttonAnimate: false,
305-
city: "",
306-
weathArray: []
307280
};
308281
},
309282
components: {
@@ -313,72 +286,11 @@ export default {
313286
// 设置按钮动画的开始与停止
314287
setButtonAnimate: function (status) {
315288
this.buttonAnimate = status;
316-
},
317-
318-
// 设置天气预报模块
319-
setWeathe: function () {
320-
// let sunqBlogWeather = this.getSQCookie("sunqBlogWeather"); // 3小时内不再刷新
321-
let sunqBlogWeather = ""; // 3小时内不再刷新
322-
323-
if (sunqBlogWeather) {
324-
this.renderWeathDom(sunqBlogWeather);
325-
} else {
326-
this.GetLocation(this.getWeathData);
327-
}
328-
},
329-
330-
getWeathData: function (cityName, cityCode) {
331-
let that = this;
332-
axios({
333-
url: "https://restapi.amap.com/v3/weather/weatherInfo",
334-
method: "GET",
335-
params: {
336-
key: "ba5f9b69f0541123a4dbe142da230b4d",
337-
city: cityCode,
338-
extensions: 'all',
339-
output: "JSON"
340-
},
341-
}).then(function (resp) {
342-
that.renderWeathDom(resp.data);
343-
344-
that.setSQCookie(
345-
"sunqBlogWeather",
346-
resp.data,
347-
3
348-
); // 相隔3小时同一浏览器再次访问时会重新获取天气
349-
})
350-
.catch();
351-
},
352-
353-
renderWeathDom: function (dataObj) {
354-
if(dataObj.status=="1" && dataObj.infocode=='10000'){
355-
let that = this,
356-
weathArray = dataObj.forecasts[0].casts,
357-
week;
358-
359-
that.city = dataObj.forecasts[0].city;
360-
if(weathArray.length > 0){
361-
weathArray.forEach(function(item,i){
362-
if(i == 0){
363-
item.week = weekJson[item.week] + '<span style="font-size:0.5rem">(今天)</span>';
364-
}else{
365-
item.week = weekJson[item.week];
366-
}
367-
368-
item.date = item.date.split('-')[1] + '' + item.date.split('-')[2] + "";
369-
item.dayweatherIcon = weathJson[item.dayweather];
370-
});
371-
weathArray.pop();
372-
that.weathArray = weathArray;
373-
}
374-
}
375-
},
289+
}
376290
},
377291
mounted: function () {
378292
Store.commit("ChangeActive", 4); // 切换Topbar高亮
379293
380-
this.setWeathe();
381-
382294
this.createLog({
383295
moduleType: "menu",
384296
operateType: "选择菜单",
@@ -398,41 +310,4 @@ export default {
398310
.about-url-card {
399311
padding: 0;
400312
}
401-
.weathDev{
402-
padding: 1rem 0.5rem;
403-
}
404-
.weathTitle{
405-
font-size: 1.1rem;
406-
margin-top: 0;
407-
}
408-
.weathContent{
409-
border-top: none;
410-
padding-bottom: 0;
411-
padding-top: 1rem;
412-
}
413-
.weathWeek{
414-
padding-bottom: .3rem;
415-
}
416-
.weathDay{
417-
opacity: .5;
418-
font-size: 0.9rem;
419-
padding-bottom: .3rem;
420-
}
421-
.temperature{
422-
font-size: 0.8rem;
423-
padding-bottom: .3rem;
424-
}
425-
.weathIcon{
426-
padding-bottom: .3rem;
427-
font-size: 2.2rem;
428-
}
429-
.citySpan{
430-
font-size: 1.1rem;
431-
}
432-
.weathChinese{
433-
padding-bottom: .3rem;
434-
font-size: .9rem;
435-
overflow: hidden;
436-
flex-wrap:nowrap
437-
}
438313
</style>

0 commit comments

Comments
 (0)