homePage.vue 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398
  1. <template>
  2. <view>
  3. <!-- 吸顶搜索框 -->
  4. <view class="sticky" v-if="flag">
  5. <input type="text" @click="gotoUrl('pages/search/searchResult')" placeholder="请输入搜索内容">
  6. </view>
  7. <!-- 轮播图 -->
  8. <view class="slideshow">
  9. <view class="wrap">
  10. <view class="search-box" @click="gotoUrl('pages/search/searchResult')" >
  11. <u-search color="black"
  12. search-icon-color="#fff" placeholder-color="#fff" bg-color="#8a7170"
  13. placeholder="请输入搜索内容" :show-action="false" input-align="center"></u-search>
  14. </view>
  15. <u-swiper mode="none" @click="swiperclick" img-mode="scaleToFill"
  16. :list="list" :title="true" height="422"></u-swiper>
  17. </view>
  18. </view>
  19. <!-- 公告 -->
  20. <view class="notice">
  21. <view class="title">
  22. 公告
  23. </view>
  24. <view class="content">
  25. <u-notice-bar :volume-icon="false"
  26. padding=" 32rpx 0 " duration="4000" @click="noticeclick"
  27. type="none" :is-circular="false" @change="noticechange"
  28. mode="vertical" :list="toplistShow"></u-notice-bar>
  29. </view>
  30. <view class="date" v-if="toplist.length">
  31. {{toplist[topindex].createTime}}
  32. </view>
  33. </view>
  34. <!-- 宫格 -->
  35. <view class="grid">
  36. <u-grid :col="4" :border="false">
  37. <u-grid-item @click="ckList(noticeList[0],'铁路概况')" >
  38. <img src="../../assets/img/tlgk.png" alt="">
  39. <view class="grid-text">铁路概况</view>
  40. </u-grid-item>
  41. <u-grid-item @click="ckList(noticeList[1],'机构设置')">
  42. <img src="../../assets/img/jgsz.png" alt="">
  43. <view class="grid-text">机构设置</view>
  44. </u-grid-item>
  45. <u-grid-item @click="ckList(noticeList[2],'政务动态')">
  46. <img src="../../assets/img/zwdt.png" alt="">
  47. <view class="grid-text">政务动态</view>
  48. </u-grid-item>
  49. <u-grid-item @click="ckList(noticeList[3],'党建动态')" >
  50. <img src="../../assets/img/djdt.png" alt="">
  51. <view class="grid-text">党建动态</view>
  52. </u-grid-item>
  53. <u-grid-item @click="ckList(noticeList[4],'法制宣传')" >
  54. <img src="../../assets/img/fzxc.png" alt="">
  55. <view class="grid-text">法制宣传</view>
  56. </u-grid-item>
  57. <u-grid-item @click="ckList(noticeList[8],'纪检监察')">
  58. <img src="../../assets/img/jjjc.png" alt="">
  59. <view class="grid-text">纪检监察</view>
  60. </u-grid-item>
  61. <u-grid-item @click="ckList(noticeList[9],'文明创建')" >
  62. <img src="../../assets/img/wmcj.png" alt="">
  63. <view class="grid-text">文明创建</view>
  64. </u-grid-item>
  65. <u-grid-item @click="ckList(noticeList[5],'为您服务')">
  66. <img src="../../assets/img/wnfw.png" alt="">
  67. <view class="grid-text">为您服务</view>
  68. </u-grid-item>
  69. </u-grid>
  70. </view>
  71. <!-- 新闻资讯 -->
  72. <view class="news" style="padding-bottom: 0px;">
  73. <view class="title">
  74. <view class="icon">
  75. <img src="../../assets/img/news.png" alt="">
  76. </view>
  77. <view class="text">
  78. 新闻资讯
  79. </view>
  80. </view>
  81. <view class="news-item" v-for="(item,i) in footlist" @click="ckInfo(item.id)" :key="i" >
  82. <view class="content">
  83. <view class="news-title">
  84. {{item.title}}
  85. </view>
  86. <view class="information">
  87. <view class="classify">
  88. {{item.typeName}}
  89. </view>
  90. <view class="date">
  91. {{item.createTime}}
  92. </view>
  93. </view>
  94. </view>
  95. <view class="img">
  96. <img v-if="item.pic" :src="item.pic" alt="">
  97. <img v-else src="@/assets/img/default_img.png" alt="">
  98. </view>
  99. </view>
  100. </view>
  101. <u-divider bg-color="#F2F4F4" @click="ckList(noticeList[10],'新闻资讯')" border-color="#CFD2D5">点击查看更多</u-divider>
  102. <tabbar ref="mytabbar"
  103. current="0"></tabbar>
  104. </view>
  105. </template>
  106. <script>
  107. import * as API from '@/apis/pagejs/news.js'
  108. import tabbar from "../../components/Tabbar.vue"
  109. export default {
  110. components: {
  111. tabbar
  112. },
  113. data() {
  114. return {
  115. noticeList:[
  116. "2044eba8-776d-4195-b54f-b3d00928ed98",// 铁路概况0 "86e29bf7-9e8f-4a28-9361-1001705d3dc6",// 机构设置 1 "939fbcca-8c31-478f-a7dc-6c649648164e",// 政务动态 2 "f57b8b67-db9a-4110-bc9b-7ec382a07954",// 党建动态 3 "39599bb3-78e9-4e84-99b5-2d6a5c1c40e3",// 法治宣传 4 "7288376a-b582-4e9a-98fa-c218e35b5c30",// 为您服务5 "696d571d-54ba-4954-804e-74f4310e4d6a",// 公众参与6 "ee0ea72a-75bf-4970-ad34-11e3132bc6a3",// 图片新闻7 "8e7f6d22-2b5b-4efc-b354-dbcddb46a8b3",// 纪检监察8 "a4870553-44e0-4172-91db-263cedf5938f",// 文明创建9 "de3958c2-0010-4009-b7e1-15bfdcc60cef",// 通知公告10
  117. ],
  118. flag: false,
  119. scrollTop: "",
  120. list: [
  121. ],
  122. toplist:[],
  123. footlist:[],
  124. topindex:0,
  125. }
  126. },
  127. onLoad(){
  128. this.getSwiperList()
  129. this.getList("de3958c2-0010-4009-b7e1-15bfdcc60cef",5,"toplist");//通知公告
  130. this.getList("ee0ea72a-75bf-4970-ad34-11e3132bc6a3",5,"footlist");//新闻资讯-图片新闻
  131. },
  132. onShow(){
  133. },
  134. computed:{
  135. toplistShow(){
  136. var sz=[];
  137. for(var i in this.toplist){
  138. var item=this.toplist[i]
  139. sz.push(item.title)
  140. }
  141. return sz;
  142. }
  143. },
  144. methods: {
  145. noticeclick(e){
  146. var id=this.toplist[e].id;
  147. this.ckInfo(id);
  148. },
  149. noticechange(e){
  150. this.topindex=e
  151. },
  152. ckList(id,title){
  153. var url="/pages/news/news?id="+id+"&title="+title;
  154. uni.navigateTo({
  155. url:url
  156. })
  157. },
  158. ckInfo(id){
  159. var url="/pages/news/articleDetails?id="+id;
  160. uni.navigateTo({
  161. url:url
  162. })
  163. },
  164. swiperclick(index){
  165. var id=this.list[index].id;
  166. this.ckInfo(id);
  167. },
  168. getList(id,pageSize,sz){
  169. API.tabList({
  170. pageSize: pageSize,
  171. typeId:id,
  172. }).then((response) => {
  173. uni.hideLoading();
  174. this[sz]=response.data
  175. }).catch(error => {
  176. uni.showToast({
  177. title: error,
  178. icon: "none"
  179. })
  180. })
  181. },
  182. getSwiperList(){
  183. uni.showLoading({
  184. title: "加载中",
  185. mask: true,
  186. })
  187. API.swiperList({
  188. pageSize: 5,
  189. }).then((response) => {
  190. uni.hideLoading();
  191. this.list=[]
  192. for(var i in response.data){
  193. var item=response.data[i]
  194. if(item.url){
  195. this.list.push({
  196. id:item.id,
  197. image: process.car.IMG_URL+item.url,
  198. title:item.title
  199. })
  200. }
  201. }
  202. }).catch(error => {
  203. uni.showToast({
  204. title: error,
  205. icon: "none"
  206. })
  207. })
  208. },
  209. onPageScroll(e) {
  210. this.scrollTop = e.scrollTop;
  211. //console.log(this.scrollTop);
  212. if (this.scrollTop >= 200) {
  213. this.flag = true;
  214. } else {
  215. this.flag = false;
  216. }
  217. },
  218. },
  219. }
  220. </script>
  221. <style scoped lang="scss">
  222. page {
  223. padding-bottom: 50px;
  224. font-family: 'Regular';
  225. }
  226. .sticky {
  227. width: 100%;
  228. position: fixed;
  229. top: 0;
  230. left: 0;
  231. right: 0;
  232. z-index: 100;
  233. border-bottom: 1px solid #fff;
  234. padding: 16rpx 40rpx;
  235. background-color: #fff;
  236. uni-input {
  237. background-color: #E8E8E8;
  238. height: 32px;
  239. line-height: 32px;
  240. border-radius: 8px;
  241. text-align: center;
  242. }
  243. }
  244. .u-search {
  245. /deep/.uni-input-placeholder {
  246. font-weight: bold;
  247. }
  248. /deep/.uni-input-input {
  249. color: #ffffff !important;
  250. font-weight: bold;
  251. }
  252. }
  253. .search-box {
  254. width: 100%;
  255. background-color: #4F3C27;
  256. padding: 16rpx 40rpx;
  257. position: absolute;
  258. line-height: 32px;
  259. color: #ffffff !important;
  260. opacity: 0.4;
  261. z-index: 999;
  262. opacity: 0.4;
  263. }
  264. // 公告
  265. .notice {
  266. background-color: rgba(255, 255, 255, 1);
  267. line-height: 40px;
  268. display: flex;
  269. padding: 0 32rpx;
  270. .title {
  271. color: rgba(31, 74, 153, 1);
  272. font-size: 18px;
  273. font-weight: bold;
  274. }
  275. .content {
  276. width: 380rpx;
  277. white-space: nowrap;
  278. overflow: hidden;
  279. text-overflow: ellipsis;
  280. color: rgba(51, 51, 51, 1);
  281. margin-left: 14px;
  282. }
  283. .date {
  284. color: rgba(119, 119, 119, 1);
  285. margin-left: auto;
  286. }
  287. }
  288. // 宫格
  289. .grid {
  290. img {
  291. width: 80rpx;
  292. height: 80rpx;
  293. }
  294. .grid-text {
  295. color: rgba(51, 51, 51, 1);
  296. margin-top: 8rpx;
  297. }
  298. }
  299. // 新闻资讯
  300. .news {
  301. padding: 40rpx 32rpx;
  302. background-color: rgba(244, 244, 244, 1);
  303. .title {
  304. display: flex;
  305. align-items: center;
  306. margin-bottom: 40rpx;
  307. font-family: 'SemiBold';
  308. img {
  309. width: 40rpx;
  310. height: 40rpx;
  311. margin-right: 8rpx;
  312. }
  313. }
  314. .news-item {
  315. display: flex;
  316. justify-content: space-between;
  317. margin-bottom: 40rpx;
  318. .content {
  319. display: flex;
  320. flex-direction: column;
  321. justify-content: space-between;
  322. .news-title {
  323. color: rgba(51, 51, 51, 1);
  324. font-size: 16px;
  325. text-align: justify;
  326. width: 438rpx;
  327. white-space: nowrap;
  328. overflow: hidden;
  329. text-overflow: ellipsis;
  330. }
  331. .information {
  332. margin-top: 44rpx;
  333. display: flex;
  334. justify-content: space-between;
  335. color: #777777;
  336. }
  337. }
  338. }
  339. .img {
  340. width: 224rpx;
  341. border-radius: 5px;
  342. overflow: hidden;
  343. img {
  344. width: 100%;
  345. height: 100%;
  346. }
  347. }
  348. }
  349. </style>