grade.vue 2.4 KB

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