<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="100px">
      <el-form-item label="UID" prop="userid">
        <el-input
          v-model="queryParams.userid"
          placeholder="请输入UID"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="昵称 " prop="nickname">
        <el-input
          v-model="queryParams.nickname"
          placeholder="请输入昵称 "
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="手机号" prop="mobile">
        <el-input
          v-model="queryParams.mobile"
          placeholder="请输入手机号 "
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="登录ip地址" prop="ipaddr">
        <el-input
          v-model="queryParams.ipaddr"
          placeholder="请输入手机号 "
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="在线状态" prop="onlineStatus">
        <el-select v-model="queryParams.onlineStatus" placeholder="请选择" clearable>
          <el-option
            v-for="dict in dict.type.app_user_online_status"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <br>
      <el-form-item label="直属上级" prop="pid">
        <el-input
          v-model="queryParams.pid"
          placeholder="请输入直属上级"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="用户身份" prop="role">
        <el-select v-model="queryParams.role" placeholder="请选择用户身份" clearable>
          <el-option
            v-for="dict in dict.type.app_user_role"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['business:user:add']"
        >新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['business:user:edit']"
        >修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['business:user:remove']"
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['business:user:export']"
        >导出</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="userList" style="width: 100%" @scroll="handleScroll" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column fixed label="UID" align="center" prop="userid" />
      <el-table-column fixed label="昵称 " align="center" prop="username" width="200"/>
      <el-table-column label="头像" align="center" prop="avatar" width="100">
        <template slot-scope="scope">
          <image-preview :src="scope.row.avatar" :width="50" :height="50"/>
        </template>
      </el-table-column>
      <el-table-column label="金币" align="center" prop="coin" width="150"/>
      <el-table-column label="余额" align="center" prop="diamondCoin" width="150"/>
      <el-table-column label="手机号" align="center" prop="mobile" width="150"/>
      <el-table-column label="最近一次登录ip" align="center" prop="ipaddr" width="150"/>
      <el-table-column label=" 上次登录时间" align="center" prop="lastLoginTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.lastLoginTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="最大连续签到天数" align="center" prop="maxSignCount" />
      <el-table-column label="主播等级" align="center" prop="anchorGrade" />
      <el-table-column label="主播积分" align="center" prop="anchorPoint" />
      <el-table-column label="连续登录天数" align="center" prop="awardLoginDay" />
      <el-table-column label="魅力等级" align="center" prop="charmGrade" />
      <el-table-column label="魅力积分" align="center" prop="charmPoint" />
      <el-table-column label="可兑换" align="center" prop="coinCash" />
      <el-table-column label="消费总额(财富积分)" align="center" prop="consumption" width="150"/>
      <el-table-column label="注册时间" align="center" prop="createTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="邀请码" align="center" prop="inviteCode" />
      <el-table-column label="主播是否认证" align="center" prop="isAnchorAuth">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.is_anchor_auth" :value="scope.row.isAnchorAuth"/>
        </template>
      </el-table-column>
