index.tsx 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. import ColEmpty from '@/components/col-empty'
  2. import Pagination from '@/components/pagination'
  3. import request from '@/helpers/request'
  4. import { ElImage, ElSkeleton, ElSkeletonItem, ElTag } from 'element-plus'
  5. import { defineComponent } from 'vue'
  6. import iconVip from '../images/icon_vip.png'
  7. import iconSvip from '../images/icon_svip.png'
  8. import iconVipDefault from '../images/icon_vip_default.png'
  9. export default defineComponent({
  10. name: 'MyFans',
  11. data() {
  12. return {
  13. pageInfo: {
  14. // 分页规则
  15. limit: 12, // 限制显示条数
  16. page: 1, // 当前页
  17. total: 0, // 总条数
  18. page_size: [12, 24, 48, 60] // 选择限制显示条数
  19. },
  20. list: [] as any[],
  21. loading: false,
  22. dataShow: false // 是否有数据
  23. }
  24. },
  25. mounted() {
  26. this.getList()
  27. },
  28. methods: {
  29. async getList() {
  30. this.loading = true
  31. try {
  32. const { data } = await request.post(
  33. '/api-website/teacher/queryMyFans',
  34. {
  35. requestType: 'json',
  36. data: {
  37. page: this.pageInfo.page,
  38. rows: this.pageInfo.limit
  39. }
  40. }
  41. )
  42. this.list = data.rows || []
  43. this.pageInfo.total = data.total
  44. if (data.total <= 0) {
  45. this.dataShow = true
  46. }
  47. } catch {}
  48. if (this.dataShow) {
  49. this.loading = false
  50. } else {
  51. setTimeout(() => {
  52. this.loading = false
  53. }, 200)
  54. }
  55. }
  56. },
  57. render() {
  58. return (
  59. <div class="rounded-md overflow-hidden">
  60. <div class="text-2xl font-semibold text-black leading-none px-6 py-5 ">
  61. 我的粉丝
  62. </div>
  63. <div class={!this.dataShow && 'pt-4'}>
  64. <ElSkeleton
  65. loading={this.loading}
  66. animated
  67. class=" w-full m-auto px-[14px] flex"
  68. count={4}
  69. v-slots={{
  70. template: () => (
  71. <div class="w-[158px] rounded-[10px] pt-10 pb-7 mb-4 m-auto flex items-center justify-center flex-col user-shadow relative">
  72. <ElSkeletonItem
  73. variant="circle"
  74. style={{ width: '48px', height: '48px' }}
  75. ></ElSkeletonItem>
  76. <ElSkeletonItem
  77. variant="h3"
  78. style={{
  79. width: '50%',
  80. marginTop: '8px',
  81. marginBottom: '20px'
  82. }}
  83. ></ElSkeletonItem>
  84. <ElSkeletonItem
  85. variant="p"
  86. style={{ width: '60%', marginTop: '6px' }}
  87. ></ElSkeletonItem>
  88. </div>
  89. )
  90. }}
  91. >
  92. <div class="flex flex-wrap px-3">
  93. {this.list.map((item: any) => (
  94. <div class="basis-1/4 ">
  95. <div class="w-[158px] rounded-[10px] pt-10 pb-7 mb-4 m-auto flex items-center justify-center flex-col user-shadow relative">
  96. <div class="bg-[#FFE7CF] absolute left-2.5 top-2.5 text-[#AB5400] text-xs py-0.5 px-2 rounded-[10px]">
  97. 学生
  98. </div>
  99. <div class="flex flex-col items-center">
  100. <ElImage
  101. src={item.avatar}
  102. class="w-12 h-12 rounded-full border-2 border-[#2DC7AA]"
  103. />
  104. {item.vipType && item.vipType !== 'NORMAL' && (
  105. <ElImage
  106. src={item.vipType === 'VIP' ? iconVip : iconSvip}
  107. class="h-5 -mt-4"
  108. />
  109. )}
  110. </div>
  111. <p class="text-base text-[#333] font-semibold leading-tight pb-5 pt-2 text-center max-w-[120px] whitespace-nowrap overflow-hidden text-ellipsis">
  112. {item.userName}
  113. </p>
  114. <p class="h-6">
  115. {item.subjectName && (
  116. <ElTag
  117. effect="dark"
  118. // size="small"
  119. color="#E0FEF9"
  120. round
  121. style={{
  122. borderColor: '#E0FEF9',
  123. color: '#1B967E',
  124. margin: '0 4px'
  125. }}
  126. >
  127. {item.subjectName}
  128. </ElTag>
  129. )}
  130. </p>
  131. </div>
  132. </div>
  133. ))}
  134. </div>
  135. </ElSkeleton>
  136. </div>
  137. <Pagination
  138. total={this.pageInfo.total}
  139. v-model:page={this.pageInfo.page}
  140. v-model:limit={this.pageInfo.limit}
  141. pageSizes={this.pageInfo.page_size}
  142. pagination={this.getList}
  143. />
  144. {this.dataShow && <ColEmpty />}
  145. </div>
  146. )
  147. }
  148. })