<template>
  <div class="home">
<!--网站概况-->
    <a-row class="top-title">
      <a-col :span="24">
          <span class="t1">
            网站概况
          </span>
          <template  v-if="siteinfo.length > 1">
<!--            <select-site @comMethods="changeUser" :comProps="parentValue" selectWidth="300px"  ref="selectSite" />-->
            <a v-if="selectSiteInfo.domain" :href="selectSiteInfo.domain" style="margin-left: 24px" class="t1 t2" target="_blank">{{ selectSiteInfo.domain }}</a>
            <a v-else-if="selectSiteInfo.domainDev" :href="'http://' + selectSiteInfo.domainDev" style="margin-left: 24px" class="t1 t2" target="_blank">http://{{ selectSiteInfo.domainDev }}</a>
          </template>
          <template v-else>
            <a v-if="selectSiteInfo.domain" :href="selectSiteInfo.domain" style="margin-left: 24px" class="t1 t2" target="_blank">{{ selectSiteInfo.domain }}</a>
            <a v-else-if="selectSiteInfo.domainDev" :href="'http://' + selectSiteInfo.domainDev" style="margin-left: 24px" class="t1 t2" target="_blank">http://{{ selectSiteInfo.domainDev }}</a>
          </template>
      </a-col>
    </a-row>

    <!--基础信息-->
    <a-row :gutter="[16,16]" class="r2">
      <a-col :span="6" class="c1">
        <a-spin :spinning="baseInfoLoading">
          <div class="wrap">
            <p class="mb">交付状态：<span class="big">{{ baseInfo.deliveryProgress | filter_Null_format}}</span></p>
            <p>运行状态：<span v-if="baseInfo.runStatus == 0">创建失败</span><span v-if="baseInfo.runStatus == 1">正常运行</span><span v-if="baseInfo.runStatus == 2">运行异常</span>
              <span v-if="baseInfo.runStatus == 3">站点停止</span>
            </p>
            <p>网站运行：{{baseInfo.runDays | filter_Null_format}}天</p>
          </div>
        </a-spin>
      </a-col>
      <a-col :span="6" class="c2">
        <a-spin :spinning="baseInfoLoading">
          <div class="wrap">
            <p class="big mb">{{baseInfo.planName | filter_Null_format}}</p>
            <p>提单时间：{{baseInfo.createTime | filter_Null_format}}</p>
            <p>预计服务到期时间：{{baseInfo.endTime | filter_Null_format}}</p>
          </div>
        </a-spin>
      </a-col>
      <a-col :span="12">
        <div class="wrap">
          <a-row>
            <a-col :span="8">
              <p class="big imgtitle">更多推广：</p>
            </a-col>
            <a-col :span="8">
              <img src="../../assets/home2-7/Google.png" />
            </a-col>
            <a-col :span="8">
              <img src="../../assets/home2-7/Facebook.png" />
            </a-col>
            <a-col :span="8">
              <img src="../../assets/home2-7/YouTube.png" />
            </a-col>
            <a-col :span="8">
              <img src="../../assets/home2-7/LinkedIn.png" />
            </a-col>
            <a-col :span="8">
              <img src="../../assets/home2-7/Yandex.png" />
            </a-col>
          </a-row>
        </div>
      </a-col>
    </a-row>

    <!--网站物料完成情况-->
    <a-row v-if="showMaterialStatistics"  class="r3">
      <a-col>
        <p class="title">网站物料完成情况