<!--      <el-table-column label="最后登录ip" align="center" prop="lastLoginIp" />-->
      <el-table-column label=" 离线时间" align="center" prop="lastOffLineTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.lastOffLineTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="用户在线状态" align="center" prop="onlineStatus">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.app_user_online_status" :value="scope.row.onlineStatus"/>
        </template>
      </el-table-column>
      <el-table-column label="手机厂商" align="center" prop="phoneFirm" />
      <el-table-column label="手机型号" align="center" prop="phoneModel" />
      <el-table-column label="直属上级" align="center" prop="pid" />
      <el-table-column label="用户身份" align="center" prop="role">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.app_user_role" :value="scope.row.role"/>
        </template>
      </el-table-column>
      <el-table-column label="连续签到次数" align="center" prop="signCount" />
      <el-table-column label="上次签到时间" align="center" prop="signTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.signTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="手机号区域" align="center" prop="smsRegion" />
      <el-table-column label="用户状态" align="center" prop="status">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.app_user_status" :value="scope.row.status"/>
        </template>
      </el-table-column>
      <el-table-column fixed="right" label="操作" align="center" width="200" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            v-if="scope.row.role == 1 && scope.row.liveLive"
            @click="handleLive(scope.row)"
          >{{scope.row.liveLive.islive==1?'关播':'虚拟开播'}}</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="getUserDetail(scope.row)"
          >查看详情</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleRestPwd(scope.row)"
          >重置密码</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-bank-card"
            @click="handleCharge(scope.row)"
          >充值</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleWithdraw(scope.row)"
          >补足提现流水</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['business:user:edit']"
          >修改</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['business:user:remove']"
          >删除</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改app用户对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="当前版本号" prop="appVersion">
          <el-input v-model="form.appVersion" placeholder="请输入当前版本号" />
        </el-form-item>
        <el-form-item label="当前版本code" prop="appVersionCode">
          <el-input v-model="form.appVersionCode" placeholder="请输入当前版本code" />
        </el-form-item>
        <el-form-item label="用户头像" prop="avatar">
          <image-upload v-model="form.avatar"/>
        </el-form-item>
        <el-form-item label="连续登录天数" prop="awardLoginDay">
          <el-input v-model="form.awardLoginDay" placeholder="请输入连续登录天数" />
        </el-form-item>
        <el-form-item label="生日" prop="birthday">
          <el-input v-model="form.birthday" placeholder="请输入生日" />
        </el-form-item>
        <el-form-item label="魅力等级" prop="charmGrade">
          <el-input v-model="form.charmGrade" placeholder="请输入魅力等级" />
        </el-form-item>
        <el-form-item label="魅力积分" prop="charmPoint">
          <el-input v-model="form.charmPoint" placeholder="请输入魅力积分" />
        </el-form-item>
        <el-form-item label="金币 /充值金额" prop="coin">
          <el-input v-model="form.coin" placeholder="请输入金币 /充值金额" />
        </el-form-item>
        <el-form-item label="可兑换" prop="coinCash">
          <el-input v-model="form.coinCash" placeholder="请输入可兑换" />
        </el-form-item>
        <el-form-item label="消费总额(财富积分)" prop="consumption">
          <el-input v-model="form.consumption" placeholder="请输入消费总额(财富积分)" />
        </el-form-item>
        <el-form-item label="邀请码" prop="inviteCode">
          <el-input v-model="form.inviteCode" type="textarea" placeholder="请输入内容" />
        </el-form-item>
        <el-form-item label=" 用户当前的位置信息ID" prop="ipaddr">
          <el-input v-model="form.ipaddr" placeholder="请输入 用户当前的位置信息ID" />
        </el-form-item>
        <el-form-item label="主播是否认证 0:未认证 1:已认证  后台添加主播时,如果是认证状态, 需要添加认证记录" prop="isAnchorAuth">
          <el-select v-model="form.isAnchorAuth" placeholder="请选择主播是否认证 0:未认证 1:已认证  后台添加主播时,如果是认证状态, 需要添加认证记录">
            <el-option
              v-for="dict in dict.type.is_anchor_auth"
              :key="dict.value"
              :label="dict.label"
              :value="parseInt(dict.value)"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="上次登录时间(连续登录用)" prop="lastLoginDay">
          <el-date-picker clearable
            v-model="form.lastLoginDay"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择上次登录时间(连续登录用)">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="最后登录ip" prop="lastLoginIp">
          <el-input v-model="form.lastLoginIp" placeholder="请输入最后登录ip" />
        </el-form-item>
        <el-form-item label=" 上次登录时间" prop="lastLoginTime">
          <el-date-picker clearable
            v-model="form.lastLoginTime"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择 上次登录时间">
          </el-date-picker>
        </el-form-item>
        <el-form-item label=" 离线时间" prop="lastOffLineTime">
          <el-date-picker clearable
            v-model="form.lastOffLineTime"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择 离线时间">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="最大连续签到天数" prop="maxSignCount">
          <el-input v-model="form.maxSignCount" placeholder="请输入最大连续签到天数" />
        </el-form-item>
        <el-form-item label=" 手机号" prop="mobile">
          <el-input v-model="form.mobile" placeholder="请输入 手机号" />
        </el-form-item>
        <el-form-item label="昵称 " prop="nickname">
          <el-input v-model="form.nickname" placeholder="请输入昵称 " />
        </el-form-item>
        <el-form-item label="用户在线状态 0:离线 1:在线" prop="onlineStatus">
          <el-select v-model="form.onlineStatus" placeholder="请选择用户在线状态 0:离线 1:在线">
            <el-option
              v-for="dict in dict.type.app_user_online_status"
              :key="dict.value"
              :label="dict.label"
              :value="parseInt(dict.value)"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="手机厂商" prop="phoneFirm">
          <el-input v-model="form.phoneFirm" placeholder="请输入手机厂商" />
        </el-form-item>
        <el-form-item label="手机型号" prop="phoneModel">
          <el-input v-model="form.phoneModel" placeholder="请输入手机型号" />
        </el-form-item>
        <el-form-item label="手机系统" prop="phoneSystem">
          <el-input v-model="form.phoneSystem" placeholder="请输入手机系统" />
        </el-form-item>
        <el-form-item label="手机唯一标识" prop="phoneUuid">
          <el-input v-model="form.phoneUuid" placeholder="请输入手机唯一标识" />
        </el-form-item>
        <el-form-item label="直属上级" prop="pid">
          <el-input v-model="form.pid" placeholder="请输入直属上级" />
        </el-form-item>
        <el-form-item label="用户身份" prop="role">
          <el-select v-model="form.role" placeholder="请选择用户身份">
            <el-option
              v-for="dict in dict.type.app_user_role"
              :key="dict.value"
              :label="dict.label"
              :value="parseInt(dict.value)"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="连续签到次数" prop="signCount">
          <el-input v-model="form.signCount" placeholder="请输入连续签到次数" />
        </el-form-item>
        <el-form-item label="上次签到时间" prop="signTime">
          <el-date-picker clearable
            v-model="form.signTime"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择上次签到时间">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="手机号区域 例如:86" prop="smsRegion">
          <el-input v-model="form.smsRegion" placeholder="请输入手机号区域 例如:86" />
        </el-form-item>
        <el-form-item label=" 用户状态 1:禁用 0:正常" prop="status">
          <el-select v-model="form.status" placeholder="请选择 用户状态 1:禁用 0:正常">
            <el-option
              v-for="dict in dict.type.app_user_status"
              :key="dict.value"
              :label="dict.label"
              :value="parseInt(dict.value)"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="余额/可提现余额" prop="diamondCoin">
          <el-input v-model="form.diamondCoin" placeholder="请输入余额/可提现余额" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>


    <!-- 重置密码对话框 -->
    <el-dialog :title="title" :visible.sync="resetPwdopen" width="500px" append-to-body>
      <el-form ref="resetPwdForm" :model="resetPwdForm" :rules="resetPwdRules" label-width="80px">
        <el-form-item label="用户id" prop="userId">
          <el-input v-model="resetPwdForm.userId" disabled />
        </el-form-item>
        <el-form-item label="密码" prop="password">
          <el-input v-model="resetPwdForm.password" placeholder="请输入密码" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitResetPwdForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>

    <!-- 充值对话框 -->
    <el-dialog :title="title" :visible.sync="chargeopen" width="700px" append-to-body>
      <el-form ref="chargeForm" :model="chargeForm" :rules="currentRules" :validate-on-rule-change=false label-width="150px">
        <el-form-item label="用户id" prop="userId">
          <el-input v-model="chargeForm.userId" disabled />
        </el-form-item>
        <el-form-item label="货币类型" prop="type">
          <el-select v-model="chargeForm.type" placeholder="请选择" clearable>
            <el-option
              v-for="dict in dict.type.app_user_coin_type"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
            />
          </el-select>
        </el-form-item>
        <el-form-item label="金额" prop="amount">
          <el-input type="text" v-model="chargeForm.amount" placeholder="请输入金额" />
        </el-form-item>
        <el-form-item label="是否扣除手续费" prop="isRate">
          <el-select v-model="chargeForm.isRate" placeholder="请选择" clearable @change="isRateChange">
            <el-option
              v-for="dict in dict.type.app_charge_rate"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
            />
          </el-select>
        </el-form-item>
        <el-form-item label="渠道（扣除对应渠道手续费）" prop="channelId" v-if="chargeForm.isRate==1">
          <el-select v-model="chargeForm.channelId" placeholder="请选择" clearable @change="chargeChannel">
            <el-option
              v-for="dict in channelList"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
            />
          </el-select>
          <span style="padding-left: 1rem;color: red;font-size: 12px" v-if="null != rate && undefined != rate">手续费：{{(rate*100).toFixed(2) + "%"}}</span>
        </el-form-item>
