Feat(AI):天气和日历对接

This commit is contained in:
lifizer
2025-05-22 10:23:49 +08:00
parent 243460eb39
commit 982fe87cc1
2 changed files with 100 additions and 46 deletions
+74 -43
View File
@@ -51,38 +51,53 @@
</view>
<view v-if="weatherData.city && holidayData.suit" class="weather-holiday-wrap">
<view class="weather-data data-wrap">
<!-- 各种天气对应的图标
https://yikeapi.com/help/wea
https://yikeapi.com/help/tianqiimg -->
<view class="title">
<image
:src="webUrl + '/aiChat/weather/' + weatherData.wea_img +'.png'"
class="icon"
mode="widthFix"
/>
<view class="tem-wrap">
<view class="tem">{{ weatherData.tem }}</view>
<view class="unit"></view>
<block v-if="!weatherDataLoading">
<view v-if="weatherIsLoad">
<!-- 各种天气对应的图标
https://yikeapi.com/help/wea
https://yikeapi.com/help/tianqiimg -->
<view class="title">
<image
:src="webUrl + '/aiChat/weather/' + weatherData.wea_img +'.png'"
class="icon"
mode="widthFix"
/>
<view class="tem-wrap">
<view class="tem">{{ weatherData.tem }}</view>
<view class="unit"></view>
</view>
</view>
<view class="loca">
<view class="addr">
<image
:src="webUrl + '/aiChat/addr.png'"
class="icon"
mode="widthFix"
/>
{{ weatherData.city }}
</view>
<view class="tem-range">
{{ weatherData.wea }}&nbsp;&nbsp;{{ weatherData.tem2 }}~{{ weatherData.tem1 }}
</view>
</view>
<view class="content">今日风向{{ weatherData.win }}</view>
</view>
</view>
<view class="loca">
<view class="addr">
<view v-else class="no-weather">
<image
:src="webUrl + '/aiChat/addr.png'"
class="icon"
:src="webUrl + '/aiChat/weather/no-weather.png'"
class="img"
mode="widthFix"
/>
{{ weatherData.city }}
<view>无法获取天气信息</view>
</view>
<view class="tem-range">
{{ weatherData.wea }}&nbsp;&nbsp;{{ weatherData.tem2 }}~{{ weatherData.tem1 }}
</view>
</view>
<view class="content">今日风向{{ weatherData.win }}</view>
</block>
<block v-else>
<view class="txt-loading">加载中...</view>
</block>
</view>
<view class="holiday-data data-wrap">
<view v-if="holidayData.suit" class="holiday-data data-wrap">
<view class="title">
<view class="day">农历{{ holidayData.lunarCalendar }}</view>
<view class="day">{{ holidayData.lunarCalendar }}</view>
<view>{{ holidayData.date.substr(5).replace('-', '/') }}&nbsp;{{ weekDayArr[holidayData.weekDay] }}</view>
</view>
<view class="desc">{{ holidayData.yearTips }}/{{ holidayData.chineseZodiac }}</view>
@@ -363,7 +378,11 @@
</view>
</view>
</view>
<view id="bottom_postion" class="bottom-postion" />
<view
v-if="chatNumber"
id="bottom_postion"
class="bottom-postion"
/>
</view>
</view>
<view
@@ -430,6 +449,8 @@ export default {
data() {
return {
cityName: '',
weatherDataLoading: false,
weatherIsLoad: true,
weatherData: {},
holidayData: {},
weekDayArr: Object.freeze(['', '周一', '周二', '周三', '周四', '周五', '周六', '周日']),
@@ -466,28 +487,37 @@ export default {
this.animationStr = `TranslateXSwiper-${data.systemTopicDivMaxWidth * 10} ${data.systemTopicDivScrollDuration}s infinite linear alternate`
}
})
getAiSystemInfoTopic().then(res => {
const { success, data } = res
if (success) {
this.topicList = data || []
}
})
if (this.cityName) {
getWeatherData({
cityName: '桂林'
}).then(res => {
const { success, data } = res
if (success) {
this.weatherData = data
}
})
this.loadData()
})
},
loadData() {
getAiSystemInfoTopic().then(res => {
const { success, data } = res
if (success) {
this.topicList = data || []
}
getHolidayData().then(res => {
})
if (this.cityName) {
this.weatherDataLoading = true
getWeatherData({
cityName: this.cityName
}).then(res => {
const { success, data } = res
if (success) {
this.holidayData = data
this.weatherData = data
}
this.weatherIsLoad = true
this.weatherDataLoading = false
}).catch(() => {
this.weatherDataLoading = false
this.weatherIsLoad = false
})
}
getHolidayData().then(res => {
const { success, data } = res
if (success) {
this.holidayData = data
}
})
},
// 创建新会话
@@ -499,6 +529,7 @@ export default {
this.loading = false
this.getConfigLoading = false
this.chatMessageList = []
this.loadData()
},
clickBackHandle() {
if (!this.chatNumber) {