<!--            <a class="detail_link" >-->
<!--              <router-link :to="{ path: '/website/detective' }">-->
<!--                详细检测>-->
<!--              </router-link>-->
<!--            </a>-->
        </p>
      </a-col>
    </a-row>
    <a-row v-if="showMaterialStatistics" class="r4" >
      <a-col :span="8">
        <p class="title">企业信息</p>
        <a-spin :spinning="infoLoading">
          <dash-chart  color="#E96B5F" :dataSource="enterpriseInfoPercent"></dash-chart>
          <div class="wrap" v-if="enterpriseInfoOK != 0">
            <div class="left">
              <p>已完成：</p>
            </div>
            <div class="right">
              <template v-for="(item, index) in enterpriseInfoList">
                <router-link :to="{ path: item.menuPath}">
                  <span class="theme-color" v-if="item.finish">{{ item.label }}</span>
                </router-link>
              </template>
            </div>
          </div>
          <div class="wrap" v-if="enterpriseInfoNO != 0">
            <div class="left">
              <p>未完成：</p>
            </div>
            <div class="right">
              <template v-for="(item, index) in enterpriseInfoList">
                <router-link :to="{ path: item.menuPath}">
                  <span class="theme-color" v-if="!item.finish">{{ item.label }}</span>
                </router-link>
              </template>
            </div>
          </div>
        </a-spin>

      </a-col>
      <a-col :span="8" class="c2">
        <p class="title">产品信息</p>
        <a-spin :spinning="infoLoading">
          <dash-chart  color="#58CCA8" :dataSource="productInfoPercent"></dash-chart>
          <div class="wrap" v-if="productInfoOK != 0">
            <div class="left">
              <p>已完成：</p>
            </div>
            <div class="right">
              <template v-for="(item, index) in productInfoList" >
                <router-link :to="{ path: item.menuPath}">
                  <span class="theme-color" v-if="item.finish">{{ item.label }}</span>
                </router-link>
              </template>
            </div>
          </div>
          <div class="wrap" v-if="productInfoNO != 0">
            <div class="left">
              <p>未完成：</p>
            </div>
            <div class="right">
              <template v-for="(item, index) in productInfoList" >
                <router-link :to="{ path: item.menuPath}">
                  <span class="theme-color" v-if="!item.finish">{{ item.label }}</span>
                </router-link>
              </template>
            </div>
          </div>
        </a-spin>
      </a-col>
      <a-col :span="8">
        <p class="title">内容中心</p>
        <a-spin :spinning="infoLoading">
          <dash-chart  color="#F0B358" :dataSource="newsInfoPercent"></dash-chart>
          <div class="wrap" v-if="newsInfoOK != 0">
            <div class="left">
              <p>已完成：</p>
            </div>
            <div class="right">
              <template v-for="(item, index) in newsInfoList">
                <router-link :to="{ path: item.menuPath}">
                  <span class="theme-color" v-if="item.finish">{{ item.label }}</span>
                </router-link>
              </template>
            </div>
          </div>
          <div class="wrap" v-if="newsInfoNO != 0">
            <div class="left">
              <p>未完成：</p>
            </div>
            <div class="right">
              <template v-for="(item, index) in newsInfoList">
                <router-link :to="{ path: item.menuPath}">
                  <span class="theme-color" v-if="!item.finish">{{ item.label }}</span>
                </router-link>
              </template>
            </div>
          </div>
        </a-spin>
      </a-col>
    </a-row>

    <!--核心数据-->
    <a-row v-if="selectSiteInfo.status == 1"  class="r3">
      <a-col><p class="title">核心数据</p></a-col>
    </a-row>
    <a-row v-if="selectSiteInfo.status == 1"  class="r5" :gutter="[20,20]">
      <a-col :span="4">
        <div class="wrap effect">
          <a-spin :spinning="coreInfoLoading">
            <router-link :to="{ path: '/inquiry/list',query:{timeType:'thisWeek'} }">
              <img src="../../assets/home2-7/weekEnquiry.svg" />
              <div class="fr">
                <p>本周询盘数</p>
                <p class="theme-color">{{currentWeekEnquiryCount | filter_Null_format}}</p>
              </div>
            </router-link>
          </a-spin>
        </div>
      </a-col>
      <a-col :span="4">
        <div class="wrap effect">
          <a-spin :spinning="coreInfoLoading">
            <router-link :to="{ path: '/inquiry/list',query:{timeType:'thisMonth'} }">
              <img src="../../assets/home2-7/monthEnquiry.svg" />
              <div class="fr">
                <p>本月询盘数</p>
                <p class="theme-color">{{currentMonthEnquiryCount | filter_Null_format}}</p>
              </div>
            </router-link>
          </a-spin>
        </div>
      </a-col>
      <a-col :span="4">
        <router-link :to="{ path: '/inquiry/list' }">
            <div class="wrap effect">
              <a-spin :spinning="coreInfoLoading">
                <img src="../../assets/home2-7/totalEnquiry.svg" />
                <div class="fr">
                  <p>累计询盘数</p>
                  <p class="theme-color">{{ totalEnquiryCount  | filter_Null_format}}</p>
                </div>
              </a-spin>
            </div>
        </router-link>
      </a-col>
<!--      SEO套餐展示seo指标-->
      <template v-if="isShow && baseInfo.planName.indexOf('SEO') !== -1">
      <a-col :span="4" >
        <div class="wrap blue">
          <a-spin :spinning="coreInfoLoading">
            <img src="../../assets/home2-7/seoReach.svg" />
            <div class="fr">
              <p>SEO目标达成数</p>
              <p >{{appointWordCount | filter_Null_format}}</p>
            </div>
          </a-spin>
        </div>
      </a-col>
        <a-col :span="4">
          <router-link :to="{ path: '/marketing/keywordsWatch/' }">
            <div class="wrap blue">
              <a-spin :spinning="coreInfoLoading">
                <img src="../../assets/home2-7/nowReach.svg"/>
                <div class="fr">
                  <p>实际达成数</p>
                  <p class="theme-color">{{ currentAchieveCount | filter_Null_format }}</p>
                </div>
              </a-spin>
            </div>
          </router-link>
        </a-col>
      <a-col :span="4">
        <div class="wrap blue">
          <a-spin :spinning="coreInfoLoading">
            <img src="../../assets/home2-7/seoReachRate.svg" />
            <div class="fr">
              <p>目标达成率</p>
              <p >{{achievePercent | filter_Null_format}}</p>
            </div>
          </a-spin>

        </div>
      </a-col>
      </template>
<!--      非SEO套餐展示流量指标-->
      <template v-else>
        <a-col :span="4" >
          <div class="wrap blue">
            <a-spin :spinning="coreInfoLoading">
              <img src="../../assets/home2-7/seoReach.svg" />
              <div class="fr">
                <p>本周流量</p>
                <p >{{flowIndicator.uvWeekCount | filter_Null_format}}</p>
              </div>
            </a-spin>
          </div>
        </a-col>
        <a-col :span="4">
          <div class="wrap blue">
            <a-spin :spinning="coreInfoLoading">
              <img src="../../assets/home2-7/nowReach.svg" />
              <div class="fr">
                <p>本月流量</p>
                <p >{{flowIndicator.uvMonthCount  | filter_Null_format}}</p>
              </div>
            </a-spin>
          </div>
        </a-col>
        <a-col :span="4">
          <div class="wrap blue">
            <a-spin :spinning="coreInfoLoading">
              <img src="../../assets/home2-7/seoReachRate.svg" />
              <div class="fr">
                <p>累计流量</p>
                <p >{{flowIndicator.uvAllCount  | filter_Null_format}}</p>
              </div>
            </a-spin>

          </div>
        </a-col>
      </template>
      <a-col :span="24" style="margin-top: 10px">
        <a-table :loading="coreDetailLoading" :columns="columns"  :rowKey="(record,index) => index" :pagination=false :data-source="coreDataTable">
