volunteer-tier.vue 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <template>
  2. <view class="px-28 py-16">
  3. <view class="flex justify-between items-center">
  4. <view class="text-lg font-bold text-fore-title">院校梯队</view>
  5. <view class="text-sm text-fore-light flex items-center" @click="goCollegeList">
  6. <text>更多</text>
  7. <uv-icon name="arrow-right" color="info"/>
  8. </view>
  9. </view>
  10. <uv-scroll-list class="mt-28">
  11. <volunteer-tier-item v-for="(t,i) in list" :key="i" :data="t" :custom-class="{'ml-28':i>0}"
  12. @more="goCollegeListByTier(t)" @item-click="goCollegeDetail"/>
  13. </uv-scroll-list>
  14. </view>
  15. </template>
  16. <script setup lang="ts">
  17. import {University, UniversityTier} from "@/types/university";
  18. import VolunteerTierItem from "@/pagesMain/pages/volunteer/components/volunteer-tier-item.vue";
  19. import {universityListByTier} from "@/api/modules/university";
  20. import {useTransferPage} from "@/hooks/useTransferPage";
  21. import {routes} from "@/common/routes";
  22. const uiConfig = [{
  23. colorFrom: '#F6FCFF',
  24. colorTo: '#EBF9FF',
  25. colorText: '#19517F',
  26. icon: '/volunteer/index/tier_medal.png'
  27. }, {
  28. colorFrom: '#F4FFFC',
  29. colorTo: '#E6FFF8',
  30. colorText: '#0E4C3C',
  31. icon: '/volunteer/index/tier_medal_2.png'
  32. }]
  33. const list = ref<UniversityTier[]>([])
  34. const {transferTo} = useTransferPage()
  35. const goCollegeList = () => {
  36. transferTo(routes.universityIndex)
  37. }
  38. const goCollegeListByTier = (t: UniversityTier) => {
  39. transferTo(routes.universityIndex, {data: {tier: t.typeValue}})
  40. }
  41. const goCollegeDetail = (u: University) => {
  42. const {id, code} = u
  43. transferTo(routes.universityDetail, {data: {id, code}})
  44. }
  45. onMounted(async () => {
  46. const res = await universityListByTier()
  47. list.value = res.data.map((item, idx) => {
  48. const conf = uiConfig[idx % uiConfig.length]
  49. return {
  50. ...item,
  51. ...conf
  52. }
  53. })
  54. })
  55. </script>
  56. <style lang="scss" scoped>
  57. </style>