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

This commit is contained in:
lifizer
2025-05-21 15:39:23 +08:00
parent 20fc34673d
commit 243460eb39
5 changed files with 206 additions and 3 deletions
+79 -1
View File
@@ -49,6 +49,57 @@
</view>
</view>
</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>
</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 class="holiday-data data-wrap">
<view class="title">
<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>
<view class="tip">
<view class="label"></view>
<view class="content">
{{ holidayData.suit }}
</view>
</view>
<view class="tip">
<view class="label label2"></view>
<view class="content">
{{ holidayData.avoid }}
</view>
</view>
</view>
</view>
<view class="topic-wrap">
<view class="title">
<image
@@ -363,6 +414,10 @@ import {
getAiSystemInfoSetting,
getAiSystemInfoTopic
} from '@/api/public'
import {
getWeatherData,
getHolidayData
} from '@/api/chat/index'
import AiHistoryList from '../components/historyList'
import BottomSend from '../components/bottomSend.vue'
export default {
@@ -374,12 +429,19 @@ export default {
mixins: [chatMixins],
data() {
return {
cityName: '',
weatherData: {},
holidayData: {},
weekDayArr: Object.freeze(['', '周一', '周二', '周三', '周四', '周五', '周六', '周日']),
animationWidth: '150%',
animationStr: '',
settingInfo: {},
topicList: []
}
},
onLoad(options) {
this.cityName = options.cityName || ''
},
onShow() {
const addNewChat = uni.getStorageSync('addNewChat') === '1'
// 从历史界面点击新增对话
@@ -410,6 +472,22 @@ export default {
this.topicList = data || []
}
})
if (this.cityName) {
getWeatherData({
cityName: '桂林'
}).then(res => {
const { success, data } = res
if (success) {
this.weatherData = data
}
})
}
getHolidayData().then(res => {
const { success, data } = res
if (success) {
this.holidayData = data
}
})
})
},
// 创建新会话
@@ -489,7 +567,7 @@ export default {
display: flex;
align-items: center;
justify-content: space-between;
padding: 60rpx 40rpx;
padding: 0 40rpx;
.guide-left {
.avatar {
display: block;