<!--          <template slot="b" slot-scope="text,record">-->
<!--            {{text}}<a-icon type="arrow-up" style="color:red" />-->
<!--          </template>-->
<!--          <template slot="c" slot-scope="text,record">-->
<!--            {{text}}<a-icon type="arrow-down" style="color:#58CBA8" />-->
<!--          </template>-->
        </a-table>
        <p style="color: #999;font-size: 13px">注：今日数据每小时更新一次。</p>
      </a-col>

      <a-row  class="r5-1">
          <a-col :span="18" >
            <div class="fl">
              <a-button :type="timeChooseIndex == '7' ? 'primary' : ''" @click="changeTime('7')">最近7天</a-button>
              <a-button :type="timeChooseIndex == '30' ? 'primary' : ''" @click="changeTime('30')">最近30天</a-button>
              <a-button :type="timeChooseIndex == '180' ? 'primary' : ''" @click="changeTime('180')">最近六个月</a-button>
            </div>
            <div class="fr" v-if="coreDataChart.x.length > 0" >
              <span><i></i>UV</span> <span><i></i>PV</span>
            </div>
            <a-spin :spinning="coreDetailLoading" style="float: left;width:100%">
              <area-chart v-if="coreDataChart.x.length > 0" :dataSource="coreDataChart" ></area-chart>
              <a-empty v-else style="float: right;width: 100%;margin-top: 110px;"></a-empty>
            </a-spin>
          </a-col>
          <a-col :span="6"  >
            <a-spin :spinning="coreDetailLoading">
              <a-row :gutter="[20,20]">
                <a-col :span="12">
                  <div class="box b1">
                    <p class="num">{{averageVisit}}</p>
                    <p><img src="../../assets/home2-7/rijunfangwenshu.svg" />日均访问数</p>
                  </div>
                </a-col>
                <a-col :span="12">
                  <div class="box b2">
                    <p class="num">{{ averageVisitDuration }}</p>
                    <p><img src="../../assets/home2-7/pingjunfangwenshichang.svg" />平均会话时长</p>
                  </div>
                </a-col>
                <a-col :span="12">
                  <div class="box b3">
                    <p class="num">{{bounceRate}}</p>
                    <p><img src="../../assets/home2-7/tiaochulv.svg" />跳出率</p>
                  </div>
                </a-col>
                <a-col :span="12">
                  <div class="box b4">
                    <p class="num">{{averageVisitPage}}</p>
                    <p><img src="../../assets/home2-7/fangkepingjunfangwen.svg" />访客平均访问页面数</p>
                  </div>
                </a-col>
              </a-row>
            </a-spin>

          </a-col>
        </a-row>


    </a-row>

    <!--快捷使用-->
    <a-row  class="r3">
      <a-col><p class="title">快捷使用</p></a-col>
    </a-row>


    <!--建站角色-->
    <a-row class="r6" :gutter="[10,0]" v-if="userRole == 'adweb_site_manager'">
      <a-col :span="6">
        <router-link :to="{ path: '/website/productSummary/productList' }">
          <div class="wrap">
            <p>产品明细<img src="../../assets/home2-7/zhutiku.svg"/></p>
          </div>
        </router-link>
      </a-col>
      <a-col :span="6">
        <router-link :to="{ path: '/deliver/AdwebSiteManageList' }">
          <div class="wrap">
            <p>站点管理<img src="../../assets/home2-7/zhandianguanli.svg"/></p>
          </div>
        </router-link>
      </a-col>
      <a-col :span="6">
        <router-link :to="{ path: '/deliver/adwebsite' }">
          <div class="wrap">
            <p>建站进度<img src="../../assets/home2-7/jianzhanjindu.svg"/></p>
          </div>
        </router-link>
      </a-col>
      <a-col :span="6">
        <router-link :to="{ path: '/deliver/serp/packagePurchaseHistory/list' }">
          <div class="wrap">
            <p>套餐绑定<img src="../../assets/home2-7/wuliaojiance.svg"/></p>
          </div>
        </router-link>
      </a-col>
    </a-row>

    <!--SEO角色-->
    <a-row class="r6" :gutter="[10,0]" v-else-if="userRole == 'adweb_seo_manager'">
      <a-col :span="6">
        <router-link :to="{ path: '/marketing/keywordsWatch' }">
          <div class="wrap">
            <p>SEO关键词排名<img src="../../assets/home2-7/taocanguanli.svg"/></p>
          </div>
        </router-link>
      </a-col>
      <a-col :span="6">
        <router-link :to="{ path: '/deliver/serp/seoMarketPlan/list2' }">
          <div class="wrap">
            <p>套餐管理<img src="../../assets/home2-7/taocanbangding.svg"/></p>
          </div>
        </router-link>
      </a-col>
      <a-col :span="6">
        <router-link :to="{ path: '/operate/process' }">
          <div class="wrap">
            <p>SEO实施<img src="../../assets/home2-7/SEOshishi.svg"/></p>
          </div>
        </router-link>
      </a-col>
      <a-col :span="6">
        <router-link :to="{ path: '/operate/keywordsManage' }">
          <div class="wrap">
            <p>关键词管理<img src="../../assets/home2-7/guanjianciguanli.svg"/></p>
          </div>
        </router-link>
      </a-col>
    </a-row>

    <!--其他角色-->
    <a-row class="r6" type="flex" :gutter="[10,0]" v-else>
      <a-col :flex="1">
        <router-link :to="{ path: '/website/productSummary/productList' }">
          <div class="wrap">
            <p>产品明细<img src="../../assets/home2-7/chanpingmingxi.svg"/></p>
          </div>
        </router-link>
      </a-col>
      <a-col :flex="1">
        <router-link :to="{ path: '/inquiry/list' }">
          <div class="wrap">
            <p>询盘列表<img src="../../assets/home2-7/xunpanliebiao.svg"/></p>
          </div>
        </router-link>
      </a-col>
      <a-col :flex="1">
        <router-link :to="{ path: '/marketing/keywordsWatch' }">
          <div class="wrap">
            <p>关键词排名<img src="../../assets/home2-7/SEOxiaoguo.svg"/></p>
          </div>
        </router-link>
      </a-col>
      <a-col :flex="1">
        <router-link :to="{ path: '/tools/home' }">
          <div class="wrap">
            <p>工具箱<img src="../../assets/home2-7/gongjuxiang.svg"/></p>
          </div>
        </router-link>
      </a-col>
      <a-col :flex="1">
        <router-link :to="{ path: '/seo/jobcontent' }">
          <div class="wrap">
            <p>SEO优化细节<img src="../../assets/home2-7/gongjuxiang.svg"/></p>
          </div>
        </router-link>
      </a-col>
    </a-row>

    <!--服务团队-->
    <a-row  class="r3" v-if="false">
      <a-col><p class="title">服务团队</p></a-col>
    </a-row>
    <a-row class="r7" v-if="false">
      <a-col :span="12" v-for="item in customerList">
        <div class="wrap">
            <span>{{ item.serviceType }}</span>
            <span>{{ item.serviceName }}    {{item.phone}}    {{item.email}}</span>
        </div>
      </a-col>
    </a-row>

    <!-- 发版通知 -->
    <a-modal v-model="showHomeMsg" wrapClassName="faban" :footer="null" width="700px" :maskClosable="false" centered>
      <template slot="closeIcon">
        <span class="self-close"><a-icon type="close" /></span>
      </template>
      <div class="top-bg">
        <p>{{message.msgTitle}}</p>
      </div>
      <div class="info-wrap">
        <div v-html="splitText(message.msgContent)"></div>
        <img src="../../assets/home2-7/faban/bottom.svg" />
      </div>
    </a-modal>
  </div>
