Commit 2c981718 by pangchong

feat: 天气预报

parent 38e5a7f5
......@@ -32,3 +32,11 @@ export const getBasicParamsListApi = (data, config) => {
config
})
}
export const getTerminalListApi = (data, config) => {
return http({
method: 'POST',
url: '/terminal/getTerminalList',
data,
config
})
}
import { http } from 'mocp/utils/http'
export const findWeatherSynopsesMessagesApi = (data, config) => {
return http({
method: 'POST',
url: '/basicinfo/findWeatherSynopsesMessages',
data,
config
})
}
import { getAircraftNumbersApi, getBasicParamsListApi } from 'mocp/api/base'
import { getAircraftNumbersApi, getBasicParamsListApi, getTerminalListApi } from 'mocp/api/base'
import { defineStore } from 'pinia'
const useBaseStore = defineStore('base', {
state: () => {
return {
selectList: {
deviceNumSelect: [] //机号
deviceNumSelect: [], //机号
terminalSelect: [] //航站下拉数据
},
allBasicParams: {}
}
},
getters: {},
getters: {
getTerminalSelect(state) {
return state.selectList.terminalSelect?.reduce((q, w) => {
if (!q[w.terminalCode]) {
q[w.terminalCode] = []
}
q[w.terminalCode] = w.terminalCity + '-' + w.terminalName + '-' + w.terminalCode
return q
}, {})
}
},
actions: {
async initSysData() {
uni.showLoading({
......@@ -18,8 +29,7 @@ const useBaseStore = defineStore('base', {
mask: true
})
try {
await this.getAircraftNumbers()
await this.getBasicParamsList()
await Promise.all(this.getAircraftNumbers(), this.getBasicParamsList(), this.getTerminalList())
uni.hideLoading()
} catch (error) {
uni.hideLoading()
......@@ -31,6 +41,12 @@ const useBaseStore = defineStore('base', {
this.selectList.deviceNumSelect = res.data
}
},
async getTerminalList() {
const res = await getTerminalListApi({ pageSize: 100, pageIndex: 1 })
if (res.code == 200) {
this.selectList.terminalSelect = res.data.list
}
},
async getBasicParamsList() {
const res = await getBasicParamsListApi({})
if (res.code == 200) {
......
......@@ -4,11 +4,11 @@
<view class="navbar-box-info">
<image src="/static/mocp/image/panel/logo.png" />
</view>
<view class="navbar-box-weather">
<image src="/static/mocp/image/panel/weather.png" />
<view class="navbar-box-weather" v-if="weatherInfo">
<!-- <image src="/static/mocp/image/panel/weather.png" /> -->
<view class="info">
<view class="place">武汉-WUH</view>
<view class="txt">晴转多云 22°</view>
<view class="place">{{ baseStore.getTerminalSelect[userStore.userInfo?.terminal] }}</view>
<view class="txt">{{ weatherInfo.weatherInfoTxt }} {{ weatherInfo.temperature }}°</view>
</view>
</view>
</view>
......@@ -32,7 +32,18 @@
</view>
</template>
<script setup></script>
<script setup>
import { ref } from 'vue'
import useUserStore from 'mocp/store/user'
import useBaseStore from 'mocp/store/base'
const userStore = useUserStore()
const baseStore = useBaseStore()
const weatherInfo = ref()
uni.$on('sendWeatherInfo', (info) => {
weatherInfo.value = info
})
</script>
<style lang="scss" scoped>
@import '../constants/panel-navbar.scss';
</style>
......@@ -13,11 +13,6 @@
<script setup>
import PanelNavbar from './components/panel-navbar.vue'
import PanelMenu from './components/panel-menu.vue'
import useBaseStore from 'mocp/store/base'
//加载基础参数
const baseStore = useBaseStore()
baseStore.initSysData()
</script>
<style lang="scss" scoped>
.page-bg {
......
......@@ -14,13 +14,38 @@
import home from '../home/index.vue'
import panel from '../panel/index.vue'
import chat from '../chat/index.vue'
import { ref } from 'vue'
import { ref, watch } from 'vue'
import useUserStore from 'mocp/store/user'
import useBaseStore from 'mocp/store/base'
import { findWeatherSynopsesMessagesApi } from 'mocp/api/panel'
import { onLoad } from '@dcloudio/uni-app'
const userStore = useUserStore()
const baseStore = useBaseStore()
//天气信息
const weatherInfo = ref()
const findWeatherSynopsesMessages = async () => {
const res = await findWeatherSynopsesMessagesApi({ airportCode: userStore.userInfo.terminal })
if (res.code == 200) {
weatherInfo.value = res.data?.at(-1)
uni.$emit('sendWeatherInfo', weatherInfo.value)
}
}
onLoad(async () => {
//加载基础参数
await baseStore.initSysData()
//加载天气信息
await findWeatherSynopsesMessages()
})
//页面参数
const query = defineProps(['name'])
const tabbarValue = ref(query.name || 'panel')
watch(tabbarValue, (value) => {
if (value == 'panel') {
findWeatherSynopsesMessages()
}
})
//退出登录
const userStore = useUserStore()
const handleLogOut = () => {
userStore.handleLogOut()
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment