index.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358
  1. <template>
  2. <view class="home" :style="'padding-top:'+nvaHeight+'px;padding-bottom:'+footHeight+'rpx'">
  3. <view class="navbox">
  4. <uni-nav-bar :title="title" leftWidth='400rpx' color="#ffffff" :background-color="backgroundColor" :border="false" statusBar='true' fixed="true">
  5. <block slot="left">
  6. <view class="topl flexc">
  7. <image src="@/static/images/home/adr.png" ></image>
  8. <view class="over">{{city}}</view>
  9. </view>
  10. </block>
  11. </uni-nav-bar>
  12. </view>
  13. <view class="hmain flex1">
  14. <view class="flexcj mb12">
  15. <view class="flex1 namea flexc">
  16. <view class="tit over">你好~ {{name}}</view>
  17. <view class="txt">{{roleGroup}}</view>
  18. <view class="imgs">
  19. <image src="@/static/images/home/change.png"></image>
  20. </view>
  21. </view>
  22. <view class="flex0 weabox">
  23. <view class="tit flexcj mb2">7月28日 <image src="@/static/images/home/wea.png"></image></view>
  24. <view class="txt">31℃/36℃<text></text>晴</view>
  25. </view>
  26. </view>
  27. <view class="mb12" v-if="bannerList&&bannerList.length">
  28. <banner :list="bannerList" height="342"></banner>
  29. </view>
  30. <view class="mb12 tipbox">
  31. <image src="@/static/images/home/tipbg.png" class="tipbg"></image>
  32. <view class="tips">
  33. <view class="flexc tipsa">
  34. <image src="@/static/images/home/tip.png" class="tipimg"></image>
  35. <image src="@/static/images/home/tipt.png" class="tipt"></image>
  36. <view class="flex1"></view>
  37. <view class="tipm flexc" @click="getNoticeFn">
  38. 全部<image src="@/static/images/home/wrimg.png"></image>
  39. </view>
  40. </view>
  41. <notice :noticelist="noticelist" @getNoticeDet="getNoticeDet"></notice>
  42. </view>
  43. </view>
  44. <view class="mb4 htabs flexcj">
  45. <view class="htab flexc">
  46. <view class="imgs flex0 flexc">
  47. <image src="@/static/images/home/htaba.png" class="imga"></image>
  48. </view>
  49. <view class="flex1" @click="getNoticeFn(1)">
  50. <view class="tit mb5">防溺通知</view>
  51. <view class="txt">预警提醒 守护安全</view>
  52. </view>
  53. </view>
  54. <view class="htab flexc" @click="getRzList">
  55. <view class="imgs flex0 flexc">
  56. <image src="@/static/images/home/htabb.png" class="imgb"></image>
  57. </view>
  58. <view class="flex1">
  59. <view class="tit mb5">绑定认证</view>
  60. <view class="txt">绑定监护 溺水早知</view>
  61. </view>
  62. </view>
  63. </view>
  64. <!-- 新闻 -->
  65. <view class="news">
  66. <view class="flexc overh mb15">
  67. <view class="flex1 overh">
  68. <tablist :tablist="tablist" :tabval="tabval" @getCheck="getCheck"></tablist>
  69. </view>
  70. <view class="flexcc hrimg" @click="getArticleFn">
  71. <image src="@/static/images/home/hrimg.png" ></image>
  72. </view>
  73. </view>
  74. <box-list :datainfo='list' :type="type" @getDetail="getDetail"></box-list>
  75. </view>
  76. <!-- 完善按钮 -->
  77. <view class="rxfbtn" v-if="initFace=='Y'">
  78. <view class="rxbtn flexc">
  79. <image src="@/static/images/home/rztip.png" class="imga flex0"></image>
  80. <view class="tit flex1 over">1分钟完善信息,守护孩子的安全</view>
  81. <view class="btn flexcc flex0">去完善</view>
  82. <image src="@/static/images/home/wclose.png" class="imgb flex0" @click="getzrCloseFn"></image>
  83. </view>
  84. </view>
  85. </view>
  86. <loading></loading>
  87. <footers v-if="isfootflag" :footerindex="footerindex"></footers>
  88. </view>
  89. </template>
  90. <script>
  91. import footers from '@/components/footer/footer.vue'
  92. import banner from '@/components/swiper/banner.vue'
  93. import notice from '@/components/swiper/notice.vue'
  94. import tablist from '@/components/tabs/index.vue'
  95. import boxList from '@/components/box/list.vue'
  96. import {checkPermi,checkRole} from "@/utils/permission"; // 权限判断函数
  97. import {getDictionaryFn} from "@/api/mine/register.js"
  98. import {getNewsList,getBannerListNoPage} from "@/api/work/index.js"
  99. import {getNoticeList} from "@/api/common.js"
  100. import {getUserProfile} from "@/api/system/user.js"
  101. export default {
  102. components:{footers,banner,notice,tablist,boxList},
  103. data(){
  104. return{
  105. footerindex:'home',
  106. isfootflag:true,
  107. activeColor:'#A7A7A7',
  108. nactiveColor:'#E6E6E6',
  109. list:[],
  110. bannerList:[],
  111. footHeight:'150',
  112. pageSize: 10,
  113. pageNum: 1,
  114. reachflag: true,
  115. wtdt:'',
  116. nvaHeight:44,
  117. backgroundColor: "transparent",
  118. title:'',
  119. city:"潜山市",
  120. name:this.$store.state.user.nickName,
  121. roleGroup:'',////角色
  122. noticelist:[],
  123. tabval:'news',
  124. type:'article',//article:文章,avideo:视频
  125. tablist:[{dictLabel:'最新',dictValue:'news'}],
  126. xwlxList:[],//新闻类型
  127. initFace:'Y',//y:显示
  128. }
  129. },
  130. onShow() {
  131. this.initFace=this.$store.state.user.initFace||'Y';
  132. if(this.initFace=='Y'){
  133. this.footHeight=282
  134. }
  135. },
  136. onLoad: function() {
  137. uni.getSystemInfo({
  138. success: (e) => {
  139. this.nvaHeight = Number(e.statusBarHeight)+44;
  140. }
  141. })
  142. this.init();
  143. this.getNewsList()
  144. this.getNoticeList()
  145. this.getBanner()
  146. },
  147. onPageScroll(e) {
  148. var scrollTop = Number(e.scrollTop);
  149. if (scrollTop > 0) {
  150. this.backgroundColor = '#DFEBFF';
  151. this.title='首页'
  152. } else {
  153. this.backgroundColor = 'transparent'
  154. this.title=''
  155. }
  156. },
  157. // 上拉触底加载更多触发事件
  158. onReachBottom() {
  159. // if (this.reachflag) {
  160. // this.pageNum++
  161. // this.getDataFn()
  162. // }
  163. },
  164. methods:{
  165. checkPermi,checkRole,
  166. init(){
  167. //新闻类型
  168. getDictionaryFn('newtype').then(res => {
  169. if (res.code == 200) {
  170. this.xwlxList = res.data.map(v => {
  171. var obj={
  172. dictLabel: v.dictLabel,
  173. dictValue: v.dictValue
  174. }
  175. this.tablist.push(obj)
  176. return {
  177. dictLabel: v.dictLabel,
  178. dictValue: v.dictValue
  179. }
  180. })
  181. }
  182. })
  183. getUserProfile().then(response => {
  184. this.roleGroup = response.roleGroup
  185. this.postGroup = response.postGroup
  186. })
  187. },
  188. getzrCloseFn(){
  189. this.$store.dispatch('checkInitFace', 'N').then(() => {
  190. this.initFace='N';
  191. this.footHeight='150';
  192. })
  193. },
  194. getCheck(val){
  195. this.tabval=val;
  196. if(val==2){
  197. this.type="avideo";
  198. }else{
  199. this.type="article";
  200. }
  201. this.getrefreshData()
  202. },
  203. getrefreshData(){
  204. this.pageNum=1;
  205. this.list=[];
  206. this.reachflag=true;
  207. this.getNewsList()
  208. },
  209. getDetail(e){
  210. this.$tab.navigateTo(`/news/pages/article/detail?id=${e}`)
  211. },
  212. getRzList(){
  213. this.$tab.navigateTo(`/work/pages/rz/index`)
  214. },
  215. getNoticeFn(type){
  216. this.$tab.navigateTo(`/news/pages/notice/index`)
  217. },
  218. getArticleFn(){
  219. this.$tab.navigateTo(`/news/pages/article/index`)
  220. },
  221. getNoticeDet(id){
  222. this.$tab.navigateTo(`/news/pages/notice/detail?id=${id}`)
  223. },
  224. getNoticeList(){
  225. var params={
  226. pageSize:5,
  227. pageNum: 1,
  228. status:'0',//0正常,1不启用
  229. noticeType:'3'
  230. }
  231. getNoticeList(params).then(res=>{
  232. if(res.code==200){
  233. this.noticelist = res.rows;
  234. }else{
  235. this.$toast(res.msg)
  236. }
  237. })
  238. },
  239. getNewsList(){
  240. var params={
  241. pageSize:2,
  242. pageNum: 1,
  243. status:'0',//0启用,1不启用
  244. }
  245. if(this.tabval!='news'){
  246. params.newType=this.tabval
  247. }
  248. getNewsList(params).then(res=>{
  249. if(res.code==200){
  250. var arr=JSON.parse(JSON.stringify(res.rows));
  251. if(this.tabval==2){
  252. arr=res.rows.map(v => {
  253. if(v.newUrl){
  254. v.newUrl=v.newUrl.split(',')
  255. }
  256. return v
  257. })
  258. }
  259. this.list = arr;
  260. }else{
  261. this.$toast(res.msg)
  262. }
  263. })
  264. },
  265. getBanner(){
  266. var params={
  267. status:'0',
  268. type:'1',//首页
  269. }
  270. getBannerListNoPage(params).then(res=>{
  271. if(res.code==200){
  272. var arr=[];
  273. if(res.rows&&res.rows.length){
  274. res.rows.map(v => {
  275. if(v.imgUrl){
  276. var newArr=v.imgUrl.split(',')
  277. arr=arr.concat(newArr)
  278. }
  279. })
  280. }
  281. this.bannerList = arr;
  282. }else{
  283. this.$toast(res.msg)
  284. }
  285. })
  286. },
  287. }
  288. }
  289. </script>
  290. <style lang="scss" scoped>
  291. .home{height: 100vh;background: linear-gradient(127deg, #DFEBFF, #F1F6FF, #E2EDFF);padding-bottom: 150rpx;display: flex;flex-direction: column;}
  292. .navbox{position: fixed;left: 0;right: 0;top: 0;z-index: 4;
  293. .topl{padding-left: 6rpx;overflow: hidden;
  294. image{width: 18rpx;height: 20rpx;margin-right: 12rpx;flex: 0 0 auto;}
  295. view{font-weight: bold;font-size: 24rpx;color: #272727;}
  296. }
  297. }
  298. .hmain{padding: 0 24rpx;overflow: auto;
  299. .namea{overflow: hidden;
  300. .tit{font-weight: bold;font-size: 32rpx;color: #272727;margin-right: 22rpx;}
  301. .txt{background: #DDEAFF;font-weight: bold;font-size:20rpx;color: #4E8CEE;border-radius: 18rpx;padding: 0 16rpx;line-height: 30rpx;
  302. border: 2rpx solid #4775EA;margin-right: 18rpx;flex: 0 0 auto;}
  303. .imgs{display: flex;align-items: center;width: 30rpx;height:30rpx;justify-content: center;}
  304. image{width: 22rpx;height: 18rpx;}
  305. }
  306. .weabox{padding-right: 26rpx;
  307. .tit{font-size: 24rpx;color: #272727;}
  308. image{width: 24rpx;height: 24rpx;}
  309. .txt{font-size: 20rpx;color: #666666;}
  310. text{display: inline-block;width: 20rpx;}
  311. }
  312. .tipbox{
  313. width: 100%;height: 162rpx;position: relative;
  314. .tipbg{width: 100%;height: 100%;}
  315. .tips{position: absolute;left: 0;right: 0;top: 0;bottom: 0;
  316. .tipsa{padding: 0rpx 26rpx;height: 60rpx;box-sizing: border-box;
  317. .tipimg{width: 34rpx;height: 34rpx;margin-right: 6rpx;}
  318. .tipt{width: 134rpx;height: 50rpx;margin-top: 4rpx;}
  319. .tit{font-size: 28rpx;color: #FFFFFD;text-shadow: 0px 4rpx 10rpx #275BB7;}
  320. .tipm{font-weight: 500;font-size: 24rpx;color: #FFFFFF;
  321. image{width: 12rpx;height: 18rpx;margin-left: 18rpx;}
  322. }
  323. }
  324. }
  325. }
  326. .htabs{
  327. .htab{height: 140rpx;background: #FFFFFF;border-radius: 20rpx;padding: 0 24rpx;box-sizing: border-box;width: 48%;
  328. .imgs{width: 74rpx;height: 70rpx;margin-right: 14rpx;
  329. .imga{width: 72rpx;height: 70rpx;}
  330. .imgb{width: 74rpx;height: 68rpx;}
  331. }
  332. .tit{font-weight: bold;font-size: 28rpx;color: #000000;}
  333. .txt{font-weight: 500;font-size: 24rpx;color: #666666;}
  334. }
  335. }
  336. .news{
  337. .hrimg{width: 80rpx;height: 80rpx;
  338. image{width: 32rpx;height: 22rpx;}
  339. }
  340. }
  341. .rxfbtn{position: fixed;left:0rpx;right: 0rpx;bottom: 150rpx;padding: 10rpx 24rpx;}
  342. .rxbtn{width: 100%;background: #4280FB;border-radius: 20rpx;padding: 16rpx 22rpx 16rpx 16rpx;
  343. .imga{width: 58rpx;height: 60rpx;margin-right: 14rpx;}
  344. .imgb{width: 20rpx;height: 20rpx;margin-left: 20rpx;}
  345. .tit{font-weight: bold;font-size: 26rpx;color: #FFFFFF;}
  346. .btn{background: #FFFFFF;padding: 0 26rpx;height: 58rpx;
  347. box-shadow: 0px 0px 0px 0px #2B6AE7;
  348. border-radius: 30rpx;font-weight: bold;
  349. font-size: 26rpx;color: #2B73FF;}
  350. }
  351. }
  352. </style>