<template>
  <div class="app-container">
    <div class="mb10">
      <el-input
        class="w260 mb10"
        clearable
        v-model="queryParams.nickName"
        placeholder="请输入用户"
      />
      <el-input
        class="w260 mb10"
        clearable
        v-model="queryParams.phone"
        :placeholder="settingToC ? '客户账号' : '客户手机号'"
      />
      <!-- <el-input
          class="w260 mb10"
          clearable
          v-model="queryParams.zjzh"
          placeholder="资金账号"
        /> -->
      <!-- <el-select class="mb10" clearable v-model="queryParams.comId" filterable placeholder="分公司">
              <el-option v-for="item in isOfColumnList" :key="item.value" :label="item.label" :value="item.value">
              </el-option>
            </el-select> -->
      <!-- <el-select
        class="mb10"
        clearable
        v-model="queryParams.deptId"
        filterable
        placeholder="营业部"
      >
        <el-option
          v-for="item in deptList"
          :key="item.id"
          :label="item.name"
          :value="item.id"
        >
        </el-option>
      </el-select> -->
      <el-select
        class="mb10"
        clearable
        v-model="queryParams.isSub"
        filterable
        placeholder="是否订阅产品"
      >
        <el-option
          v-for="item in isSubList"
          :key="item.value"
          :label="item.label"
          :value="item.value"
        >
        </el-option>
      </el-select>
      <!-- <el-select
          class="mb10"
          clearable
          v-model="queryParams.saleUserId"
          filterable
          placeholder="营销人员"
          v-if="user.roles[0] !== '运营'"
        >
          <el-option
            v-for="item in userList"
            :key="item.id"
            :label="item.name"
            :value="item.id"
          >
          </el-option>
        </el-select> -->
      <el-button type="primary" @click="searchList()">查询</el-button>
      <el-button type="success" :loading="downloadLoading" @click="toExport"
        >导出</el-button
      >
    </div>
    <div class="mb10">
      <el-table
        key="tableData"
        :data="data"
        v-loading="loading"
        border
        style="width: 100%"
      >
        <el-table-column label="序号" type="index" fixed width="180">
        </el-table-column>
        <el-table-column prop="nickName" label="用户昵称" width="180">
        </el-table-column>
        <el-table-column prop="zjzh" label="资金账号" width="180">
        </el-table-column>
        <el-table-column
          prop="phone"
          :label="settingToC ? '客户账号' : '客户手机号'"
          width="180"
        >
        </el-table-column>
        <!-- <el-table-column prop="comName" label="所属分公司" width="180">
          </el-table-column> -->
        <!-- <el-table-column prop="saleDeptName" label="所属营业部" width="180">
        </el-table-column> -->
        <!-- <el-table-column prop="saleUserName" label="营销经理名称" width="180">
          </el-table-column>
          <el-table-column prop="saleUserId" label="营销经理ID" width="180">
          </el-table-column> -->
        <el-table-column prop="readHours" label="关注主播数" width="180">
          <template slot-scope="scope">
            <el-button type="text" @click="toDetail(scope.row)">{{
              scope.row.subAdvisorCount
            }}</el-button>
          </template>
        </el-table-column>
        <el-table-column prop="messCount" label="观看直播数" width="180">
          <template slot-scope="scope">
            <el-button type="text" @click="toDetail(scope.row)">{{
              scope.row.watchVideoCount
            }}</el-button>
          </template>
        </el-table-column>
        <el-table-column
          prop="watchVideoHours"
          label="观看直播时长"
          width="180"
        >
          <template #default="scope">
            {{
              scope.row.watchVideoHours
                ? timeFormat(scope.row.watchVideoHours * 1000)
                : "00:00:00"
            }}
          </template>
        </el-table-column>
        <el-table-column prop="messCount" label="互动条数" width="180">
        </el-table-column>
        <el-table-column prop="likeCount" label="点赞数" width="180">
        </el-table-column>
        <el-table-column prop="shareCount" label="分享数" width="180">
        </el-table-column>
        <el-table-column prop="browseProCount" label="浏览产品数" width="180">
        </el-table-column>
        <el-table-column prop="subProCount" label="已订阅产品数" width="180">
        </el-table-column>
        <el-table-column
          prop="name"
          label="操作"
          align="center"
          fixed="right"
          width="200"
        >
          <template slot-scope="scope">
            <el-button type="text" @click="clickDateil(scope.row)"
              >查看详情</el-button
            >
          </template>
        </el-table-column>
      </el-table>
    </div>
    <!--分页组件-->
    <el-pagination
      :total="total"
      :current-page="queryParams.current"
      :page-size="queryParams.size"
      layout="total, sizes, prev, pager, next, jumper"
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
    />

    <el-dialog
      title="客户详情"
      :visible.sync="dialogTableVisible"
      :append-to-body="true"
      width="80%"
    >
      <div class="box-dialog">
        <div class="box-one">
          <div class="box-one_left">
            <img src="@/assets/logo/默认头像.png" class="user-avatar" />
            <div class="left-box">
              <!-- <div class="left-one">{{ clickItem.nickName }}</div> -->
              <div class="left-three">
                用户名：{{ clickItem.phone || clickItem.nickName }}
              </div>
              <div class="left-two">昵称：{{ clickItem.zjzh }}</div>
            </div>
          </div>
          <div class="box-one_right">
            <div class="right-one">风测等级</div>
            <div class="right-two">
              {{ riskLevelList[clickItem.riskLevel] }}
            </div>
          </div>
        </div>
        <div class="box-two">
          <!-- <div style="margin-right:10px;">分公司：{{ clickItem.comName }}</div> -->
          <!-- <div style="margin-right:10px;">营业部：{{  }}</div> -->
          <!-- <div v-if="user.roles[0] !== '运营'">
              营销经理：{{ clickItem.saleUserName }}
            </div> -->
        </div>
      </div>
      <el-tabs v-model="activeName" @tab-click="handleClick">
        <!-- <el-tab-pane label="订单信息" name="1"></el-tab-pane> -->
        <el-tab-pane label="直播观看记录" name="2"></el-tab-pane>
      </el-tabs>
      <div v-if="activeName === '1'" class="box-item">
        <div v-for="(item, index) in orderList" class="item">
          <div class="item-one">{{ item.label }}</div>
          <div v-if="item.value === 'orderPayAmount'">
            {{ (clickItem[item.value] / 100).toFixed(2) }}
          </div>
          <div v-else>{{ clickItem[item.value] || 0 }}</div>
        </div>
      </div>
      <div v-if="activeName === '2'" class="box-item">
        <div v-for="(item, index) in viewList" class="item">
          <div class="item-one">{{ item.label }}</div>
          <div v-if="item.value === 'finishReadRate'">
            {{ (clickItem[item.value] * 100).toFixed(2) + "%" }}
          </div>
          <div v-else-if="item.value === 'totalWatchHours'">
            {{
              clickItem[item.value]
                ? timeFormat(clickItem[item.value] * 1000)
                : "00:00:00"
            }}
          </div>
          <div v-else>{{ clickItem[item.value] || 0 }}</div>
        </div>
      </div>

      <div v-if="activeName === '1'">
        <el-button
          @click="selected(index)"
          :class="{ selected: selectedButton === index }"
          v-for="(item, index) in buttonText"
          plain
          >{{ item }}</el-button
        >
      </div>
      <div v-if="activeName === '2'">
        <el-button
          @click="selected(index)"
          :class="{ selected: selectedButton === index }"
          v-for="(item, index) in buttonTextTwo"
          plain
          >{{ item }}</el-button
        >
      </div>
      <el-table key="gridData" :data="gridData" v-if="activeName === '1'">
        <el-table-column
          align="center"
          type="index"
          width="60"
          label="序号"
          fixed="left"
        />
        <el-table-column prop="orderId" label="订单ID" width="180px">
        </el-table-column>
        <el-table-column prop="customCode" label="用户名" width="120px" />
        <el-table-column prop="customMobile" label="手机号" width="120px" />
        <el-table-column
          prop="customAccount"
          label="客户资金账户"
          width="110px"
        />
        <!-- <el-table-column  label="客户姓名" width="130px" >
        <template #default="scope">
          {{scope.row.customName}}
          </template>
        </el-table-column> -->
        <el-table-column prop="productType" label="产品类型" width="110px">
          <template #default="scope">
            <span v-if="scope.row.productType == 1">基础产品</span>
            <span v-else-if="scope.row.productType == 2">套餐产品</span>
            <span v-else></span>
          </template>
        </el-table-column>
        <el-table-column prop="productId" label="产品ID" width="100px" />
        <el-table-column prop="productName" label="产品名称" width="100px" />
        <el-table-column
          prop="categoryName"
          label="产品分类名称"
          width="110px"
        />
        <el-table-column prop="moduleStart" label="生效时间" width="180px" />
        <el-table-column prop="moduleEnd" label="到期时间" width="180px" />
        <el-table-column prop="payType" label="支付方式" width="100px">
          <template #default="scope">
            <span>{{ pay_type_words[scope.row.payType] || "" }} </span>
          </template>
        </el-table-column>

        <el-table-column prop="payId" label="微信/支付订单号" width="260px" />
        <el-table-column prop="payTime" label="支付时间" width="180px" />
        <el-table-column prop="totalPrice" label="总价(元)">
          <template #default="scope">
            {{ (scope.row.totalPrice / 100).toFixed(2) }}
          </template>
        </el-table-column>
        <el-table-column prop="payPrice" label="支付价(元)" width="100px">
          <template #default="scope">
            {{ (scope.row.payPrice / 100).toFixed(2) }}
          </template>
        </el-table-column>
        <el-table-column prop="rate" label="费率" width="100px">
          <template #default="scope">
            {{ scope.row.rate ? `${scope.row.rate * 1000}‰` : "-" }}
          </template>
        </el-table-column>
        <el-table-column prop="couponId" label="优惠券" width="180px" />
        <el-table-column prop="couponType" label="优惠券类型" width="180px">
          <template #default="scope">
            <span>{{ coupon_type_map[scope.row.couponType] || "" }}</span>
          </template>
        </el-table-column>
        <el-table-column
          prop="couponValue"
          label="优惠券赠送天数/月份"
          width="180px"
        >
          <template #default="scope">
            <span>{{
              scope.row.couponType == 1
                ? `${scope.row.couponValue}${
                    scope.row.couponFreeType == 1 ? "天" : "月"
                  }`
                : ""
            }}</span>
          </template>
        </el-table-column>

        <el-table-column
          prop="couponIdOne"
          label="优惠金额/折扣率"
          width="180px"
        >
          <template #default="scope">
            <span>{{
              [2, 3].includes(scope.row.couponType)
                ? `${(scope.row.couponValue / 100).toFixed(2)}`
                : ""
            }}</span>
          </template>
        </el-table-column>

        <el-table-column prop="isRenewal" label="是否续费订单" width="110px">
          <template #default="scope">
            <span>{{ renewal_map[scope.row.isRenewal] || "" }}</span>
          </template>
        </el-table-column>
        <!-- <el-table-column
          prop="customRiskLevel"
          label="客户风险等级"
          width="110px"
        >
          <template #default="scope">
            <span>{{ risk_levels[scope.row.customRiskLeve] || "" }}</span>
          </template>
        </el-table-column> -->
        <el-table-column
          prop="productRiskLevel"
          label="产品风险等级"
          width="110px"
        >
          <template #default="scope">
            <span>{{ risk_levels[scope.row.productRiskLevel] || "" }}</span>
          </template>
        </el-table-column>
        <el-table-column prop="productPeriod" label="产品周期" width="100px">
          <template #default="scope">
            <span v-if="scope.row.productPeriod != 6">{{
              pay_cycle[scope.row.productPeriod] || ""
            }}</span>
            <span v-else-if="scope.row.productPeriod == 6"
              >{{ scope.row.productPeriodDay }}天</span
            >
          </template>
        </el-table-column>
        <el-table-column prop="refereeld" label="推荐人工号" width="100px" />
        <el-table-column prop="platform" label="订单开通方式" width="110px">
          <template #default="scope">
            {{ scope.row.platform == 1 ? "支付购买" : "免费开通" }}
          </template>
        </el-table-column>

        <el-table-column prop="tgName" label="投顾账号" width="120px" />
        <!-- <el-table-column prop="tgComName" label="所属分公司" width="120px" /> -->
        <!-- <el-table-column prop="tgExchangeName" label="所属营业部" width="120px" /> -->
        <!-- <el-table-column prop="categoryId" label="产品分类ID" width="100px" /> -->
        <el-table-column
          prop="liveProductId"
          label="是否是直播带货订单"
          width="150px"
        >
          <template #default="scope">
            <span>{{ scope.row.liveProductId ? "是" : "否" }}</span>
          </template>
        </el-table-column>
        <el-table-column prop="liveName" label="带货直播名称" width="120px">
          <template #default="scope">
            <span>{{ scope.row.liveName }}</span>
          </template>
        </el-table-column>
        <el-table-column prop="channel" label="订单渠道" width="90px">
          <template #default="scope">
            <span>{{ channel_map[scope.row.channel] || "" }}</span>
          </template>
        </el-table-column>
        <!-- <el-table-column prop="campaign" label="免费订单来源" width="110px">
          <template #default="scope">
            <span>{{ free_order_campaign_map[scope.row.campaign] || "" }}</span>
          </template>
        </el-table-column> -->
        <el-table-column prop="status" label="订单状态" width="100px">
          <template #default="scope">
            <span>{{
              [3, 4].includes(scope.row.payType)
                ? pay_status_words_ty[scope.row.status]
                : pay_status_words[scope.row.status] || ""
            }}</span>
          </template>
        </el-table-column>
        <el-table-column prop="orderTime" label="下单时间" width="180px" />
        <el-table-column prop="updateTime" label="订单更新时间" width="180px" />
        <el-table-column prop="refundApply" label="退款申请人" width="100px" />
        <el-table-column prop="refundAmount" label="退款金额(元)" width="110px">
          <template #default="scope">
            <span>{{ scope.row.refundAmount / 100 || "" }}</span>
          </template>
        </el-table-column>
        <el-table-column prop="refundReason" label="退款理由" width="100px" />
        <el-table-column
          prop="refundApplyTime"
          label="退款申请时间"
          width="180px"
        />
        <el-table-column prop="operator" label="退款审核人" width="110px" />
        <el-table-column prop="checkStatus" label="退款审核状态" width="110px">
          <template #default="scope">
            <span v-if="scope.row.checkStatus == 0 && scope.row.refundCheckTime"
              >驳回</span
            >
            <span
              v-else-if="
                scope.row.checkStatus == 1 && scope.row.refundCheckTime
              "
              >申请中</span
            >
            <span
              v-else-if="
                scope.row.checkStatus == 2 && scope.row.refundCheckTime
              "
              >通过</span
            >
            <span v-else></span>
          </template>
        </el-table-column>
        <el-table-column prop="checkReason" label="审核意见" width="100px" />
        <el-table-column
          prop="refundCheckTime"
          label="退款审核时间"
          width="180px"
        />
        <el-table-column
          prop="refundEndTime"
          label="退款成功时间"
          width="180px"
        />
      </el-table>

      <el-table key="gridDataTwo" :data="gridDataTwo" v-if="activeName === '2'">
        <el-table-column label="直播时间" fixed width="180">
          <template slot-scope="scope">
            {{ scope.row.startTime }} ~ {{ scope.row.endTime }}
          </template>
        </el-table-column>
        <el-table-column label="序号" type="index" width="90">
        </el-table-column>
        <el-table-column prop="title" label="直播名称" width="180">
        </el-table-column>
        <el-table-column prop="name" label="标签" width="180">
          <template slot-scope="scope">
            <span v-for="item in scope.row.tagVOList" :key="item.id">{{
              item.name
            }}</span>
          </template>
        </el-table-column>
        <el-table-column prop="advisorName" label="投顾名称" width="180">
        </el-table-column>
        <!-- <el-table-column prop="comName" label="分公司" width="180">
          </el-table-column> -->
        <el-table-column prop="deptName" label="营业部" width="180">
        </el-table-column>
        <el-table-column prop="saleUserName" label="营销经理名称" width="180">
        </el-table-column>
        <el-table-column label="是否为专栏直播" width="180">
          <template slot-scope="scope">
            {{ scope.row.columnId ? "是" : "否" }}
          </template>
        </el-table-column>
        <el-table-column label="所属专栏" width="180">
          <template slot-scope="scope">
            {{ scope.row.columnName }}
          </template>
        </el-table-column>

        <el-table-column prop="hours" label="观看时长" width="180">
          <template #default="scope">
            {{
              scope.row.hours ? timeFormat(scope.row.hours * 1000) : "00:00:00"
            }}
          </template>
        </el-table-column>
        <el-table-column prop="messCount" label="互动评论数" width="180">
        </el-table-column>
        <el-table-column prop="favorCount" label="点赞数" width="180">
        </el-table-column>
        <el-table-column prop="isShare" label="是否分享直播" width="180">
          <template slot-scope="scope">
            {{ scope.row.isShare === 1 ? "是" : "否" }}
          </template>
        </el-table-column>
        <el-table-column label="是否领取了优惠券" width="180">
          <template slot-scope="scope">
            {{ scope.row.hasGotCoupon === 1 ? "是" : "否" }}
          </template>
        </el-table-column>
        <el-table-column label="是否浏览产品" width="180">
          <template slot-scope="scope">
            {{ scope.row.hasSeenCart === 1 ? "是" : "否" }}
          </template>
        </el-table-column>
        <el-table-column prop="productInfoVOS" label="浏览产品名称" width="180">
          <template slot-scope="scope">
            {{
              Array.isArray(scope.row.productInfoVOS) &&
              scope.row.productInfoVOS.length > 0
                ? output(scope.row.productInfoVOS)
                : ""
            }}
          </template>
        </el-table-column>
        <el-table-column label="是否订阅产品" width="180">
          <template slot-scope="scope">
            {{ scope.row.hasBoughtPro === 1 ? "是" : "否" }}
          </template>
        </el-table-column>
        <el-table-column label="订阅产品名称" width="180">
          <template slot-scope="scope">
            {{
              Array.isArray(scope.row.hasBoughtProName) &&
              scope.row.hasBoughtProName.length > 0
                ? scope.row.hasBoughtProName.join(",")
                : ""
            }}
          </template>
        </el-table-column>
      </el-table>
    </el-dialog>
  </div>
