grade.vue 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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. // 学生列表数组
  20. const list = ref([])
  21. // 年级信息
  22. const gradeName = ref('')
  23. // 班级信息
  24. const className = ref('')
  25. const appType = ref('')
  26. onLoad((options) => {
  27. appType.value = options.type || ''
  28. getData()
  29. })
  30. // 输入框组件自定义事件
  31. const changeInputValue = (value) => {
  32. if (value.trim()) {
  33. let temList = []
  34. list.value.forEach((ele) => {
  35. if (ele.name.indexOf(value.trim()) != -1) {
  36. temList.push(ele)
  37. }
  38. })
  39. list.value = temList
  40. } else {
  41. getData()
  42. }
  43. }
  44. const getData = async () => {
  45. const res = await myRequest({
  46. url: '/wanzai/api/wechat/queryPhoneBook',
  47. data: {
  48. id: uni.getStorageSync('userInfo').id
  49. }
  50. })
  51. // console.log(res.data)
  52. res.data.forEach((ele) => {
  53. let temlist
  54. ele.classBookList.forEach((item, index, arr) => {
  55. if (item.bookUserList.length) {
  56. // 所在年级学生的数据
  57. list.value = item.bookUserList
  58. // 班级信息
  59. className.value = arr[index].className
  60. temlist = arr
  61. }
  62. })
  63. if (ele.classBookList == temlist) {
  64. gradeName.value = ele.gradeName
  65. }
  66. })
  67. uni.setNavigationBarTitle({
  68. title: gradeName.value + className.value
  69. })
  70. }
  71. </script>
  72. <style lang="scss" scoped>
  73. .container {
  74. display: flex;
  75. flex-direction: column;
  76. padding: 0 20rpx;
  77. min-height: 100vh;
  78. background-color: #f1f6fe;
  79. // 背景图片区域样式
  80. .img_bg {
  81. position: absolute;
  82. top: -70rpx;
  83. right: 0;
  84. width: 589rpx;
  85. height: 320rpx;
  86. pointer-events: none;
  87. }
  88. // 学校名称区域样式
  89. .school {
  90. margin-top: 38rpx;
  91. color: #808080;
  92. font-size: 28rpx;
  93. }
  94. }
  95. </style>