follow.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. <template>
  2. <view v-if="appStore.amProfileStore.notDemo()" class="">
  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. :search-dropdown-list="dropList"
  9. :search-placeholder="searchPlaceholder"
  10. :search-tab-list="searchTabList"
  11. :query-type-data="queryTypeData"
  12. :height="topHeight"
  13. @search="onSearch"
  14. ></SearchBar>
  15. <vb-list
  16. :query-fun="queryType == 0 ? apis.amActivity.friendApi.listFollowMe : apis.amActivity.friendApi.listFollow"
  17. :query-params="queryParams"
  18. :height="listHeight"
  19. :data-length="10"
  20. custom-class=" pt-10"
  21. >
  22. <template #item="{ item }">
  23. <vb-cell-group outset inset custom-class="">
  24. <view class="d-flex">
  25. <view class="d-fcv me-5" @click="onClick(item)">
  26. <view class="w-60px h-60px br-round bg-gray-3 pos-r">
  27. <view
  28. class="w-20px h-20px m-auto br-round d-flex flex-center pos-a"
  29. :class="{ 'bg-blue': item.friendGender == '0', 'bg-pink': item.friendGender == '1' }"
  30. style="top: 0px; right: 0px"
  31. >
  32. <i
  33. class="iconfont fs-13 text-white"
  34. :class="{
  35. 'icon-gender-male': item.friendGender == '0',
  36. 'icon-gender-female': item.friendGender == '1',
  37. }"
  38. ></i>
  39. </view>
  40. <image class="w-100 h-100 br-round" :src="getAvatar(item)"></image>
  41. </view>
  42. </view>
  43. <view class="w-100 px-10 flex-column justify-around" style="">
  44. <view class="d-flex align-center pb-3">
  45. <view class="text-black fs-20 font-bold">
  46. {{ item.friendName }}
  47. </view>
  48. <!-- <view
  49. class="px-8 py-3 fs-10 br-10 text-white ms-10"
  50. :class="getStatusClass(item)"
  51. >
  52. {{ getStatus(item) }}
  53. </view> -->
  54. </view>
  55. <view class="d-fcv fs-16">
  56. <text class="text-vb">{{ item.graduateYear }}届-{{ item.friendClass }}</text>
  57. <view class="text-gray-5 mx-8">|</view>
  58. <view class="text-vb">{{ item.friendCity }}</view>
  59. </view>
  60. <view class="d-fcv pt-5">
  61. <view class="text-gray-5 fs-14" v-if="item.friendLastLoginDate">{{ getLastLoginTime(item) }} 活跃</view>
  62. </view>
  63. </view>
  64. <view v-if="queryType == 0" class="flex-column d-fcv">
  65. <!-- <view class="bg-danger text-white text-center fs-14 py-3 w-50px br-5 mt-10" @click="onRemove(item)">
  66. 删除
  67. </view> -->
  68. <!-- <view class="bg-gray-3 border border-1 text-center border-danger text-danger fs-14 py-3 w-50px br-5">
  69. 拉黑
  70. </view> -->
  71. </view>
  72. </view>
  73. </vb-cell-group>
  74. </template>
  75. </vb-list>
  76. </view>
  77. </template>
  78. <script lang="ts" setup>
  79. import apis from "@/api"
  80. import route from "@/route"
  81. import configs from "@/core/config"
  82. import dayjs from "dayjs"
  83. import relativeTime from "dayjs/plugin/relativeTime" // 导入插件
  84. import "dayjs/locale/zh-cn" // 导入本地化语言
  85. import appStore from "@/stores"
  86. import SearchBar from "@/components/searchBar.vue"
  87. dayjs.extend(relativeTime) // 使用插件
  88. dayjs.locale("zh-cn") // 使用本地化语言
  89. const props = withDefaults(
  90. defineProps<{
  91. type: number
  92. showRadiuChange?: boolean
  93. amId?: string | number
  94. }>(),
  95. {
  96. showRadiuChange: false,
  97. }
  98. )
  99. const wHeight = uni.getWindowInfo().windowHeight
  100. const topHeight = ref(props.showRadiuChange ? 130 : 95)
  101. const listHeight = computed(() => {
  102. return wHeight - topHeight.value - 15
  103. })
  104. const amId = computed(() => {
  105. return props.amId || appStore.amProfileStore.getProfileInfo()?.amId || ""
  106. })
  107. const queryType = ref(props.type)
  108. const searchType = ref()
  109. const searchInputValue = ref("")
  110. const searchDropdownValue = ref([])
  111. const queryParams = ref(
  112. queryType.value == 0
  113. ? {
  114. amId: amId.value,
  115. }
  116. : queryType.value == 1
  117. ? {
  118. followId: amId.value,
  119. }
  120. : {}
  121. )
  122. const searchPlaceholder = ref("搜索校友姓名")
  123. const queryTypeData = computed(() => {
  124. return props.showRadiuChange
  125. ? [
  126. { value: 0, text: "好友申请" },
  127. { value: 1, text: "我的申请" },
  128. ]
  129. : []
  130. })
  131. const yearColumns = computed(() => {
  132. const cols = []
  133. cols.push({ text: "全部年级", value: "" })
  134. for (let i = new Date().getFullYear(); i >= 1930; i--) {
  135. cols.push({ text: i + "年", value: i })
  136. }
  137. return cols
  138. })
  139. const dropList = computed(() => {
  140. const arr = []
  141. arr.push({
  142. emptyTitle: "毕业年份",
  143. data: yearColumns.value,
  144. })
  145. return arr
  146. })
  147. const searchTabList = computed(() => {
  148. const arr = []
  149. if (!props.amId) {
  150. arr.push({ text: "同届", value: "year" })
  151. arr.push({ text: "同城", value: "city" })
  152. arr.push({ text: "同行", value: "industry" })
  153. }
  154. //arr.push({ text: "全部", value: "" })
  155. return arr
  156. })
  157. function getAvatar(item: any) {
  158. return item.friendAvatar ? configs.baseUrl + item.friendAvatar : `/static/images/avatars/empty.png`
  159. }
  160. function getLastLoginTime(item: any) {
  161. return dayjs(item.friendLastLoginDate).fromNow()
  162. }
  163. function onClick(item: any) {
  164. route.navigate("alumnusDetail", {
  165. from: "followMe",
  166. id: queryType.value == 0 ? item.followId : item.amId,
  167. userId: item.userId,
  168. })
  169. }
  170. function onSearch() {
  171. search()
  172. }
  173. function search() {
  174. const params: any = {
  175. friendName: searchInputValue.value || "",
  176. graduateYear: searchDropdownValue.value[0] || "",
  177. }
  178. if (searchType.value) {
  179. switch (searchType.value) {
  180. case "year":
  181. params.graduateYear = appStore.amProfileStore.getProfileInfo()?.graduateYear || ""
  182. break
  183. case "city":
  184. params.friendCity = appStore.amProfileStore.getProfileInfo()?.city || ""
  185. break
  186. case "industry":
  187. params.friendIndustry = appStore.amProfileStore.getProfileInfo()?.industry || ""
  188. break
  189. }
  190. }
  191. if (queryType.value == 0) {
  192. params.amId = amId.value
  193. } else if (queryType.value == 1) {
  194. params.friendId = amId.value
  195. }
  196. queryParams.value = params
  197. }
  198. </script>
  199. <style scoped></style>