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>
</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="topic-wrap">
<view class="title"> <view class="title">
<image <image
@@ -363,6 +414,10 @@ import {
getAiSystemInfoSetting, getAiSystemInfoSetting,
getAiSystemInfoTopic getAiSystemInfoTopic
} from '@/api/public' } from '@/api/public'
import {
getWeatherData,
getHolidayData
} from '@/api/chat/index'
import AiHistoryList from '../components/historyList' import AiHistoryList from '../components/historyList'
import BottomSend from '../components/bottomSend.vue' import BottomSend from '../components/bottomSend.vue'
export default { export default {
@@ -374,12 +429,19 @@ export default {
mixins: [chatMixins], mixins: [chatMixins],
data() { data() {
return { return {
cityName: '',
weatherData: {},
holidayData: {},
weekDayArr: Object.freeze(['', '周一', '周二', '周三', '周四', '周五', '周六', '周日']),
animationWidth: '150%', animationWidth: '150%',
animationStr: '', animationStr: '',
settingInfo: {}, settingInfo: {},
topicList: [] topicList: []
} }
}, },
onLoad(options) {
this.cityName = options.cityName || ''
},
onShow() { onShow() {
const addNewChat = uni.getStorageSync('addNewChat') === '1' const addNewChat = uni.getStorageSync('addNewChat') === '1'
// 从历史界面点击新增对话 // 从历史界面点击新增对话
@@ -410,6 +472,22 @@ export default {
this.topicList = data || [] 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; display: flex;
align-items: center; align-items: center;
justify-content: space-between; justify-content: space-between;
padding: 60rpx 40rpx; padding: 0 40rpx;
.guide-left { .guide-left {
.avatar { .avatar {
display: block; display: block;
+8
View File
@@ -37,3 +37,11 @@ export function historyChatMessage(params) {
export function deleteChatListByType(type) { export function deleteChatListByType(type) {
return request.delete('/v1/chat/type/' + type, {}, { login: true }) return request.delete('/v1/chat/type/' + type, {}, { login: true })
} }
export function getWeatherData(params) {
return request.get('/v1/chat/weatherData', params, { login: true })
}
export function getHolidayData(params) {
return request.get('/v1/chat/holidayData', params, { login: true })
}
+109
View File
@@ -1036,4 +1036,113 @@ page {
height: 38rpx; height: 38rpx;
} }
} }
}
.weather-holiday-wrap {
display: flex;
align-items: center;
justify-content: space-between;
padding: 0 24rpx 48rpx 24rpx;
.data-wrap {
width: calc(50% - 12rpx);
height: 288rpx;
padding: 20rpx;
border-radius: 20rpx;
box-sizing: border-box;
background-color: #fff;
box-shadow: 0rpx 0rpx 20rpx rgba(0,0,0,0.16);
}
.weather-data {
.title {
display: flex;
align-items: center;
color: #3D4CF1;
.icon {
display: block;
width: 100rpx;
height: 100rpx;
margin: 0 12rpx 0 0;
}
.tem-wrap {
display: flex;
align-items: baseline;
}
.tem {
font-size: 70rpx;
line-height: 70rpx;
font-weight: bold;
}
.unit {
font-size: 36rpx;
line-height: 36rpx;
}
}
.loca {
display: flex;
padding: 24rpx 0;
font-size: 26rpx;
line-height: 36rpx;
color: #333;
.addr {
display: flex;
align-items: center;
.icon {
display: block;
width: 24rpx;
height: 24rpx;
margin: 0 4rpx 0 0;
}
}
.tem-range {
padding: 0 0 0 24rpx;
}
}
.content {
color: #3D4CF1;
font-size: 26rpx;
line-height: 36rpx;
}
}
.holiday-data {
.title {
display: flex;
font-size: 24rpx;
color: #333;
line-height: 36rpx;
.day {
margin: 0 8rpx 0 0;
color: #3D4CF1;
font-size: 28rpx;
}
}
.desc {
font-size: 24rpx;
color: #333;
line-height: 36rpx;
}
.tip {
display: flex;
flex-wrap: wrap;
padding: 20rpx 0 0 0;
.label {
display: block;
width: 32rpx;
height: 32rpx;
margin: 0 12rpx 0 0;
border-radius: 8rpx;
text-align: center;
line-height: 32rpx;
font-size: 24rpx;
color: #fff;
background-color: #3D4CF1;
}
.label2 {
background-color: #C52733;
}
.content {
width: calc(100% - 44rpx);
margin: -6rpx 0 0 0;
font-size: 24rpx;
}
}
}
} }
+7 -1
View File
@@ -15,6 +15,12 @@ import {
} from '@/api/public' } from '@/api/public'
export default { export default {
name: 'AiEntrance', name: 'AiEntrance',
props: {
cityName: {
type: String,
default: ''
}
},
data() { data() {
return { return {
showImg: false, showImg: false,
@@ -36,7 +42,7 @@ export default {
}, },
enterAiChat() { enterAiChat() {
uni.navigateTo({ uni.navigateTo({
url: '/aiChat/views/index?click=1' url: '/aiChat/views/index?click=1&cityName=' + this.cityName
}) })
} }
} }
+3 -1
View File
@@ -353,7 +353,9 @@
paddingBottom="200rpx" paddingBottom="200rpx"
/> />
<FunctionGuide :maxStep="15" @hide="setGuide('index')" :guideData="functionGuideData" ref="FunctionGuide"></FunctionGuide> <FunctionGuide :maxStep="15" @hide="setGuide('index')" :guideData="functionGuideData" ref="FunctionGuide"></FunctionGuide>
<AiEntrance /> <AiEntrance
:city-name="cityName"
/>
<xdd-tabbar :curr-index="0" @getElementData="elementData" @getIcon="getIcon"/> <xdd-tabbar :curr-index="0" @getElementData="elementData" @getIcon="getIcon"/>
</view> </view>
</template> </template>