index.vue 30.8 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 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 74 75 76 77 78 79 80 81 82 83 84 85 86 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 119 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 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 185 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 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 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 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995
<!-- 总览 -->
<template>
  <div class="indexPage">
    <reportDownloads v-if="curBtnsInfo" />
    <el-row>
      <el-col :span="24">
        <el-card class="box-card">
          <div slot="header" class="clearfix card-header">
            <span>工作台总览</span>
            <div class="tabel-desc" v-if="btnFlag" @click="goPer">
              <i class="el-icon-document"></i>渗透率报表
            </div>
            <el-select
              v-model="id"
              @change="idChange"
              v-show="isBeSuper"
              size="mini"
              style="margin-left: auto"
            >
              <el-option
                v-for="(item, index) in parkServiceList"
                :key="index"
                :value="
                  +accountType === 7 ? item.yqMerchantId : item.merchantId
                "
                :label="
                  +accountType === 7 ? item.yqMerchantName : item.merchantName
                "
              />
            </el-select>
          </div>
          <div style="text-align: right">
            <el-radio-group v-model="totalType" type="info" size="mini">
              <el-radio-button label="today"> 今日 </el-radio-button>
              <el-radio-button label="thisWeek"> 本周 </el-radio-button>
              <el-radio-button label="thisMonth"> 本月 </el-radio-button>
            </el-radio-group>
          </div>
          <el-row :gutter="40" class="row_one">
            <el-col
              v-if="+accountType !== 7"
              :span="8"
              style="border-right: 1px solid #e7eaec"
            >
              <div class="top_card">
                <div class="top_card_title">今日待预约</div>
                <div class="top_card_main">
                  <span class="red">待上线</span>
                  <!-- <span class="top_card_main_count top_card_primary">{{todayInviteCount}}</span>
                  <span class="top_card_main_unit">(人)</span> -->
                </div>
              </div>
            </el-col>
            <el-col :span="+accountType !== 7 ? 16 : 24">
              <el-row :gutter="20">
                <el-col :span="8">
                  <div class="top_card">
                    <div class="top_card_title">转化客户概览</div>
                    <div class="top_card_main top_card_main_multi">
                      <div class="top_card_md">
                        <span class="top_card_md_left">客户数(人)</span>
                        <span class="top_card_md_right top_card_second">{{
                          totalData.totalCustomerNums
                        }}</span>
                      </div>
                      <div class="top_card_bm">
                        <span class="top_card_bm_left">转化率</span>
                        <span class="top_card_bm_right"
                          >{{ totalData.customerTransfer }}%</span
                        >
                      </div>
                    </div>
                  </div>
                </el-col>
                <el-col :span="8">
                  <div class="top_card">
                    <div class="top_card_title">订单概览</div>
                    <div class="top_card_main top_card_main_multi">
                      <div class="top_card_md">
                        <span class="top_card_md_left">已成交订单数(单)</span>
                        <span class="top_card_md_right top_card_third">{{
                          totalData.totalOrderCounts
                        }}</span>
                      </div>
                      <div class="top_card_bm">
                        <span class="top_card_bm_left">成交总额</span>
                        <span class="top_card_bm_right"
                          >¥{{ totalData.totalSalesMoney }}</span
                        >
                      </div>
                    </div>
                  </div>
                </el-col>
                <el-col :span="8">
                  <div class="top_card">
                    <div class="top_card_title">财务概览</div>
                    <div class="top_card_main top_card_main_multi">
                      <div class="top_card_md">
                        <span class="top_card_md_left">流水额(元)</span>
                        <span class="top_card_md_right top_card_fourth">{{
                          totalData.totalFlowsMoney
                        }}</span>
                      </div>
                      <div class="top_card_bm">
                        <span class="top_card_bm_left">毛利</span>
                        <span class="top_card_bm_right"
                          >¥{{ totalData.totalGrossProfit }}</span
                        >
                      </div>
                    </div>
                  </div>
                </el-col>
              </el-row>
            </el-col>
          </el-row>
        </el-card>
      </el-col>
    </el-row>
    <el-row>
      <el-col :span="24">
        <el-card class="box-card">
          <div slot="header" class="clearfix">
            <span>客户报表视图</span>
          </div>
          <div>
            <el-radio-group v-model="customerType" type="info" size="mini">
              <el-radio-button label="today"> 今日 </el-radio-button>
              <el-radio-button label="thisWeek"> 本周 </el-radio-button>
              <el-radio-button label="thisMonth"> 本月 </el-radio-button>
            </el-radio-group>
          </div>
          <el-row :gutter="40" class="row_one">
            <el-col :span="16">
              <el-row :gutter="20">
                <el-col :span="8">
                  <div class="top_card">
                    <div class="top_card_title">新增客户数(人)</div>
                    <div class="top_card_main top_card_main_multi">
                      <div class="top_card_md">
                        <span class="top_card_md_right top_card_primary">{{
                          customerData.totalCustomerNums
                        }}</span>
                      </div>
                      <div
                        class="top_card_bm"
                        v-show="customerType === 'today'"
                      >
                        <span class="top_card_bm_left"
                          >周同比:{{
                            $$(customerData, "onWeekCustomerNums")
                          }}%</span
                        >
                        <span class="top_card_bm_right customer"
                          >日环比:{{ customerData.onDayCustomerNums }}%</span
                        >
                      </div>
                      <div class="top_card_bm">
                        <span class="top_card_bm_left">日均新增客户(人)</span>
                        <span class="top_card_bm_right">{{
                          customerData.perDayCustomerNums
                        }}</span>
                      </div>
                    </div>
                  </div>
                </el-col>
                <el-col :span="8">
                  <div class="top_card">
                    <div class="top_card_title">客户到店数(人)</div>
                    <div class="top_card_main top_card_main_multi">
                      <div class="top_card_md">
                        <span class="top_card_md_right top_card_second">{{
                          customerData.totalToShop
                        }}</span>
                      </div>
                      <div
                        class="top_card_bm"
                        v-show="customerType === 'today'"
                      >
                        <span class="top_card_bm_left"
                          >周同比:{{ customerData.onWeekToShop }}%</span
                        >
                        <span class="top_card_bm_right customer"
                          >日环比:{{ customerData.onDayToShop }}%</span
                        >
                      </div>
                      <div class="top_card_bm">
                        <span class="top_card_bm_left">日均到店数(人)</span>
                        <span class="top_card_bm_right">{{
                          customerData.perDayToShop
                        }}</span>
                      </div>
                    </div>
                  </div>
                </el-col>
                <el-col :span="8">
                  <div class="top_card">
                    <div class="top_card_title">转化升级率(比)</div>
                    <div class="top_card_main top_card_main_multi">
                      <div class="top_card_md">
                        <span class="top_card_md_right top_card_third"
                          >{{ customerData.upgradeTransfer }}%</span
                        >
                      </div>
                      <div
                        class="top_card_bm"
                        v-show="customerType === 'today'"
                      >
                        <span class="top_card_bm_left"
                          >周同比:{{
                            customerData.onWeekUpgradeTransfer
                          }}%</span
                        >
                        <span class="top_card_bm_right customer"
                          >日环比:{{
                            customerData.onDayUpgradeTransfer
                          }}%</span
                        >
                      </div>
                      <div class="top_card_bm">
                        <span class="top_card_bm_left">日均转化率(比)</span>
                        <span class="top_card_bm_right"
                          >{{ customerData.perDayUpgradeTransfer }}%</span
                        >
                      </div>
                    </div>
                  </div>
                </el-col>
              </el-row>
            </el-col>
            <el-col :span="8" style="border-left: 1px solid #e7eaec">
              <h4 class="funnel_title">转化漏斗模型:</h4>
              <div class="funnel_wrap">
                <div class="funnel_info">
                  <p class="funnel_label">到店转化率</p>
                  <p class="funnel_rate">{{ transferData.toShopTransfer }}%</p>
                  <p class="funnel_label">升级转化率</p>
                  <p class="funnel_rate">{{ transferData.upgradeTransfer }}%</p>
                </div>
                <div id="funnelChart" style="height: 180px" />
              </div>
            </el-col>
          </el-row>
        </el-card>
      </el-col>
    </el-row>
    <el-row>
      <el-col :span="24">
        <el-card class="box-card">
          <div slot="header" class="clearfix">
            <span>客户转化数据</span>
          </div>
          <div>
            <div id="customTransChart" style="height: 330px" />
          </div>
        </el-card>
      </el-col>
    </el-row>
    <el-row :gutter="15">
      <el-col :span="10">
        <el-card class="box-card">
          <div slot="header" class="clearfix">
            <span>4s门店客流量</span>
          </div>
          <div>
            <div id="storeFlowChart" style="height: 330px" />
          </div>
        </el-card>
      </el-col>
      <el-col :span="14">
        <el-card class="box-card">
          <div slot="header" class="clearfix">
            <span>订单数据</span>
          </div>
          <div>
            <div id="orderChart" style="height: 330px" v-show="false" />
            <div id="orderProductChart" style="height: 330px" />
          </div>
        </el-card>
      </el-col>
    </el-row>
    <el-row :gutter="15">
      <el-col :span="14">
        <el-card class="box-card">
          <div slot="header" class="clearfix">
            <span>收入明细及利润</span>
          </div>
          <div>
            <div id="incomeFlowChart" style="height: 330px" />
          </div>
        </el-card>
      </el-col>
      <el-col :span="10">
        <el-card class="box-card">
          <div slot="header" class="clearfix">
            <span>累计毛利产品占比</span>
          </div>
          <div>
            <div style="text-align: right">
              <el-radio-group v-model="productType" type="info" size="mini">
                <el-radio-button label="thisMonth"> 本月 </el-radio-button>
                <el-radio-button label="thisYear"> 本年 </el-radio-button>
                <el-radio-button label="history"> 历史 </el-radio-button>
              </el-radio-group>
            </div>
            <div id="incomeProductChart" style="height: 302px" />
          </div>
        </el-card>
      </el-col>
    </el-row>
  </div>
