grade.vue 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <template>
  2. <view class="container">
  3. <!-- 背景图片区域 -->
  4. <img class="img_bg" src="../../static/images/center-bg.png" />
  5. <!-- input组件区域 -->
  6. <headerInput @changeInputValue="changeInputValue" />
  7. <!-- 学校年级班级区域 -->
  8. <view class="school">万载三中/{{ gradeName }}/{{ className }}</view>
  9. <!-- 学生列表区域 -->
  10. <listView :list="list" :appType="appType" />
  11. </view>
  12. </template>
  13. <script setup>
  14. import { ref } from 'vue'
  15. import { onLoad } from '@dcloudio/uni-app'
  16. import headerInput from '@/components/headerInput.vue'
  17. import listView from '@/components/listView.vue'
  18. import { myRequest } from '@/utils/api.js'
  19. import { decryptDes } from '@/utils/des.js'
  20. // 学生列表数组
  21. const list = ref([])
  22. // 年级信息
  23. const gradeName = ref('')
  24. // 班级信息
  25. const className = ref('')
  26. const appType = ref('')
  27. onLoad((options) => {
  28. appType.value = options.type || ''
  29. getData()
  30. })
  31. // 输入框组件自定义事件
  32. const changeInputValue = (value) => {
  33. if (value.trim()) {
  34. let temList = []
  35. list.value.forEach((ele) => {
  36. if (ele.name.indexOf(value.trim()) != -1) {
  37. temList.push(ele)
  38. }
  39. })
  40. list.value = temList
  41. } else {
  42. getData()
  43. }
  44. }
  45. const getData = async () => {
  46. const res = await myRequest({
  47. url: '/wanzai/api/wechat/queryPhoneBook',
  48. data: {
  49. id: uni.getStorageSync('userInfo').id
  50. }
  51. })
  52. // console.log(res)
  53. const result = JSON.parse(decryptDes(res.data))
  54. result.forEach((ele) => {
  55. let temlist
  56. ele.classBookList.forEach((item, index, arr) => {
  57. if (item.bookUserList.length) {
  58. // 所在年级学生的数据
  59. list.value = item.bookUserList
  60. // 班级信息
  61. className.value = arr[index].className
  62. temlist = arr
  63. }
  64. })
  65. if (ele.classBookList == temlist) {
  66. gradeName.value = ele.gradeName
  67. }
  68. })
  69. uni.setNavigationBarTitle({
  70. title: gradeName.value + className.value
  71. })
  72. }
  73. </script>
  74. <style lang="scss" scoped>
  75. .container {
  76. display: flex;
  77. flex-direction: column;
  78. padding: 0 20rpx;
  79. min-height: 100vh;
  80. background-color: #f1f6fe;
  81. // 背景图片区域样式
  82. .img_bg {
  83. position: absolute;
  84. top: -70rpx;
  85. right: 0;
  86. width: 589rpx;
  87. height: 320rpx;
  88. pointer-events: none;
  89. }
  90. // 学校名称区域样式
  91. .school {
  92. margin-top: 38rpx;
  93. color: #808080;
  94. font-size: 28rpx;
  95. }
  96. }
  97. </style>