<template>
  <div class="app-container">
    <el-card>
      <el-tabs v-model="activeName" @tab-click="handleClick">
        <el-tab-pane label="认证会员" name="member">
          <el-form :model="queryParam" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
            <el-form-item label="手机号" prop="mobile">
              <el-input
                v-model="queryParam.mobile"
                placeholder="请输入会员手机号"
                clearable
                style="width: 240px;"
                @keyup.enter.native="handleQuery"
              />
            </el-form-item>
            <el-form-item label="认证类型" prop="fixingLevelId">
              <el-select
                v-model="queryParam.fixingLevelId"
                placeholder="请选择"
                clearable
                style="width: 300px"
              >
                <el-option v-for="item in fixingLevelList" :key="item.id+''" :label="item.name" :value="item.id+''"/>
              </el-select>
            </el-form-item>
            <el-form-item label="认证状态" prop="status">
              <el-select
                v-model="queryParam.status"
                placeholder="全部"
                clearable
                style="width: 240px"
              >
                <el-option
                  v-for="dict in dict.type.rzzt"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
                />
              </el-select>
            </el-form-item>
<!--            <el-form-item>-->
<!--              <el-date-picker-->
<!--                v-model="dateRange"-->
<!--                style="width: 240px"-->
<!--                size="medium"-->
<!--                value-format="yyyy-MM-dd"-->
<!--                type="daterange"-->
<!--                range-separator="-"-->
<!--                start-placeholder="开始日期"-->
<!--                end-placeholder="结束日期"-->
<!--              ></el-date-picker>-->
<!--            </el-form-item>-->

            <el-form-item>
              <el-button type="primary" icon="el-icon-search" @click="handleQueryMember">搜索</el-button>
            </el-form-item>
          </el-form>
        </el-tab-pane>
        <el-tab-pane label="固定等级认证" name="fixingLevel">
          <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
            <el-form-item label="等级状态" prop="status">
              <el-select
                v-model="queryParams.status"
                placeholder="全部"
                clearable
                style="width: 240px"
              >
                <el-option
                  v-for="dict in dict.type.zhzt"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
                />
              </el-select>
            </el-form-item>
<!--            <el-form-item>-->
<!--              <el-date-picker-->
<!--                v-model="dateRange"-->
<!--                style="width: 240px"-->
<!--                size="medium"-->
<!--                value-format="yyyy-MM-dd"-->
<!--                type="daterange"-->
<!--                range-separator="-"-->
<!--                start-placeholder="开始日期"-->
<!--                end-placeholder="结束日期"-->
<!--              ></el-date-picker>-->
<!--            </el-form-item>-->

            <el-form-item>
              <el-button type="primary" icon="el-icon-search" @click="handleQuery">搜索</el-button>
            </el-form-item>
          </el-form>
        </el-tab-pane>
      </el-tabs>
    </el-card>

<!--    <img src="file://D:/certifiedPhoto/static/uploadImages/20231025/8c3dbcf4924f40ebb479c17abd573ffb.jpg">-->

    <el-card>
      <div v-if="activeName=='member'">
        <el-button
          type="primary"
          icon="el-icon-plus"
          @click="handleAddMember"
        >新增用户认证</el-button>
        <el-button
          type="danger"
          icon="el-icon-document-copy"
          @click="handleAddMembers"
        >批量用户认证</el-button>
        <el-table ref="tables" v-loading="loading" :data="listMember"
                  @selection-change="handleSelectionChange" :default-sort="defaultSort"
                  @sort-change="handleSortChange">
          <el-table-column label="认证类型" prop="fixingLevelId" align="center">
            <template slot-scope="scope">
              <span>{{ scope.row.fixingLevelId ? getName(fixingLevelList, scope.row.fixingLevelId) : '-' }}</span>
            </template>
          </el-table-column>
          <el-table-column label="手机号" align="center"prop="mobile"/>
          <el-table-column label="关联会员" align="center" prop="userId">
            <template slot-scope="scope">
              <span>{{ scope.row.userId ? getName(userList, scope.row.userId) : '-' }}</span>
            </template>
          </el-table-column>
          <el-table-column label="姓名" align="center" prop="name" />
          <el-table-column label="车牌号" align="center" prop="carNumber">
            <template slot-scope="scope">
              <span>{{scope.row.carNumber ? scope.row.carNumber:"--"}}</span>
            </template>
          </el-table-column>
          <el-table-column label="认证资料" align="center" prop="attestationData">
            <template slot-scope="scope">
<!--              <p v-for="(item,index) in scope.row.imgUrlList" :key="index">{{item.imageUrl1}}</p>-->
              <span v-if="scope.row.imgUrlList==null || scope.row.imgUrlList==''">--</span>
              <span v-for="(item,index) in scope.row.imgUrlList" :key="index">
                <img v-if="item.imageUrl1" :src="'/dev-api'+item.imageUrl1" class="attImg">
                <img v-if="item.imageUrl2" :src="'/dev-api'+item.imageUrl2" class="attImg">
                <img v-if="item.imageUrl3" :src="'/dev-api'+item.imageUrl3" class="attImg">
              </span>
            </template>
          </el-table-column>
          <el-table-column label="备注" align="center" prop="remark">
            <template slot-scope="scope">
              <span>{{scope.row.remark ? scope.row.remark:"--"}}</span>
            </template>
          </el-table-column>
          <el-table-column label="状态" align="center" prop="status">
            <template slot-scope="scope">
              <dict-tag :options="dict.type.rzzt" :value="scope.row.status"/>
            </template>
          </el-table-column>
          <el-table-column label="操作" align="center" width="120" fixed='right'>
            <template slot-scope="scope">
              <el-button
                size="mini"
                type="text"
                icon="el-icon-edit"
                @click="handleUpdateMember(scope.row)"
              >修改</el-button>
              <el-button
                size="mini"
                type="text"
                icon="el-icon-delete"
                @click="handleDeleteMember(scope.row)"
              >删除</el-button>
            </template>
          </el-table-column>
        </el-table>

        <pagination
          v-show="total>0"
          :total="total"
          :page.sync="queryParam.page"
          :limit.sync="queryParam.pageSize"
          @pagination="getListMember"
        />
      </div>

      <div v-else>
        <el-button
          type="primary"
          icon="el-icon-plus"
          @click="handleAdd"
        >新增固定等级类型</el-button>
        <el-table ref="tables" v-loading="loading"
                  :data="list"
                  @selection-change="handleSelectionChange"
                  :default-sort="defaultSort"
                  @sort-change="handleSortChange">
          <el-table-column label="认证类型名称" align="center" prop="name">
            <template slot-scope="scope">
              {{ scope.row.name }}
            </template>
          </el-table-column>
          <el-table-column label="优惠类型" align="center" prop="discountType">
