main.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  1. <template>
  2. <view class="container">
  3. <!-- 自定义导航栏区域 -->
  4. <view class="tab" :style="{ height: customBarH * 2 + 'rpx', paddingTop: statusBarH * 2 + 'rpx' }" v-show="!showHeader">
  5. <img class="tab_img" src="../../static/images/people.png" @click="goLogin(1)" />
  6. 万载三中
  7. </view>
  8. <!-- 页面下拉时显示的导航栏 -->
  9. <view class="tab2" :style="{ height: customBarH * 2 + 'rpx', paddingTop: statusBarH * 2 + 'rpx' }" v-show="showHeader">万载三中</view>
  10. <!-- 顶部图片区域 -->
  11. <view class="header">
  12. <img mode="aspectFill" class="header_img" src="../../static/images/header.png" />
  13. <!-- 学校图标区域 -->
  14. <img mode="aspectFill" class="header_icon" src="../../static/images/school-logo.jpg" />
  15. <!-- 学校名称区域 -->
  16. <view class="header_school">万载县第三中学</view>
  17. </view>
  18. <!-- 登录按钮区域 -->
  19. <view class="login">
  20. <view class="login_btn" @click="goLogin(2)">登录</view>
  21. </view>
  22. <!-- 详细信息区域 -->
  23. <view class="body">
  24. <!-- 应用列表区域 -->
  25. <view class="body_list" v-if="useAppList.length">
  26. <!-- 每一个应用区域 -->
  27. <view class="list_box" v-for="item in useAppList" :key="item.id" @click="goLogin(1)">
  28. <img class="box_img" :src="item.url" />
  29. <view class="box_text">
  30. {{ item.title }}
  31. </view>
  32. </view>
  33. </view>
  34. <NoData v-if="!useAppList.length" />
  35. </view>
  36. </view>
  37. </template>
  38. <script setup>
  39. import { ref } from 'vue'
  40. import { onLoad, onPageScroll, onPullDownRefresh } from '@dcloudio/uni-app'
  41. import { myRequest } from '@/utils/api.js'
  42. import NoData from '@/components/noData.vue'
  43. import { decryptDes } from '@/utils/des.js'
  44. onLoad(() => {
  45. // 获取系统信息
  46. uni.getSystemInfo({
  47. success: (e) => {
  48. // 获取状态栏高度
  49. statusBarH.value = e.statusBarHeight
  50. // // 获取菜单按钮栏高度
  51. let custom = uni.getMenuButtonBoundingClientRect()
  52. customBarH.value = custom.height
  53. }
  54. })
  55. // 获取用户应用权限列表
  56. getUseAppList()
  57. })
  58. onPageScroll((e) => {
  59. if (e.scrollTop > 70) {
  60. showHeader.value = true
  61. } else {
  62. showHeader.value = false
  63. }
  64. })
  65. // 顶部导航栏显示隐藏控制
  66. const showHeader = ref(false)
  67. // 状态栏高度
  68. const statusBarH = ref(0)
  69. // 胶囊按钮栏高度
  70. const customBarH = ref(0)
  71. // 展示的app列表
  72. const useAppList = ref([])
  73. // 获取用户应用权限列表
  74. const getUseAppList = async () => {
  75. const res = await myRequest({
  76. url: '/wanzai/api/smartIdentity/queryIdentityApplyById',
  77. data: {
  78. // 未登录时默认展示家长权限的应用
  79. id: 1
  80. }
  81. })
  82. // console.log(res)
  83. if (res.code == 200) {
  84. const result = JSON.parse(decryptDes(res.data))
  85. useAppList.value = result
  86. }
  87. }
  88. // 跳转登录页
  89. const goLogin = (type) => {
  90. if (type === 1) {
  91. uni.showToast({
  92. title: '请您先登录',
  93. icon: 'none',
  94. mask: true
  95. })
  96. setTimeout(() => {
  97. uni.navigateTo({
  98. url: '/pages/login2/login2'
  99. })
  100. }, 1500)
  101. } else {
  102. uni.navigateTo({
  103. url: '/pages/login2/login2'
  104. })
  105. }
  106. }
  107. </script>
  108. <style lang="scss" scoped>
  109. .container {
  110. display: flex;
  111. flex-direction: column;
  112. padding: 0 20rpx;
  113. min-height: 100vh;
  114. background-color: #f1f6fe;
  115. // 自定义导航栏区域样式
  116. .tab {
  117. position: relative;
  118. display: flex;
  119. justify-content: center;
  120. align-items: center;
  121. font-size: 34rpx;
  122. .tab_img {
  123. position: absolute;
  124. top: v-bind(statusBarH);
  125. left: 0;
  126. width: 62rpx;
  127. height: 62rpx;
  128. }
  129. }
  130. .tab2 {
  131. z-index: 999;
  132. position: fixed;
  133. top: 0;
  134. left: 0;
  135. right: 0;
  136. padding: 0 20rpx;
  137. font-size: 34rpx;
  138. text-align: center;
  139. background-color: #fff;
  140. }
  141. // 顶部图片区域样式
  142. .header {
  143. position: relative;
  144. margin-top: 35rpx;
  145. width: 710rpx;
  146. height: 369rpx;
  147. color: #fff;
  148. font-size: 36rpx;
  149. border-radius: 10rpx;
  150. .header_img {
  151. width: 100%;
  152. height: 100%;
  153. }
  154. .header_icon {
  155. position: absolute;
  156. top: 25rpx;
  157. left: 25rpx;
  158. width: 47rpx;
  159. height: 47rpx;
  160. border-radius: 50%;
  161. }
  162. .header_school {
  163. position: absolute;
  164. top: 18rpx;
  165. left: 81rpx;
  166. font-size: 40rpx;
  167. }
  168. }
  169. // 登录按钮区域样式
  170. .login {
  171. display: flex;
  172. justify-content: center;
  173. align-items: center;
  174. height: 180rpx;
  175. .login_btn {
  176. display: flex;
  177. justify-content: center;
  178. align-items: center;
  179. width: 380rpx;
  180. height: 80rpx;
  181. color: #7abfa4;
  182. border-radius: 50rpx;
  183. border: 1rpx solid #7abfa4;
  184. background-color: #fff;
  185. }
  186. }
  187. // 详细信息区域样式
  188. .body {
  189. .body_list {
  190. padding: 30rpx 30rpx;
  191. display: grid;
  192. grid-template-columns: repeat(3, 1fr);
  193. grid-auto-rows: 240rpx;
  194. background-color: #fff;
  195. gap: 20rpx 10rpx;
  196. border-radius: 20rpx;
  197. .list_box {
  198. display: flex;
  199. flex-direction: column;
  200. justify-content: space-evenly;
  201. align-items: center;
  202. font-size: 28rpx;
  203. overflow: hidden;
  204. .box_img {
  205. width: 120rpx;
  206. height: 120rpx;
  207. border-radius: 32rpx;
  208. }
  209. .box_text {
  210. width: 100%;
  211. text-align: center;
  212. overflow: hidden;
  213. text-overflow: ellipsis;
  214. white-space: nowrap;
  215. }
  216. }
  217. }
  218. }
  219. }
  220. </style>