moveClient.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. <template>
  2. <div class="move-client">
  3. <van-tabs v-model="select" @change="change">
  4. <van-tab
  5. v-for="(item, i) in platfrom"
  6. :key="item.platfrom"
  7. :title="item.name"
  8. >
  9. <div class="main">
  10. <div class="item">
  11. <van-row>
  12. <van-col span="3" class="td"> 排名 </van-col>
  13. <van-col span="5" class="td"> 单位名称 </van-col>
  14. <van-col span="8" class="td"> 账号 </van-col>
  15. <van-col span="8" class="td"> 传播量 </van-col>
  16. </van-row>
  17. </div>
  18. <van-row
  19. class="item"
  20. v-for="(v, o) in platfromData[i] || []"
  21. :key="v.name"
  22. >
  23. <van-col
  24. span="3"
  25. :class="{ td: true }"
  26. :style="{ color: color[o] || '#000', fontWeight: 600 }"
  27. >
  28. {{ o + 1 }}
  29. </van-col>
  30. <van-col span="5" :class="{ td: true }">
  31. {{ v.name }}
  32. </van-col>
  33. <van-col span="8" :class="{ td: true }">
  34. {{ v.nick_name }}
  35. </van-col>
  36. <van-col span="8" :class="{ td: true }" style="color: #e1a74f">
  37. {{ formatNum(v.read_count) }}
  38. </van-col>
  39. </van-row>
  40. </div>
  41. </van-tab>
  42. </van-tabs>
  43. </div>
  44. </template>
  45. <script>
  46. // @ is an alias to /src
  47. import {
  48. Tab as vanTab,
  49. Tabs as vanTabs,
  50. Col as vanCol,
  51. Row as vanRow,
  52. } from "vant";
  53. import "vant/lib/tab/style/index";
  54. import "vant/lib/tabs/style/index";
  55. import "vant/lib/col/style/index";
  56. import "vant/lib/row/style/index";
  57. // import {} from "../utils/tool";
  58. import { jsonDataRanking } from "../../../api/index";
  59. export default {
  60. name: "move-client",
  61. data() {
  62. return {
  63. setact: false,
  64. select: 0,
  65. platfrom: [],
  66. platfromData: {},
  67. color: ["#ff0036", "#ff9b00", "#ffcc00"],
  68. };
  69. },
  70. props: {
  71. valDay: String,
  72. },
  73. watch: {
  74. valDay() {
  75. this.init();
  76. },
  77. },
  78. mounted() {
  79. this.init();
  80. },
  81. computed: {},
  82. methods: {
  83. init() {
  84. // 初始
  85. if (!this.valDay) return;
  86. this.setact = true;
  87. jsonDataRanking({
  88. url: ["platform", this.valDay].join("-"),
  89. })
  90. .then(res => {
  91. this.platfrom = res || [];
  92. this.getData();
  93. this.$emit("start", {
  94. status: 200,
  95. });
  96. })
  97. .catch(err => {
  98. this.$emit("start", {
  99. status: err,
  100. });
  101. });
  102. },
  103. formatNum(num) {
  104. if (isNaN(num)) return 0;
  105. if (num > 100000000) return (num / 100000000).toFixed(2) - 0 + "亿";
  106. if (num > 10000) return (num / 10000).toFixed(2) - 0 + "万";
  107. return num;
  108. },
  109. getData() {
  110. jsonDataRanking({
  111. url: [this.platfrom[this.select].platform, this.valDay].join(
  112. "_"
  113. ),
  114. })
  115. .then(res => {
  116. const p = JSON.parse(JSON.stringify(this.platfromData));
  117. p[this.select] = res.data || [];
  118. this.platfromData = p;
  119. this.$emit("start", {
  120. status: 200,
  121. });
  122. })
  123. .catch(err => {
  124. this.$emit("start", {
  125. status: err,
  126. });
  127. });
  128. },
  129. change() {
  130. return this.getData();
  131. },
  132. },
  133. beforeUnmount() {},
  134. components: {
  135. vanTabs,
  136. vanTab,
  137. vanCol,
  138. vanRow,
  139. },
  140. };
  141. </script>
  142. <style scoped>
  143. .move-client {
  144. font-size: 15px;
  145. }
  146. .td {
  147. text-align: center;
  148. line-height: 2.5em;
  149. white-space: nowrap;
  150. overflow: hidden;
  151. text-overflow: ellipsis;
  152. }
  153. .item {
  154. overflow: hidden;
  155. border-radius: 3px;
  156. margin-top: 11px;
  157. background-color: #f5f6f8;
  158. }
  159. .main {
  160. padding: 3px;
  161. overflow: auto;
  162. height: calc(100vh - 150px);
  163. }
  164. </style>
  165. <style>
  166. .move-client .van-tab {
  167. font-size: 16px;
  168. }
  169. </style>