<!--            <template slot-scope="scope">-->
<!--              <dict-tag :options="dict.type.yhlx" :value="scope.row.discountType"/>-->
<!--            </template>-->
          </el-table-column>
          <el-table-column label="优惠详情" align="center" width="170">.
            <template slot-scope="scope">
              <p v-if="scope.row.discountType=='优惠活动组'">
                关联优惠组：{{scope.row.promotionGroup}}
              </p>
              <p v-if="scope.row.discountType=='自定义优惠'">
                <div v-if="scope.row.discountType=='自定义优惠'">
                  汽油：
                  <el-tooltip placement="top"
                              v-if="scope.row.gasolineDiscount=='无优惠'">
                    <div slot="content">无优惠</div>
                    <el-tag type="warning">{{ scope.row.dieselDiscount }}</el-tag>>
                  </el-tooltip>
                  <span v-if="scope.row.gasolineRule!=null && scope.row.gasolineRule!=''">
                    <el-tooltip placement="top"
                                v-if="scope.row.gasolineDiscount=='满减优惠'">
                      <div slot="content"
                           v-for="(item,index) in scope.row.gasolineRuleList"
                           :key="index">消费满{{item.gasolineRule1}}元,立减{{item.gasolineRule2}}元</div>
                      <el-tag type="warning">{{ scope.row.gasolineDiscount }}</el-tag>
                    </el-tooltip>
                    <el-tooltip placement="top"
                                v-if="scope.row.gasolineDiscount=='每升优惠'">
                      <div slot="content"
                           v-for="(item,index) in scope.row.gasolineRuleList"
                           :key="index">消费满{{item.gasolineRule1}}元,每升优惠{{item.gasolineRule3}}元</div>
                      <el-tag type="warning">{{ scope.row.gasolineDiscount }}</el-tag>>
                    </el-tooltip>
                  </span><br/>
                </div>
                <div style="margin: 10px 0" v-if="scope.row.discountType=='自定义优惠'">
                  柴油：
                  <el-tooltip placement="top"
                              v-if="scope.row.dieselDiscount=='无优惠'">
                    <div slot="content">无优惠</div>
                    <el-tag type="warning">{{ scope.row.dieselDiscount }}</el-tag>>
                  </el-tooltip>
                  <span v-if="scope.row.dieselRule!=null && scope.row.dieselRule!=''">
                    <el-tooltip placement="top"
                                v-if="scope.row.dieselDiscount=='满减优惠'">
                      <div slot="content"
                           v-for="(item,index) in scope.row.dieselRuleList"
                           :key="index">消费满{{item.dieselRule1}}元,立减{{item.dieselRule2}}元</div>
                      <el-tag type="warning">{{ scope.row.dieselDiscount }}</el-tag>>
                    </el-tooltip>
                    <el-tooltip placement="top"
                                v-if="scope.row.dieselDiscount=='每升优惠'">
                      <div slot="content"
                           v-for="(item,index) in scope.row.dieselRuleList"
                           :key="index">消费满{{item.dieselRule1}}元,每升优惠{{item.dieselRule3}}元</div>
                      <el-tag type="warning">{{ scope.row.dieselDiscount }}</el-tag>>
                    </el-tooltip>
                  </span><br/>
                </div>
                <div v-if="scope.row.discountType=='自定义优惠'">
                  天然气：
                  <el-tooltip placement="top"
                              v-if="scope.row.naturalGasDiscount=='无优惠'">
                    <div slot="content">无优惠</div>
                    <el-tag type="warning">{{ scope.row.naturalGasDiscount }}</el-tag>>
                  </el-tooltip>
                  <span v-if="scope.row.naturalGasRule!=null && scope.row.naturalGasRule!=''">
                    <el-tooltip placement="top"
                                v-if="scope.row.naturalGasDiscount=='满减优惠'">
                      <div slot="content"
                           v-for="(item,index) in scope.row.naturalGasRuleList"
                           :key="index">消费满{{item.naturalGas1}}元,立减{{item.naturalGas2}}元</div>
                      <el-tag type="warning">{{ scope.row.naturalGasDiscount }}</el-tag>>
                    </el-tooltip>
                    <el-tooltip placement="top"
                                v-if="scope.row.naturalGasDiscount=='每升优惠'">
                      <div slot="content"
                           v-for="(item,index) in scope.row.naturalGasRuleList"
                           :key="index">消费满{{item.naturalGas1}}元,每单位优惠{{item.naturalGas3}}元</div>
                      <el-tag type="warning">{{ scope.row.naturalGasDiscount }}</el-tag>>
                    </el-tooltip>
                  </span><br/>
                </div>
              </p>
            </template>
          </el-table-column>
          <el-table-column label="是否参与规则" align="center">
            <el-table-column label="积分" align="center" prop="pointRule">
              <template slot-scope="scope">
                <dict-tag :options="dict.type.yes_or_no" :value="scope.row.pointRule"/>
              </template>
            </el-table-column>
<!--            <el-table-column label="加油金" align="center" prop="refuelMoneyRule">-->
<!--              <template slot-scope="scope">-->
<!--                <dict-tag :options="dict.type.yes_or_no" :value="scope.row.refuelMoneyRule"/>-->
<!--              </template>-->
<!--            </el-table-column>-->
            <el-table-column label="成长值" align="center" prop="growthValueRule">
              <template slot-scope="scope">
                <dict-tag :options="dict.type.yes_or_no" :value="scope.row.growthValueRule"/>
              </template>
            </el-table-column>
            <el-table-column label="优惠券" align="center" prop="couponRule">
              <template slot-scope="scope">
                <dict-tag :options="dict.type.yes_or_no" :value="scope.row.couponRule"/>
              </template>
            </el-table-column>
            <el-table-column label="储值优惠" align="center" prop="storeValue">
              <template slot-scope="scope">
                <dict-tag :options="dict.type.yes_or_no" :value="scope.row.storeValue"/>
              </template>
            </el-table-column>
          </el-table-column>