<!--        <el-form-item label="手续费比例" prop="rate" v-show="chargeForm.isRate==1 && chargeForm.channelId == -1">
          <el-input v-model="chargeForm.rate" placeholder="请输入手续费 (比如扣除10%，则填写0.1)" />
        </el-form-item>-->
        <template v-show="!isReadOnly">
          <el-form-item label="手续费比例" prop="rate" >
            <el-input type="number" v-model="chargeForm.rate" placeholder="请输入手续费 (比如扣除10%，则填写0.1)" :disabled="isReadOnly"/>
          </el-form-item>
        </template>

      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitChargeForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>

    <!-- 补足流水对话框 -->
    <el-dialog :title="title" :visible.sync="resetWithdrawopen" width="700px" append-to-body>
      <el-form ref="withdrawForm" :model="resetWithdrawForm" :rules="withdrawRules" :validate-on-rule-change=false label-width="150px">
        <el-form-item label="用户id" prop="userId">
          <el-input v-model="resetWithdrawForm.userId" disabled />
        </el-form-item>
        <el-form-item label="金额" prop="amount">
          <el-input type="text" v-model="resetWithdrawForm.amount" placeholder="请输入金额" />
        </el-form-item>

      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitWithdrawForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>

    <!-- 虚拟开播对话框 -->
    <el-dialog :title="title" :visible.sync="liveOpen" width="700px" append-to-body>
      <el-form :validate-on-rule-change=false label-width="150px">
        <el-form-item label="关播提示" prop="amount" v-if="liveLive.islive == 1">
          <el-input type="text" v-model="resetWithdrawForm.amount" placeholder="请输入" />
        </el-form-item>

      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitLiveForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>


    <!-- 用户详情对话框 -->
    <el-dialog :title="title" :visible.sync="superOpen" width="80%" append-to-body>
      <el-form >
        <el-form-item label="">
          <span>
            <image-preview :src="userInfo.avatar" :width="50" :height="50"/>&nbsp;&nbsp;
          </span>
          <span style="margin-left: 1rem;">{{userInfo.userid}} {{userInfo.role==0?"普通用户":"主播"}}</span>
          <span style="margin-left: 1rem;">注册IP：{{userInfo.registerIp}}</span>
          <span style="margin-left: 1rem;">最后登录IP：{{userInfo.ipaddr}}</span>
        </el-form-item>
        <el-form-item label="">
          <span>
            金币：{{userInfo.coin}}
          </span>
          <span style="margin-left: 1rem;">
            余额：{{userInfo.diamondCoin}}
          </span>
        </el-form-item>

        <el-form-item label="">
          <el-tabs v-model="activeName" @tab-click="handleClick" style="width: 100%">
            <el-tab-pane label="上级推荐人列表" name="first">
              <el-table
                :data="superUserList"
                stripe
                style="width: 100%">
                <el-table-column
                  prop="userId"
                  label="UID">
                </el-table-column>
                <el-table-column
                  prop="pid"
                  label="上级UID">
                </el-table-column>
              </el-table>
            </el-tab-pane>
            <el-tab-pane label="下级代理人列表" name="nine">
              <el-table
                :data="downUserList"
                stripe
                style="width: 100%">
                <el-table-column
                  prop="userId"
                  label="UID">
                </el-table-column>
                <el-table-column
                  prop="pid"
                  label="上级UID">
                </el-table-column>
              </el-table>
            </el-tab-pane>
            <el-tab-pane label="用户待遇" name="second">
              <el-form-item label="">
                <span>
                  直播分红：<el-input
                  v-model="appAgentForm.liveRate"
                  placeholder="请输入直播分红 "
                  style="width: 150px"
                />
                </span><span style="padding-left: 10px">%</span>
                <span style="margin-left: 1rem;">
                  保底分红：<el-input
                  v-model="appAgentForm.dividendGuaranteeRate"
                  placeholder="请输入分红比例 "
                  style="width: 150px"
                />
                </span>
                <span style="padding-left: 10px">%</span>
                <span style="margin-left: 1rem;">
                  <el-button type="primary" @click="submitAgentForm">修 改</el-button>
                </span>
                <el-table
                  :data="undefined!=userInfo.infoDetail?userInfo.infoDetail.gameCommissionList:[]"
                  stripe
                  style="width: 100%;margin-top: 10px">
                  <el-table-column
                    prop="gameName"
                    label="游戏">
                  </el-table-column>
                  <el-table-column
                    prop="gameRate"
                    label="返佣">
                    <template slot-scope="scope">
                      <el-input
                        v-model="scope.row.gameRate"
                        placeholder="请输入游戏返佣比例 "
                        style="width: 150px"
                      />
                    </template>
                  </el-table-column>
                  <el-table-column fixed="right" label="操作" align="center" width="200" class-name="small-padding fixed-width">
                    <template slot-scope="scope">
                      <el-button
                        size="mini"
                        type="text"
                        icon="el-icon-edit"
                        @click="submitGameCommissionForm(scope.row)"
                      >修 改</el-button>
                    </template>
                  </el-table-column>
                </el-table>
              </el-form-item>
            </el-tab-pane>
            <el-tab-pane label="同IP登录用户" name="three">
              <el-table
                v-loading="ipLoading"
                :data="ipUserList"
                stripe
                style="width: 100%">
                <el-table-column
                  prop="userid"
                  label="UID">
                </el-table-column>
                <el-table-column
                  prop="username"
                  label="昵称">
                </el-table-column>
                <el-table-column
                  prop="ipaddr"
                  label="最后登录ip">
                </el-table-column>
              </el-table>
              <pagination
                v-show="ipTotal>0"
                :total="ipTotal"
                :page.sync="queryIpParams.pageNum"
                :limit.sync="queryIpParams.pageSize"
                @pagination="getIpList"
              />
            </el-tab-pane>
            <el-tab-pane label="绑定提现账号" name="four">
              <el-table
                :data="accountList"
                v-loading="accountLoading"
                stripe
                style="width: 100%">
                <el-table-column
                  prop="uid"
                  label="UID">
                </el-table-column>
                <el-table-column label="账号类型" align="center" prop="type">
                  <template slot-scope="scope">
                    <dict-tag :options="dict.type.app_user_cash_account" :value="scope.row.type"/>
                  </template>
                </el-table-column>
                <el-table-column
                  prop="account"
                  label="账号">
                </el-table-column>
              </el-table>
              <pagination
                v-show="accountTotal>0"
                :total="accountTotal"
                :page.sync="queryAccountParams.pageNum"
                :limit.sync="queryAccountParams.pageSize"
                @pagination="getAccountList"
              />
            </el-tab-pane>
            <el-tab-pane label="兑换记录" name="five">
              <el-table
                :data="orderList"
                v-loading="orderLoading"
                stripe
                style="width: 100%">
                <el-table-column
                  prop="uid"
                  label="UID">
                </el-table-column>
                <el-table-column
                  prop="productNames"
                  label="商品">
                </el-table-column>
                <el-table-column label="交易金额(实付金额)" align="center" prop="transactionAmount" />
                <el-table-column label="收货人地址" align="center" prop="address" width="200"/>
                <el-table-column label="订单状态" align="center" prop="status">
                  <template slot-scope="scope">
                    <dict-tag :options="dict.type.app_goods_order_status" :value="scope.row.status"/>
                  </template>
                </el-table-column>
              </el-table>
              <pagination
                v-show="orderTotal>0"
                :total="orderTotal"
                :page.sync="queryOrderParams.pageNum"
                :limit.sync="queryOrderParams.pageSize"
                @pagination="getOrderList"
              />
            </el-tab-pane>
            <el-tab-pane label="直播获得的游戏投注返佣" name="six">
              <el-table
                :data="liveList"
                v-loading="liveLoading"
                stripe
                style="width: 100%">
                <el-table-column
                  prop="userId"
                  label="UID">
                </el-table-column>
                <el-table-column
                  prop="gameName"
                  label="游戏">
                </el-table-column>
                <el-table-column label="期号" align="center" prop="gameDate" />
                <el-table-column label="佣金" align="center" prop="commission" />
              </el-table>
              <pagination
                v-show="liveTotal>0"
                :total="liveTotal"
                :page.sync="queryLiveParams.pageNum"
                :limit.sync="queryLiveParams.pageSize"
                @pagination="getLiveList"
              />
            </el-tab-pane>
            <el-tab-pane label="收到的礼物" name="seven">
              <el-table
                :data="giftList"
                v-loading="giftLoading"
                stripe
                style="width: 100%">
                <el-table-column
                  prop="fromUid"
                  label="UID">
                </el-table-column>
                <el-table-column
                  prop="coinChange"
                  label="礼物收益">
                </el-table-column>
                <el-table-column
                  prop="remarks"
                  label="礼物">
                </el-table-column>
                <el-table-column
                  prop="createTime"
                  label="时间">
                </el-table-column>
              </el-table>
              <pagination
                v-show="giftTotal>0"
                :total="giftTotal"
                :page.sync="queryGiftParams.pageNum"
                :limit.sync="queryGiftParams.pageSize"
                @pagination="getGiftList"
              />
            </el-tab-pane>
            <el-tab-pane label="下注记录" name="eight">
              <el-table
                :data="bettingList"
                v-loading="bettingLoading"
                stripe
                style="width: 100%">
                <el-table-column label="游戏" align="center" prop="gameId">
                  <template slot-scope="scope">
                    <span>{{ getTypeName(scope.row.gameId) }}</span>
                  </template>
                </el-table-column>
                <el-table-column label="用户ID" align="center" prop="userId" />
                <el-table-column label="游戏期号" align="center" prop="gameDate" />
                <el-table-column label="主播ID" align="center" prop="liveUserId" />
                <el-table-column label="直播房间号" align="center" prop="liveRoomId" />
                <el-table-column label="是否直播间投注 " align="center" prop="isLive">
                  <template slot-scope="scope">
                    <dict-tag :options="dict.type.app_betting_is_live" :value="scope.row.isLive"/>
                  </template>
                </el-table-column>
                <el-table-column label="投注类型" align="center" prop="bettingType">
                  <template slot-scope="scope">
                    <dict-tag :options="dict.type.app_game_betting_type" :value="scope.row.bettingType"/>
                  </template>
                </el-table-column>
                <el-table-column label="投注选项" align="center" prop="bettingItem">
                  <template slot-scope="scope">
                    {{getItemName(scope.row)}}
                  </template>
                </el-table-column>
                <el-table-column label="投注选项倍数" align="center" prop="bettingMultiple" />
                <el-table-column label="投注金额" align="center" prop="bettingAmount" />
                <el-table-column label="投注佣金" align="center" prop="bettingCommission" />
                <el-table-column label="是否中奖" align="center" prop="isWinning">
                  <template slot-scope="scope">
                    <dict-tag :options="dict.type.app_game_betting_winning" :value="scope.row.isWinning"/>
                  </template>
                </el-table-column>
              </el-table>
              <pagination
                v-show="bettingTotal>0"
                :total="bettingTotal"
                :page.sync="queryBettingParams.pageNum"
                :limit.sync="queryBettingParams.pageSize"
                @pagination="getBettingList"
              />
            </el-tab-pane>
          </el-tabs>
        </el-form-item>

      </el-form>

      <div slot="footer" class="dialog-footer">
        <el-button @click="cancel">关闭</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { listUser, getUser, delUser, addUser, updateUser,resetUser,userCharge,channelList,withdraw,openLive,userDetail,liveCommission,getGift,updateUserAgent,updateGameCommissionAgent  } from "@/api/business/user";
