Files
AlgerMusicPlayer/src/components/RecommendSinger.vue
T

80 lines
2.3 KiB
Vue
Raw Normal View History

2021-07-21 15:01:39 +08:00
<template>
<!-- 推荐歌手 -->
<div class="recommend-singer">
<div class="recommend-singer-list">
<div
v-for="(item, index) in hotSingerData?.artists"
:key="item.id"
class="recommend-singer-item relative"
:class="setAnimationClass('animate__backInRight')"
:style="setAnimationDelay(index, 100)"
>
<div :style="setBackgroundImg(getImgUrl(item.picUrl, '300y300'))" class="recommend-singer-item-bg"></div>
<div class="recommend-singer-item-count p-2 text-base text-gray-200 z-10">{{ item.musicSize }}</div>
<div class="recommend-singer-item-info z-10">
<div class="recommend-singer-item-info-play" @click="toSearchSinger(item.name)">
<i class="iconfont icon-playfill text-xl"></i>
</div>
<div class="ml-4">
<div class="recommend-singer-item-info-name">{{ item.name }}</div>
<div class="recommend-singer-item-info-name">{{ item.name }}</div>
</div>
2021-07-21 15:01:39 +08:00
</div>
</div>
2021-07-21 15:01:39 +08:00
</div>
</div>
2021-07-21 15:01:39 +08:00
</template>
<script lang="ts" setup>
import { onMounted, ref } from 'vue';
import { getHotSinger } from '@/api/home';
import router from '@/router';
import type { IHotSinger } from '@/type/singer';
import { getImgUrl, setAnimationClass, setAnimationDelay, setBackgroundImg } from '@/utils';
2021-07-21 15:01:39 +08:00
// 歌手信息
const hotSingerData = ref<IHotSinger>();
// 加载推荐歌手
2021-07-21 15:01:39 +08:00
const loadSingerList = async () => {
const { data } = await getHotSinger({ offset: 0, limit: 5 });
hotSingerData.value = data;
2021-07-21 15:01:39 +08:00
};
// 页面初始化
onMounted(() => {
loadSingerList();
2021-07-21 15:01:39 +08:00
});
2021-09-28 17:31:20 +08:00
const toSearchSinger = (keyword: string) => {
router.push({
path: '/search',
query: {
keyword,
},
});
2021-09-28 17:31:20 +08:00
};
2021-07-21 15:01:39 +08:00
</script>
<style lang="scss" scoped>
.recommend-singer {
&-list {
@apply flex;
height: 280px;
}
&-item {
@apply flex-1 h-full rounded-3xl p-5 mr-5 flex flex-col justify-between;
&-bg {
@apply bg-gray-900 bg-no-repeat bg-cover bg-center rounded-3xl absolute w-full h-full top-0 left-0 z-0;
filter: brightness(80%);
2021-07-21 15:01:39 +08:00
}
&-info {
@apply flex items-center p-2;
&-play {
@apply w-12 h-12 bg-green-500 rounded-full flex justify-center items-center hover:bg-green-600 cursor-pointer;
}
2021-07-21 15:01:39 +08:00
}
}
2021-07-21 15:01:39 +08:00
}
</style>