</template>
<script>
import {
  customerList,
  tagList,
  livePlayInfo,
  infoSubmit,
  cartList,
  uVideoControl,
  updateStatus,
  recommendSave,
  deptColumnList,
  customerDetails,
  videoReadRecord
} from "@/api/videoLive";
import { list } from "@/api/user";
import { queryOrderList } from "@/api/order";
import Clipboard from "clipboard";
import { mapGetters, mapState } from "vuex";
import {
  PAY_TYPE_WORDS,
  RENEWAL_MAP,
  RISK_LEVELS,
  CHANNEL_MAP,
  FREE_ORDER_CAMPAIGN_MAP,
  PAY_STATUS_WORDS,
  PAY_STATUS_WORDS_TY,
  PAY_CYCLE,
  COUPON_TYPE_MAP
} from "@/utils/options";
import { timeFormat } from "@/utils/index";
export default {
  data() {
    return {
      pay_type_words: PAY_TYPE_WORDS,
      renewal_map: RENEWAL_MAP,
      risk_levels: RISK_LEVELS,
      channel_map: CHANNEL_MAP,
      free_order_campaign_map: FREE_ORDER_CAMPAIGN_MAP,
      pay_status_words: PAY_STATUS_WORDS,
      pay_status_words_ty: PAY_STATUS_WORDS_TY,
      pay_cycle: PAY_CYCLE,
      coupon_type_map: COUPON_TYPE_MAP,
      queryParams: {
        current: 1,
        size: 10,
        deptId: null,
        saleUserId: null,
        userType: 2 // 用户类型 1 投顾 2 营销 3 运营 4 合规风控
      },
      total: 1,
      loading: false,
      isSubList: [{ value: 1, label: "是" }, { value: 2, label: "否" }],
      liveStatusList: [
        { value: 1, label: "未开始" },
        { value: 2, label: "直播中" },
        { value: 3, label: "已结束" },
        { value: 4, label: "暂停中" }
      ],
      statusList: [
        { value: 1, label: "待提交" },
        { value: 2, label: "待审核" },
        { value: 3, label: "已上架" },
        { value: 4, label: "已驳回" },
        { value: 5, label: "已下架" }
      ],
      orderList: [
        { value: "orderPayAmount", label: "累计付费金额" },
        { value: "payCashNum", label: "累计现金签约数" },
        { value: "payCommissionNum", label: "累计提佣签约数" },
        { value: "refundNum", label: "累计退款/解约数" },
        { value: "orderUnPayNum", label: "累计下单未支付" }
      ],
      viewList: [
        { value: "totalWatchCount", label: "累计观看数" },
        { value: "totalWatchHours", label: "累计观看时长" },
        { value: "totalMessCount", label: "累计评论数" },
        { value: "totalFavorCount", label: "累计点赞数" },
        { value: "finishReadRate", label: "完播率" }
      ],
      statusListLabel: ["", "待提交", "待审核", "已上架", "已驳回", "已下架"],
      liveLabel: ["", "未开始", "直播中", "已结束", "暂停中"],
      limitTypeList: {
        1: "不限制",
        2: "手机号",
        3: "邀请码"
      },
      riskLevelList: {
        1: "低风险",
        2: "中低风险",
        3: "中风险",
        4: "中高风险",
        5: "高风险"
      },
      tagIdList: [],
      data: [],
      gridData: [],
      gridDataTwo: [],
      dialogTableVisible: false,
      dialogInputVisible: false,
      dialogTableRecommend: false,
      optionsTag: [],
      loadingTag: false,
      dialogForm: {
        pushUrl: "",
        playUrl: ""
      },
      recommendForm: {
        title: "",
        weight: "",
        option: 1,
        id: null
      },
      productTypeList: {
        3: "视频"
      },
      copyText: "",
      rules: {
        weight: [
          { required: true, message: "请输入标题", trigger: "blur" },
          { min: 1, max: 50, message: "长度在 1 到 50 个字符", trigger: "blur" }
        ]
      },
      deptList: [],
      downloadLoading: false,
      activeName: "2",
      selectedButton: 0,
      buttonText: [
        "全部订单",
        "支付成功",
        "下单未支付",
        "已退款/解约",
        "服务中",
        "已到期"
      ],
      buttonTextTwo: [
        "全部直播",
        "参与互动的直播",
        "浏览过产品的直播",
        "领取过优惠券的直播",
        "签约过产品的直播"
      ],
      clickItem: {},
      gridDataParams: {
        current: 1,
        size: 10
      },
      userList: []
    };
  },
  computed: {
    ...mapGetters(["user"]),
    ...mapState({
      settingToC: state => state.settings.settingToC
    })
  },
  mounted() {
    this.queryList();
    this.getColumnList();
    this.$nextTick(() => {
      this.init();
    });
  },

  methods: {
    timeFormat,
    handleClick(tab, event) {
      this.gridData = [];
      this.gridDataTwo = [];
      this.selected(0);
    },
    selected(index) {
      this.selectedButton = index;
      this.toProductList();
    },
    getColumnList() {
      deptColumnList({ type: 2 }).then(res => {
        if (res.code === 0) {
          this.deptList = res.data;
        }
      });
    },
    async toExport() {
      this.downloadLoading = true;

      const params = JSON.parse(JSON.stringify(this.queryParams));
      params.size = 99;
      const { data, code, message } = await customerList(params);

      if (code === 0) {
        import("@/utils/export2Excel").then(excel => {
          const tHeader = [
            "用户昵称",
            "资金账号",
            "客户账号",
            // "所属分公司",
            // "所属营业部",
            //   "营销经理名称",
            //   "营销经理ID",
            "关注主播数",
            "观看直播数",
            "观看直播时长",
            "互动条数",
            "点赞数",
            "分享数",
            "浏览产品数",
            "已订阅产品数"
          ];
          const filterVal = [
            "nickName",
            "zjzh",
            "phone",
            // "comName",
            // "deptName",
            //   "saleUserName",
            //   "saleUserId",
            "subAdvisorCount",
            "watchVideoCount",
            "watchVideoHours",
            "messCount",
            "likeCount",
            "shareCount",
            "browseProCount",
            "subProCount"
          ];
          const excelData = this.formatJson(filterVal, data.list);
          excel.export_json_to_excel({
            header: tHeader,
            data: excelData,
            filename: "客户管理"
          });
          console.log("list=>", data.list);
        });
      } else {
        this.$message.error(message);
      }
      this.downloadLoading = false;
    },
    formatJson(filterVal, jsonData) {
      return jsonData.map(v =>
        filterVal.map(j => {
          if (j === "tagVOList") {
            return v[j].map(item => {
              return item.name;
            });
          } else if (j === "advisorBasic") {
            return v[j] ? v[j].name : "";
          } else if (j === "columnId") {
            return v[j] ? "是" : "否";
          } else if (j === "riskLevel") {
            return this.riskLevelList[v[j]];
          } else if (j === "watchVideoHours") {
            return this.timeFormat(v[j] * 1000);
          } else {
            return v[j];
          }
        })
      );
    },
    async init() {
      const data = { current: 1, size: 999, roleId: 5 };
      const res = await list(data);
      if (res.code === 0) {
        this.userList = res.data.list;
      } else {
        this.$message.error(res.message);
      }
    },
    queryList() {
      this.loading = true;
      customerList(this.queryParams).then(data => {
        this.data = data.data.list;
        this.total = data.data.total;
        this.loading = false;
      });
    },
    searchList() {
      this.queryParams.size = 10;
      this.queryParams.current = 1;
      this.queryList();
    },
    handleSizeChange(val) {
      this.$set(this.queryParams, "size", val);
      this.$set(this.queryParams, "current", 1);
      this.queryList();
    },
    handleCurrentChange(val) {
      this.$set(this.queryParams, "current", val || 1);
      this.queryList();
    },
    clickDateil(val) {
      customerDetails({ userId: val.id }).then(res => {
        if (res.code === 0) {
          this.clickItem = res.data;
          this.selected(0);
          this.dialogTableVisible = true;
        }
      });
    },
    toProductList(item) {
      if (this.activeName === "2") {
        const data = {
          type: this.selectedButton,
          userId: this.clickItem.id
        };
        videoReadRecord(data).then(res => {
          if (res.code === 0) {
            this.gridDataTwo = res.data;
          } else {
            this.$message.error("获取失败!");
          }
        });
      } else {
        // 订单映射对应status
        const type = {
          0: null,
          1: 2,
          2: "1,7",
          3: 4,
          4: "2,3,5",
          5: 6
        };
        const data = {
          customCode: this.clickItem.id,
          liveMarketId: this.clickItem.saleUserId,
          status: type[this.selectedButton],
          size: 999,
          current: 1
        };
        queryOrderList(data).then(res => {
          if (res.code === 0) {
            this.gridData = res.data.list;
          }
        });
      }
    },
    toDetail(val) {},
    output(value) {
      let name = value.map(item => item.productName);
      return name.join(",");
    }
  }
};
</script>