</template>

<script>
import dashChart from '../chart/DashChartDemo.vue'
import areaChart from '../chart/areaChart.vue'
import {getAction, getFileAccessHttpUrl, postAction} from '/@/api/manage/manage'
import {store}  from '/@/store'
import { useUserStore } from '/@/store/modules/user';
// import selectSite from '/@/components/adweb/selectSite.vue'

import '/@/views/dashboard/Analysis/less/home3.0.less';

const  columns = [
  {
    title: '指标',
    dataIndex: 'targetName',
  },
  {
    title: '今日',
    dataIndex: 'todayCount',
  },
  {
    title: '昨日',
    dataIndex: 'yesterdayCount',
    scopedSlots: { customRender: 'yesterdayCount' },
  },
  {
    title: '本周',
    dataIndex: 'currentWeekCount',
    scopedSlots: { customRender: 'currentWeekCount' },

  },
  {
    title: '上周',
    dataIndex: 'lastWeekCount',
  },
  {
    title: '本月',
    dataIndex: 'currentMonthCount',
  },
  {
    title: '上月',
    dataIndex: 'lastMonthCount',
  },
  {
    title: '全部',
    dataIndex: 'totalCount',
  }
]
export default {
  name: 'adwebHomeV2-7',
  components:{dashChart,areaChart},
  data(){
    return{
      parentValue:'父组件的值',
      userRole:'',
      columns,
      timeChooseIndex:'7',
      //网站概况
      siteinfo:[],
      selectSiteInfo:{},
      siteCode:'',
      baseInfo:{},
      baseInfoLoading:false,
      //物料完成情况
      enterpriseInfoList:[],
      enterpriseInfoOK:0,
      enterpriseInfoNO:0,
      enterpriseInfoPercent:0,
      newsInfoList:[],
      newsInfoOK:0,
      newsInfoNO:0,
      newsInfoPercent:0,
      productInfoList:[],
      productInfoOK:0,
      productInfoNO:0,
      productInfoPercent:0,
      infoLoading:false,
      //服务团队
      customerList:[],
      //核心数据
      coreInfoLoading:false,
      coreDetailLoading:false,
      achievePercent: 0,
      appointWordCount: 0,
      currentAchieveCount: 0,
      currentMonthEnquiryCount: 0,
      currentWeekEnquiryCount: 0,
      totalEnquiryCount: 0,
      flowIndicator:{},
      coreDataTable:[],
      coreDataChart:{
        x:[],
        uv:[],
        pv:[]
      },
      averageVisit: 0,
      averageVisitDuration: 0,
      averageVisitPage: 0,
      bounceRate: 0,
      showMaterialStatistics:false,
      promoteCustomerService:{},
      // 首页弹出消息
      showHomeMsg: false,
      message: {},
      isShow: false,
    }
  },
  created() {
    // 跳出消息通知弹窗
    this.getSysUpdateMsg();
  },
  mounted() {
    this.userRole =  useUserStore().roleList;
    this.getSiteInfo()
  },
  filters: {
    filter_Null_format(value) {
      if(value === '' || value === null || value === undefined){
        return  '--'
      }else{
        return value
      }
    }
  },
  methods:{
    // 从后台获取系统更新消息
    getSysUpdateMsg() {
      let that = this
      getAction('/message/adwebMessage/home/message').then(function (res) {
        console.log('首页弹出信息', res);
        if (res.code === 200 && res.result) {
          that.message = res.result;
          that.showHomeMsg = true;
          let msgId = res.result.id;
          postAction('/message/adwebMessage/readmessage?msgId=' + msgId);
        }
      })
    },
    splitText(text) {
      if (!text) {
        return '';
      }
      let res = '';
      let arr = text.split('\n');
      for (let item of arr) {
        res = res + '<p>' + item + '</p>\n';
      }
      return res;
    },
    getFileAccessHttpUrl,
    //保证先获取到站点列表，获取到siteCode及siteId后再进行此方法
    getAllInfo(){
      this.getBaseInfo()
      this.getMaterialStatistics()
      this.getCoreData()
      this.getCoreDataChart()
    },
    //进入获取站点code
    getSiteInfo() {
      let that = this
      getAction('/sys/api/getSiteListByUid').then(function (res) {
        if (res.code == 0) {
          that.siteinfo = res.data
          let isInSite = false
          for (let i in res.data){
            if(localStorage.getItem('siteCode') !== null && res.data[i].code === localStorage.getItem('siteCode')){
              isInSite = true
              that.selectSiteInfo = res.data[i]
            }
          }
          if (localStorage.getItem('siteCode') !== null && isInSite) {
            that.siteCode = localStorage.getItem("siteCode")
          }else {
            that.siteCode = res.data[0].code
            that.selectSiteInfo = res.data[0]
            localStorage.setItem("siteCode",res.data[0].code)
          }
          that.getAllInfo()
        } else {
          that.$message.error('站点获取失败，请刷新重试')
        }
      })
    },

    //改变站点
    changeUser(value,e) {

      this.siteCode = value
      this.selectSiteInfo = e.data.attrs.info
      this.showMaterialStatistics = false
      this.getAllInfo()
    },
    //站点搜索
    filterOption(input, option) {
      return (
        option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
      )
    },
    //获取基础信息
    getBaseInfo(){
      let that = this
      let d = {
        siteCode:that.siteCode
      }
      that.baseInfoLoading = true
      getAction('/serp/averApiSearchKeywords/siteBasicInfo',d).then(function (res) {
        that.baseInfoLoading = false
        if (res.code == 200) {
          that.baseInfo = res.result
          that.isShow=true;
        } else {
          that.$message.error('获取站点基础信息失败，请刷新重试')
        }
      })
    },
    //获取物料完成情况
    resetMaterialStatistics(){
      this.enterpriseInfoList=[]
      this.enterpriseInfoOK=0
      this.enterpriseInfoNO=0
      this.enterpriseInfoPercent=0
      this.newsInfoList=[]
      this.newsInfoOK=0
      this.newsInfoNO=0
      this.newsInfoPercent=0
      this.productInfoList=[]
      this.productInfoOK=0
      this.productInfoNO=0
      this.productInfoPercent=0
    },
    getMaterialStatistics(){
      let that = this
      let d = {
        siteCode:that.siteCode
      }
      that.infoLoading = true
      getAction('/materialcollect/materialStatistics',d).then(function (res) {
        that.infoLoading = false
        that.resetMaterialStatistics()
        if (res.code == 200) {
          if(res.result.status == '已发布'){
            that.showMaterialStatistics = false
          }else{
            that.showMaterialStatistics = true
          }

          that.enterpriseInfoList = res.result.enterpriseInfo.detectList
          if(res.result.enterpriseInfo.detectList.length > 0){
            for(let i in res.result.enterpriseInfo.detectList){
              if(res.result.enterpriseInfo.detectList[i].finish){
                that.enterpriseInfoOK++
              }else{
                that.enterpriseInfoNO++
              }
            }
          }
          that.enterpriseInfoPercent = res.result.enterpriseInfo.percent
          that.newsInfoList = res.result.newsInfo.detectList
          if(res.result.newsInfo.detectList.length > 0){
            for(let i in res.result.newsInfo.detectList){
              if(res.result.newsInfo.detectList[i].finish){
                that.newsInfoOK++
              }else{
                that.newsInfoNO++
              }
            }
          }
          that.newsInfoPercent = res.result.newsInfo.percent
          that.productInfoList = res.result.productInfo.detectList
          if(res.result.productInfo.detectList.length > 0){
            for(let i in res.result.productInfo.detectList){
              if(res.result.productInfo.detectList[i].finish){
                that.productInfoOK++
              }else{
                that.productInfoNO++
              }
            }
          }
          that.productInfoPercent = res.result.productInfo.percent
        }else if(res.code == 500){
          that.showMaterialStatistics = true
          that.$message.warning(res.message)
        }else {
          that.showMaterialStatistics = false
          that.$message.error('获取站点获取物料完成情况失败，请刷新重试')
        }
      })
    },

    //获取核心数据
    getCoreData(){
      // http://127.0.0.1:8080/adwebv21/adweb/dashboard/coreData/info?siteCode=2111237a6q9m&siteId=1069
      let that = this
      let d = {
         siteCode:that.siteCode,
        // siteId:'1069',
        // siteCode:'2111237a6q9m'
      }
      that.coreInfoLoading = true
      that.flowIndicator = {};
      getAction('/adweb/dashboard/coreData/info',d).then(function (res) {
        that.coreInfoLoading = false
        if (res.code == 0) {
          that.achievePercent = res.data.achievePercent
          that.appointWordCount = res.data.appointWordCount
          that.currentAchieveCount = res.data.currentAchieveCount
          that.currentMonthEnquiryCount = res.data.currentMonthEnquiryCount
          that.currentWeekEnquiryCount = res.data.currentWeekEnquiryCount
          that.totalEnquiryCount = res.data.totalEnquiryCount
          that.flowIndicator = res.data.flowIndicator
        } else {
          that.$message.error('获取核心数据信息失败，请刷新重试')
        }
      })
    },
    //改变图表的时间维度
    changeTime(time){
      this.timeChooseIndex = time
      this.getCoreDataChart()
    },
    //核心数据的面积图
    getCoreDataChart(){
      let that = this
      let d = {
         siteCode:that.siteCode,
        // siteId:'1069',
        // siteCode:'2111237a6q9m',
        days:that.timeChooseIndex
      }
      that.coreDetailLoading = true
      getAction('/adweb/dashboard/coreData/detail',d).then(function (res) {
        that.coreDetailLoading = false
        if (res.code == 0) {
          let r = res.data
          that.averageVisit = r.averageVisit == null ? '0' : r.averageVisit
          that.averageVisitDuration = r.averageVisitDuration == null ? '0' : r.averageVisitDuration
          that.averageVisitPage = r.averageVisitPage == null ? '0' : r.averageVisitPage
          that.bounceRate = r.bounceRate == null ? '0' : r.bounceRate
          that.coreDataTable = r.countInfo  == null ? [] : r.countInfo
          let x = [] ,pv = [] ,uv = []
          if(r.trendInfo!=null && r.trendInfo.length > 0){
            for(let i in r.trendInfo){
              x.push(r.trendInfo[i].date)
              pv.push(r.trendInfo[i].pvCount)
              uv.push(r.trendInfo[i].uvCount)
            }
          }
          that.coreDataChart.x = x
          that.coreDataChart.pv = pv
          that.coreDataChart.uv = uv
        } else {
          that.averageVisit = '0'
          that.averageVisitDuration ='0'
          that.averageVisitPage = '0'
          that.bounceRate = '0'
          that.coreDataTable = []
          that.coreDataChart.x = []
          that.coreDataChart.pv = []
          that.coreDataChart.uv = []
          that.$message.error('获取核心数据图表信息失败，请刷新重试')
        }
      })
    },

  }
}
</script>

