tag.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. <template>
  2. <view class="tag">
  3. <view @click="itemClick(item)" :class="item.type == 1 ? 'outstanding' :'criticize'" v-for="(item,index) in list"
  4. :key="index" class="tag-item">
  5. {{item.tab_name}}
  6. <view :class="item.type == 1 ? 'outstanding' :'criticize'" class="tag-item-right">
  7. {{item.type == 1 ?'+':'-'}}{{item.num}}
  8. </view>
  9. <view v-if="item.show" :class="item.type == 1 ? 'outstanding' :'criticize'" class="tag-item-score">
  10. <view @click="tagClick(item,item1)" v-for="(item1,index1) in [1,2,3,4]" :key="index1"
  11. class="tag-item-score-value">
  12. {{item.type == 1 ?'+':'-'}}{{item1}}
  13. <!-- :class="color(item,index1)" -->
  14. </view>
  15. <view
  16. :style="`${item.type == 1 ? 'border-top: 5px solid rgba(228, 255, 250, 1)':'border-top: 5px solid rgba(255, 236, 229, 1)'}`"
  17. class="tag-item-score-bottom">
  18. </view>
  19. </view>
  20. </view>
  21. </view>
  22. </template>
  23. <script>
  24. export default {
  25. components: {
  26. },
  27. props: {
  28. list: {
  29. type: Array,
  30. default: () => []
  31. }
  32. },
  33. data() {
  34. return {
  35. active: 0
  36. };
  37. },
  38. methods: {
  39. itemClick(item) {
  40. this.list.forEach(it => {
  41. if (it.tab_name == item.tab_name) {
  42. it.show = true
  43. } else {
  44. it.show = false
  45. }
  46. })
  47. this.$emit('update:list', this.list)
  48. },
  49. color(item, index) {
  50. if (index == this.active) {
  51. if (item.type == 'outstanding') {
  52. return 'blue'
  53. } else {
  54. return 'red'
  55. }
  56. }
  57. },
  58. tagClick(item, score) {
  59. this.$emit('click', item, score)
  60. }
  61. },
  62. watch: {
  63. list() {
  64. }
  65. },
  66. mounted() {
  67. console.log(1111);
  68. }
  69. }
  70. </script>
  71. <style lang="scss" scoped>
  72. .tag {
  73. display: flex;
  74. flex-wrap: wrap;
  75. .tag-item {
  76. margin-bottom: 32rpx;
  77. padding: 20rpx 30rpx;
  78. margin-right: 10rpx;
  79. border-radius: 40rpx;
  80. position: relative;
  81. .tag-item-right {
  82. position: absolute;
  83. right: 0;
  84. top: -20rpx;
  85. width: 40rpx;
  86. border-radius: 50%;
  87. height: 40rpx;
  88. text-align: center;
  89. }
  90. .tag-item-score {
  91. position: absolute;
  92. top: -90rpx;
  93. left: 0;
  94. display: flex;
  95. padding: 10rpx;
  96. border-radius: 5px;
  97. .tag-item-score-value {
  98. width: 50rpx;
  99. }
  100. }
  101. }
  102. }
  103. .outstanding {
  104. background-color: rgba(228, 255, 250, 1);
  105. color: rgba(29, 206, 169, 1);
  106. }
  107. .criticize {
  108. background-color: rgba(255, 236, 229, 1);
  109. color: rgba(249, 132, 134, 1);
  110. }
  111. .tag-item-score-bottom {
  112. width: 0;
  113. height: 0;
  114. border-top: 5px solid skyblue;
  115. border-right: 5px solid transparent;
  116. border-left: 5px solid transparent;
  117. position: absolute;
  118. bottom: -5px;
  119. left: 10px;
  120. }
  121. .active {}
  122. .red {
  123. background-color: rgba(249, 132, 134, 1);
  124. color: #fff;
  125. border-radius: 50%;
  126. text-align: center;
  127. width: 46rpx;
  128. height: 46rpx;
  129. }
  130. .blue {
  131. background-color: rgba(29, 206, 169, 1);
  132. color: #fff;
  133. text-align: center;
  134. border-radius: 50%;
  135. width: 46rpx;
  136. height: 46rpx;
  137. }
  138. </style>