<!--          <el-table-column label="二维码" align="center">-->
<!--            <svg t="1698032190345" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4097" width="32" height="32"><path d="M742.8 121.5c-2.3 0.3-4.7 0.1-7 0.1-38 0-76-0.1-114 0.1-11 0-21.9 1.4-32.4 5.1-18.6 6.5-29.8 19.5-34.4 38.4-1.7 7-2.4 14.1-2.4 21.3 0 67.2-0.1 134.3 0.1 201.5 0 13.8 0.9 27.6 6.2 40.8 6.9 17.1 19.7 27.2 37.3 31.7 6.3 1.6 12.8 2.2 19.3 2.2h218c8.3 0 16.6-0.7 24.8-2.3 24.4-4.5 40.4-20.7 44.9-45 0.4-2.2-0.4-5.2 2.9-6.2v-232c-0.4-0.4-0.5-0.9-0.5-1.5-1.5-4.8-1.7-9.8-3.3-14.7-7.1-21-21.7-33.4-42.8-38.8-6.4-1.6-12.8-2.4-19.5-2.1-1.3 0.1-3 1-3.9-0.9h-89c-0.4 2.6-2.7 2.1-4.3 2.3z m98.7 40.7c4 0 8.1 0.9 11.9 2.1 6.9 2.2 10.7 7.6 10.7 15.1 0 74.8 0.1 149.6-0.1 224.4 0 11.2-8.6 18-21.1 18.1-38.2 0.3-76.3 0.1-114.5 0.1h-113c-4.5 0-8.6-1.3-12.7-2.7-8.5-3.1-9.6-10.5-9.7-17.9-0.2-37.5-0.1-75-0.1-112.5V183.4c0-6.5 1.5-12.5 6.9-17 4.6-3.8 10.3-4.3 15.6-4.3 75.4-0.1 150.8 0 226.1 0.1z" p-id="4098"></path><path d="M742 120c-39.5 0.1-79 0.1-118.4 0.1-9.4 0-18.6 1-27.7 3.1-11.6 2.7-22.1 7.7-30 16.7-10.6 12.1-14.8 26.9-14.8 42.6-0.2 69.6-0.2 139.3 0 208.9 0 9.1 0.7 18.3 2.8 27.2 2.8 11.7 7.6 22.5 16.7 30.5 11.7 10.3 25.9 15 41.5 15 74.1 0.1 148.3 0.1 222.4 0 9.3 0 18.7-0.5 27.7-3 19-5.4 33.6-15.9 40-35.8 1.7-5.3 1.8-10.9 3.8-16.1-3.2 1-2.5 4-2.9 6.2-4.5 24.4-20.5 40.5-44.9 45-8.2 1.5-16.5 2.3-24.8 2.3h-218c-6.5 0-13-0.6-19.3-2.2-17.5-4.5-30.4-14.6-37.3-31.7-5.3-13.1-6.2-27-6.2-40.8-0.2-67.2-0.1-134.3-0.1-201.5 0-7.2 0.7-14.3 2.4-21.3 4.6-18.9 15.8-31.9 34.4-38.4 10.5-3.7 21.4-5 32.4-5.1 38-0.2 76-0.1 114-0.1 2.3 0 4.7 0.2 7-0.1 1.7-0.2 3.9 0.2 4.2-2.4-1.2 2.1-3.2 0.9-4.9 0.9zM120.6 410.3c2 12.5 5.5 24.4 14.3 34 11.5 12.7 26.5 18 43 18.1 75.1 0.3 150.2 0.3 225.4 0 9.4 0 18.9-1 28.1-3.9 24.5-7.7 39.1-27.3 39.1-53.1 0-74 0-147.9 0.1-221.9 0-6.4-0.8-12.6-2.4-18.8-5.8-22.4-24.5-39.1-47.5-42.3-4.1-0.6-8.2-1.1-12.4-1.1-2 0-4.5 0.6-5.2-2.4h-89c-1.3 2.1-3.3 0.9-4.9 0.9-41.1 0.1-82.2-0.2-123.3 0.2-14.8 0.1-29.2 2.6-42.2 10.7-12.5 7.8-19.8 19.1-23.7 33-0.8 2.7-0.2 5.7-1.9 8.2v233c2.9 0.9 2.2 3.5 2.5 5.4z m39.5-231c0-8.1 6.2-14.6 14.5-16.3 4.4-0.9 8.8-1 13.2-1h219c4.3 0 8.4 0.8 12.4 2 7.5 2.4 10.8 6.9 10.8 14.6v225.5c0 8.2-3.8 13.3-11.6 15.9-4 1.3-8.1 2.1-12.4 2-37.2-0.1-74.3-0.1-111.5-0.1-37.7 0-75.3 0.1-113-0.1-6.3 0-12.6-0.9-17.3-6.1-2.7-3-4.1-6.3-4.1-10.1-0.1-75.3-0.1-150.8 0-226.3z" p-id="4099"></path><path d="M119 407.5c0.1 8.9 2.6 17.3 6.4 25.1 10.4 21.4 28.9 31 51.6 31.2 74.5 0.6 149 0.2 223.4 0.2 9.3 0 18.6-0.8 27.7-3 27.1-6.7 43.6-26.4 43.8-54.4 0.5-73.8 0.2-147.6 0.2-221.4 0-4.9 0-9.8-0.9-14.7-3-16.2-10.7-29.4-24.2-39-11-7.8-23.5-11-36.9-11.4-2.3-0.1-4.9 1.2-6.9-0.9 0.7 3 3.3 2.4 5.2 2.4 4.2 0 8.3 0.6 12.4 1.1 23 3.2 41.7 19.9 47.5 42.3 1.6 6.2 2.4 12.4 2.4 18.8-0.1 74 0 147.9-0.1 221.9 0 25.7-14.6 45.3-39.1 53.1-9.2 2.9-18.7 3.9-28.1 3.9-75.1 0.2-150.2 0.3-225.4 0-16.5-0.1-31.4-5.4-43-18.1-8.8-9.7-12.3-21.5-14.3-34-0.3-1.9 0.4-4.6-2.6-5.2 1.3 0.1 0.9 1.3 0.9 2.1zM191.8 882.7c2.1-0.3 4.3-0.1 6.5-0.1h206c8.4 0 16.6-1 24.7-3.1 25.5-6.6 41.4-26.9 41.5-53.2 0.1-25.3 0-50.7 0-76v-148c0-32.3-21.4-56.2-53.6-59.7-11.4-1.2-22.9-1.7-34.4-2-34.5-0.7-69 0.5-103.4 1.3-33 0.8-66 0.2-98.9 0.7-11.5 0.2-22.6 2.7-32.7 8.1-13.6 7.2-21.9 18.5-25.7 33.4-0.7 2.8-0.1 6.5-3.7 8v234c2 5.5 2.2 11.4 3.9 17.1 5.9 20.7 19.4 33.3 39.8 38.9 6.5 1.8 13.2 2.3 19.9 2.1 1.4 0 3.3-1.1 4.4 0.9h2c0.2-2.3 2.1-2.2 3.7-2.4z m-11.4-40.6c-12.2 0-20.7-6.6-20.6-20.5 0.4-73.3 0.2-146.6 0.1-220 0-11.8 7-18.1 18.3-18.5 74.6-2.4 149.1-0.5 223.7-0.8 6.4 0 13.4-0.4 19.6 3 5.4 3 8.5 7.2 8.5 13.7-0.1 37.5 0 75 0 112.5 0 37.2-0.2 74.3 0.1 111.5 0.1 12.1-7.8 17.6-18.7 19.3-8.6 1.3-17 0-25.5-0.1-68.5-0.2-137-0.1-205.5-0.1z" p-id="4100"></path><path d="M193.5 884.2c67.8-0.1 135.7-0.1 203.5 0 9.4 0 18.7-0.2 28-2.1 12.5-2.5 23.8-7.8 32.5-17.1 9.7-10.4 14.5-23.4 14.5-37.6 0.2-74.3 0.1-148.7 0.1-223 0-6.3-0.4-12.4-2-18.5-5.3-19.9-17.3-33.7-36.7-41.3-13.3-5.2-27.3-5-41-5.3-23.1-0.5-46.2-0.9-69.3 0.5-19 1.2-38.2 0.3-57.3 1-27.6 0.9-55.3 0.3-83 0.2-6.4 0-12.7 0.6-19 2-18.4 4.2-32.5 13.8-40.6 31.3-2.6 5.7-2.8 12-5.2 17.7 3.7-1.5 3-5.2 3.7-8 3.8-14.9 12.2-26.2 25.7-33.4 10.2-5.4 21.2-7.9 32.7-8.1 33-0.5 65.9 0.1 98.9-0.7 34.5-0.8 68.9-2 103.4-1.3 11.5 0.2 23 0.7 34.4 2 32.2 3.5 53.5 27.4 53.6 59.7v148c0 25.3 0.1 50.7 0 76-0.2 26.4-16 46.6-41.5 53.2-8.1 2.1-16.3 3.1-24.7 3.1h-206c-2.2 0-4.3-0.1-6.5 0.1-1.6 0.2-3.5 0-3.7 2.4 1.5-1.9 3.7-0.8 5.5-0.8z" p-id="4101"></path><path d="M143.6 130.9c13-8 27.4-10.6 42.2-10.7 41.1-0.4 82.2-0.1 123.3-0.2 1.6 0 3.6 1.2 4.9-0.9-1.7 1-3.6 0.5-5.4 0.5-44.8 0.3-89.6-0.8-134.4 0.6-18.9 0.6-34.9 8.1-46.5 23.6-6.3 8.4-9.1 18-9.7 28.3 1.8-2.4 1.2-5.4 1.9-8.2 4-13.9 11.2-25.2 23.7-33zM840 120c6.6-0.3 13.1 0.5 19.5 2.1 21 5.4 35.7 17.8 42.8 38.8 1.6 4.8 1.8 9.9 3.3 14.7v-0.4c0.4-28.1-24.4-53.2-52.7-55.3-5.6-0.4-11.2 0.5-16.8-0.9 0.8 2.1 2.6 1.1 3.9 1zM181.6 884.2c-6.7 0.2-13.4-0.3-19.9-2.1-20.4-5.6-33.9-18.2-39.8-38.9-1.6-5.7-1.8-11.6-3.9-17.1 1.1 5.3 0.8 10.8 2.1 16.1 5.5 22.8 25.5 40.6 48.6 42 5.8 0.4 11.6-0.6 17.3 0.8-1.1-1.9-3-0.9-4.4-0.8z" p-id="4102"></path><path d="M608.4 667.2c-12.3 0.2-20.4 8.3-20.4 20V859c0 12.3 8.5 20.1 20.8 19.9 12.9-0.2 21-6.9 21.1-19.7 0.2-57.4 0.1-114.9 0-172.3 0-12-8.4-19.9-21.5-19.7zM861.4 667.4c-9.9-1.8-23.3 4.9-23.3 18.2-0.2 29.2 0 58.3 0 87.5v87c0 1.6-0.1 3.4 0.4 4.9 3.3 9.4 14.4 16.2 23.5 14 11.4-2.7 17.9-7.2 18-21.4 0.2-55.5 0.1-111 0.1-166.5-0.1-14.4-4.6-21.1-18.7-23.7zM768.7 727.3c-2.6-9.4-13-16.8-22.1-15.1-12.4 2.4-19.4 6.6-19.5 20.9-0.3 41.1-0.1 82.3-0.1 123.4 0 13.8 5.7 20 17.5 22.2 11.1 2.1 24.4-4.5 24.5-19.1v-63.5-64.5c0-1.3 0-2.9-0.3-4.3zM741 544.8c-8.7 1.9-14 10.2-14 19.8V653c0 13.1 4 21 18.1 23.7 10.3 1.9 24-5.2 23.9-18.5-0.1-15.8 0-31.6 0-47.5 0-15.3-0.2-30.6 0-46 0.3-19-14.6-22.8-28-19.9zM622 547.4c-4.9-3.4-10.1-3.3-15.4-3.3-10.5 0-18.5 7.9-18.5 18.3v26c0 9-0.1 18 0 27 0.1 4.6 1.3 8.7 4.9 12.3 5.2 5.2 11.2 6.7 18.2 6.5 9.9-0.3 18.8-8.9 18.8-18.7 0.1-17.7 0.2-35.3-0.1-53 0-6.1-2.4-11.3-7.9-15.1zM878.3 555.9c-2.2-6.2-9.8-11.8-17.9-12-14.3-0.5-23.6 7.9-22.5 22.8 0.5 7 0.1 14 0.1 21v25c0 1.5 0 3 0.4 4.4 3.2 10.3 12.9 15.5 23.9 14 11-1.6 17.4-8.4 17.6-19.7 0.3-15.8 0.1-31.7 0.1-47.5 0-2.9-0.8-5.5-1.7-8zM352 257.8c-1.9-7.3-7.9-12.7-15.4-13.7-1.3-0.2-2.7-0.4-4-0.4-0.6 0-1.5 0.2-1.7-0.8h-28.8c-0.4 0.7-1.1 0.3-1.6 0.3-13.3 0-26.6-0.1-39.9 0.1-4.8 0-9.5 0.9-13.7 3.5-4.1 2.5-6.4 6.2-7.7 10.7-0.2 0.9 0 1.9-0.6 2.6v75.5c1 0.2 0.7 1.1 0.8 1.7 0.7 4.1 1.8 7.9 4.6 11 3.7 4.1 8.6 5.8 13.9 5.9 24.3 0.1 48.7 0.1 73 0 3.1 0 6.1-0.3 9.1-1.3 7.9-2.5 12.7-8.9 12.7-17.2v-71.9c0.1-2-0.2-4-0.7-6zM785.5 250.1c-1.9-7.3-7.9-12.7-15.4-13.7-1.3-0.2-2.7-0.4-4-0.4-0.6 0-1.5 0.2-1.7-0.8h-28.8c-0.4 0.7-1.1 0.3-1.6 0.3-13.3 0-26.6-0.1-39.9 0.1-4.8 0-9.5 0.9-13.7 3.5-4.1 2.5-6.4 6.2-7.7 10.7-0.2 0.9 0 1.9-0.6 2.6v75.5c1 0.2 0.7 1.1 0.8 1.7 0.7 4.1 1.8 7.9 4.6 11 3.7 4.1 8.6 5.8 13.9 5.9 24.3 0.1 48.7 0.1 73 0 3.1 0 6.1-0.3 9.1-1.3 7.9-2.5 12.7-8.9 12.7-17.2v-71.9c0.2-2-0.2-4.1-0.7-6zM351.4 676.6c-1.9-7.3-7.9-12.7-15.4-13.7-1.3-0.2-2.7-0.4-4-0.4-0.6 0-1.5 0.2-1.7-0.8h-28.8c-0.4 0.7-1.1 0.3-1.6 0.3-13.3 0-26.6-0.1-39.9 0.1-4.8 0-9.5 0.9-13.7 3.5-4.1 2.5-6.4 6.2-7.7 10.7-0.2 0.9 0 1.9-0.6 2.6v75.5c1 0.2 0.7 1.1 0.8 1.7 0.7 4.1 1.8 7.9 4.6 11 3.7 4.1 8.6 5.8 13.9 5.9 24.3 0.1 48.7 0.1 73 0 3.1 0 6.1-0.3 9.1-1.3 7.9-2.5 12.7-8.9 12.7-17.2v-71.9c0.1-2-0.2-4-0.7-6z" p-id="4103"></path></svg>-->
<!--          </el-table-column>-->
          <el-table-column label="状态" align="center" prop="status">.
            <template slot-scope="scope">
              <dict-tag :options="dict.type.zhzt" :value="scope.row.status"/>
            </template>
          </el-table-column>
          <el-table-column label="操作" align="center" width="120" fixed='right'>.
            <template slot-scope="scope">
              <el-button
                size="mini"
                type="text"
                icon="el-icon-edit"
                @click="handleUpdate(scope.row)"
              >修改</el-button>
              <el-button
                size="mini"
                type="text"
                icon="el-icon-delete"
                @click="handleDelete(scope.row)"
              >删除</el-button>
            </template>
          </el-table-column>
        </el-table>

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

    <!-- 批量添加用户认证信息 -->
    <el-dialog :title="title" :visible.sync="openMembers"
               :close-on-click-modal="false" append-to-body>
      <el-form ref="form2" :model="form2" :rules="rules2">
        <el-row>
          <el-col :span="24">
            <el-form-item label="认证类型" prop="fixingLevelId">
              <el-select
                v-model="form2.fixingLevelId"
                placeholder="请选择"
                clearable
              >
                <el-option v-for="item in fixingLevelList" :key="item.id+''" :label="item.name" :value="item.id"/>
              </el-select>
              <div>
                <div style="color: grey;font-size: 12px;height: 18px;margin-left: 8%">
                  认证会员类型,每个会员仅支持认证一个类型
                </div>
              </div>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="手机号" prop="mobile">
              <el-input v-model="form2.mobile"
                        type="textarea"
                        maxlength="12000"
                        style="width: 85%;height: 300px;"
                        show-word-limit
                        placeholder="请输入会员手机号，多个手机号换行操作，每行一个会员手机号！单次最大支持1000个会员手机号认证~">
              </el-input>
              <div>
                <div style="color: grey;font-size: 12px;height: 18px;margin-left: 8%">
                  多个会员手机号换行操作,每行为一个会员手机号，单次最大支持1000个会员手机号认证,请确保用户手机号已注册为油站会员(在会员列表已显示),否则无法添加认证信息
                </div>
              </div>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitFormMembers">确 定</el-button>
        <el-button @click="cancelMembers">取 消</el-button>
      </div>
    </el-dialog>

    <!--    批量导入结果-->
    <el-dialog width="400px" style="margin-top: 150px" :title="title" :visible.sync="openResult" append-to-body>
      <div class="huiyuan">
        认证总数：<span class="num">{{result.total}}</span> 人
      </div>
      <div class="huiyuan">
        成功人数：<span class="num">{{result.success}}</span> 人
      </div>
      <div class="huiyuan">
        失败人数：<span class="num">{{result.error}}</span> 人
        <span v-if="result.error!=0" style="color: red;font-size: 12px">会员信息不存在</span>
      </div>
      <div class="huiyuan">
        已认证人数：<span class="num">{{result.certified}}</span> 人
      </div>
    </el-dialog>

    <!-- 添加用户认证或修改对话框 -->
    <el-dialog :title="title" :visible.sync="openMember"
               :close-on-click-modal="false" append-to-body>
      <el-form ref="form1" :model="form1" :rules="rules1">
        <el-row>
          <el-col :span="24">
            <el-form-item label="手机号" prop="mobile">
              <el-input v-model="form1.mobile"
                        style="width: 75%"
                        :disabled="isEdit"
                        placeholder="请输入用户手机号"/>
              <div>
                <div style="color: grey;font-size: 12px;height: 18px;margin-left: 8%">
                  请确保用户手机号已注册为油站会员(在会员列表已显示),否则无法添加认证信息
                </div>
              </div>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="认证类型" prop="fixingLevelId">
              <el-select
                v-model="form1.fixingLevelId"
                placeholder="请选择"
                clearable
              >
                <el-option v-for="item in fixingLevelList" :key="item.id+''" :label="item.name" :value="item.id"/>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="用户姓名" prop="name">
              <el-input
                v-model="form1.name"
                placeholder="请输入用户姓名"
                clearable
                style="width: 240px;"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="车牌号码" prop="carNumber">
              <el-input
                v-model="form1.carNumber"
                placeholder="请输入用户车牌号"
                clearable
                style="width: 240px;"
              />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item label="认证图片1" prop="photo1">
              <div>
                <el-upload
                  action="/dev-api/backendApi/file/upload"
                  :show-file-list="false"
                  list-type="picture-card"
                  :headers="headers"
                  :on-success="handleAvatarSuccess1"
                  :on-change="onChange1"
                  ref="upload"
                >
                  <img v-if="imageUrl.imageUrl1" :src="'/dev-api'+imageUrl.imageUrl1" class="avatar">
                  <i v-else class="el-icon-plus avatar-uploader-icon"></i>
                </el-upload>
              </div>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="认证图片2" prop="photo2">
              <div>
                <el-upload
                  action="/dev-api/backendApi/file/upload"
                  :show-file-list="false"
                  list-type="picture-card"
                  :headers="headers"
                  :on-success="handleAvatarSuccess2"
                  :on-change="onChange2"
                  ref="upload"
                >
                  <img v-if="imageUrl.imageUrl2" :src="'/dev-api'+imageUrl.imageUrl2" class="avatar">
                  <i v-else class="el-icon-plus avatar-uploader-icon"></i>
                </el-upload>
              </div>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="认证图片3" prop="photo3">
              <div>
                <el-upload
                  action="/dev-api/backendApi/file/upload"
                  :show-file-list="false"
                  list-type="picture-card"
                  :headers="headers"
                  :on-success="handleAvatarSuccess3"
                  :on-change="onChange3"
                  ref="upload"
                >
                  <img v-if="imageUrl.imageUrl3" :src="'/dev-api'+imageUrl.imageUrl3" class="avatar">
                  <i v-else class="el-icon-plus avatar-uploader-icon"></i>
                </el-upload>
              </div>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="备注信息">
              <el-input v-model="form1.remark"
                        type="textarea"
                        style="width: 75%"
                        placeholder="用户其他的一些信息"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="认证状态" prop="status">
              <el-radio-group v-model="form1.status">
                <el-radio label="enable">启用</el-radio>
                <el-radio label="disable">禁用</el-radio>
                <el-radio label="dsh">待审核</el-radio>
              </el-radio-group>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitFormMember">确 定</el-button>
        <el-button @click="cancelMember">取 消</el-button>
      </div>
    </el-dialog>

    <!-- 添加固定等级或修改对话框 -->
    <el-dialog :title="title" :visible.sync="open" class="roll-dialog"
               :close-on-click-modal="false" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="120px">
        <el-row>
          <el-col :span="24">
            <el-form-item label="类型名称" prop="name">
              <el-input v-model="form.name" placeholder="如：出租车认证、网约车认证" maxlength="8" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <div style="font-size: 16px">
              优惠特权
            </div>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="优惠类型" prop="discountType">
              <el-radio-group v-model="form.discountType">
