feat; 消息与天气接口对接
This commit is contained in:
@@ -7,58 +7,21 @@
|
||||
<view class="flex flex-col flex-full min-width-0">
|
||||
<view class="flex flex-row flex-items-center flex-justify-between min-width-0">
|
||||
<text class="flex-full min-width-0 font-size-20 font-500 color-white ellipsis-1">{{ mainPageDataModel.welcomeContent }}</text>
|
||||
<text class="flex-shrink-0 font-size-20 font-500 color-white mt-4"> 26°C ☀️ </text>
|
||||
<text class="flex-shrink-0 font-size-20 font-500 color-white mt-4"> {{ weatherText }} </text>
|
||||
</view>
|
||||
|
||||
<swiper @change="onSwiperChange" class="swiper" circular :autoplay="autoplay" :interval="interval"
|
||||
:duration="duration" :indicator-dots="false">
|
||||
<swiper-item v-for="item in bannerList" :key="item.title">
|
||||
<view class="swiper-item flex flex-col flex-items-start flex-justify-between px-10">
|
||||
<text class="font-size-12 font-600 color-B45309">
|
||||
{{ item.title }}
|
||||
</text>
|
||||
<view class="flex flex-row flex-justify-between">
|
||||
<text class="font-size-10 font-500 color-D97706">
|
||||
发布时间:{{ item.time }}
|
||||
</text>
|
||||
<text class="font-size-10 font-500 color-B45309 underline-text">
|
||||
详情
|
||||
</text>
|
||||
</view>
|
||||
</view>
|
||||
</swiper-item>
|
||||
</swiper>
|
||||
|
||||
<yo-indicator-dot :current-index="currentIndex" :length="bannerList.length" duration="0.5" default-width="4px"
|
||||
active-width="16px" dot-height="4px" shape="circle" default-color="rgba(255,255,255,0.5)"
|
||||
active-color="rgba(255,255,255,1)" />
|
||||
<NoticeMessage />
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
<script setup>
|
||||
import { ref } from "vue";
|
||||
import { onMounted, ref } from "vue";
|
||||
import { defineProps, computed } from "vue";
|
||||
import SpriteAnimator from "@/components/Sprite/SpriteAnimator.vue";
|
||||
import NoticeMessage from "../NoticeMessage/index.vue";
|
||||
import { getLocalWeather } from "@/request/api/MainPageDataApi";
|
||||
|
||||
const autoplay = ref(true);
|
||||
const interval = ref(7000);
|
||||
const duration = ref(500);
|
||||
|
||||
const currentIndex = ref(0);
|
||||
const bannerList = ref([
|
||||
{
|
||||
title: "小七欢迎你~",
|
||||
time: "2025年7月12日 09:30",
|
||||
},
|
||||
{
|
||||
title: "小8欢迎你~",
|
||||
time: "2025年7月13日 09:30",
|
||||
},
|
||||
{
|
||||
title: "小9欢迎你~",
|
||||
time: "2025年7月15日 09:30",
|
||||
},
|
||||
]);
|
||||
const weatherText = ref("26°C ☀️");
|
||||
|
||||
const props = defineProps({
|
||||
mainPageDataModel: {
|
||||
@@ -92,29 +55,18 @@ const spriteStyle = computed(() => {
|
||||
};
|
||||
});
|
||||
|
||||
const onSwiperChange = (e) => {
|
||||
currentIndex.value = e.detail.current;
|
||||
};
|
||||
const getLocalWeatherData = async () => {
|
||||
const res = await getLocalWeather();
|
||||
if (res && res.code === 0) {
|
||||
const { temperature, weather } = res.data;
|
||||
weatherText.value = `${temperature}°C ${weather}`;
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
getLocalWeatherData();
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.swiper {
|
||||
height: 50px;
|
||||
margin-top: 8px;
|
||||
}
|
||||
|
||||
.swiper-item {
|
||||
display: block;
|
||||
height: 46px;
|
||||
background: #fffbeb;
|
||||
box-shadow: 0px 1px 2px 0px rgba(0, 0, 0, 0.05);
|
||||
border-radius: 12px;
|
||||
border: 2px solid #fef3c7;
|
||||
}
|
||||
|
||||
.underline-text {
|
||||
text-decoration: underline;
|
||||
text-decoration-color: #b45309;
|
||||
}
|
||||
</style>
|
||||
<style scoped></style>
|
||||
|
||||
Reference in New Issue
Block a user