home.vue 7.9 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 class="header_img" src="../../static/images/header.png" />
  13. <!-- 学校图标区域 -->
  14. <img class="header_icon" src="../../static/images/header-icon.png" />
  15. <!-- 学校名称区域 -->
  16. <view class="header_school">万载三中</view>
  17. <!-- 学生姓名区域 -->
  18. <view class="header_name">张三</view>
  19. <!-- 学生年级区域 -->
  20. <view class="header_grade">初二</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">
  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 list" :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. })
  67. onPullDownRefresh(() => {
  68. qrcodeRef.value.remake()
  69. setTimeout(() => {
  70. uni.stopPullDownRefresh()
  71. }, 1500)
  72. })
  73. onPageScroll((e) => {
  74. if (e.scrollTop > 70) {
  75. showHeader.value = true
  76. } else {
  77. showHeader.value = false
  78. }
  79. })
  80. // 顶部导航栏显示隐藏控制
  81. const showHeader = ref(false)
  82. // 状态栏高度
  83. const statusBarH = ref(0)
  84. // 胶囊按钮栏高度
  85. const customBarH = ref(0)
  86. // 二维码元素引用标记
  87. const qrcodeRef = ref(null)
  88. // 应用列表数据
  89. const list = ref([
  90. // {
  91. // id: 1,
  92. // title: '考勤管理',
  93. // url: '../../static/images/icon.png'
  94. // },
  95. // {
  96. // id: 2,
  97. // title: '课表查询',
  98. // url: '../../static/images/icon.png',
  99. // path: ''
  100. // },
  101. {
  102. id: 3,
  103. title: '学生轨迹',
  104. url: '../../static/images/icon.png',
  105. path: '/pages/track/track'
  106. },
  107. // {
  108. // id: 4,
  109. // title: '打卡接龙',
  110. // url: '../../static/images/icon.png'
  111. // },
  112. // {
  113. // id: 5,
  114. // title: '人脸采集',
  115. // url: '../../static/images/icon.png'
  116. // },
  117. // {
  118. // id: 6,
  119. // title: '智慧教学',
  120. // url: '../../static/images/icon.png'
  121. // },
  122. {
  123. id: 7,
  124. title: '消息通知',
  125. url: '../../static/images/icon.png',
  126. path: '/pages/msgWarn/msgWarn'
  127. },
  128. {
  129. id: 8,
  130. title: '访客预约',
  131. url: '../../static/images/icon.png',
  132. path: '/pagesReservation/reservation/reservation'
  133. },
  134. // {
  135. // id: 9,
  136. // title: '课后作业',
  137. // url: '../../static/images/icon.png'
  138. // },
  139. // {
  140. // id: 10,
  141. // title: '留言',
  142. // url: '../../static/images/icon.png'
  143. // },
  144. {
  145. id: 11,
  146. title: '通讯录',
  147. url: '../../static/images/icon.png',
  148. path: '/pages/addressBook/addressBook'
  149. }
  150. ])
  151. // 二维码信息
  152. const QRCodeUrl = ref('123')
  153. // 二维码自定义样式
  154. const options = {
  155. typeNumber: 4,
  156. foregroundImageBorderRadius: 5,
  157. foregroundImageSrc: '/static/images/school-logo.png'
  158. }
  159. // 跳转页面函数
  160. const goPage = (url) => {
  161. if (url === '/pagesReservation/reservation/reservation') {
  162. uni.setStorageSync('Tab-activeIndex', 0)
  163. }
  164. uni.navigateTo({
  165. url
  166. })
  167. }
  168. // 点击二维码时的回调
  169. const handleClickCode = () => {
  170. uni.navigateTo({
  171. url: `/pages/quickMark/quickMark?value=${QRCodeUrl.value}`
  172. })
  173. }
  174. </script>
  175. <style lang="scss" scoped>
  176. .container {
  177. display: flex;
  178. flex-direction: column;
  179. padding: 0 20rpx;
  180. min-height: 100vh;
  181. background-color: #f1f6fe;
  182. // 自定义导航栏区域样式
  183. .tab {
  184. position: relative;
  185. display: flex;
  186. justify-content: center;
  187. align-items: center;
  188. font-size: 34rpx;
  189. .tab_img {
  190. position: absolute;
  191. top: v-bind(statusBarH);
  192. left: 0;
  193. width: 62rpx;
  194. height: 62rpx;
  195. }
  196. }
  197. .tab2 {
  198. z-index: 999;
  199. position: fixed;
  200. top: 0;
  201. left: 0;
  202. right: 0;
  203. padding: 0 20rpx;
  204. font-size: 34rpx;
  205. text-align: center;
  206. background-color: #fff;
  207. }
  208. // 顶部图片区域样式
  209. .header {
  210. position: relative;
  211. margin-top: 35rpx;
  212. width: 710rpx;
  213. height: 369rpx;
  214. color: #fff;
  215. font-size: 36rpx;
  216. border-radius: 10rpx;
  217. background-color: deepskyblue;
  218. .header_img {
  219. width: 100%;
  220. height: 100%;
  221. }
  222. .header_icon {
  223. position: absolute;
  224. top: 25rpx;
  225. left: 25rpx;
  226. width: 47rpx;
  227. height: 47rpx;
  228. border-radius: 50%;
  229. }
  230. .header_school {
  231. position: absolute;
  232. top: 18rpx;
  233. left: 81rpx;
  234. font-size: 40rpx;
  235. }
  236. .header_name {
  237. position: absolute;
  238. top: 243rpx;
  239. right: 145rpx;
  240. }
  241. .header_grade {
  242. position: absolute;
  243. top: 292rpx;
  244. right: 145rpx;
  245. }
  246. .header_code {
  247. position: absolute;
  248. top: 245rpx;
  249. right: 28rpx;
  250. display: flex;
  251. justify-content: center;
  252. align-items: center;
  253. width: 98rpx;
  254. height: 98rpx;
  255. border-radius: 10rpx;
  256. background-color: #fff;
  257. }
  258. }
  259. // 详细信息区域样式
  260. .body {
  261. margin-top: 20rpx;
  262. .body_header {
  263. position: relative;
  264. width: 710rpx;
  265. height: 128rpx;
  266. .info_bg {
  267. position: absolute;
  268. z-index: 1;
  269. width: 100%;
  270. height: 100%;
  271. pointer-events: none;
  272. }
  273. .info_img {
  274. position: absolute;
  275. top: 20rpx;
  276. left: 20rpx;
  277. z-index: 1;
  278. width: 90rpx;
  279. height: 90rpx;
  280. border-radius: 50%;
  281. }
  282. .info_name {
  283. position: absolute;
  284. top: 15rpx;
  285. left: 132rpx;
  286. z-index: 1;
  287. font-size: 32rpx;
  288. font-weight: bold;
  289. }
  290. .info_detail {
  291. position: absolute;
  292. top: 64rpx;
  293. left: 132rpx;
  294. z-index: 1;
  295. width: 136rpx;
  296. height: 46rpx;
  297. line-height: 46rpx;
  298. text-align: center;
  299. font-size: 24rpx;
  300. color: #0061ff;
  301. border-radius: 5rpx;
  302. background-color: #ebf2ff;
  303. }
  304. .info_change {
  305. position: absolute;
  306. top: 48rpx;
  307. left: 393rpx;
  308. z-index: 1;
  309. font-size: 24rpx;
  310. color: #a6a6a6;
  311. }
  312. .info_bind {
  313. position: absolute;
  314. top: 20rpx;
  315. right: 0;
  316. display: flex;
  317. justify-content: flex-end;
  318. align-items: center;
  319. padding-right: 25rpx;
  320. width: 300rpx;
  321. height: 102rpx;
  322. font-size: 28rpx;
  323. color: #0061ff;
  324. background-color: #e8f1ff;
  325. .bind_img {
  326. margin-right: 5rpx;
  327. width: 42rpx;
  328. height: 42rpx;
  329. }
  330. }
  331. }
  332. .body_list {
  333. padding: 30rpx 30rpx;
  334. display: grid;
  335. grid-template-columns: repeat(3, 1fr);
  336. grid-auto-rows: 240rpx;
  337. background-color: #fff;
  338. gap: 20rpx 10rpx;
  339. .list_box {
  340. display: flex;
  341. flex-direction: column;
  342. justify-content: space-evenly;
  343. align-items: center;
  344. font-size: 28rpx;
  345. .box_img {
  346. width: 120rpx;
  347. height: 120rpx;
  348. border-radius: 32rpx;
  349. }
  350. }
  351. }
  352. }
  353. }
  354. </style>