home.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397
  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="goPage('/pages/myCenter/myCenter')" />
  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. <!-- 学生姓名区域 -->
  18. <view class="header_name">张三</view>
  19. <!-- 学生年级区域 -->
  20. <view class="header_grade">{{ userType === 0 ? '家长' : '教师' }}</view>
  21. <!-- 二维码区域 -->
  22. <view class="header_code">
  23. <uv-qrcode ref="qrcodeRef" size="82rpx" :value="QRCodeUrl" :options="options" @click="handleClickCode"></uv-qrcode>
  24. </view>
  25. </view>
  26. <!-- 详细信息区域 -->
  27. <view class="body">
  28. <!-- 个人信息区域 -->
  29. <view class="body_header" v-if="userType == 0">
  30. <img class="info_bg" src="../../static/images/info-bg.png" />
  31. <img class="info_img" src="../../static/images/user-photo.png" />
  32. <view class="info_name">王佳明</view>
  33. <view class="info_detail" @click="goPage('/pages/myMsg/myMsg')">个人信息></view>
  34. <view class="info_change" @click="goPage('/pages/change/change')">切换 ></view>
  35. <!-- 关联区域 -->
  36. <view class="info_bind">
  37. <img @click="goPage('/pages/bind/bind')" class="bind_img" src="../../static/images/bind.png" />
  38. <text @click="goPage('/pages/bind/bind')">关联小孩</text>
  39. </view>
  40. </view>
  41. <!-- 应用列表区域 -->
  42. <view class="body_list">
  43. <!-- 每一个应用区域 -->
  44. <view class="list_box" v-for="item in useAppList" :key="item.id" @click="goPage(item.path)">
  45. <img class="box_img" :src="item.url" />
  46. {{ item.title }}
  47. </view>
  48. </view>
  49. </view>
  50. </view>
  51. </template>
  52. <script setup>
  53. import { ref } from 'vue'
  54. import { onLoad, onPageScroll, onPullDownRefresh } from '@dcloudio/uni-app'
  55. onLoad(() => {
  56. // 获取系统信息
  57. uni.getSystemInfo({
  58. success: (e) => {
  59. // 获取状态栏高度
  60. statusBarH.value = e.statusBarHeight
  61. // // 获取菜单按钮栏高度
  62. let custom = uni.getMenuButtonBoundingClientRect()
  63. customBarH.value = custom.height
  64. }
  65. })
  66. userType.value = uni.getStorageSync('userType')
  67. console.log('身份类型', userType.value)
  68. // 获取权限app
  69. const appList = uni.getStorageSync('appList')
  70. if (appList) {
  71. useAppList.value = filterApp(list.value, appList)
  72. }
  73. })
  74. // 页面下拉刷新回调
  75. onPullDownRefresh(() => {
  76. qrcodeRef.value.remake()
  77. setTimeout(() => {
  78. uni.stopPullDownRefresh()
  79. }, 1500)
  80. })
  81. onPageScroll((e) => {
  82. if (e.scrollTop > 70) {
  83. showHeader.value = true
  84. } else {
  85. showHeader.value = false
  86. }
  87. })
  88. const userType = ref()
  89. // 顶部导航栏显示隐藏控制
  90. const showHeader = ref(false)
  91. // 状态栏高度
  92. const statusBarH = ref(0)
  93. // 胶囊按钮栏高度
  94. const customBarH = ref(0)
  95. // 二维码元素引用标记
  96. const qrcodeRef = ref(null)
  97. // 全部应用列表数据
  98. const list = ref([
  99. {
  100. id: 3,
  101. title: '学生轨迹',
  102. url: '../../static/images/icon.png',
  103. path: '/pages/track/track'
  104. },
  105. {
  106. id: 7,
  107. title: '消息通知',
  108. url: '../../static/images/icon.png',
  109. path: '/pages/msgWarn/msgWarn'
  110. },
  111. {
  112. id: 8,
  113. title: '访客预约',
  114. url: '../../static/images/icon.png',
  115. path: '/pagesReservation/reservation/reservation'
  116. },
  117. {
  118. id: 10,
  119. title: '校园预警',
  120. url: '../../static/images/icon.png',
  121. path: '/pagesWarning/home/home'
  122. },
  123. {
  124. id: 11,
  125. title: '通讯录',
  126. url: '../../static/images/icon.png',
  127. path: '/pages/grade/grade?type=通讯录'
  128. }
  129. ])
  130. // 展示的app列表
  131. const useAppList = ref([])
  132. // 二维码信息
  133. const QRCodeUrl = ref('123')
  134. // 二维码自定义样式
  135. const options = {
  136. typeNumber: 4,
  137. foregroundImageBorderRadius: 5,
  138. foregroundImageSrc: '/static/images/school-logo.jpg'
  139. }
  140. // 跳转页面函数
  141. const goPage = (url) => {
  142. if (url === '/pages/track/track') {
  143. if (userType.value == 1) {
  144. uni.navigateTo({
  145. url: '/pages/grade/grade?type=学生轨迹'
  146. })
  147. return
  148. }
  149. }
  150. if (url === '/pagesReservation/reservation/reservation') {
  151. uni.setStorageSync('Tab-activeIndex', 0)
  152. }
  153. uni.navigateTo({
  154. url
  155. })
  156. }
  157. // 点击二维码时的回调
  158. const handleClickCode = () => {
  159. uni.navigateTo({
  160. url: `/pages/quickMark/quickMark?value=${QRCodeUrl.value}`
  161. })
  162. }
  163. // 过滤方法
  164. const filterApp = (arr1, arr2) => {
  165. return arr1.filter((item) => {
  166. return arr2.includes(item.title)
  167. })
  168. }
  169. </script>
  170. <style lang="scss" scoped>
  171. .container {
  172. display: flex;
  173. flex-direction: column;
  174. padding: 0 20rpx;
  175. min-height: 100vh;
  176. background-color: #f1f6fe;
  177. // 自定义导航栏区域样式
  178. .tab {
  179. position: relative;
  180. display: flex;
  181. justify-content: center;
  182. align-items: center;
  183. font-size: 34rpx;
  184. .tab_img {
  185. position: absolute;
  186. top: v-bind(statusBarH);
  187. left: 0;
  188. width: 62rpx;
  189. height: 62rpx;
  190. }
  191. }
  192. .tab2 {
  193. z-index: 999;
  194. position: fixed;
  195. top: 0;
  196. left: 0;
  197. right: 0;
  198. padding: 0 20rpx;
  199. font-size: 34rpx;
  200. text-align: center;
  201. background-color: #fff;
  202. }
  203. // 顶部图片区域样式
  204. .header {
  205. position: relative;
  206. margin-top: 35rpx;
  207. width: 710rpx;
  208. height: 369rpx;
  209. color: #fff;
  210. font-size: 36rpx;
  211. border-radius: 10rpx;
  212. .header_img {
  213. width: 100%;
  214. height: 100%;
  215. }
  216. .header_icon {
  217. position: absolute;
  218. top: 25rpx;
  219. left: 25rpx;
  220. width: 47rpx;
  221. height: 47rpx;
  222. border-radius: 50%;
  223. }
  224. .header_school {
  225. position: absolute;
  226. top: 18rpx;
  227. left: 81rpx;
  228. font-size: 40rpx;
  229. }
  230. .header_name {
  231. position: absolute;
  232. top: 243rpx;
  233. right: 145rpx;
  234. }
  235. .header_grade {
  236. position: absolute;
  237. top: 292rpx;
  238. right: 145rpx;
  239. }
  240. .header_code {
  241. position: absolute;
  242. top: 245rpx;
  243. right: 28rpx;
  244. display: flex;
  245. justify-content: center;
  246. align-items: center;
  247. width: 98rpx;
  248. height: 98rpx;
  249. border-radius: 10rpx;
  250. background-color: #fff;
  251. }
  252. }
  253. // 详细信息区域样式
  254. .body {
  255. margin-top: 20rpx;
  256. .body_header {
  257. position: relative;
  258. width: 710rpx;
  259. height: 128rpx;
  260. .info_bg {
  261. position: absolute;
  262. z-index: 1;
  263. width: 100%;
  264. height: 100%;
  265. pointer-events: none;
  266. }
  267. .info_img {
  268. position: absolute;
  269. top: 20rpx;
  270. left: 20rpx;
  271. z-index: 1;
  272. width: 90rpx;
  273. height: 90rpx;
  274. border-radius: 50%;
  275. }
  276. .info_name {
  277. position: absolute;
  278. top: 15rpx;
  279. left: 132rpx;
  280. z-index: 1;
  281. font-size: 32rpx;
  282. font-weight: bold;
  283. }
  284. .info_detail {
  285. position: absolute;
  286. top: 64rpx;
  287. left: 132rpx;
  288. z-index: 1;
  289. width: 136rpx;
  290. height: 46rpx;
  291. line-height: 46rpx;
  292. text-align: center;
  293. font-size: 24rpx;
  294. color: #0061ff;
  295. border-radius: 5rpx;
  296. background-color: #ebf2ff;
  297. }
  298. .info_change {
  299. position: absolute;
  300. top: 48rpx;
  301. left: 393rpx;
  302. z-index: 1;
  303. font-size: 24rpx;
  304. color: #a6a6a6;
  305. }
  306. .info_bind {
  307. position: absolute;
  308. top: 20rpx;
  309. right: 0;
  310. display: flex;
  311. justify-content: flex-end;
  312. align-items: center;
  313. padding-right: 25rpx;
  314. width: 300rpx;
  315. height: 102rpx;
  316. font-size: 28rpx;
  317. color: #0061ff;
  318. background-color: #e8f1ff;
  319. .bind_img {
  320. margin-right: 5rpx;
  321. width: 42rpx;
  322. height: 42rpx;
  323. }
  324. }
  325. }
  326. .body_list {
  327. padding: 30rpx 30rpx;
  328. display: grid;
  329. grid-template-columns: repeat(3, 1fr);
  330. grid-auto-rows: 240rpx;
  331. background-color: #fff;
  332. gap: 20rpx 10rpx;
  333. .list_box {
  334. display: flex;
  335. flex-direction: column;
  336. justify-content: space-evenly;
  337. align-items: center;
  338. font-size: 28rpx;
  339. .box_img {
  340. width: 120rpx;
  341. height: 120rpx;
  342. border-radius: 32rpx;
  343. }
  344. }
  345. }
  346. }
  347. }
  348. </style>