list.tsx 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. import ColEmpty from '@/components/col-empty'
  2. import Pagination from '@/components/pagination'
  3. import request from '@/helpers/request'
  4. import styles from './index.module.less'
  5. import { ElSkeleton, ElSkeletonItem } from 'element-plus'
  6. import { defineComponent } from 'vue'
  7. import MusicItem from '../../user-info/music-class/item'
  8. export default defineComponent({
  9. name: 'list',
  10. props: {
  11. auditStatus: {
  12. type: String,
  13. default: ''
  14. },
  15. onNumber: {
  16. type: Function,
  17. default: (data: any) => {}
  18. }
  19. },
  20. data() {
  21. return {
  22. pageInfo: {
  23. // 分页规则
  24. limit: 10, // 限制显示条数
  25. page: 1, // 当前页
  26. total: 0, // 总条数
  27. page_size: [10, 20, 40, 50] // 选择限制显示条数
  28. },
  29. list: [] as any[],
  30. loading: false,
  31. dataShow: false // 是否有数据
  32. }
  33. },
  34. mounted() {
  35. this.getList()
  36. },
  37. methods: {
  38. async getList() {
  39. this.loading = true
  40. try {
  41. const url =
  42. this.auditStatus === 'MYSCORE'
  43. ? '/api-website/music/sheet/my'
  44. : '/api-website/music/sheet/favorite'
  45. const { data } = await request.get(url, {
  46. params: {
  47. page: this.pageInfo.page,
  48. rows: this.pageInfo.limit
  49. }
  50. })
  51. this.list = data.rows || []
  52. this.pageInfo.total = data.total
  53. if (data.total <= 0) {
  54. this.dataShow = true
  55. }
  56. } catch {}
  57. if (this.dataShow) {
  58. this.loading = false
  59. } else {
  60. setTimeout(() => {
  61. this.loading = false
  62. }, 200)
  63. }
  64. }
  65. },
  66. render() {
  67. return (
  68. <>
  69. <div class="mt-5">
  70. <ElSkeleton
  71. loading={this.loading}
  72. animated
  73. class=" w-full m-auto px-[14px] flex items-center flex-col"
  74. count={3}
  75. v-slots={{
  76. template: () => (
  77. <div class="h-[94px] flex items-center justify-between w-full mb-2">
  78. <div class="w-2/3 flex items-center">
  79. <ElSkeletonItem
  80. variant="circle"
  81. style={{ width: '88px', height: '88px' }}
  82. ></ElSkeletonItem>
  83. <div class="w-1/2 pl-2">
  84. <ElSkeletonItem variant="h3"></ElSkeletonItem>
  85. <ElSkeletonItem
  86. variant="p"
  87. style={{ width: '50%' }}
  88. ></ElSkeletonItem>
  89. </div>
  90. </div>
  91. <ElSkeletonItem
  92. variant="p"
  93. style={{ width: '20%' }}
  94. ></ElSkeletonItem>
  95. </div>
  96. )
  97. }}
  98. >
  99. {this.list.map((item: any) => (
  100. <MusicItem
  101. onClick={(item: any) => {
  102. if (this.auditStatus === 'UNPASS') {
  103. console.log(item)
  104. this.$router.push({
  105. path: '/userInfo/musicOperation',
  106. query: {
  107. type: 'update',
  108. id: item.id
  109. }
  110. })
  111. } else {
  112. // 跳转对应详情 个人中心不跳转到详情
  113. }
  114. }}
  115. item={{
  116. id: item.id,
  117. addName: item.addName,
  118. addUserAvatar: item.addUserAvatar,
  119. musicSheetName: item.musicSheetName,
  120. subjectNames: item.subjectNames,
  121. composer: item.composer,
  122. chargeType: item.chargeType
  123. }}
  124. class={[
  125. styles.musicListItem,
  126. 'mb-2 cursor-pointer border-b border-solid border-[#E7E6E6]'
  127. ]}
  128. />
  129. ))}
  130. </ElSkeleton>
  131. </div>
  132. <Pagination
  133. total={this.pageInfo.total}
  134. v-model:page={this.pageInfo.page}
  135. v-model:limit={this.pageInfo.limit}
  136. pageSizes={this.pageInfo.page_size}
  137. pagination={this.getList}
  138. />
  139. {this.dataShow && <ColEmpty style={{ marginBottom: '30px' }} />}
  140. </>
  141. )
  142. }
  143. })