index.vue 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <script setup lang="ts">
  2. import { useRoute, useRouter } from 'vue-router'
  3. import { ref, watch } from 'vue'
  4. import { getNews, type NewsData } from '@/api/home'
  5. import { queryFieldMethod } from '@/utils/queryFieldMethod'
  6. import { ElMessage } from 'element-plus'
  7. import NewDynamics from '@/components/NewDynamics.vue'
  8. import SmallSearch from '@/components/SmallSearch.vue'
  9. import FourDynamics from '@/components/FourDynamics.vue'
  10. const route = useRoute()
  11. const router = useRouter()
  12. const creditDynamicsList = ref<NewsData[]>([]);
  13. const knowMore = (dickMapKey:string|undefined,dickMapValue:string|undefined)=>{
  14. router.push({
  15. path:'/creditDynamicsDetail',
  16. query:{
  17. dickMapKey,
  18. dickMapValue
  19. }
  20. });
  21. }
  22. watch(()=>route.query.dickMapKey,()=>{
  23. getData();
  24. })
  25. const dataList = ref<NewsData[]>();
  26. const getData =async ()=>{
  27. const res =await getNews(queryFieldMethod('special_column',route.query.dickMapKey as string));
  28. if(res.code == 200){
  29. dataList.value = res.data;
  30. }else {
  31. ElMessage({
  32. message:res.msg,
  33. type:'error'
  34. })
  35. }
  36. }
  37. const init = async ()=>{
  38. await getData()
  39. const res5 = await getNews(queryFieldMethod('special_column','credit_dynamics'));
  40. if (res5.code == 200){
  41. creditDynamicsList.value = res5.data;
  42. }
  43. }
  44. const toDetail = (id:number|undefined)=>{
  45. if(!id){
  46. return
  47. }
  48. router.push({
  49. path:'/newsDetail',
  50. query:{
  51. id
  52. }
  53. })
  54. }
  55. init();
  56. </script>
  57. <template>
  58. <div class="warnningContainer">
  59. <div class="w-912px ml-auto mr-auto pt-20px mb-20px text-14px">
  60. 你所在的位置:<span class="cursor-pointer" @click="$router.push('/home')" >首页</span> > <span class="cursor-pointer" @click="$router.push('/creditDynamics')">信用动态</span>> > <span class="color-#006eff">{{$route.query.dickMapValue?$route.query.dickMapValue:'详情'}}</span>
  61. </div>
  62. <div class="w-912px ml-auto mr-auto flex">
  63. <div class="w-603px bg-white bg-opacity-90 mr-15px">
  64. <div class="p-20px pl-24px pr-24px cursor-pointer " v-for="(item,index) in dataList" :key="index" @click="toDetail(item.id)">
  65. <div class="text-16px text-#000000 bold ">{{ item.title }}</div>
  66. <div class="mt-8px line-height-23px text-13px text-#464646 line-clamp-4" v-html="item.content"></div>
  67. <div class="mt-20px h-1px bg-#e9e9e9"></div>
  68. </div>
  69. </div>
  70. <div class="w-294px bg-opacity-90">
  71. <small-search />
  72. <four-dynamics />
  73. <new-dynamics />
  74. </div>
  75. </div>
  76. </div>
  77. </template>
  78. <style scoped>
  79. .warnningContainer {
  80. background-color: #ecf0f9;
  81. }
  82. </style>