import { listAccount} from "@/api/business/account";
import { listOrder } from "@/api/business/order";
import { listBetting} from "@/api/business/betting";
import {allGameList } from "@/api/business/game_item";
import {allList} from "@/api/business/lottery";

export default {
  name: "User",
  dicts: ['is_anchor_auth', 'app_user_role', 'app_user_status', 'app_user_online_status','app_user_coin_type','app_charge_rate','app_goods_order_status','app_betting_is_live','app_game_betting_type','app_game_betting_winning','app_user_cash_account'],
  data() {
    return {
      activeName:"first",
      // 遮罩层
      loading: true,
      ipLoading: true,
      accountLoading: true,
      orderLoading: true,
      liveLoading: true,
      giftLoading: true,
      bettingLoading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      ipTotal: 0,
      accountTotal: 0,
      orderTotal: 0,
      liveTotal: 0,
      giftTotal: 0,
      bettingTotal: 0,
      // app用户表格数据
      userList: [],
      ipUserList: [],
      accountList: [],
      orderList: [],
      liveList: [],
      giftList: [],
      bettingList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 是否显示弹出层
      resetPwdopen: false,
      // 是否显示弹出层
      resetWithdrawopen: false,
      // 是否显示弹出层
      chargeopen: false,
      channelList:[],
      isReadOnly:true,
      rate:null,
      channelMap:{},
      liveLive:{},
      liveOpen:false,
      superOpen:false,
      userInfo:{},
      closeMsg:null,
      superUserList:[],
      downUserList:[],
      typeMap:{},
      typeList:[],
      gameItemMap:{},
      gameItemList:[],
      gameItemShowList:[],
      appAgentForm:{
        liveRate:null,
        dividendGuaranteeRate:null,
        userId:null
      },
      appGameCommissionForm:{
        id:null,
        gameId:null,
        userId:null,
        pid:null,
        gameRate:null,
        gameName:null
      },
      queryIpParams: {
        pageNum: 1,
        pageSize: 10,
        ipaddr: null,
      },
      queryAccountParams: {
        pageNum: 1,
        pageSize: 10,
        uid: null,
      },
      queryOrderParams: {
        pageNum: 1,
        pageSize: 10,
        uid: null,
      },
      queryLiveParams: {
        pageNum: 1,
        pageSize: 10,
        userId: null,
      },
      queryGiftParams: {
        pageNum: 1,
        pageSize: 10,
        userId: null,
      },
      queryBettingParams: {
        pageNum: 1,
        pageSize: 10,
        userId: null,
      },
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        userid: null,
        anchorGrade: null,
        anchorPoint: null,
        appVersion: null,
        appVersionCode: null,
        avatar: null,
        awardLoginDay: null,
        birthday: null,
        charmGrade: null,
        charmPoint: null,
        coin: null,
        coinCash: null,
        consumption: null,
        createTime: null,
        ipaddr: null,
        isAnchorAuth: null,
        nickname: null,
        onlineStatus: null,
        phoneFirm: null,
        phoneModel: null,
        phoneSystem: null,
        phoneUuid: null,
        pid: null,
        role: null,
        diamondCoin: null,
        mobile:null,
      },
      // 表单参数
      form: {},
      //重置密码
      resetPwdForm:{},
      //补足流水
      resetWithdrawForm:{},
      //充值
      chargeForm:{},
      // 表单校验
      rules: {
        level: [
          { required: true, message: "不能为空", trigger: "blur" }
        ],
      },
      resetPwdRules: {
        password: [
          { required: true, message: "密码不能为空", trigger: "blur" }
        ],
      },
      chargeRules: {
        amount: [
          { required: true, message: "金额不能为空", trigger: "blur" }
        ],
        type: [
          { required: true, message: "类型不能为空", trigger: "blur" }
        ],
        isRate: [
          { required: true, message: "请选择是否扣除手续费", trigger: "blur" }
        ]
      },
      withdrawRules: {
        amount: [
          { required: true, message: "金额不能为空", trigger: "blur" }
        ]
      },
      scrollLeft: 0
    };
  },
  created() {
    let that = this;
    allList().then(response => {
      if(response.data){
        for(var i in response.data){
          var item = response.data[i];
          that.gameItemMap[item.itemLocation.toString() + "_" + item.gameId] = item.itemName;
          that.gameItemList.push({
            value:item.itemLocation+"_"+item.gameId,
            label:item.itemName,
            gameId:item.gameId
          })
        }
      }
    });
    allGameList().then(response => {
      if(response.data){
        for(var i in response.data){
          var item = response.data[i];
          that.typeMap[item.id.toString()] = item.name;
          that.typeList.push({
            value:item.id,
            label:item.name
          })
        }
      }
      that.getList();

    });
  },
  computed: {
    currentRules:function(){
      if(this.chargeForm.isRate == 1){
        this.chargeRules["channelId"] = [
          { required: true, message: "请选择充值渠道", trigger: "blur" }
        ];
      }else{
        delete this.chargeRules["channelId"]
      }
      return this.chargeRules;
    },
  },
  methods: {
    getItemName(row){
      let that = this;
      let bettingGameType = row.bettingGameType;
      let bettingItem = row.bettingItem;
      let gameId = row.gameId;
      if("0" == bettingGameType){
        return that.gameItemMap[bettingItem+"_"+gameId];
      }else{
        let name = "";
        let arr = JSON.parse(bettingItem);
        for(var i in arr){
          let item = arr[i];
          if("" != name){
            name = name + ",";
          }
          name = name + that.gameItemMap[item["bettingItem"]+"_"+gameId];
        }
        return name;
      }
    },
    getTypeName(id) {
      return this.typeMap[id.toString()];
    },
    /** 查询app用户列表 */
    getList() {
      this.loading = true;
      listUser(this.queryParams).then(response => {
        this.userList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    /** 查询同ip app用户列表 */
    getIpList() {
      this.ipLoading = true;
      this.queryIpParams.ipaddr = this.userInfo.ipaddr;
      listUser(this.queryIpParams).then(response => {
        this.ipUserList = response.rows;
        this.ipTotal = response.total;
        this.ipLoading = false;
      });
    },
    /** 查询提现账号列表 */
    getAccountList() {
      this.accountLoading = true;
      this.queryAccountParams.uid = this.userInfo.userid;
      listAccount(this.queryAccountParams).then(response => {
        this.accountList = response.rows;
        this.accountTotal = response.total;
        this.accountLoading = false;
      });
    },
    /** 查询兑换列表 */
    getOrderList() {
      this.orderLoading = true;
      this.queryOrderParams.uid = this.userInfo.userid;
      listOrder(this.queryOrderParams).then(response => {
        this.orderList = response.rows;
        this.orderTotal = response.total;
        this.orderLoading = false;
      });
    },
    /** 查询兑换列表 */
    getLiveList() {
      this.liveLoading = true;
      this.queryLiveParams.userId = this.userInfo.userid;
      liveCommission(this.queryLiveParams).then(response => {
        this.liveList = response.rows;
        this.liveTotal = response.total;
        this.liveLoading = false;
      });
    },
    /** 查询礼物列表 */
    getGiftList() {
      this.giftLoading = true;
      this.queryGiftParams.userId = this.userInfo.userid;
      getGift(this.queryGiftParams).then(response => {
        this.giftList = response.rows;
        this.giftTotal = response.total;
        this.giftLoading = false;
      });
    },
    /** 查询下注记录 */
    getBettingList() {
      this.bettingLoading = true;
      this.queryBettingParams.userId = this.userInfo.userid;
      listBetting(this.queryBettingParams).then(response => {
        this.bettingList = response.rows;
        this.bettingTotal = response.total;
        this.bettingLoading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.resetPwdopen = false;
      this.chargeopen = false;
      this.resetWithdrawopen = false;
      this.liveOpen = false;
      this.superOpen = false;
      this.reset();
      this.resetPwd();
      this.resetCharge();
      this.resetWithdraw();
    },
    // 表单重置
    reset() {
      this.form = {
        userid: null,
        address: null,
        agentId: null,
        amount: null,
        anchorGrade: null,
        anchorPoint: null,
        appVersion: null,
        appVersionCode: null,
        avatar: null,
        awardLoginDay: null,
        birthday: null,
        broadCast: null,
        channelId: null,
        chargeShow: null,
        charmGrade: null,
        charmPoint: null,
        city: null,
        cityEdit: null,
        coin: null,
        coinCash: null,
        constellation: null,
        consumption: null,
        createTime: null,
        dealScalePlan: null,
        delFlag: null,
        deviceId: null,
        devoteShow: null,
        giftGlobalBroadcast: null,
        goodnum: null,
        groupId: null,
        gsRoomId: null,
        gsRoomType: null,
        guildId: null,
        headNo: null,
        height: null,
        hideDistance: null,
        inviteCode: null,
        bindCode: null,
        ipaddr: null,
        isAnchorAuth: null,
        isAutomatic: null,
        isJoinJg: null,
        isLiveAccount: null,
        isNotDisturb: null,
        isOooAccount: null,
        isPush: null,
        isRecommend: null,
        isShowHomePage: null,
        isSvip: null,
        isTone: null,
        isYouthModel: null,
        ishot: null,
        isrecord: null,
        issuper: null,
        iszombie: null,
        iszombiep: null,
        joinRoomShow: null,
        kickTime: null,
        lastGameNum: null,
        lastLoginDay: null,
        lastLoginIp: null,
        lastLoginTime: null,
        lastOffLineTime: null,
        lat: null,
        level: null,
        liveFunction: null,
        liveStatus: null,
        liveThumb: null,
        liveThumbs: null,
        lng: null,
        lockReason: null,
        lockTime: null,
        loginType: null,
        managerCoId: null,
        managerId: null,
        maxSignCount: null,
        mobile: null,
        nickname: null,
        nobleGrade: null,
        onlineStatus: null,
        oooHomePageSortNo: null,
        oooLiveStatus: null,
        oooTwoClassifyId: null,
        openLiveZombieNum: null,
        openid: null,
        optUserName: null,
        password: null,
        phoneFirm: null,
        phoneModel: null,
        phoneSystem: null,
        phoneUuid: null,
        pid: null,
        portrait: null,
        poster: null,
        province: null,
        pushPlatform: null,
        pushRegisterId: null,
        readShortVideoNumber: null,
        regType: null,
        registerIp: null,
        role: null,
        roomId: null,
        roomTitle: null,
        roomType: null,
        roomTypeVal: null,
        salt: null,
        sanwei: null,
        score: null,
        sex: null,
        signCount: null,
        signTime: null,
        signature: null,
        smsRegion: null,
        source: null,
        starId: null,
        status: null,
        totalAmount: null,
        totalAmountCash: null,
        totalCash: null,
        totalCharge: null,
        unionid: null,
        updatePwdTime: null,
        userActivationKey: null,
        userEmail: null,
        userGrade: null,
        userPoint: null,
        userSetOnlineStatus: null,
        userType: null,
        userUrl: null,
        username: null,
        video: null,
        videoCoin: null,
        videoImg: null,
        vocation: null,
        voice: null,
        voiceCoin: null,
        voiceStatus: null,
        voipToken: null,
        votes: null,
        votestotal: null,
        wealthGrade: null,
        wechat: null,
        weight: null,
        whetherEnablePositioningShow: null,
        youthPassword: null,
        zombieMaxNum: null,
        zombieRatio: null,
        agentGrade: null,
        liveDividedInto: null,
        gameDividedInto: null,
        inviteBindTime: null,
        fundPassword: null,
        diamondCoin: null,
        diamondCoinTotal: null,
        diamondCoinCashTotal: null,
        agentFlag: null,
        diamondCoinCash: null,
        otherPid: null
      };
      this.resetForm("form");
    },// 表单重置
    resetPwd() {
      this.resetPwdForm = {
        userId: null,
        password: null
      };
      this.resetForm("restPwdForm");
    },// 表单重置
    resetWithdraw() {
      this.resetWithdrawForm = {
        userId: null,
        amount: null
      };
      this.resetForm("restWithdraoForm");
    },// 表单重置
    resetCharge() {
      this.chargeForm = {
        userId: null,
        amount: null,
        type:null,
        isRate:null,
        rate:null,
        channelId:null
      };
      this.resetForm("restPwdForm");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.userid)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加app用户";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const userid = row.userid || this.ids
      getUser(userid).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "修改app用户";
      });
    },
    handleLive(row){
      this.liveLive = row.liveLive;
      this.title = row.liveLive.islive==1?"关播":"虚拟开播";
      this.liveOpen = true;
      this.closeMsg = null;
    },
    /** 重置密码按钮操作 */
    handleRestPwd(row) {
      this.resetPwd();
      const userid = row.userid;
      this.resetPwdForm = {
        userId:userid,
        password:""
      };
      this.resetPwdopen = true;
      this.title = "重置密码";
    },
    /** 补足流水按钮操作 */
    handleWithdraw(row) {
      this.resetWithdraw();
      const userid = row.userid;
      this.resetWithdrawForm = {
        userId:userid,
        password:""
      };
      this.resetWithdrawopen = true;
      this.title = "补足提现流水";
    },
    /** 充值按钮操作 */
    handleCharge(row) {
      var that = this;
      that.channelList = [];
      that.channelMap = {};
      channelList().then(response => {
        if(response.data){
          for(var i in response.data){
            var item = response.data[i];
            that.channelMap[item.id] = item.rate;
            that.channelList.push({
              value:item.id,
              label:item.name,
              rate:item.rate
            })
          }
        }
      });
      this.resetCharge();
      const userid = row.userid;
      this.chargeForm = {
        userId:userid,
        type: null,
        amount:null
      };
      this.chargeopen = true;
      this.title = "充值";

      /*this.$nextTick(()=>{
        // 重置当前页面的所有字段值
        this.$refs['chargeForm'].resetFields();

        if (data){
          // 模式1
          this.form.patternType = 1;
        }else{
          // 模式2
          this.form.patternType = 2;
        }
        // 设置校验规则
        this.setValidRules(this.form.patternType);
      })*/
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.userid != null) {
            updateUser(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addUser(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 重置密码提交按钮 */
    submitResetPwdForm() {
      this.$refs["resetPwdForm"].validate(valid => {
        if (valid) {
          const loading = this.$loading({
            lock: true,
            text: '加载中',
            spinner: 'el-icon-loading',
            background: 'rgba(0, 0, 0, 0.7)'
          });
          setTimeout(function (){loading.close();},1000);
          resetUser(this.resetPwdForm).then(response => {
            this.$modal.msgSuccess("修改成功");
            this.resetPwdopen = false;
            this.getList();
            loading.close();
          });
        }
      });
    },
    /** 补足流水提交按钮 */
    submitWithdrawForm() {
      var that =this;
      this.$refs["withdrawForm"].validate(valid => {
        if (valid) {
          const loading = this.$loading({
            lock: true,
            text: '加载中',
            spinner: 'el-icon-loading',
            background: 'rgba(0, 0, 0, 0.7)'
          });
          setTimeout(function (){loading.close();},1000);
          withdraw(this.resetWithdrawForm).then(response => {
            this.$modal.msgSuccess("补足流水成功");
            this.resetWithdrawopen = false;
            this.getList();
            loading.close();
          });
        }
      });
    },
    /** 充值提交按钮 */
    submitChargeForm() {
      var that =this;
      this.$refs["chargeForm"].validate(valid => {
        if (valid) {
          if(that.chargeForm.isRate != 1){
            that.chargeForm.rate = null;
          }
          if(that.chargeForm.channelId == -1 && (undefined == that.chargeForm.rate || null == that.chargeForm.rate)){
            this.$modal.msgError("请输入手续费比例");
            return;
          }
          if(that.chargeForm.channelId == -1 &&  that.chargeForm.rate >= 1){
            this.$modal.msgError("手续费比例超过最大值");
            return;
          }
          const loading = this.$loading({
            lock: true,
            text: '加载中',
            spinner: 'el-icon-loading',
            background: 'rgba(0, 0, 0, 0.7)'
          });
          setTimeout(function (){loading.close();},1000);
          userCharge(this.chargeForm).then(response => {
            this.$modal.msgSuccess("修改成功");
            this.chargeopen = false;
            this.getList();
            loading.close();
          });
        }
      });
    },
    /** 开关播提交按钮 */
    submitLiveForm() {
      var that =this;
      this.liveLive["title"] = this.closeMsg;
      const loading = this.$loading({
        lock: true,
        text: '加载中',
        spinner: 'el-icon-loading',
        background: 'rgba(0, 0, 0, 0.7)'
      });
      setTimeout(function (){loading.close();},1000);
      openLive(this.liveLive).then(response => {
        that.liveOpen = false;
        setTimeout(function (){
          that.getList();
        },4000);
        if(this.liveLive.islive!=1){
          that.$alert(response["msg"], '开播成功', {
            confirmButtonText: '确定',
            callback: action => {
              /*this.$message({
                type: 'info',
                message: `action: ${ action }`
              });*/
            }
          });
        }else{
          that.$modal.msgSuccess(this.liveLive.islive==1?"关播":"虚拟开播"+"成功");
        }
        loading.close();
      });
    },
    /** 代理待遇提交按钮 */
    submitAgentForm() {
      var that =this;
      if(!that.appAgentForm.liveRate){
        that.$modal.msgError("直播分红不能为空！");
        return;
      }
      if(!that.appAgentForm.dividendGuaranteeRate){
        that.$modal.msgError("保底分红不能为空！");
        return;
      }
      const loading = this.$loading({
        lock: true,
        text: '加载中',
        spinner: 'el-icon-loading',
        background: 'rgba(0, 0, 0, 0.7)'
      });
      setTimeout(function (){loading.close();},1000);
      updateUserAgent(this.appAgentForm).then(response => {
        that.$modal.msgSuccess("修改成功");
        that.getList();
        loading.close();
      });
    },
    /** 代理游戏待遇提交按钮 */
    submitGameCommissionForm(row) {
      var that =this;
      that.appGameCommissionForm = row;
      if(!that.appGameCommissionForm.gameRate){
        that.$modal.msgError("游戏返佣比例不能为空！");
        return;
      }
      if(!that.appGameCommissionForm.gameRate){
        that.$modal.msgError("游戏返佣不能为空！");
        return;
      }
      const loading = this.$loading({
        lock: true,
        text: '加载中',
        spinner: 'el-icon-loading',
        background: 'rgba(0, 0, 0, 0.7)'
      });
      setTimeout(function (){loading.close();},1000);
      updateGameCommissionAgent(this.appGameCommissionForm).then(response => {
        that.getList();
        that.$modal.msgSuccess("修改成功");
        loading.close();
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const userids = row.userid || this.ids;
      this.$modal.confirm('是否确认删除app用户编号为"' + userids + '"的数据项？').then(function() {
        return delUser(userids);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('business/user/export', {
        ...this.queryParams
      }, `user_${new Date().getTime()}.xlsx`)
    },
    handleScroll(event) {
      // 当滚动时同步左右滚动
      this.scrollLeft = event.target.scrollLeft;
    },
    isRateChange(val){
      let rule = {};
      for(var i in this.chargeRules){
        rule[i] = this.chargeRules[i];
      }
      this.chargeRules = {};
      if(this.chargeForm.isRate == 1){
        rule["channelId"] = [
          { required: true, message: "请选择充值渠道", trigger: "blur" }
        ];
        /*rule["rate"] = [
          { required: true, message: "请输入手续费比例", trigger: "blur" }
        ];*/
      }else{
          delete rule["channelId"];
          // delete rule["rate"];
      }
      this.chargeRules = rule;
    },
    chargeChannel(val){
      let rule = {};
      for(var i in this.chargeRules){
        rule[i] = this.chargeRules[i];
      }
      this.chargeRules = {};
      if(this.chargeForm.channelId == -1){
        /*this.chargeForm.rate = null;
        rule["rate"] = [
          { required: true, message: "请输入手续费比例", trigger: "blur" }
        ];*/
        this.isReadOnly = false;
        this.rate = null;
      }else{
        let rate = this.channelMap[this.chargeForm.channelId];
        this.chargeForm.rate = rate;
        // delete rule["rate"];
        this.isReadOnly = true;
        this.rate = rate;
      }
      // this.chargeRules = rule;
    },
    getUserDetail(row){
      let that = this;
      that.title = "用户详情"
      that.activeName = "first";
      that.userInfo = row;
      that.userInfo["infoDetail"] = {};
      userDetail({"userId":row.userid}).then(response => {
          that.superUserList = response.data.superUserList;
          that.downUserList = response.data.downUserList;
          that.userInfo["infoDetail"] = response.data;
          that.superOpen = true;
          that.appAgentForm["dividendGuaranteeRate"] = undefined!=that.userInfo.infoDetail?that.userInfo.infoDetail.dividendGuaranteeRate:0.00;
          that.appAgentForm["liveRate"] = undefined!=that.userInfo.infoDetail?that.userInfo.infoDetail.liveRate:0.00;
          that.appAgentForm["userId"] = that.userInfo.infoDetail.userId;
      });
    },
    handleClick(tab, event) {
      if("three" == tab.$options.propsData.name){
        this.getIpList();
      }
      if("four" == tab.$options.propsData.name){
        this.getAccountList();
      }
      if("five" == tab.$options.propsData.name){
        this.getOrderList();
      }
      if("six" == tab.$options.propsData.name){
        this.getLiveList();
      }
      if("seven" == tab.$options.propsData.name){
        this.getGiftList();
      }
      if("eight" == tab.$options.propsData.name){
        this.getBettingList();
      }
    }
  }
};
</script>
<style scoped>

</style>
