news.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327
  1. <template>
  2. <custom-layout class="main">
  3. <el-col :span="24" class="one">
  4. <div class="w_1300">
  5. <el-col :span="24" class="one_1">
  6. <h2 class="name">双高新闻资讯</h2>
  7. <h5 class="remark">跟紧政策指引方向 &nbsp;&nbsp;&nbsp; 抓牢各地双高机遇</h5>
  8. <div class="search">
  9. <el-input v-model="input1" size="large" placeholder="请输入关键字" :suffix-icon="Search">
  10. <template #append>
  11. <el-button type="primary" size="large">搜索</el-button>
  12. </template>
  13. </el-input>
  14. </div>
  15. </el-col>
  16. <el-col :span="24" class="one_2">
  17. <el-col :span="24" class="two">
  18. <el-col :span="18" class="left">
  19. <el-col :span="24" class="list" v-for="(item, index) in list" :key="index" @click="toView(item)">
  20. <el-col :span="6" class="left">
  21. <el-image class="image" v-if="item.logo && item.logo.length > 0" :src="getUrl(item.logo)" fit="fill">
  22. <template v-slot:error>
  23. <el-image class="image" :src="new_4" fit="fill" />
  24. </template>
  25. </el-image>
  26. <el-image class="image" v-else :src="new_4" fit="fill" />
  27. </el-col>
  28. <el-col :span="17" class="right">
  29. <el-col :span="24" class="right_1 textOne">
  30. {{ item.title || '暂无标题' }}
  31. </el-col>
  32. <el-col :span="24" class="right_2 textMore">
  33. <div v-html="removeHtmlStyle(item.content)"></div>
  34. </el-col>
  35. <el-col :span="24" class="right_3">
  36. {{ item.time || '暂无' }}
  37. </el-col>
  38. </el-col>
  39. </el-col>
  40. </el-col>
  41. <el-col :span="6" class="right">
  42. <el-col :span="24" class="title">
  43. <el-col :span="18" class="left">成果展示 </el-col>
  44. <el-col :span="6" class="right" @click="toMore(0)"> 查看更多</el-col>
  45. </el-col>
  46. <el-col :span="24" class="content">
  47. <a-timeline>
  48. <a-timeline-item v-for="(item, index) in achievementList" :key="index" @click="toCommon(item, '/achievement/detail')">
  49. <div class="name textOne">{{ item.name }}</div>
  50. <div class="time">{{ item.time }}</div>
  51. </a-timeline-item>
  52. </a-timeline>
  53. </el-col>
  54. <el-col :span="24" class="title">
  55. <el-col :span="18" class="left">项目精选 </el-col>
  56. <el-col :span="6" class="right" @click="toMore(1)"> 查看更多</el-col>
  57. </el-col>
  58. <el-col :span="24" class="content">
  59. <a-timeline>
  60. <a-timeline-item v-for="(item, index) in projectList" :key="index" @click="toCommon(item, '/project/detail')">
  61. <div class="name textOne">{{ item.name }}</div>
  62. <div class="time">{{ item.time }}</div>
  63. </a-timeline-item>
  64. </a-timeline>
  65. </el-col>
  66. </el-col>
  67. </el-col>
  68. <el-col :span="24" class="thr">
  69. <el-pagination background layout="total, prev, pager, next" :page-sizes="[10, 20, 50, 100, 200]" :total="total" :page-size="limit" v-model:current-page="currentPage" @current-change="changePage" @size-change="sizeChange"> </el-pagination>
  70. </el-col>
  71. </el-col>
  72. </div>
  73. </el-col>
  74. </custom-layout>
  75. </template>
  76. <script setup>
  77. // 接口
  78. import { NewsStore } from '@/store/api/platform/news'
  79. import { AchievementStore } from '@/store/api/platform/achievement'
  80. import { ProjectStore } from '@/store/api/platform/project'
  81. const store = NewsStore()
  82. const projectStore = ProjectStore()
  83. const achievementStore = AchievementStore()
  84. // 路由
  85. const router = useRouter()
  86. // 图片引入
  87. import new_4 from '/images/new_4.png'
  88. // 加载中
  89. const loading = ref(false)
  90. // 列表
  91. const list = ref([])
  92. let skip = 0
  93. let limit = inject('limit')
  94. const total = ref(0)
  95. const achievementList = ref([])
  96. const projectList = ref([])
  97. // 请求
  98. onMounted(async () => {
  99. loading.value = true
  100. await searchOther()
  101. await search({ skip, limit })
  102. loading.value = false
  103. })
  104. const searchOther = async () => {
  105. const info = {
  106. skip: 0,
  107. limit: 6
  108. }
  109. let res
  110. res = await achievementStore.query(info)
  111. if (res.errcode == '0') achievementList.value = res.data
  112. res = await projectStore.query(info)
  113. if (res.errcode == '0') projectList.value = res.data
  114. }
  115. const search = async (query = { skip, limit }) => {
  116. skip = query.skip
  117. limit = query.limit
  118. const info = {
  119. skip: query.skip,
  120. limit: query.limit,
  121. status: '1',
  122. is_use: '0'
  123. }
  124. const res = await store.query(info)
  125. if (res.errcode == '0') {
  126. list.value = res.data
  127. total.value = res.total
  128. }
  129. }
  130. // 查看
  131. const toView = (item) => {
  132. router.push({ path: `/news/detail`, query: { id: item.id || item._id } })
  133. }
  134. // 查看更多
  135. const toMore = (type) => {
  136. if (type == '0') router.push({ path: `/nine` })
  137. else router.push({ path: `/project` })
  138. }
  139. // 详情
  140. const toCommon = (item, route) => {
  141. router.push({ path: route, query: { id: item._id || item.id } })
  142. }
  143. const removeHtmlStyle = (html) => {
  144. let relStyle = /style\s*?=\s*?([‘"])[\s\S]*?\1/g //去除样式
  145. let relTag = /<.+?>/g //去除标签
  146. let relClass = /class\s*?=\s*?([‘"])[\s\S]*?\1/g // 清除类名
  147. let newHtml = ''
  148. if (html) {
  149. newHtml = html.replace(relStyle, '')
  150. newHtml = newHtml.replace(relTag, '')
  151. newHtml = newHtml.replace(relClass, '')
  152. }
  153. return newHtml
  154. }
  155. const currentPage = ref(1)
  156. // 分页
  157. const changePage = (page = currentPage.value) => {
  158. search({ skip: (page - 1) * limit, limit: limit })
  159. }
  160. const sizeChange = (limits) => {
  161. limit = limits
  162. currentPage.value = 1
  163. search({ skip: 0, limit: limit })
  164. }
  165. const getUrl = (item) => {
  166. if (item) return `${import.meta.env.VITE_APP_HOST}${item[0].uri}`
  167. }
  168. </script>
  169. <style scoped lang="scss">
  170. .main {
  171. .one {
  172. background: url(/images/bg-list_detail.jpg) no-repeat;
  173. .one_1 {
  174. padding: 85px 0 0;
  175. .name {
  176. font-size: 33px !important;
  177. font-weight: bold;
  178. color: #ffffff;
  179. text-align: center;
  180. }
  181. .remark {
  182. margin: 27px 0 80px;
  183. font-size: $global-font-size-14;
  184. color: #ffffff;
  185. text-align: center;
  186. }
  187. .search {
  188. margin: 0 auto;
  189. width: 810px;
  190. :deep(.el-input--large .el-input__inner) {
  191. height: 60px !important;
  192. }
  193. }
  194. }
  195. .one_2 {
  196. margin-top: 100px !important;
  197. padding: 30px !important;
  198. background-color: $global-color-fff;
  199. .two {
  200. display: flex;
  201. width: 100%;
  202. background-color: #fff;
  203. border-radius: 10px;
  204. .left {
  205. .list {
  206. display: flex;
  207. align-items: center;
  208. margin-bottom: 30px;
  209. .left {
  210. .image {
  211. width: 216px;
  212. height: 144px;
  213. }
  214. }
  215. .right {
  216. margin: 0 0 0 10px;
  217. .right_1 {
  218. height: 24px;
  219. font-size: $global-font-size-20;
  220. font-family:
  221. PingFangSC-Medium,
  222. PingFang SC;
  223. font-weight: 500;
  224. color: #111;
  225. display: block;
  226. line-height: 24px;
  227. margin-bottom: 20px;
  228. }
  229. .right_2 {
  230. margin-bottom: 20px;
  231. height: 48px;
  232. overflow: hidden;
  233. font-size: $global-font-size-18;
  234. font-family:
  235. PingFangSC-Regular,
  236. PingFang SC;
  237. font-weight: 400;
  238. color: #999;
  239. line-height: 24px;
  240. cursor: pointer;
  241. }
  242. .right_3 {
  243. font-size: $global-font-size-14;
  244. font-family:
  245. PingFangSC-Regular,
  246. PingFang SC;
  247. font-weight: 400;
  248. color: #999;
  249. line-height: $global-font-size-14;
  250. cursor: pointer;
  251. }
  252. .right_1:hover {
  253. color: #2374ff;
  254. cursor: pointer;
  255. }
  256. }
  257. }
  258. }
  259. .right {
  260. .title {
  261. display: flex;
  262. align-items: center;
  263. justify-content: space-between;
  264. background: linear-gradient(90deg, #d7e8ff, #fff);
  265. width: 300px;
  266. height: 64px;
  267. padding-left: 21px;
  268. box-sizing: border-box;
  269. margin-bottom: 7px;
  270. .left {
  271. font-size: $global-font-size-26;
  272. font-family:
  273. PingFangSC-Medium,
  274. PingFang SC;
  275. font-weight: 500;
  276. color: #111;
  277. line-height: 24px;
  278. }
  279. .right {
  280. text-align: right;
  281. font-size: $global-font-size-16;
  282. font-family:
  283. PingFangSC-Regular,
  284. PingFang SC;
  285. font-weight: 400;
  286. color: #666;
  287. cursor: pointer;
  288. }
  289. }
  290. .content {
  291. margin: 10px 0 0 0;
  292. .name {
  293. max-height: 48px;
  294. font-size: $global-font-size-18;
  295. font-family:
  296. PingFangSC-Medium,
  297. PingFang SC;
  298. font-weight: 500;
  299. color: #111;
  300. line-height: 24px;
  301. display: block;
  302. cursor: pointer;
  303. }
  304. .time {
  305. margin-top: 8px;
  306. font-size: $global-font-size-14;
  307. font-family:
  308. PingFangSC-Medium,
  309. PingFang SC;
  310. font-weight: 500;
  311. color: #999;
  312. line-height: 17px;
  313. cursor: pointer;
  314. }
  315. }
  316. }
  317. }
  318. .thr {
  319. display: flex;
  320. flex-direction: row-reverse;
  321. padding: 20px;
  322. }
  323. }
  324. }
  325. }
  326. </style>