income-detail.vue 5.72 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11
<template>
  <div class="income-detail">
    <div class="chart-box">
      <v-chart class="chart" :option="pieOption" />
    </div>
    <div class="detail">
      <p style="font-size:14px;font-weight:bold;">收益明细</p>
      <div class="detail-list">
        <base-refresh-scroll @downLoad="onDownLoad" @upRefresh="onUpRefresh">
          <div slot="content">
            <div
leiqingsong's avatar
leiqingsong committed
12
              v-for="(item, index) in detailList"
13 14 15
              :key="`income-detail-${index}`"
              class="detail-list-item"
            >
leiqingsong's avatar
leiqingsong committed
16
              <span style="width: 100px;">{{ item.name }}</span>
leiqingsong's avatar
leiqingsong committed
17
              <span>{{ item.money }}</span>
leiqingsong's avatar
leiqingsong committed
18
              <span class="time">{{ item.incomeTime }}</span>
19 20 21 22 23 24 25 26 27
            </div>
          </div>
        </base-refresh-scroll>
      </div>
    </div>
  </div>
</template>

<script>
leiqingsong's avatar
leiqingsong committed
28
import { queryIncomeDetail } from "@/api/wallet";
29 30 31 32 33 34
import BaseRefreshScroll from "../../components/BaseRefreshScroll.vue";
export default {
  components: { BaseRefreshScroll },
  name: "IncomeDetail",
  data() {
    return {
leiqingsong's avatar
leiqingsong committed
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
      detailList: [],
      legendPos: [
        {
          x: "1%",
          y: "65%"
        },
        {
          x: "28%",
          y: "65%"
        },
        {
          x: "65%",
          y: "65%"
        },
        {
          x: "1%",
          y: "75%"
        },
        {
          x: "28%",
          y: "75%"
        },
        {
          x: "65%",
          y: "75%"
        },
        {
          x: "1%",
          y: "85%"
        },
        {
          x: "28%",
          y: "85%"
        },
        {
          x: "65%",
          y: "85%"
        }
      ],
74
      pieOption: {
leiqingsong's avatar
leiqingsong committed
75
        legend: [],
76 77 78 79 80 81 82 83 84 85
        tooltip: {
          trigger: "item"
        },
        series: [
          {
            name: "访问来源",
            type: "pie",
            radius: ["50%", "70%"], // pie 内外环
            width: "180",
            height: "180",
leiqingsong's avatar
leiqingsong committed
86
            top: -10,
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118
            left: "center",
            avoidLabelOverlap: true,
            label: {
              // 标签
              show: false,
              position: "outside", // 饼图扇区外侧
              overflow: "break"
            },
            emphasis: {
              // 点击圆环上的每一项显示label
              label: {
                show: false
              }
            },
            labelLine: {
              show: false
            },
            data: [
              { value: 1048, name: "工资收益" },
              { value: 735, name: "曾极差奖金" },
              { value: 580, name: "自身消费返佣" },
              { value: 484, name: "培育奖" },
              { value: 300, name: "月度肥料池分红" },
              { value: 300, name: "进步奖" },
              { value: 300, name: "红包" },
              { value: 300, name: "运营中心补贴" },
              { value: 300, name: "其他收益" }
            ]
          }
        ],
        graphic: {
          type: "group",
leiqingsong's avatar
leiqingsong committed
119
          top: "70",
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155
          left: "center",
          height: 80,
          children: [
            {
              type: "text",
              top: "25%",
              left: "center",
              style: {
                width: "80",
                text: "",
                textAlign: "center",
                overflow: "truncate",
                textVerticaAlign: "middle",
                fill: "#3d383a",
                fontSize: "16px",
                fontWeight: "bold"
              }
            },
            {
              type: "text",
              top: "50%",
              left: "center",
              style: {
                text: "当前总收益",
                textAlign: "center",
                textVerticaAlign: "middle",
                fill: "#333333",
                fontSize: "12px"
              }
            }
          ]
        }
      }
    };
  },
  mounted() {
leiqingsong's avatar
leiqingsong committed
156
    this.getDetail();
157 158 159 160 161 162 163
  },
  methods: {
    onDownLoad(val) {
      console.log("下拉刷新", val);
    },
    onUpRefresh(val) {
      console.log("上拉加载", val);
leiqingsong's avatar
leiqingsong committed
164 165 166
    },
    getDetail() {
      const params = {
leiqingsong's avatar
leiqingsong committed
167
        userId: JSON.parse(localStorage.getItem("user")).userId
leiqingsong's avatar
leiqingsong committed
168
      };
leiqingsong's avatar
leiqingsong committed
169 170
      queryIncomeDetail(params).then(res => {
        if (res.code === 0) {
leiqingsong's avatar
leiqingsong committed
171
          this.pieOption.graphic.children[0].style.text = res.data.totalIncome;
leiqingsong's avatar
leiqingsong committed
172 173 174 175
          this.detailList = res.data.list.map(item => {
            return {
              name: item.typeName,
              money: item.money,
leiqingsong's avatar
leiqingsong committed
176
              incomeTime: item.incomeTime.substr(0, 16).replace(/-/g, ".")
leiqingsong's avatar
leiqingsong committed
177
            };
leiqingsong's avatar
leiqingsong committed
178 179
          });
          this.pieOption.series[0].data = this.detailList.map(item => {
leiqingsong's avatar
leiqingsong committed
180
            return {
leiqingsong's avatar
leiqingsong committed
181 182 183
              value: item.money,
              name: item.name
            };
leiqingsong's avatar
leiqingsong committed
184 185
          });
          const legend = this.detailList.map((item, index) => {
leiqingsong's avatar
leiqingsong committed
186 187 188 189 190
            return {
              selectedMode: false,
              ...this.legendPos[index],
              itemWidth: 12,
              data: [item.name]
leiqingsong's avatar
leiqingsong committed
191
            };
leiqingsong's avatar
leiqingsong committed
192 193
          });
          this.pieOption.legend = legend;
leiqingsong's avatar
leiqingsong committed
194

leiqingsong's avatar
leiqingsong committed
195
          if (!res.data.totalIncome) {
leiqingsong's avatar
leiqingsong committed
196
            this.pieOption.graphic.children[1].style.text = "暂无数据~";
leiqingsong's avatar
leiqingsong committed
197
          }
leiqingsong's avatar
leiqingsong committed
198
        }
leiqingsong's avatar
leiqingsong committed
199
      });
200 201 202 203 204 205 206 207 208 209 210 211 212
    }
  }
};
</script>

<style lang="scss" scoped>
.income-detail {
  padding: 10px 16px;
}
.chart-box {
  width: 345px;
  height: 268px;
  margin: 15px auto 12px;
leiqingsong's avatar
leiqingsong committed
213
  padding: 0 5px;
214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241
  background-color: #ffffff;
}

.detail {
  box-sizing: border-box;
  width: 345px;
  margin: 0 auto;
  padding: 10px 16px;
  font-size: 14px;
  background-color: #ffffff;

  .detail-list {
    position: relative;
    height: 309px;
  }
  .detail-list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    color: #333333;

    .time {
      color: #999999;
    }
  }
}
</style>