bountyDisplay.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. <!-- 滚动展示 -->
  2. <template>
  3. <div style="height: 100%; width: 100%;">
  4. <div class="mb-3" style="font-size: 13px; color: #666;">最近30天已有<span class="red">68人</span>提现成功,累计提现<span class="red">¥9450</span></div>
  5. <!-- 滚动 -->
  6. <div
  7. style="height: calc(100% - 42px); overflow: hidden; font-size: 13px;color: #333;"
  8. >
  9. <!-- 数据list -->
  10. <div class="scrollBox" id="scrollBox">
  11. <div
  12. v-for="(item) in dataList"
  13. :key="item[keyText] || item.name"
  14. class="d-flex justify-space-between align-center"
  15. style="height: 40px;"
  16. >
  17. <!-- 头像、用户名 -->
  18. <div class="d-flex align-center">
  19. <v-avatar size="30" :image="item.avatar || 'https://minio.citupro.com/dev/menduner/7.png'"></v-avatar>
  20. <div class="ml-2">{{ formatName(item.name) }}</div>
  21. <!-- <div class="ml-2">{{ item.name }}</div> -->
  22. </div>
  23. <div class="d-flex" style="width: calc(100% - 65px);">
  24. <!-- 内容 -->
  25. <div class="d-flex ellipsisText mx-4" style="flex: 1;">
  26. <div>推荐到</div>
  27. <div class="ellipsisText ml-1" style="max-width: 100px;">{{ item.company }}</div>
  28. <div class="ellipsisText ml-1" style="max-width: 60px;">{{ item.job }}</div>
  29. </div>
  30. <!-- 赏金 -->
  31. <div>提现¥<span class="red">{{ item.money }}</span></div>
  32. </div>
  33. </div>
  34. </div>
  35. </div>
  36. </div>
  37. </template>
  38. <script setup>
  39. import { ref } from 'vue'
  40. defineOptions({name: 'publicRecruitment-bountyDisplay'})
  41. defineProps({
  42. keyText: {
  43. type: String,
  44. default: 'id'
  45. }
  46. })
  47. const avatarList = [
  48. 'https://img0.baidu.com/it/u=230622178,1565949306&fm=253&fmt=auto&app=138&f=JPEG?w=449&h=300',
  49. 'https://img0.baidu.com/it/u=1401084042,2724457850&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=726',
  50. 'https://q7.itc.cn/q_70/images03/20240423/6d236fae5c8f44ed9b60d977f32debb7.jpeg',
  51. 'https://q1.itc.cn/q_70/images03/20240609/1c1be14298be4dbe978e55bde6e958b0.jpeg',
  52. 'https://q4.itc.cn/q_70/images03/20240528/298d4abda5e4469d98fa77e7cde46525.jpeg',
  53. 'https://q5.itc.cn/q_70/images03/20240520/ceb0d77d1be24eea8cd3826994eac1c1.jpeg',
  54. 'https://img1.baidu.com/it/u=3995643348,1848098846&fm=253&fmt=auto&app=138&f=JPEG?w=800&h=800',
  55. ]
  56. const realDataList = []
  57. for (let index = 0; index < 68; index++) {
  58. const obj = {
  59. id: 'id' + (index+1),
  60. name: '用户' + (index+1),
  61. avatar: avatarList[index % 7],
  62. company: '某某公司' + (index+1),
  63. job: '某某职位' + (index+1),
  64. money: index*index*(100 - index) || 100,
  65. }
  66. realDataList.push(obj)
  67. }
  68. const setDataList = () => {
  69. // 将数据的基数设置极大-> totalNum: 总数
  70. const totalNum = 1000 // 设置长度
  71. if (realDataList.length >= totalNum) {
  72. return realDataList.slice(0, totalNum)
  73. } else {
  74. const multipleCount = Math.ceil(totalNum/realDataList.length)
  75. // 创建一个长度为multipleCount的新数组,并用realDataList填充,取totalNum长度
  76. const arr = realDataList.concat(...Array.from({ length: multipleCount }, () => [...realDataList]))
  77. return arr.slice(0, totalNum)
  78. }
  79. }
  80. let dataList = ref([]) // 渲染的数据
  81. if (realDataList?.length) dataList.value = setDataList()
  82. // 用户名加*号
  83. const formatName = (name) => {
  84. if (name.length === 1) {
  85. return name // 如果名字只有一个字,则直接返回该字
  86. } else if (name.length === 2) {
  87. return name.charAt(0) + '*' // 如果名字有两个字,则返回第一个字后跟一个星号
  88. } else {
  89. return name.charAt(0) + '**' // 如果名字有多于两个字,则返回第一个字后跟两个星号
  90. }
  91. }
  92. // 滚动实现代码部分
  93. </script>
  94. <style lang="scss" scoped>
  95. .red {
  96. color: red;
  97. }
  98. .ellipsisText {
  99. // width: 120px;
  100. white-space: nowrap;
  101. text-overflow: ellipsis;
  102. overflow: hidden;
  103. }
  104. .scrollBox {
  105. position:relative;
  106. animation: myMove 1500s linear infinite;
  107. }
  108. @keyframes myMove
  109. {
  110. // from { bottom: 0%; }
  111. // to { bottom: 100%; }
  112. 0% {
  113. transform: translateY(0%);
  114. }
  115. 100% {
  116. transform: translateY(-100%);
  117. }
  118. }
  119. </style>