main.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  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. const result = JSON.parse(decryptDes(res.data))
  84. useAppList.value = result
  85. }
  86. // 跳转登录页
  87. const goLogin = (type) => {
  88. if (type === 1) {
  89. uni.showToast({
  90. title: '请您先登录',
  91. icon: 'none',
  92. mask: true
  93. })
  94. setTimeout(() => {
  95. uni.navigateTo({
  96. url: '/pages/login/login'
  97. })
  98. }, 1500)
  99. } else {
  100. uni.navigateTo({
  101. url: '/pages/login/login'
  102. })
  103. }
  104. }
  105. </script>
  106. <style lang="scss" scoped>
  107. .container {
  108. display: flex;
  109. flex-direction: column;
  110. padding: 0 20rpx;
  111. min-height: 100vh;
  112. background-color: #f1f6fe;
  113. // 自定义导航栏区域样式
  114. .tab {
  115. position: relative;
  116. display: flex;
  117. justify-content: center;
  118. align-items: center;
  119. font-size: 34rpx;
  120. .tab_img {
  121. position: absolute;
  122. top: v-bind(statusBarH);
  123. left: 0;
  124. width: 62rpx;
  125. height: 62rpx;
  126. }
  127. }
  128. .tab2 {
  129. z-index: 999;
  130. position: fixed;
  131. top: 0;
  132. left: 0;
  133. right: 0;
  134. padding: 0 20rpx;
  135. font-size: 34rpx;
  136. text-align: center;
  137. background-color: #fff;
  138. }
  139. // 顶部图片区域样式
  140. .header {
  141. position: relative;
  142. margin-top: 35rpx;
  143. width: 710rpx;
  144. height: 369rpx;
  145. color: #fff;
  146. font-size: 36rpx;
  147. border-radius: 10rpx;
  148. .header_img {
  149. width: 100%;
  150. height: 100%;
  151. }
  152. .header_icon {
  153. position: absolute;
  154. top: 25rpx;
  155. left: 25rpx;
  156. width: 47rpx;
  157. height: 47rpx;
  158. border-radius: 50%;
  159. }
  160. .header_school {
  161. position: absolute;
  162. top: 18rpx;
  163. left: 81rpx;
  164. font-size: 40rpx;
  165. }
  166. }
  167. // 登录按钮区域样式
  168. .login {
  169. display: flex;
  170. justify-content: center;
  171. align-items: center;
  172. height: 180rpx;
  173. .login_btn {
  174. display: flex;
  175. justify-content: center;
  176. align-items: center;
  177. width: 380rpx;
  178. height: 80rpx;
  179. color: #7abfa4;
  180. border-radius: 50rpx;
  181. border: 1rpx solid #7abfa4;
  182. background-color: #fff;
  183. }
  184. }
  185. // 详细信息区域样式
  186. .body {
  187. .body_list {
  188. padding: 30rpx 30rpx;
  189. display: grid;
  190. grid-template-columns: repeat(3, 1fr);
  191. grid-auto-rows: 240rpx;
  192. background-color: #fff;
  193. gap: 20rpx 10rpx;
  194. border-radius: 20rpx;
  195. .list_box {
  196. display: flex;
  197. flex-direction: column;
  198. justify-content: space-evenly;
  199. align-items: center;
  200. font-size: 28rpx;
  201. overflow: hidden;
  202. .box_img {
  203. width: 120rpx;
  204. height: 120rpx;
  205. border-radius: 32rpx;
  206. }
  207. .box_text {
  208. width: 100%;
  209. text-align: center;
  210. overflow: hidden;
  211. text-overflow: ellipsis;
  212. white-space: nowrap;
  213. }
  214. }
  215. }
  216. }
  217. }
  218. </style>