ranking-item.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. <template>
  2. <view class="ranking-item" @tap="toself" :class="bg ? 'bg' : ''">
  3. <view class="left">
  4. <image v-if="index == 1" src="../static/icon/first.png" mode="scaleToFill"></image>
  5. <image v-else-if="index == 2" src="../static/icon/second.png" mode="scaleToFill"></image>
  6. <image v-else-if="index == 3" src="../static/icon/third.png" mode="scaleToFill"></image>
  7. <text class="ranking-num" v-else>{{ index }}</text>
  8. </view>
  9. <view class="center">
  10. <view class="avatar-box">
  11. <image :src="item.avatar" mode="scaleToFill" class="avatar"></image>
  12. <image v-if="item.score >= 200" class="hat" src="../static/new/hat.png" mode="scaleToFill"></image>
  13. </view>
  14. <text style="text-align:left;">{{ getName(item.name) }}</text>
  15. </view>
  16. <view class="right">
  17. <view class="score">
  18. {{ item.score }}
  19. </view>
  20. <view class="float" v-if="item.float > 0 && (type === 0 || type === 1)">
  21. <image src="../static/icon/up.png" mode="scaleToFill"></image>
  22. <text>{{ item.float }}</text>
  23. </view>
  24. </view>
  25. </view>
  26. </template>
  27. <script>
  28. export default {
  29. props: {
  30. item: Object,
  31. type: Number,
  32. index: Number,
  33. rank: Number,
  34. bg: Boolean
  35. },
  36. computed: {
  37. userServerInfo() {
  38. return this.$store.state.userServerInfo
  39. }
  40. },
  41. methods: {
  42. getName(name, len) {
  43. if (name) {
  44. return name.length > 6 ? name.slice(0, 6) + '...' : name;
  45. }
  46. return '';
  47. },
  48. toself() { //点击排行榜列表时
  49. if (this.userServerInfo.type === 2) { //批发商可以查看个人榜和团队榜
  50. if (this.type === 0 || this.type === 2) {
  51. uni.navigateTo({
  52. url: `../self/self?from=ranking&id=${this.item.id}`
  53. })
  54. }
  55. } else if (this.userServerInfo.type === 3) { //客服只可以查看个人榜
  56. if (this.type === 0) {
  57. uni.navigateTo({
  58. url: `../self/self?from=ranking&id=${this.item.id}`
  59. })
  60. }
  61. }
  62. }
  63. }
  64. }
  65. </script>
  66. <style lang="scss" scoped>
  67. .ranking-item {
  68. width: 100%;
  69. background-color: #FFFFFF;
  70. height: 120rpx;
  71. line-height: 120rpx;
  72. box-sizing: border-box;
  73. padding: 0 30rpx;
  74. display: flex;
  75. justify-content: flex-start;
  76. color: #2A2A2A;
  77. position: relative;
  78. font-size: 30rpx;
  79. margin: 0 auto;
  80. &.bg {
  81. background: rgba(250, 99, 66, .2);
  82. }
  83. .left {
  84. height: 100%;
  85. // width: 76rpx;
  86. width: 13%;
  87. display: flex;
  88. justify-content: center;
  89. align-items: center;
  90. image {
  91. width: 76rpx;
  92. height: 62rpx;
  93. }
  94. .ranking-num {
  95. font-size: 40rpx;
  96. }
  97. }
  98. .center {
  99. margin-left: 40rpx;
  100. height: 100%;
  101. // width: 380rpx;
  102. width: 57%;
  103. display: flex;
  104. align-items: center;
  105. position: relative;
  106. overflow: hidden;
  107. .avatar-box {
  108. width: 84rpx;
  109. height: 100%;
  110. display: flex;
  111. justify-content: center;
  112. align-items: center;
  113. position: relative;
  114. .avatar {
  115. width: 64rpx;
  116. height: 64rpx;
  117. border-radius: 50%;
  118. position: absolute;
  119. left: 19rpx;
  120. top: 35rpx;
  121. }
  122. .hat {
  123. width: 84rpx;
  124. height: 85rpx;
  125. }
  126. }
  127. // image {
  128. // width: 64rpx;
  129. // height: 64rpx;
  130. // border-radius: 50%;
  131. // &.hat {
  132. // position: absolute;
  133. // top: 50%;
  134. // margin-top: -44rpx;
  135. // left: -11rpx;
  136. // width: 80rpx;
  137. // height: 80rpx;
  138. // }
  139. // }
  140. text {
  141. flex: 1;
  142. margin-left: 20rpx;
  143. // overflow: hidden;
  144. // white-space: nowrap;
  145. // text-overflow: ellipsis;
  146. text-align: center;
  147. }
  148. }
  149. .right {
  150. width: 30%;
  151. // flex: 1;
  152. display: flex;
  153. align-items: center;
  154. justify-content: flex-start;
  155. .score {
  156. // width: 130rpx;
  157. height: 100%;
  158. display: flex;
  159. align-items: center;
  160. justify-content: flex-start;
  161. text-align: center;
  162. color: #FA6342;
  163. }
  164. .float {
  165. flex: 1;
  166. display: flex;
  167. align-items: center;
  168. margin-left: 24rpx;
  169. image {
  170. width: 24rpx;
  171. height: 30rpx;
  172. }
  173. text {
  174. margin-left: 10rpx;
  175. color: #FA6342;
  176. }
  177. }
  178. }
  179. }
  180. </style>