HeadBlock.vue 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298
  1. <script setup lang="ts">
  2. import { ref, watch } from 'vue'
  3. import { Search } from '@element-plus/icons-vue'
  4. // import type { TabsInstance } from 'element-plus'
  5. import { useRoute, useRouter } from 'vue-router'
  6. import { getNews, type NewsData, type NewsResponseData } from '@/api/home'
  7. import { getFileExtension } from '@/utils/getFileExtension'
  8. import { queryFieldMethod } from '@/utils/queryFieldMethod'
  9. import { useSearchStore } from '@/stores/searchStore'
  10. const searchStore = useSearchStore();
  11. const input3 = ref('')
  12. const firstNewsList = ref<NewsData[]>();
  13. const tabs = ref([
  14. { title: '企业名称', placeholder: '请输入企业名称' },
  15. { title: '统一社会信用代码', placeholder: '请输入统一社会信用代码' },
  16. { title: '站内文章', placeholder: '请输入站内文章关键字' }
  17. ])
  18. const isHome = ref<boolean>(false);
  19. const route: any = useRoute()
  20. const router: any = useRouter()
  21. const BASE_URL = import.meta.env.VITE_APP_BASE_URL;
  22. const homeImgUrl = ref<string>('');
  23. const munTabs = ref([
  24. { title: '首页', route: 'home' },
  25. { title: '信用动态', route: 'creditDynamics' },
  26. { title: '信用惠企', route: 'creditWiseEnterprise' },
  27. { title: '信用红榜', route: 'creditEcaluationResults' },
  28. { title: '信用警示', route: 'creditWarning' },
  29. { title: '企业自主上报', route: 'creditServices' },
  30. { title: '园区通知公告', route: 'about' }
  31. ])
  32. const checkIndex = ()=>{
  33. const filter = munTabs.value.find(item=> item.title == route.meta.title );
  34. let index =null;
  35. if(filter){
  36. index = munTabs.value.indexOf(filter)
  37. }
  38. return index;
  39. }
  40. const activeTab = ref(0)
  41. const activeMun = ref(checkIndex())
  42. const staticNews = ref<NewsData>();
  43. watch(() => route.meta.title,()=>{
  44. activeMun.value = checkIndex();
  45. })
  46. const placeholder = ref('请输入企业名称')
  47. // const tabPosition = ref<TabsInstance['tabPosition']>('left')
  48. const setActiveTab = (index: any, value: any) => {
  49. if(!index){
  50. activeTab.value = 0
  51. }else {
  52. activeTab.value = index
  53. }
  54. if(!value){
  55. placeholder.value = '请输入企业名称'
  56. }else {
  57. placeholder.value = value?.placeholder
  58. }
  59. }
  60. setActiveTab(route.query.searchModule,tabs.value[route.query.searchModule])
  61. const munActiveTab = (index: any, tab: any) => {
  62. activeMun.value = index
  63. router.push({
  64. path: tab.route,
  65. query: {}
  66. })
  67. }
  68. const toSearch = (searchModule:number,value:string)=>{
  69. router.push({
  70. path:'/search',
  71. query:{
  72. searchModule,
  73. value
  74. }
  75. })
  76. }
  77. const toDetail = (id:number|undefined)=>{
  78. if(!id){
  79. return;
  80. }
  81. router.push({
  82. path:'/newsDetail',
  83. query:{
  84. id
  85. }
  86. })
  87. }
  88. const getData =async ()=>{
  89. const res:NewsResponseData = await getNews(queryFieldMethod('special_column','big_news'));
  90. // console.log(res)
  91. if(res.code == 200){
  92. firstNewsList.value = res.data.slice(0,5);
  93. }
  94. const res1:NewsResponseData = await getNews(queryFieldMethod('special_column','static_news'))
  95. if(res1.code == 200){
  96. staticNews.value = res1.data[0];
  97. }
  98. // const find = res.data.find(item=>{
  99. // return item.files.find(q=>{
  100. // return getFileExtension(q.fileOriginalName) == 'png'||getFileExtension(q.fileOriginalName) == 'jpg'
  101. // })
  102. // })
  103. // if(find){
  104. // firstNews.value = find;
  105. // }else {
  106. // firstNews.value = res.data[0];
  107. // }
  108. // homeImgUrl.value = BASE_URL + firstNews.value?.files.find(item=>{
  109. // return getFileExtension(item.fileOriginalName) == 'png'||getFileExtension(item.fileOriginalName) == 'jpg'
  110. // })?.fileUrl
  111. // console.log(homeImgUrl)
  112. // console.log(firstNews.value)
  113. };
  114. const computeImgUrl = (files:FileType[])=>{
  115. return BASE_URL + files.filter(item=>{
  116. return getFileExtension(item.fileUrl) == 'png'||getFileExtension(item.fileUrl) == 'jpg'
  117. })?.[0]?.fileUrl
  118. }
  119. const init = ()=>{
  120. getData()
  121. if(route.query.value){
  122. input3.value = route.query.value;
  123. }
  124. }
  125. const toManager = ()=>{
  126. window.open('http://42.48.99.5:81/')
  127. }
  128. init()
  129. </script>
  130. <template>
  131. <div class="headContainer w-99vw" style="background-image:url('/static/首页背景.png');background-size: 100% 100%;object-fit: fill">
  132. <!-- 标题部分登录跳转 -->
  133. <div class="headTitle">
  134. <text>欢迎来到怀化高新区企业信用分级分类网</text>
  135. <div>
  136. <el-button type="primary" @click="toManager">登录</el-button>
  137. </div>
  138. </div>
  139. <!-- 头部功能及其显示内容 -->
  140. <div class="headModule">
  141. <div class="h-238px">
  142. <h1>怀化高新区企业信用分级分类网</h1>
  143. <!-- <h3>www.aabbccd.com</h3>-->
  144. </div>
  145. <div class="headSearch">
  146. <!-- 搜索上方tab切换选择 -->
  147. <div class="headSTab">
  148. <div v-for="(tab, index) in tabs" :key="index" class="tab cursor-pointer hover:bg-#FF9900 hover:bg-op-80" :class="{ active: activeTab == index }"
  149. @click="setActiveTab(index, tab)">
  150. {{ tab.title }}
  151. </div>
  152. </div>
  153. <!-- 搜索框位置 -->
  154. <div>
  155. <el-input v-model="input3" style="width: 337px;height:33px" :placeholder=placeholder
  156. class="input-with-select">
  157. <template #append>
  158. <el-button :icon="Search" @click="toSearch(activeTab,input3)" />
  159. </template>
  160. </el-input>
  161. </div>
  162. </div>
  163. </div>
  164. <div class="D" style="display:flex;justify-content:center">
  165. <div style="width:100%;
  166. bottom: 0;
  167. display: flex;
  168. justify-content: center;
  169. background:rgba(255,255,255,.22);
  170. height:46px"
  171. >
  172. <div class="headMune bg-opacity-22">
  173. <div v-for="(tab, index) in munTabs" :key="index" class="tab cursor-pointer hover:bg-#FF9900 hover:bg-op-80" :class="{ activeMun: activeMun === index }"
  174. @click="munActiveTab(index,tab)">
  175. {{ tab.title }}
  176. </div>
  177. </div>
  178. </div>
  179. </div>
  180. <div v-if="route.meta.title == '首页'">
  181. <div class="h-100px" >
  182. <div class="w-1112px ml-auto mr-auto text-center mt-21px mb-20px bg-white bg-opacity-90 h-102px cursor-pointer" @click="toDetail(staticNews?.id)">
  183. <div class="text-26px font-600 color-black line-height-60px pt-21px pb-10px">{{staticNews?.title}}</div>
  184. <div class="mb-17px " ></div>
  185. </div>
  186. </div>
  187. <div class="w-1112px ml-auto mr-auto mt-20px pb-54px ">
  188. <el-carousel :interval="5000" arrow="always" indicator-position="none" height="367px">
  189. <el-carousel-item v-for="item in firstNewsList" :key="item">
  190. <div class="flex">
  191. <div class="w-685px h-351px">
  192. <img class="w-100% h-100%" :src="computeImgUrl(item.files)" />
  193. </div>
  194. <div class="w-427px h-351px p-22px bg-white bg-opacity-90">
  195. <div class="w-368px h-44px mb-12px bold text-22px line-height-22px line-clamp-2">{{item.title}}</div>
  196. <div class="w-368px h-206px mb-17px line-clamp-8 line-height-23px overflow-hidden text-13px" v-html="item.content"></div>
  197. <div class="color-006eff cursor-pointer text-right" @click="toDetail(item.id)" >了解更多 ></div>
  198. </div>
  199. </div>
  200. </el-carousel-item>
  201. </el-carousel>
  202. </div>
  203. </div>
  204. </div>
  205. </template>
  206. <style scoped lang="scss">
  207. $boxWidth: 1200px;
  208. .headContainer {
  209. background-size: 100% 100%;
  210. position: relative;
  211. //background-image: url(src/assets/img/首页背景.png);
  212. .headTitle {
  213. margin: 0 40px;
  214. height: 40px;
  215. display: flex;
  216. justify-content: space-between;
  217. align-items: center;
  218. text {
  219. font-weight: 400;
  220. font-size: 13px;
  221. color: #FFFFFF;
  222. }
  223. }
  224. .headModule {
  225. margin-top: 27px;
  226. width: $boxWidth;
  227. margin: 27px auto 0 auto;
  228. display: flex;
  229. justify-content: space-between;
  230. align-items: center;
  231. H1 {
  232. font-weight: bold;
  233. font-size: 26px;
  234. color: #FFFFFF;
  235. }
  236. H3 {
  237. font-weight: bold;
  238. font-size: 14px;
  239. color: #FFFFFF;
  240. margin: 16px 0 0 0;
  241. }
  242. .headSearch {
  243. .headSTab {
  244. display: flex;
  245. .tab {
  246. color: white;
  247. padding: 6px 6px;
  248. margin-bottom: 16px;
  249. border-radius: 6px;
  250. }
  251. .active {
  252. background-color: #FF9900;
  253. }
  254. }
  255. }
  256. }
  257. .headMune {
  258. width: 100%;
  259. bottom: 0;
  260. width: $boxWidth;
  261. display: flex;
  262. justify-content: space-between;
  263. align-items: center;
  264. height: 46px;
  265. .tab {
  266. color: white;
  267. width: 100%;
  268. height: 100%;
  269. display: flex;
  270. justify-content: center;
  271. align-items: center;
  272. }
  273. .activeMun {
  274. background-color: #FF9900;
  275. }
  276. }
  277. }
  278. </style>