grade.vue 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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 ? gradeName + '/' : '' }}{{ className ? className : '' }}</view>
  9. <!-- 学生列表区域 -->
  10. <listView :list="list" :appType="appType" />
  11. </view>
  12. </template>
  13. <script setup>
  14. import { ref, nextTick } 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. // console.log(value)
  33. // console.log(value.trim())
  34. if (value.trim()) {
  35. let temList = []
  36. list.value.forEach((ele) => {
  37. if (ele.name.indexOf(value.trim()) != -1) {
  38. temList.push(ele)
  39. }
  40. })
  41. list.value = temList
  42. } else {
  43. getData()
  44. }
  45. }
  46. const getData = async () => {
  47. const res = await myRequest({
  48. url: '/wanzai/api/wechat/queryPhoneBook',
  49. data: {
  50. id: uni.getStorageSync('userInfo').id
  51. }
  52. })
  53. // console.log(res)
  54. res.data.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. // console.log(list.vlaue)
  70. if (className.value) {
  71. uni.setNavigationBarTitle({
  72. title: gradeName.value + className.value
  73. })
  74. }
  75. }
  76. </script>
  77. <style lang="scss" scoped>
  78. .container {
  79. display: flex;
  80. flex-direction: column;
  81. padding: 0 20rpx;
  82. min-height: 100vh;
  83. background-color: #f1f6fe;
  84. // 背景图片区域样式
  85. .img_bg {
  86. position: absolute;
  87. top: -70rpx;
  88. right: 0;
  89. width: 589rpx;
  90. height: 320rpx;
  91. pointer-events: none;
  92. }
  93. // 学校名称区域样式
  94. .school {
  95. margin-top: 38rpx;
  96. color: #808080;
  97. font-size: 28rpx;
  98. }
  99. }
  100. </style>