</template>

<script>
import reportDownloads from "./components/reportDownloads"
import {
  // getTodayInvite,
  getTotalData,
  getCustomerData,
  getTransferData,
  getCustomerTransList,
  getStoreFlow,
  getOrderProductData,
  getIncomeFlowList,
  getIncomeProductList
} from "@api/index"
// import notice from '@/common/notice'
// import moment from 'moment'
import dayjs from "dayjs"
import customTransOption from "./customTransOption"
import storeFlowOption from "./storeFlowOption"
import orderOption from "./orderOption"
import orderProductOption from "./orderProductOption"
import incomeFlowOption from "./incomeFlowOption"
import incomeProductOption from "./incomeProductOption"
import funnelOption from "./funnelOption"
import { debounce } from "./debounce"
import { getParkStore } from "@api/editCustomer"
import { getPartnerYqListApi } from "@/api/account"
import * as echarts from "echarts"
export default {
  name: "Index",
  components: {
    reportDownloads
  },
  data() {
    return {
      // store: $store.getters['d2admin/auth/curBtns'],
      id: "",
      isBeSuper: false,
      userInfo: this.$store.state.d2admin.user.info,
      // 7 - 服务商
      accountType: this.$store.state.d2admin.user.info.detail.accountType,
      customTransChart: null,
      todayInviteCount: "",
      totalType: "today",
      totalData: {
        totalCustomerNums: "",
        customerTransfer: "",
        totalOrderCounts: "",
        totalSalesMoney: "",
        totalFlowsMoney: "",
        totalGrossProfit: ""
      },
      customerType: "today",
      customerData: {
        totalCustomerNums: "",
        onDayCustomerNums: "",
        onWeekCustomerNums: "",
        totalToShopTotal: "",
        onWeekToShop: "",
        onDayToShop: "",
        perDayToShop: "",
        totalFlowsMoney: "",
        onDayUpgradeTransfer: "",
        onWeekUpgradeTransfer: "",
        perDayUpgradeTransfer: ""
      },
      transferData: {
        toShopTransfer: "",
        upgradeTransfer: ""
      },
      parkServiceList: [],
      productType: "thisMonth",
      btnFlag: false
    }
  },
  computed: {
    curBtnsInfo() {
      const curBtns = this.$store.getters["d2admin/auth/curBtns"] || []
      return (
        curBtns.some((item) => {
          //  路由定义的权限id
          return item.authId == "90701"
        }) && !this.specialAccout
      )
      // return this.$store.getters['d2admin/auth/curBtns']
    },
    specialAccout() {
      return this.userInfo?.loginAccount?.loginAccout == "18123663366"
    }
  },
  mounted() {
    this.getUserId().then(() => {
      this.init()
    })
    this.$nextTick(() => {
      const $store = this.$store.getters["d2admin/auth/curBtns"]
      const btnId = "90707" // 渗透率报表权限ID
      const _item = $store?.find((i) => i.authId === btnId)
      if (_item) this.btnFlag = true
    })
  },
  watch: {
    totalType(newType) {
      this.getTotal()
    },
    customerType(newType) {
      this.getCustomer()
    },
    productType(newType) {
      this.drawIncomeProductChart()
    }
  },
  methods: {
    init() {
      // getTodayInvite({}).then((res) => {
      //   this.todayInviteCount = res
      // })
      this.getTotal()
      this.getCustomer()

      this.customTransChart = echarts.init(
        document.getElementById("customTransChart")
      )
      this.storeFlowChart = echarts.init(
        document.getElementById("storeFlowChart")
      )
      this.orderChart = echarts.init(document.getElementById("orderChart"))
      this.orderProductChart = echarts.init(
        document.getElementById("orderProductChart")
      )
      this.incomeFlowChart = echarts.init(
        document.getElementById("incomeFlowChart")
      )
      this.incomeProductChart = echarts.init(
        document.getElementById("incomeProductChart")
      )
      this.funnelChart = echarts.init(document.getElementById("funnelChart"))

      window.addEventListener("resize", () => this.resize())

      this.drawCustomTransChart()
      this.drawStoreFlowChart()
      this.drawOrderProductChart()
      this.drawIncomeFlowChart()
      this.drawIncomeProductChart()
      this.drawFunnelChart()
    },
    goPer() {
      this.$router.push({
        name: "permeation"
      })
    },
    getUserId() {
      return new Promise((resolve, reject) => {
        if (this.userInfo.beSuper) {
          this.isBeSuper = true
          getParkStore({}).then((res) => {
            if (typeof res === "object") {
              res.unshift({
                merchantNo: "",
                merchantName: "全部"
              })
              res.forEach((item) => {
                item.merchantId = item.merchantNo
              })
              this.parkServiceList = res
              this.id = this.parkServiceList[0].merchantId
            }

            resolve()
          })
        } else if (this.userInfo.detail.accountType === 7) {
          this.isBeSuper = true
          getPartnerYqListApi({}).then((res) => {
            if (typeof res === "object") {
              res.unshift({
                yqMerchantId: "",
                yqMerchantName: "全部"
              })
              this.parkServiceList = res
            }
            resolve()
          })
        } else {
          this.id = this.userInfo.detail.merchantId
          resolve()
        }
      })
    },
    idChange() {
      // console.log(this.id)
      this._idTimeoutId && clearTimeout(this._idTimeoutId)
      this._idTimeoutId = setTimeout(() => {
        this.getTotal()
        this.getCustomer()

        this.drawCustomTransChart()
        this.drawStoreFlowChart()
        this.drawOrderProductChart()
        this.drawIncomeFlowChart()
        this.drawIncomeProductChart()
        this.drawFunnelChart()
      }, 500)
    },
    resize() {
      debounce(this.resizeChart.bind(this), 300)()
    },
    initChart() {
      this.customTransChart.setOption(customTransOption)
      this.storeFlowChart.setOption(storeFlowOption)
      this.orderChart.setOption(orderOption)
      this.orderProductChart.setOption(orderProductOption)
      this.incomeFlowChart.setOption(incomeFlowOption)
      this.incomeProductChart.setOption(incomeProductOption)
    },
    resizeChart() {
      this.customTransChart.resize()
      this.storeFlowChart.resize()
      this.orderChart.resize()
      this.orderProductChart.resize()
      this.incomeFlowChart.resize()
      this.incomeProductChart.resize()
      this.funnelChart.resize()
    },
    showChartLoading(chart) {
      chart.showLoading({
        text: "加载中",
        color: "#2B9AFF"
      })
    },
    hideChartLoading(chart) {
      chart.hideLoading()
    },
    drawCustomTransChart() {
      this.showChartLoading(this.customTransChart)

      getCustomerTransList({
        yqMerchantId: this.isBeSuper ? this.id : "",
        beginDateStr: dayjs().startOf("month").format("YYYY-MM-DD"),
        endDateStr: dayjs().endOf("month").format("YYYY-MM-DD")
      }).then((res) => {
        const data = res

        const dateArr = data.map((item) => item.dataDateStr)
        const toShopArr = data.map((item) => item.totalToShop)
        const transArr = data.map((item) => item.totalUpgrade)

        customTransOption.xAxis.data = dateArr
        customTransOption.series[0].data = toShopArr
        customTransOption.series[1].data = transArr

        this.customTransChart.setOption(customTransOption)
        this.hideChartLoading(this.customTransChart)
      })
    },
    drawFunnelChart() {
      /* this.funnelChart.showLoading({
        text: '加载中',
        color: '#2B9AFF',
      }) */
      this.showChartLoading(this.funnelChart)
      getTransferData({ yqMerchantId: this.isBeSuper ? this.id : "" }).then(
        (res) => {
          funnelOption.series[0].data[0].tooltipValue = res.totalCustomerNums
          funnelOption.series[0].data[1].tooltipValue = res.totalToShop
          funnelOption.series[0].data[2].tooltipValue = res.totalUpgrade

          this.transferData.toShopTransfer = res.toShopTransfer
          this.transferData.upgradeTransfer = res.upgradeTransfer
          this.funnelChart.setOption(funnelOption)
          this.hideChartLoading(this.funnelChart)
        }
      )
    },
    drawStoreFlowChart() {
      this.showChartLoading(this.storeFlowChart)
      getStoreFlow({ yqMerchantId: this.isBeSuper ? this.id : "" }).then(
        (res) => {
          const data = res

          const legendArr = []
          const storeArr = data.map((item, index) => {
            legendArr.push(item.merchantName)
            return {
              value: item.totalToShop,
              name: item.merchantName,
              itemStyle: {
                color: storeFlowOption.color[index]
              }
            }
          })

          storeFlowOption.legend.data = legendArr
          storeFlowOption.series[0].data = storeArr
          this.storeFlowChart.setOption(storeFlowOption)
          this.hideChartLoading(this.storeFlowChart)
        }
      )
    },
    drawOrderProductChart() {
      this.showChartLoading(this.orderProductChart)
      const params = {
        yqMerchantId: this.isBeSuper ? this.id : "",
        /* beginDateStr: '2020-12-07',
        endDateStr: '2020-12-13', */
        ...this.getDateFormatByType("thisWeek")
      }

      getOrderProductData(params).then((res) => {
        // console.log(res)
        const data = res

        const colors = [
          "rgba(0,110,214,0.4)",
          "rgba(0,110,214,0.6)",
          "rgba(0,110,214,1)"
        ]
        var idObj = {}
        for (var key in data) {
          // var index = dayjs(key).format('E') - 1
          // console.log(key)
          var index = dayjs(key).format("d") - 1
          // key
          // console.log(index, 'index')
          var list = data[key]
          list.sort((a, b) => {
            return b.goodsTotal - a.goodsTotal
          })

          list.forEach((item, i) => {
            // 处理判空
            if (!(item.id in idObj) && item.id != null) {
              idObj[item.id] = {
                data: [],
                name: item.goodsName,
                color: colors[i]
              }
              idObj[item.id].data.push([Number(index), item.goodsTotal])
            }
          })
        }
        // console.log(idObj)
        var seriesArr = []
        for (const key in idObj) {
          // console.log(idObj[key].data)
          seriesArr.push({
            name: idObj[key].name,
            type: "bar",
            stack: "总量",
            barGap: "-100%",
            label: {
              show: false,
              formatter: "{a}",
              position: "insideRight"
            },
            itemStyle: {
              color: idObj[key].color
              // color: '#2A58AD'
            },
            data: idObj[key].data
            // data: [6, 6.5, 6, 6, 5.5, 6, 6, 6.5, 6, 6, 5.5]
          })
        }
        // console.log(seriesArr)

        this.orderProductChart.clear()
        orderProductOption.series = seriesArr
        orderProductOption.xAxis.data = [
          "周一",
          "周二",
          "周三",
          "周四",
          "周五",
          "周六",
          "周日"
        ]
        const dateArr = Object.keys(res).sort(
          (a, b) => new Date(a) - new Date(b)
        )
        orderProductOption.xAxis.data.forEach((item, index) => {
          orderProductOption.xAxis.data[index] =
            item + "\n" + dateArr[index].slice(5)
        })
        this.orderProductChart.setOption(orderProductOption)
        this.hideChartLoading(this.orderProductChart)
      })
    },
    drawIncomeFlowChart() {
      this.showChartLoading(this.incomeFlowChart)
      getIncomeFlowList({
        yqMerchantId: this.isBeSuper ? this.id : "",
        year: dayjs().format("YYYY")
      }).then((res) => {
        const data = res

        // incomeFlowOption.xAxis.data = data.map((item) => item.month)
        incomeFlowOption.series[0].data = data.map(
          (item) => item.totalIncomeMoney
        )
        // incomeFlowOption.series[1].data = data.map((item) => item.totalCost)
        this.incomeFlowChart.setOption(incomeFlowOption)
        this.hideChartLoading(this.incomeFlowChart)
      })
      /* incomeFlowOption.xAxis.data = [] //month
      incomeFlowOption.series[0].data = [] //
      incomeFlowOption.series[1].data = [] // */
    },
    drawIncomeProductChart() {
      this.showChartLoading(this.incomeProductChart)
      let params = {
        yqMerchantId: this.isBeSuper ? this.id : ""
      }
      if (this.productType !== "history") {
        params = {
          ...params,
          /* beginDateStr: '2020-12-07',
          endDateStr: '2020-12-13', */
          ...this.getDateFormatByType(this.productType)
        }
      }
      getIncomeProductList(params).then((res) => {
        const data = res

        incomeProductOption.title.text = `累计毛利\n${data.totalGrossProfit}元`
        incomeProductOption.series[0].data = []

        incomeProductOption.series[0].data = data.rankList.map((item) => {
          return {
            value: item.totalGrossProfit,
            name: item.goodsName
          }
        })
        this.incomeProductChart.setOption(incomeProductOption)
        this.hideChartLoading(this.incomeProductChart)
      })
      /* incomeProductOption.title.text = '累计收入\n555555元'; //totalOrderMoney
      incomeProductOption.series[0].data.push({
        value: 335,
        name: '直接访问'
      }) */
      // goodsName totalMoney
    },
    getDateFormatByType(type) {
      let beginDateStr = ""
      let endDateStr = ""

      switch (type) {
        case "today":
          beginDateStr = dayjs().startOf("day").format("YYYY-MM-DD")
          endDateStr = dayjs().endOf("day").format("YYYY-MM-DD")
          break
        case "yesterday":
          beginDateStr = dayjs()
            .subtract(1, "day")
            .startOf("day")
            .format("YYYY-MM-DD")
          endDateStr = dayjs()
            .subtract(1, "day")
            .endOf("day")
            .format("YYYY-MM-DD")
          break
        case "thisWeek":
          // 0 - 周日,特殊处理
          beginDateStr = dayjs().day()
            ? dayjs().day(1).startOf("day").format("YYYY-MM-DD")
            : dayjs().subtract(6, "days").startOf("day").format("YYYY-MM-DD")
          endDateStr = dayjs().day()
            ? dayjs().day(1).add(6, "days").endOf("day").format("YYYY-MM-DD")
            : dayjs().endOf("day").format("YYYY-MM-DD")
          break
        case "thisMonth":
          beginDateStr = dayjs().startOf("month").format("YYYY-MM-DD")
          endDateStr = dayjs().endOf("month").format("YYYY-MM-DD")
          break
        case "thisYear":
          beginDateStr = dayjs().startOf("year").format("YYYY-MM-DD")
          endDateStr = dayjs().endOf("year").format("YYYY-MM-DD")
          break
      }

      return {
        beginDateStr,
        endDateStr
      }
    },
    getTotal() {
      const params = {
        ...this.getDateFormatByType(this.totalType),
        yqMerchantId: this.isBeSuper ? this.id : ""
      }

      getTotalData(params).then((res) => {
        this.totalData = res
      })
    },
    getCustomer() {
      const params = {
        ...this.getDateFormatByType(this.customerType),
        yqMerchantId: this.isBeSuper ? this.id : ""
      }
      if (this.customerType === "today") {
        params.needCompareDateStr = dayjs().startOf("day").format("YYYY-MM-DD")
      }
      getCustomerData(params).then((res) => {
        // console.log(res)
        this.customerData = res
      })
    }
  }
}
</script>
<style lang="scss">
.indexPage {
  box-sizing: border-box;
  height: calc(100vh - 115px);
  width: 100%;
  padding: 0px 5px 0 15px;
  overflow-y: auto;
  overflow-x: hidden;
  min-width: 1150px;

  & > .el-row {
    margin-bottom: 20px;
  }

  .d2-container-full__body {
    background-color: transparent !important;
  }

  .row_one {
    .el-col {
      //padding: 15px 0;
    }
  }

  .top_card {
    margin: 15px 0;
    padding: 15px;
    background: #f8faff;
    border: 1px solid #f1f1f1;
    border-radius: 5px;
    border-radius: 5px;

    .top_card_title {
      font-size: 16px;
      color: #666;
    }

    .top_card_main {
      height: 100px;
      display: flex;
      align-items: center;
      justify-content: center;

      .red {
        color: red;
      }

      .top_card_main_unit {
      }

      .top_card_main_count {
        color: #0947c6;
        font-size: 30px;
        margin-right: 5px;
      }

      &.top_card_main_multi {
        flex-direction: column;
        align-items: flex-start;
        justify-content: space-between;
        font-size: 12px;

        .top_card_md {
          display: flex;
          align-items: center;
          width: 100%;
          padding-top: 20px;
          justify-content: space-between;

          .top_card_md_right {
            font-size: 30px;

            &.top_card_primary {
              color: #0947c6;
            }

            &.top_card_second {
              color: #ffaa00;
            }

            &.top_card_third {
              color: #f46967;
            }

            &.top_card_fourth {
              color: #82c239;
            }
          }
        }

        .top_card_bm {
          display: flex;
          align-items: center;
          width: 100%;
          justify-content: space-between;

          .top_card_bm_right {
            font-size: 16px;

            &.customer {
              font-size: 12px;
            }
          }
        }
      }
    }
  }
  .card-header {
    display: flex;
    align-items: center;
    .tabel-desc {
      cursor: pointer;
      width: 122px;
      height: 32px;
      background: #ecf2ff;
      border-radius: 18px;
      font-size: 14px;
      color: #666666;
      line-height: 32px;
      text-align: center;
      margin-left: 16px;
      i {
        color: #185efe;
        font-size: 16px;
      }
    }
  }
  .funnel_wrap {
    display: flex;
    max-width: 300px;
    margin: 0 auto;

    .funnel_info {
      margin: 30px 15px 0 0;
      padding-top: 20px;

      & > p {
        margin: 8px 0;
      }
    }

    .funnel_label {
      color: #999;
      font-size: 12px;
    }

    .funnel_rate {
      margin: 0 0 10px;
      color: #0947c6;
    }

    #funnelChart {
      flex: 1;
    }
  }

  .funnel_title {
    position: absolute;
    top: -10px;
    color: #0947c6;
  }
}

.ad_wrap {
  text-align: center;
  margin-bottom: 20px;
  font-size: 0;

  .ad_img {
    max-width: 100%;
  }
}
</style>