grade.vue 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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 } 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. // console.log(result)
  55. result.forEach((ele) => {
  56. let temlist
  57. ele.classBookList.forEach((item, index, arr) => {
  58. if (item.bookUserList.length) {
  59. // 所在年级学生的数据
  60. list.value = item.bookUserList
  61. // 班级信息
  62. className.value = arr[index].className
  63. temlist = arr
  64. }
  65. })
  66. if (ele.classBookList == temlist) {
  67. gradeName.value = ele.gradeName
  68. }
  69. })
  70. uni.setNavigationBarTitle({
  71. title: gradeName.value + className.value
  72. })
  73. }
  74. </script>
  75. <style lang="scss" scoped>
  76. .container {
  77. display: flex;
  78. flex-direction: column;
  79. padding: 0 20rpx;
  80. min-height: 100vh;
  81. background-color: #f1f6fe;
  82. // 背景图片区域样式
  83. .img_bg {
  84. position: absolute;
  85. top: -70rpx;
  86. right: 0;
  87. width: 589rpx;
  88. height: 320rpx;
  89. pointer-events: none;
  90. }
  91. // 学校名称区域样式
  92. .school {
  93. margin-top: 38rpx;
  94. color: #808080;
  95. font-size: 28rpx;
  96. }
  97. }
  98. </style>