index.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. <template>
  2. <view class="content">
  3. <view class="top">
  4. <!-- 自定义导航栏 -->
  5. <i-navbar></i-navbar>
  6. <!-- 公告 -->
  7. <i-notice :notice="notice"></i-notice>
  8. </view>
  9. <!-- banner -->
  10. <i-banner :banners="banners"></i-banner>
  11. <!-- news -->
  12. <i-news-list :newsList="newsList"></i-news-list>
  13. <!-- i-nav-list -->
  14. <i-nav-list :navsList="navsList"></i-nav-list>
  15. <!-- i-block-list -->
  16. <i-block-list :blocksList="blocksList"></i-block-list>
  17. <!-- null-bottom -->
  18. <i-null-bottom></i-null-bottom>
  19. </view>
  20. </template>
  21. <script>
  22. export default {
  23. data() {
  24. return {
  25. notice:{
  26. title:"今日值班",
  27. message:"",
  28. },
  29. banners:[],
  30. newsList:[],
  31. navsList:[],
  32. blocksList:[]
  33. }
  34. },
  35. onLoad() {
  36. // 获取公告
  37. this.getNotice()
  38. // 获取轮播图
  39. this.getBanner()
  40. // 获取新闻列表
  41. this.getNews()
  42. // 获取首页导航
  43. this.getNavs()
  44. // 获取首页分类链接
  45. this.getBlocksList()
  46. },
  47. methods:{
  48. // 请求获取公告
  49. async getNotice(){
  50. const res = await this.$myRequest({
  51. url: '/notice/list',
  52. })
  53. // console.log(res)
  54. const data = res.data.data
  55. this.notice.title = data.title
  56. if(!data.content){
  57. this.notice.message = data.message + '。'
  58. return
  59. }
  60. this.notice.message = data.content.split(';')
  61. },
  62. // 请求轮播图
  63. async getBanner(){
  64. const res = await this.$myRequest({
  65. url: '/scrollImg/list',
  66. })
  67. // console.log(res.data.data.data)
  68. const data = res.data.data.data
  69. this.banners = data
  70. // console.log(this.banners)
  71. },
  72. // 请求新闻动态
  73. async getNews(){
  74. const res = await this.$myRequest({
  75. url: '/article/list',
  76. })
  77. // console.log(res.data.data.data)
  78. const data = res.data.data.data
  79. this.newsList = data
  80. },
  81. // 请求首页导航设置
  82. async getNavs(){
  83. const res = await this.$myRequest({
  84. url: '/homeNav/list',
  85. })
  86. // console.log(res.data.data.data)
  87. const data = res.data.data.data
  88. this.navsList = data
  89. },
  90. // 请求首页分类链接
  91. async getBlocksList(){
  92. const res = await this.$myRequest({
  93. url: '/home/links',
  94. header:{
  95. Authorization : uni.getStorageSync('token_type') +' '+uni.getStorageSync('Authorization')
  96. }
  97. })
  98. console.log(res.data.data)
  99. const data = res.data.data
  100. this.blocksList = data
  101. },
  102. }
  103. }
  104. </script>
  105. <style lang="scss">
  106. .top {
  107. width: 100%;
  108. height: 457rpx;
  109. background-image: url(../../../static/top.png);
  110. background-size: cover;
  111. background-repeat: no-repeat;
  112. }
  113. </style>