<style lang="less">
.home{
  .ant-select{
    color: #fff;
    .ant-select-selection{
      background-color: transparent;
    }
    .ant-select-arrow{
      color: #fff;
    }
  }
}

</style>

<style scoped lang="less">
p,span{
  color: #000;
  margin: 0;
}
.theme-color{
  color: @primary-color;
}
.title{
  font-size: 18px;
  color: #000;
}


</style>

<style lang="less">
.pop-wrap{
  .ant-popover-inner-content{
    padding: 0;
  }

  .wrap{
    width: 400px;
    padding: 20px 20px;
    background: url("../../assets/home2-7/pop-bg.svg") no-repeat;
    background-position: bottom right;
    p{
      line-height: 1.8;
      i{
        color: @primary-color;
        margin-right: 10px;
      }
    }
    .name{
      font-size: 18px;
      margin-bottom: 20px;
    }

    .job{
      font-size: 15px;
      color: #9f9f9f;
    }

    .ant-col-8{
      text-align: right;
    }
  }
}
.faban{
  .ant-modal{
    .ant-modal-content{
      background-color: transparent;
      box-shadow: none;
      .ant-modal-close{
        top: 70px;
        right: -10px;
        .ant-modal-close-x{
          width: auto;
          height: auto;
        }
      }
      .self-close{
        i{
          color: #fff;
          border: 1px solid #fff;
          border-radius: 50%;
          width: 25px;
          height: 25px;
          display: block;
          line-height: 25px;
        }
      }
      .ant-modal-body{
        .top-bg{
          background: url("../../assets/home2-7/faban/topbg.png") no-repeat;
          min-height: 242px;
          background-size: 100% 100%;
          display: flex;
          justify-content: center;
          align-items: flex-end;
          font-size: 38px;
          padding-bottom: 60px;
          p{
            color: #fff;
          }
        }
        .info-wrap{
          background: #fff;
          padding: 0 40px;
          overflow: hidden;
          border-bottom-left-radius: 15px;
          border-bottom-right-radius: 15px;
          margin-top: -1px;
          p{
            position: relative;
            padding-left: 30px;
            margin-bottom: 5px;
            letter-spacing: 1px;
            &:before{
              content: '';
              position: absolute;
              left: 0;
              width: 15px;
              height: 15px;
              background: url("../../assets/home2-7/faban/dot.svg");
              background-repeat: no-repeat;
              top: 3px;
            }
          }
          img{
            width: 70px;
            float: right;
            padding: 40px 0;
          }
        }
      }

    }

  }
}
</style>
