1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- <template>
- <div class="hotList">
- <div class="title">
- <img :src="hotIcon" style="width: 18px; height: 18px" />
- 热度排行
- </div>
- <div
- class="hotItem"
- v-for="(item, index) in listHot"
- :key="item.rk"
- @click="() => searchHot(item.content)"
- >
- <span
- :style="{ color: colorRanking[index] || '#999', 'font-size': '14px' }"
- >{{ index + 1 }}</span
- >
- {{ item.content }}
- </div>
- </div>
- </template>
- <script setup>
- import { ref, defineEmits, defineProps, watch } from 'vue';
- import { hotRank } from '../../../api/index';
- import hotIcon from '../../../assets/img/hot.png';
- const emit = defineEmits(['changeSearch']);
- const listHot = ref([]);
- const colorRanking = ['#FE2D46', '#F60', '#FAA90E'];
- const props = defineProps({
- province: String,
- });
- const hot = () => {
- hotRank({
- data: {
- province: props.province || undefined,
- },
- }).then(res => {
- listHot.value = res || [];
- });
- };
- watch(props, () => {
- console.log(props.province);
- hot();
- });
- const searchHot = text => {
- emit('changeSearch', text);
- };
- hot();
- </script>
- <style scoped>
- .hotList {
- position: absolute;
- width: 300px;
- right: 50px;
- top: 100px;
- }
- .title {
- font-size: 18px;
- font-weight: 600;
- height: 49px;
- line-height: 49px;
- padding-left: 8px;
- border-bottom: 1px solid #f5f5f5;
- }
- .hotItem {
- line-height: 1em;
- font-size: 16px;
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
- cursor: pointer;
- padding: 0.6em;
- }
- .hotItem:not(:last-child) {
- border-bottom: 1px dashed #e9e9e9;
- }
- .hotItem:hover {
- font-weight: 600;
- color: rgb(64, 158, 255);
- border-radius: 5px;
- background-color: rgba(64, 158, 255, 0.1);
- border-bottom: none;
- }
- </style>
|