analysis_hot_list.vue 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <template>
  2. <div class="hotList">
  3. <div class="title">
  4. <img :src="hotIcon" style="width: 18px; height: 18px" />
  5. 热度排行
  6. </div>
  7. <div
  8. class="hotItem"
  9. v-for="(item, index) in listHot"
  10. :key="item.rk"
  11. @click="() => searchHot(item.content)"
  12. >
  13. <span
  14. :style="{ color: colorRanking[index] || '#999', 'font-size': '14px' }"
  15. >{{ index + 1 }}</span
  16. >
  17. {{ item.content }}
  18. </div>
  19. </div>
  20. </template>
  21. <script setup>
  22. import { ref, defineEmits, defineProps, watch } from 'vue';
  23. import { hotRank } from '../../../api/index';
  24. import hotIcon from '../../../assets/img/hot.png';
  25. const emit = defineEmits(['changeSearch']);
  26. const listHot = ref([]);
  27. const colorRanking = ['#FE2D46', '#F60', '#FAA90E'];
  28. const props = defineProps({
  29. province: String,
  30. });
  31. const hot = () => {
  32. hotRank({
  33. data: {
  34. province: props.province || undefined,
  35. },
  36. }).then(res => {
  37. listHot.value = res || [];
  38. });
  39. };
  40. watch(props, () => {
  41. console.log(props.province);
  42. hot();
  43. });
  44. const searchHot = text => {
  45. emit('changeSearch', text);
  46. };
  47. hot();
  48. </script>
  49. <style scoped>
  50. .hotList {
  51. position: absolute;
  52. width: 300px;
  53. right: 50px;
  54. top: 100px;
  55. }
  56. .title {
  57. font-size: 18px;
  58. font-weight: 600;
  59. height: 49px;
  60. line-height: 49px;
  61. padding-left: 8px;
  62. border-bottom: 1px solid #f5f5f5;
  63. }
  64. .hotItem {
  65. line-height: 1em;
  66. font-size: 16px;
  67. overflow: hidden;
  68. text-overflow: ellipsis;
  69. white-space: nowrap;
  70. cursor: pointer;
  71. padding: 0.6em;
  72. }
  73. .hotItem:not(:last-child) {
  74. border-bottom: 1px dashed #e9e9e9;
  75. }
  76. .hotItem:hover {
  77. font-weight: 600;
  78. color: rgb(64, 158, 255);
  79. border-radius: 5px;
  80. background-color: rgba(64, 158, 255, 0.1);
  81. border-bottom: none;
  82. }
  83. </style>