activity.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. <template>
  2. <view>
  3. <SearchBar
  4. v-model:query-type="queryType"
  5. v-model:search-input-value="searchInputValue"
  6. v-model:search-type="searchType"
  7. v-model:search-dropdown-value="searchDropdownValue"
  8. :query-type-data="queryTypeData"
  9. :search-dropdown-list="dropList"
  10. :search-placeholder="searchPlaceholder"
  11. :search-tab-list="searchTabList"
  12. :height="topHeight"
  13. @search="onSearch"
  14. ></SearchBar>
  15. <vb-list
  16. custom-class="mx-15 pt-15"
  17. :query-fun="apis.amActivity.statisticsApi.queryStatisticsSource"
  18. :query-params="queryParams"
  19. :height="listHeight"
  20. >
  21. <template #item="{ item }">
  22. <ListCard :item="item" type="activityDetail" :map="{ id: 'activityId', date: 'date' }"></ListCard>
  23. </template>
  24. </vb-list>
  25. </view>
  26. </template>
  27. <script lang="ts" setup>
  28. import dayjs from "dayjs"
  29. import "dayjs/locale/zh-cn" // 导入本地化语言
  30. import apis from "@/api"
  31. import route from "@/route"
  32. import appStore from "@/stores"
  33. import SearchBar from "@/components/searchBar.vue"
  34. import ListCard from "@/components/listCard.vue"
  35. dayjs.locale("zh-cn") // 使用本地化语言
  36. const wHeight = uni.getWindowInfo().windowHeight
  37. const topHeight = ref(130)
  38. const listHeight = computed(() => {
  39. return wHeight - topHeight.value - 15
  40. })
  41. const params = route.getRouteParams("favoriteActivity")
  42. const amId = computed(() => {
  43. if (params && params.amId) {
  44. return params.amId
  45. }
  46. return appStore.authStore.getUser().amId
  47. })
  48. const searchInputValue = ref("")
  49. const queryType = ref(0)
  50. const searchType = ref("")
  51. const searchDropdownValue = ref([])
  52. const searchPlaceholder = ref("搜索校友活动标题")
  53. const categoryColumns = ref<any>([])
  54. const queryTypeData = computed(() => {
  55. return [
  56. { value: 0, text: "我的收藏" },
  57. { value: 1, text: "我的点赞" },
  58. ]
  59. })
  60. const dropList = computed(() => {
  61. const arr = []
  62. arr.push({
  63. emptyTitle: "全部分类",
  64. data: categoryColumns.value,
  65. map: { text: "categoryName", value: "categoryId" },
  66. })
  67. return arr
  68. })
  69. const searchTabList = computed(() => {
  70. const arr = []
  71. arr.push({ text: "近一周", value: "week" })
  72. arr.push({ text: "近一月", value: "month" })
  73. arr.push({ text: "全部", value: "" })
  74. return arr
  75. })
  76. const queryParams = ref({
  77. amId: amId.value,
  78. title: "",
  79. favoriteStatus: "1",
  80. sourceType: "activity",
  81. })
  82. function onSearch() {
  83. const params: any = {
  84. amId: amId.value,
  85. title: searchInputValue.value || "",
  86. category: searchDropdownValue.value[0] || "",
  87. sourceType: "activity",
  88. }
  89. if (queryType.value == 0) {
  90. params.favoriteStatus = "1"
  91. } else if (queryType.value == 1) {
  92. params.starStatus = "1"
  93. }
  94. switch (searchType.value) {
  95. case "week":
  96. params.beginDate = dayjs().startOf("day").add(-7, "day").format("YYYY-MM-DD HH:mm:ss")
  97. params.endDate = dayjs().endOf("day").format("YYYY-MM-DD HH:mm:ss")
  98. break
  99. case "month":
  100. params.beginDate = dayjs().startOf("day").add(-30, "day").format("YYYY-MM-DD HH:mm:ss")
  101. params.endDate = dayjs().endOf("day").format("YYYY-MM-DD HH:mm:ss")
  102. break
  103. }
  104. queryParams.value = params
  105. }
  106. function loadData() {
  107. apis.system.categoryApi.getActivityCategory().then((res) => {
  108. categoryColumns.value = [{ categoryName: "全部分类", categoryId: "" }, ...res]
  109. })
  110. }
  111. function init() {
  112. loadData()
  113. }
  114. onLoad(init)
  115. </script>
  116. <style scoped></style>