<!--                <el-radio-->
<!--                  v-for="dict in dict.type.yhlx"-->
<!--                  :key="dict.value"-->
<!--                  :label="dict.label"-->
<!--                  :value="dict.value"></el-radio>-->
                <el-radio
                  label="自定义优惠"
                  value="自定义优惠"></el-radio>
              </el-radio-group>
              <div>
                <div style="color: grey;font-size: 12px;height: 18px">
                  自定义优惠:当前页面自定义简单的油品优惠
                </div>
                <div style="color: grey;font-size: 12px;height: 18px">
                  优惠活动组:使用优惠组设置来配置当前等级用户的优惠信息,支持周期性
                </div>
              </div>
            </el-form-item>
          </el-col>
        </el-row>

        <div v-if="form.discountType=='自定义优惠'">
          <el-row>
            <el-col :span="24">
              <el-form-item label="汽油优惠"  prop="gasolineDiscount">
                <el-radio-group v-model="form.gasolineDiscount">
                  <el-radio label="无优惠">无优惠</el-radio>
                  <el-radio label="满减优惠">满减优惠</el-radio>
                  <el-radio label="每升优惠">每升优惠</el-radio>
                </el-radio-group>
                <div v-if="form.gasolineDiscount != '无优惠'">
                  <div v-for="(item,idx) in gasolinePreferential" style="display: flex">
                    <el-input v-model="item.gasolineRule1" placeholder="1" style="width: 260px;">
                      <template slot="prepend">消费满</template>
                      <template slot="append">元，</template>
                    </el-input>
                    <el-input v-model="item.gasolineRule2" placeholder="1" style="width: 260px;" v-if="form.gasolineDiscount == '满减优惠'">
                      <template slot="prepend">立减</template>
                      <template slot="append">元</template>
                    </el-input>
                    <el-input v-model="item.gasolineRule3" placeholder="1" style="width: 260px;" v-if="form.gasolineDiscount == '每升优惠'">
                      <template slot="prepend">每升优惠</template>
                      <template slot="append">元</template>
                    </el-input>
                    <el-button v-if="idx==0" type="primary" @click="addGasOline()" icon="el-icon-plus" style="margin-left: 20px"></el-button>
                    <el-button v-else type="danger" @click="subGasOline(idx)" icon="el-icon-close" style="margin-left: 20px"></el-button>
                  </div>
                </div>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="24">
              <el-form-item label="柴油优惠" prop="dieselDiscount">
                <el-radio-group v-model="form.dieselDiscount">
                  <el-radio label="无优惠">无优惠</el-radio>
                  <el-radio label="满减优惠">满减优惠</el-radio>
                  <el-radio label="每升优惠">每升优惠</el-radio>
                </el-radio-group>
                <div v-if="form.dieselDiscount != '无优惠'">
                  <div v-for="(item,idx) in dieselPreferential" style="display: flex">
                    <el-input v-model="item.dieselRule1" placeholder="1" style="width: 260px;">
                      <template slot="prepend">消费满</template>
                      <template slot="append">元，</template>
                    </el-input>
                    <el-input v-model="item.dieselRule2" placeholder="1" style="width: 260px;" v-if="form.dieselDiscount == '满减优惠'">
                      <template slot="prepend">立减</template>
                      <template slot="append">元</template>
                    </el-input>
                    <el-input v-model="item.dieselRule3" placeholder="1" style="width: 260px;" v-if="form.dieselDiscount == '每升优惠'">
                      <template slot="prepend">每升优惠</template>
                      <template slot="append">元</template>
                    </el-input>
                    <el-button v-if="idx==0" type="primary" @click="addDiesel()" icon="el-icon-plus" style="margin-left: 20px"></el-button>
                    <el-button v-else type="danger" @click="subDiesel(idx)" icon="el-icon-close" style="margin-left: 20px"></el-button>
                  </div>
                </div>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="24">
              <el-form-item label="天然气优惠" prop="naturalGasDiscount">
                <el-radio-group v-model="form.naturalGasDiscount">
                  <el-radio label="无优惠">无优惠</el-radio>
                  <el-radio label="满减优惠">满减优惠</el-radio>
                  <el-radio label="每单位优惠">每单位优惠</el-radio>
                </el-radio-group>
                <div v-if="form.naturalGasDiscount != '无优惠'">
                  <div v-for="(item,idx) in naturalGasPreferential" style="display: flex">
                    <el-input v-model="item.naturalGas1" placeholder="1" style="width: 260px;">
                      <template slot="prepend">消费满</template>
                      <template slot="append">元，</template>
                    </el-input>
                    <el-input v-model="item.naturalGas2" placeholder="1" style="width: 260px;" v-if="form.naturalGasDiscount == '满减优惠'">
                      <template slot="prepend">立减</template>
                      <template slot="append">元</template>
                    </el-input>
                    <el-input v-model="item.naturalGas3" placeholder="1" style="width: 260px;" v-if="form.naturalGasDiscount == '每单位优惠'">
                      <template slot="prepend">每单位优惠</template>
                      <template slot="append">元</template>
                    </el-input>
                    <el-button v-if="idx==0" type="primary" @click="addNaturalGas()" icon="el-icon-plus" style="margin-left: 20px"></el-button>
                    <el-button v-else type="danger" @click="subNaturalGas(idx)" icon="el-icon-close" style="margin-left: 20px"></el-button>
                  </div>
                </div>
              </el-form-item>
            </el-col>
          </el-row>
        </div>
        <div v-else>
          <el-row>
            <el-col :span="24">
              <el-form-item label="关联优惠组" prop="promotionGroup">
                <el-select v-model="form.promotionGroup">
                  <el-option
                    v-for="dict in dict.type.yhhdz"
                    :key="dict.value"
                    :label="dict.label"
                    :value="dict.value"
                  />
                </el-select>
                <div>
                  <div style="color: grey;font-size: 12px;height: 18px">
                    关联组后当前等级的用户优惠将按照优惠组的规则享受满减优惠
                  </div>
                  <div style="color: grey;font-size: 12px;height: 18px">
                    优惠活动组请前往活动营销-特惠活动-优惠活动组进行配置
                  </div>
                </div>
              </el-form-item>
            </el-col>
          </el-row>
        </div>

        <el-row>
          <el-col :span="24">
            <el-form-item label="积分参与" prop="pointRule">
              <el-radio-group v-model="form.pointRule">
                <el-radio label="yes">参与</el-radio>
                <el-radio label="no">不参与</el-radio>
              </el-radio-group>
              <div>
                <div style="color: grey;font-size: 12px;height: 18px">
                  如系统启用消费获得积分,当前设置不参与则用户消费后不获得积分
                </div>
              </div>
            </el-form-item>
          </el-col>
        </el-row>
