首页+登录页
This commit is contained in:
114
src/components/homeSide.vue
Normal file
114
src/components/homeSide.vue
Normal file
@ -0,0 +1,114 @@
|
||||
<template>
|
||||
<div class="pr-8">
|
||||
<d-card class="mt-10 bg-white">
|
||||
<template #title>
|
||||
<div class="flex items-center">
|
||||
<icon-time class="w-5 mr-2"></icon-time>
|
||||
节日天气
|
||||
</div>
|
||||
</template>
|
||||
<template #content>
|
||||
<div class="w-full text-center text-[#ec66ab] font-500 text-2xl font-[yj]">{{ t }}</div>
|
||||
<div class="mt-2 text-center">{{ d }}</div>
|
||||
</template>
|
||||
</d-card>
|
||||
|
||||
<d-card class="mt-10 bg-white">
|
||||
<template #title>
|
||||
<div class="flex items-center">
|
||||
<icon-date class="w-5 mr-2"></icon-date>
|
||||
农历节气
|
||||
</div>
|
||||
</template>
|
||||
<template #content>
|
||||
<div class="w-full text-center text-[#ec66ab] font-500">{{ jq.yearTips }}年 {{ jq.lunarCalendar }}</div>
|
||||
<div class="w-full flex justify-center">
|
||||
<img class="mt-2 w-[90%] rounded" :src="jqImg" alt=""></img>
|
||||
</div>
|
||||
<div class="mt-2 text-center">{{ jq.solarTerms }}</div>
|
||||
</template>
|
||||
</d-card>
|
||||
|
||||
<d-card class="mt-10 bg-white">
|
||||
<template #title>
|
||||
<div class="flex items-center">
|
||||
<icon-news class="w-5 mr-2"></icon-news>
|
||||
百度新闻
|
||||
</div>
|
||||
</template>
|
||||
<template #content>
|
||||
<div class="py-1" v-for="i in bdNews" :key="i.id">
|
||||
<a class="devui-link flex justify-between" :href="i.url" target="_blank">
|
||||
<span>{{ i.index }}. {{ i.title }}</span>
|
||||
<span class="text-primary">{{ i.hot }}</span>
|
||||
</a>
|
||||
</div>
|
||||
<div class="mt-2 text-center">
|
||||
<a class="devui-link" href="https://www.baidu.com/s?ie=utf-8&wd=百度新闻" target="_blank">更多</a>
|
||||
</div>
|
||||
</template>
|
||||
</d-card>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
//mark import
|
||||
import { formatTime } from '@/util/index';
|
||||
|
||||
//mark data
|
||||
const t = ref<any>('')
|
||||
const d = ref<any>('')
|
||||
let timer: any = null
|
||||
const jq = ref<any>("")
|
||||
const jqImg = ref<any>("")
|
||||
const bdNews = ref<any>([])
|
||||
//mark method
|
||||
function getTime() {
|
||||
const date = new Date();
|
||||
t.value = formatTime(date, 'hh:mm:ss')
|
||||
d.value = formatTime(date, 'YYYY 年 MM 月 DD 日')
|
||||
}
|
||||
|
||||
async function getJq() {
|
||||
const res = await $http.mix.getJq({
|
||||
date: formatTime(new Date(), "YYYYMMDD")
|
||||
})
|
||||
console.log('>>> --> getJq --> res:', res.data)
|
||||
jq.value = res.data
|
||||
const j = res.data.solarTerms.slice(0, 2)
|
||||
jqImg.value = 'https://www.hxyouzi.com/img/jq/' + j + '.png'
|
||||
}
|
||||
|
||||
async function getBdhot() {
|
||||
const res = await $http.mix.getBdhot()
|
||||
console.log('>>> --> getBdhot --> res:', res.data)
|
||||
// 取前5条
|
||||
bdNews.value = res.data.slice(0, 5)
|
||||
}
|
||||
|
||||
//mark 周期、内置函数等
|
||||
onMounted(() => {
|
||||
getJq()
|
||||
getBdhot()
|
||||
|
||||
timer = setInterval(() => {
|
||||
getTime()
|
||||
}, 1000)
|
||||
})
|
||||
onUnmounted(() => {
|
||||
clearInterval(timer)
|
||||
})
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
<style scoped lang="less">
|
||||
@font-face {
|
||||
font-family: 'yj';
|
||||
src: url('@/assets/font/LCDML.woff2');
|
||||
}
|
||||
|
||||
:deep(.devui-card__shadow--hover:hover, .devui-card__shadow--always) {
|
||||
box-shadow: none !important;
|
||||
}
|
||||
</style>
|
Reference in New Issue
Block a user