detail.vue 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. <template>
  2. <view>
  3. <view class="list">
  4. <view class="item" v-for="(item,index) in list" :key="index">
  5. <view class="left">
  6. <view class="icon">
  7. <image v-if="item.avatar" :src="item.avatar" mode="aspectFill"></image>
  8. <view class="avatar" v-if="!item.avatar" :style="{backgroundColor:bgColor[index]}">
  9. {{item.name.split('').pop()}}
  10. </view>
  11. </view>
  12. <view class="info">
  13. <view class="name">{{item.name}}({{item.section}})</view>
  14. <view class="time">{{item.time}}</view>
  15. </view>
  16. </view>
  17. <view class="right">
  18. {{item.size}} 次
  19. </view>
  20. </view>
  21. </view>
  22. </view>
  23. </template>
  24. <script>
  25. export default {
  26. data() {
  27. return {
  28. list: [],
  29. // 头像随机色
  30. bgColor: [],
  31. };
  32. },
  33. onLoad(option) {
  34. // 设置头像
  35. for (let i = 0; i < 100; i++) {
  36. // 获取随机色
  37. let r = parseInt(Math.random() * 256)
  38. let g = parseInt(Math.random() * 256)
  39. let b = parseInt(Math.random() * 256)
  40. // ES6 字符串拼接
  41. // this.bgColor = `rgba(${r},${g},${b},0.3)`
  42. let color = "rgba(" + r + "," + g + "," + b + "," + 0.3 + ")"
  43. // console.log(color)
  44. this.bgColor.push(color)
  45. }
  46. this.get_list(option.id)
  47. },
  48. methods: {
  49. get_list(id) {
  50. uni.showLoading({
  51. mask:true
  52. })
  53. this.$api.trouble_grid_check_detailed({
  54. type: 1,
  55. check_id: id
  56. }).then((res)=>{
  57. uni.hideLoading()
  58. console.log(res.data.data)
  59. this.list = res.data.data
  60. })
  61. }
  62. }
  63. }
  64. </script>
  65. <style lang="scss">
  66. .list {
  67. box-sizing: border-box;
  68. padding: 25rpx;
  69. .item {
  70. padding: 10rpx 0;
  71. border-bottom: 1rpx solid #F0F0F0;
  72. display: flex;
  73. justify-content: space-between;
  74. align-items: center;
  75. height: 115rpx;
  76. .left {
  77. display: flex;
  78. align-items: center;
  79. .icon {
  80. width: 110rpx;
  81. height: 110rpx;
  82. border-radius: 50%;
  83. overflow: hidden;
  84. image {
  85. width: 110rpx;
  86. height: 110rpx;
  87. }
  88. .avatar {
  89. width: 110rpx;
  90. line-height: 110rpx;
  91. text-align: center;
  92. font-size: 44rpx;
  93. color: #FFFFFF;
  94. }
  95. }
  96. .info {
  97. margin-left: 20rpx;
  98. .name {
  99. line-height: 50rpx;
  100. font-weight: 500;
  101. color: #2C3E50;
  102. }
  103. .time {
  104. font-size: 30rpx;
  105. color: #9C9FA5;
  106. }
  107. }
  108. }
  109. .right {
  110. font-size: 30rpx;
  111. }
  112. }
  113. }
  114. </style>