<!--        <el-row>-->
<!--          <el-col :span="24">-->
<!--            <el-form-item label="加油金参与" prop="refuelMoneyRule">-->
<!--              <el-radio-group v-model="form.refuelMoneyRule">-->
<!--                <el-radio label="yes">参与</el-radio>-->
<!--                <el-radio label="no">不参与</el-radio>-->
<!--              </el-radio-group>-->
<!--              <div>-->
<!--                <div style="color: grey;font-size: 12px;height: 18px">-->
<!--                  启用参与后将参与加油金的获得和使用,相反则无法获得加油金且无法使用-->
<!--                </div>-->
<!--              </div>-->
<!--            </el-form-item>-->
<!--          </el-col>-->
<!--        </el-row>-->
        <el-row>
          <el-col :span="24">
            <el-form-item label="成长值参与" prop="growthValueRule">
              <el-radio-group v-model="form.growthValueRule">
                <el-radio label="yes">参与</el-radio>
                <el-radio label="no">不参与</el-radio>
              </el-radio-group>
              <div>
                <div style="color: grey;font-size: 12px;height: 18px">
                  如系统启用会员等级,当设置不参与,用户消费后将不获得对应成长值
                </div>
              </div>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="优惠券参与" prop="couponRule">
              <el-radio-group v-model="form.couponRule">
                <el-radio label="yes">参与</el-radio>
                <el-radio label="no">不参与</el-radio>
              </el-radio-group>
              <div>
                <div style="color: grey;font-size: 12px;height: 18px">
                  如用户有优惠券,消费是否可以直接使用优惠券抵用优惠、设置不参与、用户消费无法使用优惠券
                </div>
              </div>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="储值优惠参与" prop="storeValue">
              <el-radio-group v-model="form.storeValue">
                <el-radio label="yes">参与</el-radio>
                <el-radio label="no">不参与</el-radio>
              </el-radio-group>
              <div>
                <div style="color: grey;font-size: 12px;height: 18px">
                  如系统启用营销功能储值优惠当前参数有效,当设置不参与,用户消费时将无法享受会员储值优惠
                </div>
              </div>
            </el-form-item>
          </el-col>
        </el-row>
