income-detail.vue 7.21 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 17
              <span>{{ item.name }}</span>
              <span>{{ item.money }}</span>
18
              <span class="time">2021.02.26 10:02</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 75 76
      pieOption: {
        legend: [
          {
leiqingsong's avatar
leiqingsong committed
77
            selectedMode: false,
78 79
            x: "1%",
            y: "65%",
leiqingsong's avatar
leiqingsong committed
80
            itemWidth: 12,
81 82 83
            data: ["工资收益"]
          },
          {
leiqingsong's avatar
leiqingsong committed
84
            selectedMode: false,
85 86
            x: "28%",
            y: "65%",
leiqingsong's avatar
leiqingsong committed
87
            itemWidth: 12,
88 89 90
            data: ["曾极差奖金"]
          },
          {
leiqingsong's avatar
leiqingsong committed
91
            selectedMode: false,
92 93
            x: "65%",
            y: "65%",
leiqingsong's avatar
leiqingsong committed
94
            itemWidth: 12,
95 96 97
            data: ["自身消费返佣"]
          },
          {
leiqingsong's avatar
leiqingsong committed
98
            selectedMode: false,
99 100
            x: "1%",
            y: "75%",
leiqingsong's avatar
leiqingsong committed
101
            itemWidth: 12,
102 103 104
            data: ["培育奖"]
          },
          {
leiqingsong's avatar
leiqingsong committed
105
            selectedMode: false,
106 107
            x: "28%",
            y: "75%",
leiqingsong's avatar
leiqingsong committed
108
            itemWidth: 12,
109 110 111
            data: ["月度肥料池分红"]
          },
          {
leiqingsong's avatar
leiqingsong committed
112
            selectedMode: false,
113 114
            x: "65%",
            y: "75%",
leiqingsong's avatar
leiqingsong committed
115
            itemWidth: 12,
116 117 118
            data: ["进步奖"]
          },
          {
leiqingsong's avatar
leiqingsong committed
119
            selectedMode: false,
120 121
            x: "1%",
            y: "85%",
leiqingsong's avatar
leiqingsong committed
122
            itemWidth: 12,
123 124 125
            data: ["红包"]
          },
          {
leiqingsong's avatar
leiqingsong committed
126
            selectedMode: false,
127 128 129
            align: "left",
            x: "28%",
            y: "85%",
leiqingsong's avatar
leiqingsong committed
130
            itemWidth: 12,
131 132 133
            data: ["运营中心补贴"]
          },
          {
leiqingsong's avatar
leiqingsong committed
134
            selectedMode: false,
135 136 137
            align: "left",
            x: "65%",
            y: "85%",
leiqingsong's avatar
leiqingsong committed
138
            itemWidth: 12,
139 140 141 142 143 144 145 146 147 148 149 150 151
            data: ["其他收益"]
          }
        ],
        tooltip: {
          trigger: "item"
        },
        series: [
          {
            name: "访问来源",
            type: "pie",
            radius: ["50%", "70%"], // pie 内外环
            width: "180",
            height: "180",
leiqingsong's avatar
leiqingsong committed
152
            top: -10,
153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184
            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
185
          top: "70",
186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221
          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
222
    this.getDetail();
223 224 225 226 227 228 229
  },
  methods: {
    onDownLoad(val) {
      console.log("下拉刷新", val);
    },
    onUpRefresh(val) {
      console.log("上拉加载", val);
leiqingsong's avatar
leiqingsong committed
230 231 232
    },
    getDetail() {
      const params = {
leiqingsong's avatar
leiqingsong committed
233
        userId: JSON.parse(localStorage.getItem("user")).userId
leiqingsong's avatar
leiqingsong committed
234
      };
leiqingsong's avatar
leiqingsong committed
235 236
      queryIncomeDetail(params).then(res => {
        if (res.code === 0) {
leiqingsong's avatar
leiqingsong committed
237
          this.pieOption.graphic.children[0].style.text = res.data.totalIncome;
leiqingsong's avatar
leiqingsong committed
238 239 240 241
          this.detailList = res.data.list.map(item => {
            return {
              name: item.typeName,
              money: item.money,
leiqingsong's avatar
leiqingsong committed
242
              incomeTime: item.incomeTime.substr(0, 16).replace(/-/g, ".")
leiqingsong's avatar
leiqingsong committed
243
            };
leiqingsong's avatar
leiqingsong committed
244 245
          });
          this.pieOption.series[0].data = this.detailList.map(item => {
leiqingsong's avatar
leiqingsong committed
246
            return {
leiqingsong's avatar
leiqingsong committed
247 248 249
              value: item.money,
              name: item.name
            };
leiqingsong's avatar
leiqingsong committed
250 251
          });
          const legend = this.detailList.map((item, index) => {
leiqingsong's avatar
leiqingsong committed
252 253 254 255 256
            return {
              selectedMode: false,
              ...this.legendPos[index],
              itemWidth: 12,
              data: [item.name]
leiqingsong's avatar
leiqingsong committed
257
            };
leiqingsong's avatar
leiqingsong committed
258 259
          });
          this.pieOption.legend = legend;
leiqingsong's avatar
leiqingsong committed
260
          if (!res.data.totalIncome) {
leiqingsong's avatar
leiqingsong committed
261
            this.pieOption.graphic.children[1].style.text = "暂无数据~";
leiqingsong's avatar
leiqingsong committed
262
          }
leiqingsong's avatar
leiqingsong committed
263
        }
leiqingsong's avatar
leiqingsong committed
264
      });
265 266 267 268 269 270 271 272 273 274 275 276 277
    }
  }
};
</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
278
  padding: 0 5px;
279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306
  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>