homePage.vue 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392
  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
  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. computed:{
  133. toplistShow(){
  134. var sz=[];
  135. for(var i in this.toplist){
  136. var item=this.toplist[i]
  137. sz.push(item.title)
  138. }
  139. return sz;
  140. }
  141. },
  142. methods: {
  143. noticeclick(e){
  144. var id=this.toplist[e].id;
  145. this.ckInfo(id);
  146. },
  147. noticechange(e){
  148. this.topindex=e
  149. },
  150. ckList(id,title){
  151. var url="/pages/news/news?id="+id+"&title="+title;
  152. uni.navigateTo({
  153. url:url
  154. })
  155. },
  156. ckInfo(id){
  157. var url="/pages/news/articleDetails?id="+id;
  158. uni.navigateTo({
  159. url:url
  160. })
  161. },
  162. swiperclick(index){
  163. var id=this.list[index].id;
  164. this.ckInfo(id);
  165. },
  166. getList(id,pageSize,sz){
  167. API.tabList({
  168. pageSize: pageSize,
  169. typeId:id,
  170. }).then((response) => {
  171. uni.hideLoading();
  172. this[sz]=response.data
  173. }).catch(error => {
  174. uni.showToast({
  175. title: error,
  176. icon: "none"
  177. })
  178. })
  179. },
  180. getSwiperList(){
  181. uni.showLoading({
  182. title: "加载中",
  183. mask: true,
  184. })
  185. API.swiperList({
  186. pageSize: 5,
  187. }).then((response) => {
  188. uni.hideLoading();
  189. this.list=[]
  190. for(var i in response.data){
  191. var item=response.data[i]
  192. this.list.push({
  193. id:item.id,
  194. image:item.url,
  195. title:item.title
  196. })
  197. }
  198. }).catch(error => {
  199. uni.showToast({
  200. title: error,
  201. icon: "none"
  202. })
  203. })
  204. },
  205. onPageScroll(e) {
  206. this.scrollTop = e.scrollTop;
  207. //console.log(this.scrollTop);
  208. if (this.scrollTop >= 200) {
  209. this.flag = true;
  210. } else {
  211. this.flag = false;
  212. }
  213. },
  214. },
  215. }
  216. </script>
  217. <style scoped lang="scss">
  218. page {
  219. padding-bottom: 50px;
  220. }
  221. .sticky {
  222. width: 100%;
  223. position: fixed;
  224. top: 0;
  225. left: 0;
  226. right: 0;
  227. z-index: 100;
  228. border-bottom: 1px solid #fff;
  229. padding: 16rpx 40rpx;
  230. background-color: #fff;
  231. uni-input {
  232. background-color: #E8E8E8;
  233. height: 32px;
  234. line-height: 32px;
  235. border-radius: 8px;
  236. text-align: center;
  237. }
  238. }
  239. .u-search {
  240. /deep/.uni-input-placeholder {
  241. font-weight: bold;
  242. }
  243. /deep/.uni-input-input {
  244. color: #ffffff !important;
  245. font-weight: bold;
  246. }
  247. }
  248. .search-box {
  249. width: 100%;
  250. background-color: #4F3C27;
  251. padding: 16rpx 40rpx;
  252. position: absolute;
  253. line-height: 32px;
  254. color: #ffffff !important;
  255. opacity: 0.4;
  256. z-index: 999;
  257. opacity: 0.4;
  258. }
  259. // 公告
  260. .notice {
  261. background-color: rgba(255, 255, 255, 1);
  262. line-height: 40px;
  263. display: flex;
  264. padding: 0 32rpx;
  265. .title {
  266. color: rgba(31, 74, 153, 1);
  267. font-size: 18px;
  268. font-weight: bold;
  269. }
  270. .content {
  271. width: 380rpx;
  272. white-space: nowrap;
  273. overflow: hidden;
  274. text-overflow: ellipsis;
  275. color: rgba(51, 51, 51, 1);
  276. margin-left: 14px;
  277. }
  278. .date {
  279. color: rgba(119, 119, 119, 1);
  280. margin-left: auto;
  281. }
  282. }
  283. // 宫格
  284. .grid {
  285. img {
  286. width: 80rpx;
  287. height: 80rpx;
  288. }
  289. .grid-text {
  290. color: rgba(51, 51, 51, 1);
  291. margin-top: 8rpx;
  292. }
  293. }
  294. // 新闻资讯
  295. .news {
  296. padding: 40rpx 32rpx;
  297. background-color: rgba(244, 244, 244, 1);
  298. .title {
  299. display: flex;
  300. align-items: center;
  301. margin-bottom: 40rpx;
  302. img {
  303. width: 40rpx;
  304. height: 40rpx;
  305. margin-right: 8rpx;
  306. }
  307. }
  308. .news-item {
  309. display: flex;
  310. justify-content: space-between;
  311. margin-bottom: 40rpx;
  312. .content {
  313. display: flex;
  314. flex-direction: column;
  315. justify-content: space-between;
  316. .news-title {
  317. color: rgba(51, 51, 51, 1);
  318. font-size: 16px;
  319. text-align: justify;
  320. width: 438rpx;
  321. white-space: nowrap;
  322. overflow: hidden;
  323. text-overflow: ellipsis;
  324. }
  325. .information {
  326. margin-top: 44rpx;
  327. display: flex;
  328. justify-content: space-between;
  329. color: #777777;
  330. }
  331. }
  332. }
  333. .img {
  334. width: 224rpx;
  335. border-radius: 5px;
  336. overflow: hidden;
  337. img {
  338. width: 100%;
  339. height: 100%;
  340. }
  341. }
  342. }
  343. </style>