<!--        <el-row>-->
<!--          <el-col :span="24">-->
<!--            <el-form-item label="认证审核" prop="process">-->
<!--              <el-radio-group v-model="form.process">-->
<!--                <el-radio label="sh">审核</el-radio>-->
<!--                <el-radio label="bsh">不审核</el-radio>-->
<!--              </el-radio-group>-->
<!--              <div>-->
<!--                <div style="color: grey;font-size: 12px;height: 18px">-->
<!--                  专车二维码用户扫码提交认证后是否需要审核-->
<!--                </div>-->
<!--              </div>-->
<!--            </el-form-item>-->
<!--          </el-col>-->
<!--        </el-row>-->
        <el-row>
          <el-col :span="24">
            <el-form-item label="类型状态" prop="status">
              <el-radio-group v-model="form.status">
                <el-radio label="qy">启用</el-radio>
                <el-radio label="jy">禁用</el-radio>
              </el-radio-group>
              <div>
                <div style="color: grey;font-size: 12px;height: 18px">
                  启用后,属于当前认证类型的用户才可享受当前类型的优惠配置规则
                </div>
              </div>
            </el-form-item>
          </el-col>
        </el-row>
      </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>
  </div>
</template>

<script>
import {
  addFixingLevel,
  delFixingLevel,
  getFixingLevel,
  listFixingLevel, queryFixingLevel,
  updateFixingLevel
} from "@/api/staff/user/fixinglevel";
import {
  addCertifiedMember, addCertifiedMembers,
  delCertifiedMember,
  getCertifiedMember, getCertifiedMemberByUserId,
  listCertifiedMember,
  updateCertifiedMember
} from "@/api/staff/user/certifiedmember";
import {getUser, getUserMobile, listUser} from "@/api/staff/user/user";
import {getToken} from "@/utils/auth";

