index.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. <template>
  2. <view class="container">
  3. <view class="banner">
  4. <swiper v-if='bannerList.length != 0' style="height: 500rpx;">
  5. <swiper-item v-for='(item,index) in bannerList' :key="index">
  6. <u-image :src='item.image' mode="widthFix"></u-image>
  7. </swiper-item>
  8. </swiper>
  9. <u-empty v-else text="banner图为空" mode="list" style="margin: 50rpx;"></u-empty>
  10. <view class="inform_div mim-flex-wrap" :style="{height:menuButtonHeight+'rpx',top:menuButtonTop+'rpx'}"
  11. @click="goPage('inform')">
  12. <view class="mim-flex-wrap-right" style="position: relative;">
  13. <u-image src="@/static/icon/inform.png" width="36rpx" height="38rpx"></u-image>
  14. <!-- <text class="mim-font-16 message">消息</text> -->
  15. <i class="icon_msg" v-if="isRead"></i>
  16. </view>
  17. </view>
  18. </view>
  19. <view class="mim-view">
  20. <view>
  21. <view class="mim-font-16 h">便民服务</view>
  22. <view class="storm"
  23. style="background-image: url('http://api.jczl.site.xmnk.cn//storage/file/account/RkXRuVCsbgNDqBMPhzLbkraE2SJbIxjK.png');"
  24. @click="goPage('command')">
  25. <view class="mim-flex-wrap-left">
  26. <view class="mim_img_div mim-flex-wrap">
  27. <u-image src="../../../static/icon/file.png" width="40rpx" height="44rpx"></u-image>
  28. </view>
  29. <view class="mim-flex-vertical" style="margin-left: 24rpx;">
  30. <view class="mim-font-14 h">指挥交办</view>
  31. <view class="mim-font-12">服务于民 方便于民</view>
  32. </view>
  33. </view>
  34. </view>
  35. <view class="storm" v-if="admin"
  36. style="background-image: url('http://api.jczl.site.xmnk.cn//storage/file/account/BnaPPLhdfcXqvzVue5t8UAD6ETmaMYYA.png');"
  37. @click="goPage('throughTrain')">
  38. <view class="mim-flex-wrap-left">
  39. <view class="mim_img_div mim-flex-wrap">
  40. <u-image src="../../../static/icon/file_1.png" width="40rpx" height="44rpx"></u-image>
  41. </view>
  42. <view class="mim-flex-vertical" style="margin-left: 24rpx;">
  43. <view class="mim-font-14 h">社情民意直通车</view>
  44. <view class="mim-font-12">党群连心 有呼必应</view>
  45. </view>
  46. </view>
  47. </view>
  48. </view>
  49. </view>
  50. </view>
  51. </template>
  52. <script>
  53. export default {
  54. data() {
  55. return {
  56. bannerList: [],
  57. statusBarHeight: '',
  58. navHeight: '',
  59. menuButtonHeight: '',
  60. menuButtonTop: '',
  61. isRead: false,
  62. admin: false
  63. };
  64. },
  65. onLoad() {
  66. // 设备系统信息
  67. // #ifdef MP-WEIXIN
  68. let systemInfomations = uni.getSystemInfoSync()
  69. // 机型适配比例系数
  70. let scaleFactor = 750 / systemInfomations.windowWidth
  71. // 状态栏高度(以 rpx 为单位)
  72. const menuButtonInfo = wx.getMenuButtonBoundingClientRect()
  73. // 胶囊高度(以 rpx 为单位)
  74. let menuButtonHeight = menuButtonInfo.height * scaleFactor
  75. // 状态栏高度(以 rpx 为单位)
  76. let statusBarHeight = systemInfomations.statusBarHeight //rpx
  77. // 胶囊按钮(右上角按钮)相对于可视区域顶部的上边距(即距离可视区域顶部的高度)
  78. let menuButtonTop = menuButtonInfo.top * scaleFactor //rpx
  79. // 导航栏高度(以 rpx 为单位)
  80. var navHeight = menuButtonHeight + (menuButtonTop - statusBarHeight) * 2
  81. this.navHeight = navHeight - 40
  82. this.statusBarHeight = statusBarHeight
  83. this.menuButtonHeight = menuButtonHeight
  84. this.menuButtonTop = menuButtonTop
  85. console.log(menuButtonHeight, menuButtonTop)
  86. // #endif
  87. let roles = this.userRoles
  88. let arr = roles.filter(item => {
  89. return item.name == "admin"
  90. })
  91. if (arr.length > 0) {
  92. this.admin = true
  93. } else {
  94. this.admin = false
  95. }
  96. },
  97. onShow() {
  98. const token = uni.getStorageSync('token')
  99. if (!token) {
  100. this.$u.route({
  101. type: 'reLaunch',
  102. url: '/pages/login/login'
  103. })
  104. } else {
  105. this.homeFn()
  106. }
  107. },
  108. methods: {
  109. goPage(e) {
  110. switch (e) {
  111. case 'inform': //我的消息页面
  112. this.$u.route('/pages/info/info');
  113. break;
  114. case 'command': //指挥交办页面
  115. this.$u.route('/pages/command/command');
  116. break;
  117. case 'throughTrain': //社情民意直通车
  118. this.$u.route('/pages/throughTrain/throughTrain');
  119. break;
  120. default:
  121. console.log('Unknown fruit');
  122. break;
  123. }
  124. },
  125. //获取主页信息
  126. async homeFn() {
  127. const res = await this.$u.api.home()
  128. this.isRead = res.data.isRead
  129. this.bannerList = res.data.bannersS
  130. },
  131. }
  132. }
  133. </script>
  134. <style lang="scss">
  135. page {
  136. background-color: #f7f7f7;
  137. .container {
  138. .banner {
  139. width: 100%;
  140. position: relative;
  141. .inform_div {
  142. position: absolute;
  143. z-index: 1;
  144. left: 24rpx;
  145. .message {
  146. color: #fff;
  147. margin-left: 16rpx;
  148. font-weight: bold;
  149. }
  150. .icon_msg {
  151. width: 20rpx;
  152. height: 20rpx;
  153. background: #DE2E27;
  154. border-radius: 50%;
  155. position: absolute;
  156. z-index: 1;
  157. top: 0;
  158. left: 22rpx;
  159. }
  160. }
  161. }
  162. .mim-view {
  163. margin-top: -24rpx;
  164. .h {
  165. font-weight: bold;
  166. }
  167. .storm {
  168. display: flex;
  169. padding: 0 24rpx;
  170. align-items: center;
  171. margin-top: 24rpx;
  172. height: 212rpx;
  173. border-radius: 16rpx;
  174. opacity: 1;
  175. background-position: center;
  176. background-repeat: no-repeat;
  177. background-size: 100% 100%;
  178. .mim_img_div {
  179. width: 84rpx;
  180. height: 84rpx;
  181. opacity: 1;
  182. background: #FFFFFF;
  183. border-radius: 50%;
  184. }
  185. .h {
  186. margin-bottom: 4rpx;
  187. font-weight: bold;
  188. }
  189. }
  190. }
  191. }
  192. }
  193. </style>