Home.vue 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. <template>
  2. <!-- 我的推广页 -->
  3. <div id="home">
  4. <!-- 团队 -->
  5. <ShowMoney :title="teamTitleArr" :content="teamContentArr" />
  6. <!-- 个人 -->
  7. <!-- <ShowMoney :title="myTitleArr" :content="myContentArr" /> -->
  8. <!-- 链接部分 -->
  9. <!-- <HomeLink /> -->
  10. </div>
  11. </template>
  12. <script>
  13. import ShowMoney from "@/components/ShowMoney/ShowMoney";
  14. import HomeLink from "@/views/Home/HomeLink/HomeLink";
  15. import { mapActions, mapState } from "vuex";
  16. export default {
  17. name: "Home",
  18. components: {
  19. ShowMoney,
  20. HomeLink,
  21. },
  22. inject: ["checkCode"],
  23. data() {
  24. return {
  25. teamTitleArr: [
  26. "玩家人数",
  27. "推广员人数",
  28. "玩家总充值(总佣金)",
  29. "推广员总充值(总佣金)",
  30. "总充值",
  31. "当前已赚取佣金",
  32. ],
  33. teamContentArr: [0, 0, "0(0)", "0(0)", 0, 0],
  34. };
  35. },
  36. computed: {
  37. ...mapState(["userProfit"]),
  38. },
  39. watch: {
  40. userProfit() {
  41. this.init();
  42. },
  43. },
  44. created() {},
  45. mounted() {
  46. this.onProfit();
  47. },
  48. methods: {
  49. ...mapActions(["userProfitAction"]),
  50. // 初始化
  51. init() {
  52. const {
  53. game_user_amount,
  54. game_user_profit,
  55. promo_user_amount,
  56. promo_user_profit,
  57. game_user_count,
  58. promo_user_count,
  59. } = this.userProfit;
  60. this.teamContentArr = [
  61. game_user_count,
  62. promo_user_count,
  63. `${(game_user_amount / 100).toFixed(2)}(${(
  64. game_user_profit / 100
  65. ).toFixed(2)})`,
  66. `${(promo_user_amount / 100).toFixed(2)}(${(
  67. promo_user_profit / 100
  68. ).toFixed(2)})`,
  69. ((game_user_amount + promo_user_amount) / 100).toFixed(2),
  70. ((game_user_profit + promo_user_profit) / 100).toFixed(2),
  71. ];
  72. },
  73. // 获取已赚取佣金
  74. onProfit() {
  75. this.$api.profit().then((res) => {
  76. this.checkCode(res);
  77. const { code, data } = res.data;
  78. if (code) {
  79. return;
  80. }
  81. // 成功 todo
  82. this.userProfitAction(data);
  83. this.init();
  84. });
  85. },
  86. },
  87. };
  88. </script>
  89. <style scoped>
  90. #home {
  91. min-width: 1120px;
  92. width: 98%;
  93. margin: 0 auto;
  94. overflow: hidden;
  95. }
  96. </style>