<style scoped lang="scss">
.box {
  padding: 20px;
}

.mb10 {
  margin-bottom: 10px;
}

.flex-box {
  display: inline-flex;
  flex-direction: row;

  &_item {
    display: inline-flex;
    flex-direction: column;
    margin-right: 10px;
    cursor: pointer;
    background-color: rgb(255, 255, 255);
    align-self: center;

    div {
      padding: 5px 0;
      display: inline-flex;
      align-self: center;
    }
  }
}

.charts-box {
  padding: 20px;
  width: 60%;
}

.w260 {
  width: 260px;
}
.box-dialog {
  width: 100%;
  display: flex;
  flex-direction: column;
  margin-bottom: 20px;
  .box-one {
    width: 100%;
    display: flex;
    flex-direction: row;
    margin-bottom: 16px;
    justify-content: flex-start;
    .box-one_left {
      width: 70%;
      display: flex;
      flex-direction: row;
      align-items: center;
      justify-content: flex-start;
      img {
        margin: 0 10px 0 0 !important;
        width: 84px;
      }
      .left-box {
        display: flex;
        flex-direction: column;
        .left-one {
          margin-bottom: 15px;
        }
        .left-two {
          margin-bottom: 15px;
        }
      }
    }
    .box-one_right {
      display: flex;
      flex-direction: column;
      justify-content: space-between;
      .right-one {
        font-size: 14px;
      }
      .right-two {
        font-size: 16px;
        font-weight: 600;
      }
    }
  }
  .box-two {
    display: inline-flex;
    flex-direction: row;
  }
}
.box-item {
  width: 100%;
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  margin-bottom: 20px;
  .item {
    width: 19%;
    background-color: #99999930;
    display: flex;
    flex-direction: column;
    padding: 10px 0;
    align-items: center;
    border-radius: 5px;
    .item-one {
      margin-bottom: 10px;
    }
  }
}
.selected {
  background-color: #409eff !important;
  color: #ffffff !important;
}
</style>
