interact.vue 4.71 KB
Newer Older
xulili's avatar
xulili committed
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
<template>
  <div class="interaction">
    <div class="common-title">
      <div class="icon-and-title">
        <img class="icon-title" src="@/assets/overview/board.png" alt="" />
        <span class="title">{{ title }}</span>
      </div>
      <img class="bg" src="@/assets/overview/bg_title02.png" alt="" />
    </div>
    <div id="tends"></div>
  </div>
</template>

<script>
import { getCurDate } from "@/utils/util.time.js";
export default {
  name: "interaction",
  data() {
    return {
      title: "展板点播趋势图",
      xAxisData: [],
      yAxisData: [],
    };
  },
  components: {},
  mounted() {
    this.getList()
  },
  methods: {
    getList() {
      let curTime = getCurDate();
      let playDate = curTime.year + curTime.month;
      let _this = this
      this.$https({
        method: "post",
        url: "tBoardStatistic/getBoardTrendPageList?playDate=" + playDate,
        authType: this.backToken,
      })
        .then((res) => {
          if (res.status == 200) {
            if (res.data.resultCode == 200) {
              this.xAxisData = res.data.data.dateList;
              this.yAxisData = res.data.data.cntList;
            } else {
              this.xAxisData = [];
              this.yAxisData = [];
            }
          } else {
            this.xAxisData = [];
            this.yAxisData = [];
          }
          this.init();
        })
        .catch((err) => {
          this.$message.error(err.message);
          this.xAxisData = [];
          this.yAxisData = [];
          this.init();
        });
    },
    init() {
      let option = {
        tooltip: {
          trigger: "axis",
        },
        grid: {
          top: 20,
          left: "2%",
          right: 40,
          bottom: 30,
          containLabel: true,
        },
        dataZoom: [
          {
            type: "slider",
            show: true,
            bottom: 0,
            start: 0,
            end: 100,
            height: 18,
            handleStyle: {
              color: "#d3dee5",
            },
            textStyle: {
              color: "#fff",
              fontSize: "10px",
            },
          },
        ],
        xAxis: {
          type: "category",
          boundaryGap: false, //坐标轴两边留白
          data: this.xAxisData,
          axisLabel: {
            //坐标轴刻度标签的相关设置。
            textStyle: {
              color: "#333333",
              fontStyle: "normal",
              fontFamily: "微软雅黑",
              fontSize: 14,
            },
          },
          axisTick: {
            //坐标轴刻度相关设置。
            show: false,
          },
          axisLine: {
            //坐标轴轴线相关设置
            lineStyle: {
              color: "#eeeeee",
              type: "solid",
            },
          },
          splitLine: {
            //坐标轴在 grid 区域中的分隔线。
            show: false,
          },
        },
        yAxis: [
          {
            type: "value",
            splitNumber: 5,
            max: 100,
            axisLabel: {
              textStyle: {
                color: "#333333",
                fontStyle: "normal",
                fontFamily: "微软雅黑",
                fontSize: 12,
              },
              interval: "auto",
            },
            axisLine: {
              show: false,
            },
            axisTick: {
              show: false,
            },
            splitLine: {
              show: true,
              lineStyle: {
                color: "#eeeeee",
                type: "dashed",
              },
            },
          },
        ],
        series: [
          {
            type: "line",
            smooth: true,
            itemStyle: {
              normal: {
                color: "#AC9374",
                lineStyle: {
                  color: "#9B1E23",
                  width: 1,
                },
                areaStyle: {
                  color: new this.$echarts.graphic.LinearGradient(0, 1, 0, 0, [
                    {
                      offset: 0,
                      color: "rgba(172,141,116,0.4)",
                    },
                    {
                      offset: 1,
                      color: "rgba(155,30,35,0.4)",
                    },
                  ]),
                },
              },
            },
            data: this.yAxisData,
          },
        ],
      };
      let echartsDiv = this.$echarts.init(document.getElementById("tends"));
      echartsDiv.setOption(option);
    },
    // // 点击事件
    // echartsClick() {
    //   this.$emit("itemClick", { type: 2, title: this.title });
    // },
  },
};
</script>

<style  lang="less">
#tends {
  width: 100%;
  height: calc(100% - 45px);
}
</style>