export default {
  dicts: ['yhlx','yes_or_no','zhzt','yhhdz','rzzt'],
  data() {
    return {
      headers: {
        'Access-Token': getToken(),
      },
      result:{},
      isEdit:false,
      // 上传图片信息
      imageUrl: {
        imageUrl1: '',
        imageUrl2: '',
        imageUrl3: '',
      },
      mobile:'',
      activeName: 'member',
      // 显示搜索条件
      showSearch: true,
      // 固定等级列表
      fixingLevelList:[],
      // 会员信息列表
      userList:[],
      mobile1:'',
      // 查询参数
      queryParams: {
        page: 1,
        pageSize: 10,
        id: '',
        mobile:'',
        type: '',
        status: '',
      },// 查询参数
      queryParam: {
        page: 1,
        pageSize: 10,
        userId: '',
        mobile: '',
        id: '',
        type: '',
        status: '',
      },
      // 遮罩层
      loading: true,
      // 日期范围
      dateRange: [],
      // 总条数
      total: 0,
      // 表格数据
      list: [],
      // 表格数据
      listMember: [],
      // 默认排序
      defaultSort: {prop: 'updateTime', order: 'descending'},
      // 标题
      title: "",
      // 选中数组
      ids: [],
      // 是否显示弹出层
      open: false,
      openMember: false,
      openMembers: false,
      openResult: false,
      // 表单参数
      form: {
        id: '', name: '',discountType:'自定义优惠',gasolineDiscount:'无优惠',
        dieselDiscount:'无优惠',naturalGasDiscount:'无优惠',promotionGroup:'',
        pointRule:'yes',refuelMoneyRule:'yes',growthValueRule:'yes',couponRule:'yes',
        storeValue:'yes',process:'bsh',status: 'qy'
      },
      form1:{
        id: '', name: '',mobile:'',carNumber:'',userId:'',
        attestationData:'',remark:'',status: 'enable'
      },
      form2:{},
      // 优惠值
      gasolinePreferential:[
        {
          gasolineRule1:1,
          gasolineRule2:1,
          gasolineRule3:1,
        }
      ],
      dieselPreferential:[
        {
          dieselRule1:1,
          dieselRule2:1,
          dieselRule3:1,
        }
      ],
      naturalGasPreferential:[
        {
          naturalGas1:1,
          naturalGas2:1,
          naturalGas3:1,
        }
      ],
      // 表单校验
      rules: {
        name: [
          { required: true, message: "请填写认证名称", trigger: "blur" },
        ],
        discountType: [
          { required: true, message: "请选择优惠类型", trigger: "blur" },
        ],
        gasolineDiscount: [
          { required: true, message: "请选择优惠类型", trigger: "blur" },
        ],
        dieselDiscount: [
          { required: true, message: "请选择优惠类型", trigger: "blur" },
        ],
        naturalGasDiscount: [
          { required: true, message: "请选择优惠类型", trigger: "blur" },
        ],
        pointRule: [
          { required: true, message: "请选择是否参与积分规则", trigger: "blur" },
        ],
        refuelMoneyRule: [
          { required: true, message: "请选择是否参与加油金规则", trigger: "blur" },
        ],
        growthValueRule: [
          { required: true, message: "请选择是否参与成长值规则", trigger: "blur" },
        ],
        couponRule: [
          { required: true, message: "请选择是否参与优惠券规则", trigger: "blur" },
        ],
        storeValue: [
          { required: true, message: "请选择是否参与储值优惠规则", trigger: "blur" },
        ],
        process: [
          { required: true, message: "请选择是否进行认证审核", trigger: "blur" },
        ],
        status: [
          { required: true, message: "请选择类型状态", trigger: "blur" },
        ],
      },
      // 表单校验
      rules1: {
        mobile: [
          { required: true, message: "手机号不能为空", trigger: "blur" },
          { min: 7, max: 11, message: '请输入正确的手机号', trigger: 'blur' }
        ],
        fixingLevelId: [
          { required: true, message: "请选择认证类型", trigger: "blur" },
        ],
        status: [
          { required: true, message: "请选择认证状态", trigger: "blur" },
        ],
      },
      // 表单校验
      rules2: {
        mobile: [
          { required: true, message: "请填写认证手机号", trigger: "blur" },
        ],
        fixingLevelId: [
          { required: true, message: "请选择认证类型", trigger: "blur" },
        ],
      },
    };
  },
  created() {
    this.getList();
    this.getListMember();
    this.getUserList();
  },
  methods: {
    handleClick(tab, event) {
      // console.log(tab, event);
    },
    // 搜索按钮操作
    handleQuery() {
      this.queryParams.page = 1;
      this.getList();
    },
    // 搜索按钮操作
    handleQueryMember() {
      this.queryParams.page = 1;
      this.getListMember();
    },
    // 获取固定等级信息
    getList(){
      this.loading = true;
      listFixingLevel(this.addDateRange(this.queryParams, this.dateRange)).then( response => {
        this.list = response.data.records;
        this.fixingLevelList = response.data.records;
        this.total = response.data.total;
        this.loading = false;
      });
    },
    // 获取认证会员信息
    getListMember(){
      this.loading = true;
      listCertifiedMember(this.addDateRange(this.queryParam, this.dateRange)).then( response => {
        this.listMember = response.data.records;
        this.total = response.data.total;
        this.loading = false;
      });

    },
    // 获取会员信息
    getUserList(){
      listUser(this.addDateRange({mobile:this.mobile1})).then( response => {
        this.userList = response.data.records;
      });
    },
    // 表单
    reset() {
      this.form = {
        id: '', name: '',discountType:'自定义优惠',gasolineDiscount:'无优惠',
        dieselDiscount:'无优惠',naturalGasDiscount:'无优惠',promotionGroup:'',
        pointRule:'yes',refuelMoneyRule:'yes',growthValueRule:'yes',couponRule:'yes',
        storeValue:'yes',process:'bsh',status: 'qy'
      };
      this.gasolinePreferential=[
        {
          gasolineRule1:1,
          gasolineRule2:1,
          gasolineRule3:1,
        }
      ],
        this.dieselPreferential=[
          {
            dieselRule1:1,
            dieselRule2:1,
            dieselRule3:1,
          }
        ],
        this.naturalGasPreferential=[
          {
            naturalGas1:1,
            naturalGas2:1,
            naturalGas3:1,
          }
        ],
        this.resetForm("form");
    },
    // 表单重置
    reset1() {
      this.form1 = {
        id: '', name: '',mobile:'',carNumber:'',userId:'',
        attestationData:'',remark:'',status: 'enable'
      };
      this.imageUrl={
        imageUrl1 : "",
        imageUrl2 : "",
        imageUrl3 : "",
      };
      this.resetForm("form1");
    },
    reset2() {
      this.form2 = {};
      this.resetForm("form2");
    },
    // 新增按钮操作
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "新增固定等级类型";
    },
    // 新增按钮操作
    handleAddMember() {
      this.openMember = true;
      this.title = "新增用户认证";
    },
    handleAvatarSuccess1(res, file) {
      // this.imageUrl.imageUrl1 = URL.createObjectURL(file.raw);
      this.imageUrl.imageUrl1 = res.data.fileName;
    },
    handleAvatarSuccess2(res, file) {
      this.imageUrl.imageUrl2 = res.data.fileName;
    },
    handleAvatarSuccess3(res, file) {
      this.imageUrl.imageUrl3 = res.data.fileName;
    },
    onChange1 (file,fileList) {
      if(file){
        const suffix = file.name.split('.')[1]
        const size = file.size / 1024 / 1024 < 2
        if(['png','jpeg','jpg'].indexOf(suffix) < 0){
          this.$message.error('上传图片只支持 png、jpeg、jpg 格式！')
          this.$refs.upload.clearFiles()
          return false
        }
        if(!size){
          this.$message.error('上传文件大小不能超过 2MB!')
          return false
        }
        return file
      }
    },
    onChange2 (file,fileList) {
      if(file){
        const suffix = file.name.split('.')[1]
        const size = file.size / 1024 / 1024 < 2
        if(['png','jpeg','jpg'].indexOf(suffix) < 0){
          this.$message.error('上传图片只支持 png、jpeg、jpg 格式！')
          this.$refs.upload.clearFiles()
          return false
        }
        if(!size){
          this.$message.error('上传文件大小不能超过 2MB!')
          return false
        }
        return file
      }
    },
    onChange3 (file,fileList) {
      if(file){
        const suffix = file.name.split('.')[1]
        const size = file.size / 1024 / 1024 < 2
        if(['png','jpeg','jpg'].indexOf(suffix) < 0){
          this.$message.error('上传图片只支持 png、jpeg、jpg 格式！')
          this.$refs.upload.clearFiles()
          return false
        }
        if(!size){
          this.$message.error('上传文件大小不能超过 2MB!')
          return false
        }
        return file
      }
    },
    // 新增按钮操作
    handleAddMembers() {
      this.openMembers = true;
      this.title = "批量用户认证";
    },
    // 修改按钮操作
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids;
      getFixingLevel(id).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "编辑固定等级类型";
      });
    },
    // 修改按钮操作
    handleUpdateMember(row) {
      this.isEdit = true;
      this.reset1();
      const id = row.id || this.ids;
      getCertifiedMember(id).then(response => {
        this.form1 = response.data;
        this.openMember = true;
        this.title = "编辑用户认证";
        if (this.form1.attestationData!=null && this.form1.attestationData!=""){
          this.imageUrl = JSON.parse(this.form1.attestationData)
        }
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 取消按钮
    cancelMember() {
      this.openMember = false;
      this.reset1();
      this.isEdit = false;
    },
    // 取消按钮
    cancelMembers() {
      this.openMembers = false;
      this.reset2();
    },
    // 提交按钮 固定等级
    submitForm: function() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          this.form.gasolineRule = JSON.stringify(this.gasolinePreferential)
          this.form.dieselRule = JSON.stringify(this.dieselPreferential)
          this.form.naturalGasRule = JSON.stringify(this.naturalGasPreferential)
          if (this.form.id) {
            updateFixingLevel(this.form).then(response => {
              this.$modal.msgSuccess("认证类型更新成功");
              this.open = false;
              this.getList();
            });
          } else {
            queryFixingLevel({name:this.form.name}).then( response => {
              if(response.data!=null){
                this.$modal.msgError("固定等级名称不可重复");
              }else {
                addFixingLevel(this.form).then(response => {
                  this.$modal.msgSuccess("认证类型创建成功");
                  this.open = false;
                  this.getList();
                });
              }
            })
          }
        }
      });
    },
    // 提交按钮 单个认证会员信息
    submitFormMember: function() {
      this.$refs["form1"].validate(valid => {
        if (valid) {
          this.form1.attestationData = JSON.stringify(this.imageUrl)
          if (this.form1.id) {
            updateCertifiedMember(this.form1).then(response => {
              this.$modal.msgSuccess("用户认证信息更新成功");
              this.openMember = false;
              this.isEdit = false;
              this.reset1();
              this.getListMember();
            });
          } else {
            getUserMobile({mobile:this.form1.mobile}).then( response => {
              if (response.data==null){
                this.$modal.msgError("用户信息不存在,请检查当前用户是否已注册")
              }else {
                this.form1.userId = response.data.id
                getCertifiedMemberByUserId(this.form1.userId).then( res => {
                  if(res.data!=null){
                    this.$modal.msgError("当前用户已存在认证记录,请检索后编辑对应用户资料处理")
                  }
                  if(res.data==null){
                    addCertifiedMember(this.form1).then(response => {
                      this.$modal.msgSuccess("新增用户认证信息成功");
                      this.openMember = false;
                      this.reset1();
                      this.getListMember();
                    });
                  }
                })
              }
            })
          }
        }
      });
    },
    // 提交按钮 批量认证会员信息
    submitFormMembers: function() {
      this.$refs["form2"].validate(valid => {
        if (valid) {
          addCertifiedMembers(this.form2).then(response => {
            this.openMembers = false;
            this.openResult = true;
            this.title = "会员认证结果";
            this.result = response.data;
            this.reset2();
            this.getListMember();
          })
        }
      });
    },
    // 删除按钮操作
    handleDelete(row) {
      const name = row.name
      this.$modal.confirm('所绑定的认证会员信息将会失效！！确定删除"' + name + '"的固定等级信息？').then(function() {
        // return deleteMember(row.id);
        return delFixingLevel(row.id);
      }).then(() => {
        this.queryParams.page = 1
        this.getList();
        this.getListMember();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {});
    },
    // 删除按钮操作
    handleDeleteMember(row) {
      const name = row.name
      this.$modal.confirm('确定删除"' + name + '"的认证会员信息？').then(function() {
        // return deleteMember(row.id);
        return delCertifiedMember(row.id);
      }).then(() => {
        this.queryParam.page = 1
        this.getListMember();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {});
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.multiple = !selection.length
    },
    // 排序触发事件
    handleSortChange(column, prop, order) {
      this.queryParams.orderByColumn = column.prop;
      this.queryParams.isAsc = column.order;
      this.getList();
    },
    addGasOline(){
      let temp= {
        gasolineRule1:1,
        gasolineRule2:1,
        gasolineRule3:1,
      }
      this.gasolinePreferential.push(temp);
    },
    subGasOline(idx){
      this.gasolinePreferential.splice(idx-1,1);
    },
    addDiesel(){
      let temp= {
        dieselRule1:1,
        dieselRule2:1,
        dieselRule3:1,
      }
      this.dieselPreferential.push(temp);
    },
    subDiesel(idx){
      this.dieselPreferential.splice(idx-1,1);
    },
    addNaturalGas(){
      let temp= {
        naturalGas1:1,
        naturalGas2:1,
        naturalGas3:1,
      }
      this.naturalGasPreferential.push(temp);
    },
    subNaturalGas(idx){
      this.naturalGasPreferential.splice(idx-1,1);
    },
  }
}
</script>

<style lang="scss" scoped>
  .app-container{
    width: 100%;
    height: 100%;
    background: #f6f8f9;
  }
  .huiyuan{
    height: 30px;
    line-height: 30px;
    font-size: 16px;
  }
  .num{
    font-weight: bold;
    color: red;
    font-size: 18px;
  }
  .roll-dialog ::v-deep .el-dialog .el-dialog__body {
    padding: 3px 30px;
    overflow-y: scroll;
    height: 600px;
  }
  .avatar{
    width: 100%;
    height: 100%;
  }
  .attImg{
    width: 40px;
    height: 40px;
    margin: 2px;
    border-radius: 50%;
  }
</style>
