<template>
  <div class="app-center">
<!--    支付金额、会员登录-->
    <div class="center-left">
      <div class="center-vh">
        <div class="center-left-top">
          <div class="vip-bottom" v-if="isMember == false" @click="dialogVisiblevip = true">
            <div>会员登录</div>
          </div>
          <div v-else style="width: 96%;margin: 0 auto;display: flex;justify-content: space-between">
            <div
                 style="display: flex;color: white;justify-content: space-around;width: 55%;
                 height: 90%;border-radius: 10px;
                 padding-top: 10px;
                 background-color: rgb(67,119,204)">
              <div>
                <template>
                  <img v-if="member.avatar" class="list-avatar" :src="member.avatar">
                  <img v-else class="list-avatar" src="@/assets/images/avatar.png">
                </template>
              </div>
              <div style="text-align: center">
                <span style="margin-bottom: 10px">{{ member.name }}</span><br/>
                <span>{{ member.mobile }}</span>
              </div>
              <div style="background-color: rgba(46,82,142,0.65);width: 50px;height: 45px;padding-top: 5px;
                    border-radius: 5px;text-align: center">
                <el-tooltip placement="top">
                  <div slot="content">
                    <p>会员储值账户余额：{{ member.cardBalance }}</p>
                    <p>积分余额：{{ member.points }}</p>
                  </div>
                  <i class="el-icon-bank-card" style="font-size: 35px"></i>
                </el-tooltip>
              </div>
              <div style="background-color: rgba(46,82,142,0.65);width: 50px;height: 45px;padding-top: 5px;
                    border-radius: 5px;text-align: center">
                <el-tooltip placement="top">
                  <div slot="content">
                    会员等级：{{ gradeName }}
                  </div>
                  <i class="el-icon-medal" style="font-size: 35px"></i>
                </el-tooltip>
              </div>
            </div>
            <div class="vip-bottom" style="height: 40px;margin-top: 10px" @click="resetMember">
              <div>重置会员</div>
            </div>
          </div>
        </div>
        <div class="center-left-hj">
          <div class="hj-box" style="justify-content: left">油品:￥{{ oilAmount }}</div>
          <div class="hj-box" style="border-left: 1px solid #d1d1d4; border-right: 1px solid #d1d1d4;">商品:￥{{ goodsAmount }}</div>
          <div class="hj-box" style="justify-content: flex-end">合计: ￥{{ oilAmount + goodsAmount }}</div>
        </div>
        <div class="center-left-hj">
          <div>
            <el-popover
              placement="bottom-start"
              width="400"
              trigger="click">
              <div>
                <el-checkbox-group v-model="checkedCities1" @change="handleCheckedCitiesChange1">
                  <el-checkbox v-for="(item,index) in fullReduceDiscount" :label="item.type" :key="index">
                    <div style="display: flex;justify-content: space-between;height: 40px;line-height: 40px;">
                      <div style="width: 200px">{{item.type}}</div>
                      <div style="line-height: 20px;width:150px;font-size: 12px;text-align: right">
                        <div style="color: red">-￥{{ fullReduction }}</div>
                        <div style="color: grey" v-if="item.discount!=0">满{{ item.full }}元，打{{ item.discount }}折</div>
                        <div style="color: grey" v-else>满{{ item.full }}元，减{{ item.reduce }}元</div>
                      </div>
                    </div>
                  </el-checkbox>
                </el-checkbox-group>
              </div>
              <div slot="reference">
                <el-checkbox :indeterminate="isIndeterminate1"
                             style="color: black;font-size: 16px"
                             v-model="checkAll1" @change="handleCheckAllChange1">
                </el-checkbox>
                满减活动
              </div>
            </el-popover>
          </div>
          <div>-￥{{ fullReduction + goodsDiscount }}</div>
        </div>
        <div class="center-left-hj" v-show="isMember">
          <div>
            <el-popover
              placement="bottom-start"
              width="400"
              trigger="click">
              <div>
                <el-checkbox-group v-model="checkedCities2" @change="handleCheckedCitiesChange2">
                  <el-checkbox v-for="(item,index) in gradeDiscount" :label="item.type" :key="index">
                    <div style="display: flex;justify-content: space-between;height: 40px;line-height: 40px;">
                      <div style="width: 200px">{{item.type}}</div>
                      <div style="line-height: 20px;width:150px;font-size: 12px;text-align: right">
                        <div style="color: red">-￥{{ oilDiscount }}</div>
                        <div v-if="item.type=='满减优惠'" style="color: grey">消费满{{ item.full }}元，立减{{ item.reduce }}元</div>
                        <div v-else style="color: grey">消费满{{ item.full }}元，每升优惠{{ item.reduce }}元</div>
                      </div>
                    </div>
                  </el-checkbox>
                </el-checkbox-group>
              </div>
              <div slot="reference">
                <el-checkbox :indeterminate="isIndeterminate2"
                             style="color: black;font-size: 16px"
                             v-model="checkAll2" @change="handleCheckAllChange2">
                </el-checkbox>
                等级优惠
              </div>
            </el-popover>
          </div>
          <div>-￥{{ oilDiscount + goodsDiscount }}</div>
        </div>
        <div class="center-left-hj" v-show="isMember && refuelMoney!=null">
          <div>
            <el-popover
              placement="bottom-start"
              width="400"
              trigger="click">
              <div>
                <el-checkbox-group v-model="checkedCities3" @change="handleCheckedCitiesChange3">
                  <el-checkbox v-for="city in cities3" :label="city" :key="city">
                    <div style="display: flex;justify-content: space-between;height: 40px;line-height: 40px;">
                      <div style="width: 200px">{{city}}</div>
                      <div style="line-height: 20px;width:150px;font-size: 12px;text-align: right">
                        <div style="color: red">-￥1.56</div>
                        <div style="color: grey">满100元每升优惠0.2元</div>
                      </div>
                    </div>
                  </el-checkbox>
                </el-checkbox-group>
              </div>
              <div slot="reference">
                <el-checkbox :indeterminate="isIndeterminate3"
                             style="color: black;font-size: 16px"
                             v-model="checkAll3" @change="handleCheckAllChange3">
                </el-checkbox>
                囤油卡
                <div style="margin: 5px 0" v-for="(item,index) in refuelMoney" :key="index">
                  （{{ item.type }}卡
                  <span style="color: #00afff">{{ item.oilType }}</span>
                  余额：{{ item.refuelMoney }}L）
                </div>
              </div>
            </el-popover>
          </div>
          <div>- {{ consumeRefuelMoney }}L</div>
        </div>
        <div class="center-left-hj" v-show="isMember">
          <div>
            <el-popover
              placement="bottom-start"
              width="400"
              trigger="click">
              <div>
                <el-checkbox-group v-model="checkedCities4" @change="handleCheckedCitiesChange4">
                  <el-checkbox v-for="city in cities4" :label="city" :key="city">
                    <div style="display: flex;justify-content: space-between;height: 40px;line-height: 40px;">
                      <div style="width: 200px">{{city}}</div>
                      <div style="line-height: 20px;width:150px;font-size: 12px;text-align: right">
                        <div style="color: red">-￥1.56</div>
                        <div style="color: grey">满100元每升优惠0.2元</div>
                      </div>
                    </div>
                  </el-checkbox>
                </el-checkbox-group>
              </div>
              <div slot="reference">
                <el-checkbox :indeterminate="isIndeterminate4"
                             style="color: black;font-size: 16px"
                             v-model="checkAll4" @change="handleCheckAllChange4">
                </el-checkbox>
                储值卡
                <span>（账户余额：{{ balance }}元）</span>
              </div>
            </el-popover>
          </div>
          <div>-￥{{ consumeAmount }}</div>
        </div>
        <div class="center-left-hj" v-show="isMember">
          <div>
            <el-popover
              placement="bottom-start"
              width="400"
              trigger="click">
              <div>
                <el-checkbox-group v-model="checkedCities5" @change="handleCheckedCitiesChange5">
                  <el-checkbox v-for="city in cities5" :label="city" :key="city">
                    <div style="display: flex;justify-content: space-between;height: 40px;line-height: 40px;">
                      <div style="width: 200px">{{city}}</div>
                      <div style="line-height: 20px;width:150px;font-size: 12px;text-align: right">
                        <div style="color: red">-￥1.56</div>
                        <div style="color: grey">满100元每升优惠0.2元</div>
                      </div>
                    </div>
                  </el-checkbox>
                </el-checkbox-group>
              </div>
              <div slot="reference">
                <el-checkbox :indeterminate="isIndeterminate5"
                             style="color: black;font-size: 16px"
                             v-model="checkAll5" @change="handleCheckAllChange5">
                </el-checkbox>
                优惠券
              </div>
            </el-popover>
          </div>
          <div>-￥{{ couponAmount }}</div>
        </div>
        <div class="center-left-th">
          <div class="th-box">
            <div>扫码支付</div>
            <div class="bule">{{ oilActualPay + goodsActualPay }}</div>
          </div>
          <div class="th-box">
            <div>找零</div>
            <div class="bule">{{ seekZero }}</div>
          </div>
          <div class="th-box">
            <div @click="dialogVisible = true">加油员</div>
            <div style="cursor: pointer;color: crimson" @click="dialogVisible = true" >{{ staff.realName }}</div>
          </div>
        </div>
      </div>
      <div class="bottom-posi">
        <div class="center-left-wrap">
          <div class="wrap-box" v-for="item in payList"
               :key="item.dictValue"
               :value="item.dictValue">
            <span @click="payMethod(item.dictValue)">{{ item.dictLabel }}</span>
          </div>
          <div class="wrap-box" >
            <span @click="addCredits">挂账</span>
          </div>
        </div>
        <div class="center-left-bottom">
          <div>
            <div class="bottom-price">￥{{ oilActualPay + goodsActualPay }}</div>
            <div class="price-red">优惠合计：{{ oilDiscount + goodsDiscount }}元/{{consumeRefuelMoney}}L</div>
          </div>
          <div class="center-left-lv" @click="settlement">立即结算</div>
        </div>
      </div>

    </div>

<!--    油品选择-->
    <div class="center-right">
      <div class="center-top">
        <div class="center-top-tab">
          <el-tabs v-model="activeName" @tab-click="handleClick">
            <el-tab-pane label="全部" name="1"></el-tab-pane>
            <el-tab-pane v-for="item in oilNameList" :key="item.id"
                         :label="item.oilName" :name="item.id+''"></el-tab-pane>
<!--            <el-tab-pane v-for="(item,index) in gunList" :key="index"-->
<!--                         :label="item.oilName" :name="item.numberId+''"></el-tab-pane>-->
          </el-tabs>
        </div>

        <div class="center-top-data">
          <div class="center-top-of">
            <div class="wrap-wrap">
              <div class="of-box" v-for="(item,index) in gunList" :key="index"
                   :style="{'background-color': colorList[index%5].color}"
                   @click="refuel(item)">
<!--                <div>{{ getName(oilNameList,item.oilName) }}</div>-->
                <div>{{ item.oilNumber }}</div>

                <div class="of-title" >{{item.gunName}}</div>
                <div style="display: flex;justify-content: space-between">
                  <img src="../../../assets/images/jya.png" style="width: 18px;height: 18px;">
                  <span style="font-size: 12px">{{ item.tankName }}</span>
                </div>
              </div>
<!--              <div class="of-box" v-for="(item,index) in oilNumGunList" :key="index"-->
<!--                   :style="{'background-color': colorList[index%5].color}"-->
<!--                   @click="refuel(item.id)">-->
<!--                <div>{{ getName(oilNameList,item.oilName) }}</div>-->

<!--                <div class="of-title" >{{item.oilGunNum}}号枪</div>-->
<!--                <div>-->
<!--                  <img src="../../../assets/images/jya.png" style="width: 18px;height: 18px;">-->
<!--                </div>-->
<!--              </div>-->
            </div>
          </div>

          <!--            -->
          <div class="content-top-bottom">
            <div>订单笔数 <span class="bule">{{ oilTotal }}件</span> </div>
            <div>订单金额 <span class="bule">￥{{ oilAmount }}</span> </div>
          </div>
        </div>
      </div>
      <div class="center-left-bottom">
        <div class="bottom-gd" @click="resetting">重置</div>
<!--        <div class="bottom-qk">解锁</div>-->
      </div>
    </div>

<!--    商品选择-->
    <div class="center-app">
      <div class="center-top">
        <div class="center-top-title">非油商品</div>
        <div class="center-top-input">
          <template>
            <el-autocomplete
              popper-class="my-autocomplete"
              style="width: 94%"
              v-model="goods"
              :fetch-suggestions="querySearch"
              placeholder="商品名称，商品关键词，商品条码"
              @select="changeGoods">
              <template slot-scope="{ item }">
                <div style="display: flex;justify-content: space-between">
                  <span class="name">{{ item.name }}</span>
                  <span v-if="isMember" class="addr">{{ item.memberPrice }}</span>
                  <span v-else class="addr">{{ item.retailPrice }}</span>
                </div>
              </template>
            </el-autocomplete>
<!--            <el-select v-model="goods" filterable-->
<!--                       style="width: 95%;font-size: 20px;"-->
<!--                       @change="changeGoods"-->
<!--                       @keydown.enter.native="queryGoods"-->
<!--                       clearable-->
<!--                       placeholder="请输入商品名称，商品关键词">-->
<!--              <el-option-->
<!--                v-for="item in goodsList"-->
<!--                :key="item.id"-->
<!--                :label="item.name"-->
<!--                :value="item.id">-->
<!--                <span style="float: left">{{ item.name }}</span>-->
<!--                <span style="float: right; color: #8492a6; font-size: 13px">{{ item.retailPrice }}</span>-->
<!--              </el-option>-->
<!--            </el-select>-->
          </template>
        </div>
        <div class="center-top-data">
          <div class="data-top">
            <div class="data-top-title">商品</div>
            <div class="data-top-three">
              <div v-if="isMember == false">单价</div>
              <div v-else>会员价</div>
              <div>数量</div>
              <div>操作</div>
            </div>
          </div>
          <div class="data-top-box" v-for="(item,index) in goodsOrder" :key="index">
            <div class="data-top-title">{{ item.name }}</div>
            <div class="data-top-three">
              <div v-if="isMember == false">{{ item.retailPrice }}</div>
              <div v-else>{{ item.memberPrice }}</div>
              <div>
                <el-input-number v-model="item.num" size="small" controls-position="right"
                                 @change="handleChange" :min="1" :max="10"></el-input-number>
              </div>
              <div @click="delGoods(index)"><i class="el-icon-circle-close" style="font-size: 22px"></i></div>
            </div>
          </div>
          <div class="content-top-bottom">
            <div>商品数量 <span class="bule">{{ goodsTotal }}件</span> </div>
            <div>商品总额 <span class="bule">￥{{ goodsAmount }}</span> </div>
          </div>
        </div>
      </div>
      <div class="center-left-bottom">
        <div class="bottom-qk" @click="empty">清空</div>
        <div style="display: flex">
          <div class="bottom-qd" @click="dialogTakeOrder = true">取单</div>
          <div class="bottom-gd" @click="dialogRegistration = true">挂单</div>
        </div>
      </div>
    </div>

<!--    加油员姓名-->
    <el-dialog
      title="选择加油员"
      :visible.sync="dialogVisible"
      width="30%"
      :close-on-click-modal="false">
      <div class="wrap-wrap">
        <div class="of-box" v-for="(item,index) in staffList" :key="index"
             @click="chooseStaff(item)"
             :style="{'background-color': item.color}">
          <div class="of-title">{{ item.realName }}</div>
          <div style="text-align: center;font-size: 17px">{{ item.mobile }}</div>
        </div>
      </div>
         <span slot="footer" class="dialog-footer">
        <el-button @click="dialogVisible = false">关 闭</el-button>
<!--        <el-button type="primary" @click="dialogVisible = false">确 定</el-button>-->
      </span>
    </el-dialog>

<!--    挂单-->
    <el-dialog
      title="挂单提示"
      :visible.sync="dialogRegistration"
      width="20%"
      style="margin-top: 200px"
      :close-on-click-modal="false">
      <div class="wrap-wrap">
        <p>
          挂单只可将非油商品进行挂单,挂单成功后可在取单页面进行取单操作、挂单备注为选填
        </p>
        <div>
          <el-input
            type="textarea"
            :rows="2"
            style="width: 180%"
            placeholder="请输入挂单备注(选填)"
            v-model="registrationRemark">
          </el-input>
        </div>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button @click="dialogRegistration = false">关 闭</el-button>
        <el-button type="primary" @click="registration">确 定</el-button>
      </span>
    </el-dialog>

<!--    挂单成功提示-->
    <el-dialog
      title="挂单成功"
      :visible.sync="dialogSuccess"
      width="20%"
      style="margin-top: 200px"
      :close-on-click-modal="false">
      <span>商品记录挂单成功</span>
      <span slot="footer" class="dialog-footer">
<!--        <el-button @click="dialogVisible = false">取 消</el-button>-->
        <el-button type="primary" @click="dialogSuccess = false">确 定</el-button>
      </span>
    </el-dialog>

<!--    取单提示-->
    <el-dialog
      title="取单"
      :visible.sync="dialogTakeOrder"
      width="50%"
      :close-on-click-modal="false">
      <div style="height: 500px">
        <el-row class="tac">
          <el-col :span="6">
            <el-input v-model="putRemark" placeholder="挂单备注检索" style="margin-bottom: 20px;width: 80%"></el-input>
            <el-menu
              default-active="2"
              v-for="(item,index) in registrationList"
              :key="index"
              class="el-menu-vertical-demo">
              <el-menu-item :index="index+''" @click="getTakeGoods(item,index)">
                <span slot="title">{{ item.menu }}</span>
              </el-menu-item>
            </el-menu>
          </el-col>
          <el-col :span="18">
            <el-table ref="tables" :data="takeList">
              <el-table-column label="商品名称" align="center" prop="name" />
              <el-table-column label="零售价" align="center" prop="retailPrice"/>
              <el-table-column label="数量" align="center" prop="num"/>
              <el-table-column label="金额" align="center">
                <template slot-scope="scope">
                  <span>{{ scope.row.retailPrice * scope.row.num }}</span>
                </template>
              </el-table-column>
            </el-table>
          </el-col>
        </el-row>
      </div>
      <span style="display: flex;justify-content: space-between">
        <el-button class="elBut" @click="dialogTakeOrder = false" round>返 回</el-button>
        <span>
          <el-button class="elBut" type="danger" @click="cancel" round>作 废</el-button>
          <el-button class="elBut" type="success" @click="pickOrder" round>取 单</el-button>
        </span>
      </span>
    </el-dialog>

<!--    立即结算-->
    <el-dialog
      title="扫码支付"
      :visible.sync="dialogVisiblej"
      width="30%"
      :close-on-click-modal="false">
      <div v-if="isPay == true"
           v-loading="loading">
        <div style="text-align: center;font-size: 15px;font-weight: bold">应收金额</div>
        <div style="text-align: center;font-size: 30px;font-weight: bold;color: red;margin: 10px 0">
          ￥{{ oilActualPay + goodsActualPay }}
        </div>
        <div style="text-align: center;margin-bottom: 10px">
          合计金额：{{ oilAmount + goodsAmount }}元、优惠合计{{ oilDiscount + goodsDiscount }}元
        </div>
        <div v-if="map.payType != 'CASH'">
          <div>
            <el-input v-model="authCode"
                      autofocus="autofocus"
                      @keydown.enter.native="collection"
                      placeholder="扫描或输入付款码、支持微信、支付宝、云闪付">
              <i
                slot="suffix">
                <svg t="1697791915471" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="1479" width="32" height="32"><path d="M149.333333 170.858667A21.546667 21.546667 0 0 1 170.858667 149.333333H384V106.666667H170.858667A64.213333 64.213333 0 0 0 106.666667 170.858667V384h42.666666V170.858667zM170.858667 874.666667A21.546667 21.546667 0 0 1 149.333333 853.141333V640H106.666667v213.141333A64.213333 64.213333 0 0 0 170.858667 917.333333H384v-42.666666H170.858667zM853.12 149.333333A21.546667 21.546667 0 0 1 874.666667 170.858667V384h42.666666V170.858667A64.213333 64.213333 0 0 0 853.141333 106.666667H640v42.666666h213.141333zM874.666667 853.141333A21.546667 21.546667 0 0 1 853.141333 874.666667H640v42.666666h213.141333A64.213333 64.213333 0 0 0 917.333333 853.141333V640h-42.666666v213.141333zM106.666667 490.666667h810.666666v42.666666H106.666667v-42.666666z" fill="#3D3D3D" p-id="1480"></path></svg>
              </i>
            </el-input>
          </div>
          <div class="demo-image"></div>
          <div class="block" style="text-align: center">
            <el-image
              style="width: 200px; height: 200px"
              fit="cover"
              src="https://oil.wudb.cn/static/img/scan-demo.fcb8b1ab.png"></el-image>
          </div>
        </div>
        <div v-else>
          <div>
            <el-input v-model="authCode"
                      autofocus="autofocus"
                      @input="changeSeekZero"
                      @keydown.enter.native="collection"
                      placeholder="请输入收款金额">
            </el-input>
          </div>
          <div style="text-align: right;margin: 10px 0">
            <span>应找零</span>
            <span style="color: red;font-size: 18px"> ￥{{ seekZero }}</span>
          </div>
        </div>
        <el-divider></el-divider>
        <span slot="footer" class="dialog-footer" style="display: flex;justify-content: space-around">
          <el-button @click="dialogVisiblej = false" class="but">取 消</el-button>
          <el-button type="primary" class="but" @click="collection">确 定 收 款</el-button>
        </span>
      </div>
      <div v-else>
        <div v-if="isPaySuccess">
          <el-result icon="success" title="收款成功">
            <template slot="extra">
              <el-button type="primary" @click="handClose">关 闭</el-button>
            </template>
          </el-result>
        </div>
        <div v-else>
          <el-result icon="error" title="支付失败，请重新支付">
            <template slot="extra">
              <el-button type="primary" @click="handClose">关 闭</el-button>
            </template>
          </el-result>
        </div>
      </div>
    </el-dialog>

<!--    会员登录-->
    <el-dialog
      title="会员信息"
      :visible.sync="dialogVisiblevip"
      width="30%"
      :close-on-click-modal="false">
      <div >
        <el-input placeholder="会员手机号、用户昵称" v-model="userNo"
                  clearable
                  @keyup.enter.native="getUser"
                  class="input-with-select" style="text-align: center;">
          <el-select v-model="select1" slot="prepend" placeholder="请选择" style="width: 120px">
            <el-option label="会员手机号" value="会员手机号"></el-option>
            <el-option label="用户昵称" value="用户昵称"></el-option>
          </el-select>
          <el-button slot="append" @click="getUser">查询</el-button>
        </el-input>
      </div>
      <el-row>
        <el-descriptions title="会员信息" :column="2">
          <el-descriptions-item label="手机号">{{member.mobile ? member.mobile : "--"}}</el-descriptions-item>
          <el-descriptions-item label="会员昵称">{{member.name ? member.name : "--"}}</el-descriptions-item>
          <el-descriptions-item label="积分">{{member.points ? member.points : "--"}}</el-descriptions-item>
<!--          <el-descriptions-item label="加油金余额">0</el-descriptions-item>-->
          <el-descriptions-item label="车牌号">{{member.carNo ? member.carNo : "--"}}</el-descriptions-item>
          <el-descriptions-item label="会员备注">{{member.remark ? member.remark : "--"}}</el-descriptions-item>
        </el-descriptions>
        <el-descriptions title="会员等级">
          <el-descriptions-item label="等级名称">{{member.gradeId ? getGradeName(gradeList,member.gradeId) : "--"}}</el-descriptions-item>
        </el-descriptions>
        <el-descriptions title="储值余额">
          <template slot="extra">
            <span style="color: red;margin-right: 20px">余额充值</span>
            <span style="font-weight: bold">￥{{member.cardBalance ? member.cardBalance : "--"}}</span>
          </template>
          <el-descriptions-item v-if="member.cardBalance!=0" label="账户余额">{{member.cardBalance ? member.cardBalance : "--"}}元</el-descriptions-item>
        </el-descriptions>
      </el-row>
      <span slot="footer" class="dialog-footer">
        <el-button @click="dialogVisiblevip = false">取 消</el-button>
        <el-button type="primary" :disabled="isSure" @click="chooseUser(member)">确 定</el-button>
      </span>
    </el-dialog>

<!--    加油枪加油金额-->
    <el-dialog
      title="加油金额"
      :close-on-click-modal="false"
      :visible.sync="dialogVisibleamount"
      width="30%">
      <div class="amount">
        <span>已选油品</span>
        <span class="amountBlue">{{ getName(oilNameList,form.oilName) }}</span>
      </div>
      <div class="amount">
        <span>已选油枪</span>
        <span class="amountBlue">{{ form.gunName }}</span>
      </div>
      <div class="amount">
        <span>油品单价</span>
        <span class="amountBlue">{{ form.oilPrice }}元/L</span>
      </div>
      <div >
        <el-input v-model="amount" @input="form.amount = amount" placeholder="请输入加油金额"
                  style="font-weight: 700;text-align: center;font-size: 20px;">
          <el-select v-model="select" style="width: 70px" @change="changeSelect" slot="append" placeholder="请选择">
            <el-option label="元" value="元"></el-option>
            <el-option label="L" value="L"></el-option>
          </el-select>
        </el-input>
<!--        <el-input v-model="form.amount"></el-input>-->
      </div>
      <el-row :gutter="20">
        <el-col :span="6" v-for="(item,index) in rise" :key="index">
          <el-button class="grid-content bg-purple" @click="changeAmount(item.value)">{{ item.value }}</el-button>
        </el-col>
      </el-row>
      <span slot="footer" class="dialog-footer" style="display: flex;justify-content: space-around">
        <el-button @click="dialogVisibleamount = false" class="but">取 消</el-button>
        <el-button type="primary" @click="getOilOrder" class="but">确 定</el-button>
      </span>
    </el-dialog>

<!--    模糊查询会员列表信息-->
    <el-dialog
      title="请选择会员"
      :visible.sync="dialogVisibleMember"
      :close-on-click-modal="false">
      <div class="wrap-wrap">
        <el-table ref="tables" :data="memberList">
          <el-table-column label="ID" align="center" prop="id" width="80" />
          <el-table-column label="头像" align="center" width="70">
            <template slot-scope="scope">
              <img v-if="scope.row.avatar" class="list-avatar" :src="scope.row.avatar">
              <img v-else class="list-avatar" src="@/assets/images/avatar.png">
            </template>
          </el-table-column>
          <el-table-column label="姓名" align="center" prop="name" />
          <el-table-column label="手机号" align="center" prop="mobile"/>
          <el-table-column label="注册时间" align="center" prop="createTime">
            <template slot-scope="scope">
              <span>{{ parseTime(scope.row.createTime) }}</span>
            </template>
          </el-table-column>
          <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
            <template slot-scope="scope">
              <el-button
                type="primary" round
                @click="handleChoose(scope.row)"
              >选择</el-button>
            </template>
          </el-table-column>
        </el-table>
      </div>
    </el-dialog>

<!--    新增挂账信息-->
    <el-dialog
      title="挂账" width="700px"
      :visible.sync="dialogVisibleCredit"
      :close-on-click-modal="false">
      <el-form ref="form" :model="form1" :rules="rules" label-width="120px">
        <el-row>
          <el-col :span="24">
            <el-form-item label="挂账单位" prop="unitName" style="width: 420px">
              <el-autocomplete
                popper-class="my-autocomplete"
                v-model="form1.unitName"
                style="width: 180%"
                :fetch-suggestions="querySearch1"
                placeholder="请选择挂账单位"
                @select="changeUnit">
                <template slot-scope="{ item }">
                  <div style="display: flex;justify-content: space-between">
                    {{item.unitName}}（{{item.personCredit}} {{item.contactMobile}}）
                  </div>
                </template>
                <el-button slot="append" @click="open1 = true">新增挂账单位</el-button>
              </el-autocomplete>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="可用额度" prop="creditLimit">
              <el-input v-model="form1.creditLimit" placeholder="请先选择挂账单位" disabled>
                <template slot="append">元</template>
              </el-input>
              <span style="font-size: 12px;color: grey;">
                可用额度为挂账人的最大可用额度,如挂账金额大于可用额度,将无法进行挂账,0为不限额
              </span>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="挂账金额" prop="amount">
              <el-input v-model="form1.amount" placeholder="请输入挂账金额" maxlength="30" >
                <template slot="append">元</template>
              </el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-form-item label="备注信息" prop="remark">
          <el-input v-model="form1.remark" type="textarea" placeholder="请输入内容"></el-input>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="dialogVisibleCredit = false">取 消</el-button>
        <el-button type="primary" @click="addHangbill">确 定</el-button>
      </span>
    </el-dialog>

<!--    新增挂账单位信息-->
    <el-dialog title="新增挂账单位" :visible.sync="open1" width="700px" append-to-body>
      <el-form ref="formName" :model="form2" :rules="rules1" label-width="120px">
        <el-row>
          <el-col :span="24">
            <el-form-item label="挂账单位" prop="unitName">
              <el-input v-model="form2.unitName" show-word-limit placeholder="请输入挂账单位名称" maxlength="50" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="负责人" prop="personCredit">
              <el-input v-model="form2.personCredit" show-word-limit placeholder="请输入挂账单位负责人姓名" maxlength="10" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="联系电话" prop="contactMobile">
              <el-input v-model="form2.contactMobile" show-word-limit placeholder="请输入挂账单位联系电话" maxlength="15" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="挂账额度" prop="creditLimit">
              <el-input v-model="form2.creditLimit" placeholder="请输入挂账额度，为0则不限额" maxlength="30">
                <template slot="append">元</template>
              </el-input>
              <span style="font-size: 12px;color: grey;">
                0为不限额,额度为当前单位最大可挂账金额,如已挂账金额归还,额度将也同步返还
              </span>
            </el-form-item>
          </el-col>
        </el-row>
        <el-form-item label="备注信息" prop="remark">
          <el-input v-model="form2.remark" type="textarea" placeholder="请输入内容"></el-input>
        </el-form-item>
        <el-row>
          <el-col :span="24">
            <el-form-item label="单位状态" prop="status">
              <el-radio-group v-model="form2.status">
                <el-radio label="qy" value="qy">启用</el-radio>
                <el-radio label="jy" value="jy">禁用</el-radio>
              </el-radio-group>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="open1 = false">取 消</el-button>
        <el-button type="primary" @click="addCredit">确 定</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
  import {getDicts} from "@/api/dict/data";
  import {getOilNameList, getOilNumGun, listOilNumGun} from "@/api/cashier/oilnumgun";
  import {listgoods} from "@/api/cashier/ljgoods";
  import {getUserVoMobile, getUserVoName} from "@/api/cashier/user";
  import {queryStaffs, staffInfo} from "@/api/cashier/staff";
  import {addLJGoods, goodsOrder, oilOrder} from "@/api/cashier/oilorder";
  import {getUserGrade, listUserGrade} from "@/api/cashier/usergrade";
  import {getOilGun} from "@/api/cashier/oilGuns";
  import {listCardFavorableRecord} from "@/api/cashier/cardfavorablerecord";
  import {getOilNumberById} from "@/api/cashier/oilnumber";
  import {selectPreferential} from "@/api/cashier/preferential";
  import {addHangBill} from "@/api/cashier/hangbill";
  import {addCreditUnit, listCreditUnit} from "@/api/cashier/creditunit";

  const cityOptions = ['上海', '北京'];
  export default {
    name: "homeindex",
    data(){
      return{
        // 满减全选
        checkAll1: false,
        isIndeterminate1: true,
        checkedCities1: [],
        cities1: cityOptions,
        fullReduceDiscount: [],
        // 等级全选
        checkAll2: false,
        isIndeterminate2: true,
        checkedCities2: [],
        cities2: cityOptions,
        gradeDiscount: [],
        // 囤油卡全选
        checkAll3: false,
        isIndeterminate3: true,
        checkedCities3: ['上海'],
        cities3: cityOptions,
        // 储值卡全选
        checkAll4: false,
        isIndeterminate4: true,
        checkedCities4: ['上海'],
        cities4: cityOptions,
        // 优惠券全选
        checkAll5: false,
        isIndeterminate5: true,
        checkedCities5: ['上海'],
        cities5: cityOptions,
        // 优惠券列表
        couponList:[],
        // 消费升数
        consumeRefuelMoney:0,
        // 满减优惠
        fullReduction:0,
        // 囤油卡信息
        refuelMoney:null,
        // 会员消费金额（储值卡需要减少的金额）
        consumeAmount:0,
        // 账户余额
        balance:0,
        // 绑定金额数据
        amount:0,
        // 找零金额
        seekZero:0,
        // 等待中
        loading:false,
        // 油品类型
        oilType:'',
        // 取单列表
        takeList:[],
        // 挂单备注检索
        putRemark:"",
        // 挂单备注
        registrationRemark:"",
        // 挂单列表
        registrationList:[],
        // 油品订单
        oilOrder:[],
        // 油品金额
        oilAmount:0,
        // 油品订单数
        oilTotal:0,
        // 油品实付金额
        oilActualPay:0,
        // 油品优惠金额
        oilDiscount:0,
        // 商品优惠金额
        goodsDiscount:0,
        // 商品实付金额
        goodsActualPay:0,
        // 商品订单
        goodsOrder:[],
        // 商品金额
        goodsAmount:0,
        // 商品订单数
        goodsTotal:0,
        // 加油金额
        rise:[
          {value:"￥100"},
          {value:"￥150"},
          {value:"￥200"},
          {value:"￥300"},
        ],
        // 会员信息
        member:{},
        // 会员列表信息
        memberList:[],
        select1:'会员手机号',
        // 查询会员信息参数
        userNo:"",
        // 查询的商品信息
        goods:"",
        select:"元",
        form:{ amount : 0 },
        form1:{},
        form2:{
          unitName:"",
          personCredit:"",
          contactMobile:"",
          creditLimit:0,
          remark:'',
          status:'qy',
        },
        oilNumGunList:[],
        authCode:'',
        // 油号列表
        oilNumList:[],
        // 商品列表
        goodsList:[],
        // 油枪列表
        oilGunList:[],
        // 支付方式列表
        payList:[],
        dialogVisible: false,
        dialogVisiblej: false,
        dialogVisiblevip:false,
        dialogVisibleamount:false,
        dialogVisibleMember:false,
        dialogRegistration:false,
        dialogSuccess:false,
        dialogTakeOrder:false,
        dialogVisibleCredit:false,
        open1:false,
        activeName: '1',
        tabarr:[
          {name:'收银台',icon:'el-icon-s-platform'},
          {name:'充值',icon: 'el-icon-s-finance'},
          {name:'订单',icon: 'el-icon-s-order'},
          {name:'会员',icon: 'el-icon-s-custom'},
          {name:'核销',icon: 'el-icon-s-check'},
          {name:'挂账',icon:'el-icon-s-claim'},
          {name:'积分',icon:'el-icon-s-data'},
          {name:'交班',icon: 'el-icon-s-flag'},
        ],
        leftindex:0,
        oilList:[],
        colorList:[
          {color:'#e5f0ff'},
          {color:'#fff2e5'},
          {color:'#e5edf1'},
          {color:'#ecfae5'},
          {color:'#fafafa'}
        ],
        restaurants:'',
        num: 1,
        // 油号名称
        oilNameList:'',
        // 员工列表
        staffList:[],
        isMember: false,
        // 员工信息
        staff:"",
        map:{
          allAmount:0,
          // 用户支付条码信息
          authCode:'',
          // 油品订单
          oilOrder:"",
          // 商品订单
          goodsOrder:"",
          // 支付方式
          payType:"CASH",
          // 油品订单金额
          oilAmount:0,
          // 商品订单金额
          goodsAmount:0,
          // 油品实付金额
          oilActualPay:0,
          // 商品实付金额
          goodsActualPay:0,
          // 付款用户
          payUser:"",
          // 油品优惠金额
          oilDiscount:0,
          // 商品优惠金额
          goodsDiscount:0,
          // 员工id
          staffId:"",
          // 优惠券id
          couponId:"",
          // 会员id
          userId:"",
          // 提成金额
          commissionAmount:0,
          // 使用积分数量
          usePoint:0,
          // 积分金额
          pointAmount:0,
          // 终端
          terminal:"PC",
          // 商品数量
          goodsNum:0,
          // 会员消费金额（储值卡需要减少的金额）
          consumeAmount:0,
          // 消费后的升数json
          refuelMoney:"",
          // 找零金额
          seekZero:0,
        },
        // 会员等级名称
        gradeName:"",
        // 会员等级列表
        gradeList:"",
        menu:1,
        index:0,
        // 是否支付
        isPay:true,
        isPaySuccess:false,
        // 订单号
        orderNo:'',
        timer: null,
        // 是否一直查询
        isQuery:true,
        // 油枪列表
        gunList:[],
        // 是否可以点会员确定按钮
        isSure:true,
        // 优惠券消费金额
        couponAmount:0,
        // 查询优惠活动信息所需参数
        preferentialData:{
          userId:"",
          storeId:"",
          gradeId:"",
          oilName:"",
          oilPrice:"",
          oilLiters:"",
        },
        // 挂账单位信息
        unitList:[],
        // 表单校验
        rules: {
          unitName: [ { required: true, message: "请选择挂账单位", trigger: "blur" }, ],
          amount: [{ required: true, message: "请输入挂账金额", trigger: "blur" }],
          creditLimit: [{ required: true, message: "可用额度不可为空", trigger: "blur" }],
        },
        rules1: {
          unitName: [ { required: true, message: "请填写挂账单位名称", trigger: "blur" }, ],
          personCredit: [{ required: true, message: "请填写挂账单位负责人姓名", trigger: "blur" }],
          contactMobile: [ { required: true, message: "请填写挂账单位联系电话", trigger: "blur" }, ],
          creditLimit: [ { required: true, message: "请填写挂账额度", trigger: "blur" }, ],
          status: [ { required: true, message: "请选择挂账单位状态", trigger: "blur" }, ],
        },
      }
    },
    created() {
      this.getPayList();
      this.getOilName();
      this.getGoods();
      this.getStaffList();
      this.getStaff();
      this.getList();
      this.getCouponList();
      this.getUnitList();
    },
    methods:{
      // 挂账
      addCredits(){
        this.dialogVisibleCredit = true
        this.form1.amount = this.oilAmount + this.goodsAmount
      },
      // 获取挂账单位列表
      getUnitList(){
        let obj = {};
        let _this = this;
        listCreditUnit().then( response => {
          response.data.forEach(item => {
            obj = item;
            obj.value = `${item.unitName}（${item.personCredit} ${item.contactMobile}）`
            _this.unitList.push(obj)
          })
        })
      },
      // 添加挂账单位信息
      addCredit(){
        this.$refs["formName"].validate((valid) => {
          if (valid) {
            addCreditUnit(this.form2).then( response => {
              this.$modal.msgSuccess("挂账单位信息创建成功");
              this.open1 = false;
              this.getUnitList();
            })
          }else {
            return false;
          }
        })
      },
      // 添加挂账记录
      addHangbill(){
        this.$refs["form"].validate((valid) => {
          if (valid) {
            addHangBill(this.form1).then( response => {
              if (response.data==0){
                this.$modal.msgError("挂账单位可用额度不足，无法进行挂账");
              }else {
                this.$modal.msgSuccess("挂账记录添加成功");
                this.dialogVisibleCredit = false;
                this.resetMember();
                this.resetting();
                this.empty();
              }
            })
          }else {
            return false;
          }
        })
      },
      // 选择挂账单位
      changeUnit(val){
        this.form1.creditUnitId = val.id;
        this.form1.creditLimit = val.creditLimit
        return val.id
      },
      querySearch1(queryString, cb) {
        let _this = this;
        let obj = {};
        let results = _this.unitList
        if (queryString != "" && queryString!=undefined){
          results = [];
          _this.unitList.forEach(item => {
            if (item.unitName.includes(queryString)){
              obj = item;
              obj.value = `${item.unitName}（${item.personCredit} ${item.contactMobile}）`
              results.push(obj)
            }
            if (item.personCredit.includes(queryString)){
              obj = item;
              obj.value = `${item.unitName}（${item.personCredit} ${item.contactMobile}）`
              results.push(obj)
            }
            if (item.contactMobile.includes(queryString)){
              obj = item;
              obj.value = `${item.unitName}（${item.personCredit} ${item.contactMobile}）`
              results.push(obj)
            }
          })
        }
        cb(results);
      },
      // 计算找零金额
      changeSeekZero(){
        this.seekZero = this.authCode - this.oilActualPay - this.goodsActualPay
      },
      // 获取会员等级id
      getGradeName(list,id){
        let name = "";
        list.forEach(item => {
          if (item.id == id){
            name = item.name
          }
        })
        this.gradeName = name;
        return name;
      },
      // 选择优惠信息
      handleCheckAllChange1(val) {
        let list = []
        this.fullReduceDiscount.forEach(item => {
          list.push(item.type)
        })
        this.checkedCities1 = val ? list : [];
        this.isIndeterminate1 = false;
      },
      handleCheckedCitiesChange1(value) {
        let checkedCount = value.length;
        this.checkAll1 = checkedCount === this.fullReduceDiscount.length;
        this.isIndeterminate1 = checkedCount > 0 && checkedCount < this.fullReduceDiscount.length;
      },
      handleCheckAllChange2(val) {
        let list = []
        this.gradeDiscount.forEach(item => {
          list.push(item.type)
        })
        this.checkedCities2 = val ? list : [];
        this.isIndeterminate2 = false;
      },
      handleCheckedCitiesChange2(value) {
        let checkedCount = value.length;
        this.checkAll2 = checkedCount === this.gradeDiscount.length;
        this.isIndeterminate2 = checkedCount > 0 && checkedCount < this.gradeDiscount.length;
      },
      handleCheckAllChange3(val) {
        this.checkedCities3 = val ? cityOptions : [];
        this.isIndeterminate3 = false;
      },
      handleCheckedCitiesChange3(value) {
        let checkedCount = value.length;
        this.checkAll3 = checkedCount === this.cities3.length;
        this.isIndeterminate3 = checkedCount > 0 && checkedCount < this.cities3.length;
      },
      handleCheckAllChange4(val) {
        this.checkedCities4 = val ? cityOptions : [];
        this.isIndeterminate4 = false;
      },
      handleCheckedCitiesChange4(value) {
        let checkedCount = value.length;
        this.checkAll4 = checkedCount === this.cities4.length;
        this.isIndeterminate4 = checkedCount > 0 && checkedCount < this.cities4.length;
      },
      handleCheckAllChange5(val) {
        this.checkedCities5 = val ? cityOptions : [];
        this.isIndeterminate5 = false;
      },
      handleCheckedCitiesChange5(value) {
        let checkedCount = value.length;
        this.checkAll5 = checkedCount === this.cities5.length;
        this.isIndeterminate5 = checkedCount > 0 && checkedCount < this.cities5.length;
      },
      // 模糊查询商品信息
      querySearch(queryString, cb) {
        let _this = this;
        let results = _this.goodsList;
        if (queryString != ""){
          results = [];
          _this.goodsList.forEach(item => {
            if(item.name.includes(queryString)){
              results.push(item)
            }
            if(item.goodsNo.includes(queryString)){
              results.push(item)
            }
          })
        }
        cb(results);
      },
      // 取单
      pickOrder(){
        let list = this.takeList
        this.goodsOrder = list;
        let num = 0;
        let amount = 0;
        let _this = this;
        list.forEach(item => {
          num += item.num;
          if (_this.isMember){
            amount += item.memberPrice;
          }else {
            amount += item.retailPrice;
          }
        })
        this.goodsTotal = num;
        this.goodsAmount = amount;
        this.goodsActualPay = this.goodsAmount - this.goodsDiscount;
        this.dialogTakeOrder = false;
      },
      // 作废
      cancel(){
        this.registrationList.splice(this.index,1);
        this.takeList = [];
      },
      // 取单列表
      getTakeGoods(data,index){
        this.takeList = data.children;
        this.index = index;
      },
      // 挂单
      registration(){
        this.dialogRegistration = false;
        this.registrationList.push({menu:this.menu,children:this.goodsOrder})
        this.menu++;
        this.goodsOrder = [];
        this.goodsTotal = 0;
        this.goodsAmount = 0;
        this.goodsActualPay = this.goodsAmount - this.goodsDiscount;
        this.getTakeGoods(this.registrationList[0]);
        this.dialogSuccess = true;
      },
      // 重置会员
      resetMember(){
        this.member = {};
        this.isMember = false;
        this.map.payUser == "";
        this.balance = 0;
        this.oilDiscount = 0;
        this.goodsDiscount = 0;
        this.userNo = "";
        this.oilActualPay = this.oilAmount - this.oilDiscount - this.couponAmount
        this.goodsActualPay = this.goodsAmount - this.goodsDiscount
        this.isSure = true;
        this.handleChange();
      },
      // 根据会员等级信息获取等级优惠信息
      getGrade(id){
        let _this = this;
        this.oilDiscount = 0;
        this.gradeDiscount = [];
        getUserGrade(id).then( response => {
          let gasolineDiscount = 0;
          let dieselDiscount = 0;
          let naturalGasDiscount = 0;
          _this.oilOrder.forEach(item => {
            if (item.oilType == "汽油"){
              let gasolineRule = JSON.parse(response.data.gasolineRule);
              if (response.data.preferential == '自定义优惠' && response.data.status == 'qy'){
                if (response.data.gasolineDiscount=="满减优惠"){
                  let oilDiscount = 0;
                  let discount = {type:"满减优惠",full:0,reduce:0}
                  for (let i = 1; i <= gasolineRule.length; i++){
                    // 将满减条件加入等级优惠列表
                    discount.full = gasolineRule[i-1].gasolineRule1
                    if (gasolineRule.length>1){
                      if (item.amount >= gasolineRule[gasolineRule.length-1].gasolineRule1){
                        oilDiscount = (item.amount/gasolineRule[gasolineRule.length-1].gasolineRule1 *
                          gasolineRule[gasolineRule.length-1].gasolineRule2).toFixed(2);
                        discount.reduce = gasolineRule[i-1].gasolineRule2
                        break;
                      }
                      if (item.amount >= gasolineRule[i-1].gasolineRule1 && item.amount < gasolineRule[i].gasolineRule1){
                        oilDiscount = (item.amount/gasolineRule[i-1].gasolineRule1 * gasolineRule[i-1].gasolineRule2).toFixed(2)
                        discount.reduce = gasolineRule[i-1].gasolineRule2
                      }
                    }else {
                      if (item.amount >= gasolineRule[i-1].gasolineRule1){
                        oilDiscount = (item.amount/gasolineRule[i-1].gasolineRule1 * gasolineRule[i-1].gasolineRule2).toFixed(2);
                        discount.reduce = gasolineRule[i-1].gasolineRule2
                      }
                    }
                  }
                  if (discount.reduce!=0){
                    _this.gradeDiscount.push(discount)
                    _this.checkedCities2 = ['满减优惠']
                  }
                  gasolineDiscount += +oilDiscount
                }else if (response.data.gasolineDiscount=="每升优惠"){
                  let discount = {type:"每升优惠",full:0,reduce:0}
                  let oilDiscount = 0;
                  for (let i = 1; i <= gasolineRule.length; i++){
                    // 将满减条件加入等级优惠列表
                    discount.full = gasolineRule[i-1].gasolineRule1
                    if (gasolineRule.length>1){
                      if (item.amount >= gasolineRule[gasolineRule.length-1].gasolineRule1){
                        oilDiscount = (item.liters * gasolineRule[gasolineRule.length-1].gasolineRule3).toFixed(2);
                        discount.reduce = gasolineRule[i-1].gasolineRule3
                        break;
                      }
                      if (item.amount >= gasolineRule[i-1].gasolineRule1 && item.amount < gasolineRule[i].gasolineRule1){
                        oilDiscount = (item.liters * gasolineRule[i-1].gasolineRule3).toFixed(2)
                        discount.reduce = gasolineRule[i-1].gasolineRule3
                      }
                    }else {
                      if (item.amount >= gasolineRule[i-1].gasolineRule1){
                        oilDiscount = (item.liters * gasolineRule[i-1].gasolineRule3).toFixed(2)
                        discount.reduce = gasolineRule[i-1].gasolineRule3
                      }
                    }
                  }
                  if (discount.reduce!=0){
                    _this.gradeDiscount.push(discount)
                    _this.checkedCities2 = ['每升优惠']
                  }
                  gasolineDiscount += +oilDiscount
                }else {
                  gasolineDiscount = 0;
                }
              }
            }
            if (item.oilType == "柴油"){
              let dieselRule = JSON.parse(response.data.dieselRule);
              if (response.data.preferential == '自定义优惠' && response.data.status == 'qy'){
                if (response.data.dieselDiscount=="满减优惠"){
                  let oilDiscount = 0;
                  let discount = {type:"满减优惠",full:0,reduce:0}
                  for (let i = 1; i <= dieselRule.length; i++){
                    // 将满减条件加入等级优惠列表
                    discount.full = dieselRule[i-1].dieselRule1
                    if (dieselRule.length>1){
                      if (item.amount >= dieselRule[dieselRule.length-1].dieselRule1){
                        oilDiscount = (item.amount/dieselRule[dieselRule.length-1].dieselRule1 *
                          dieselRule[dieselRule.length-1].dieselRule2).toFixed(2);
                        discount.reduce = dieselRule[i-1].dieselRule2
                        break;
                      }
                      if (item.amount >= dieselRule[i-1].dieselRule1 && item.amount < dieselRule[i].dieselRule1){
                        oilDiscount = (item.amount/dieselRule[i-1].dieselRule1 * dieselRule[i-1].dieselRule2).toFixed(2);
                        discount.reduce = dieselRule[i-1].dieselRule2
                      }
                    }else {
                      if (item.amount >= dieselRule[i-1].dieselRule1){
                        oilDiscount = (item.amount/dieselRule[i-1].dieselRule1 * dieselRule[i-1].dieselRule2).toFixed(2);
                        discount.reduce = dieselRule[i-1].dieselRule2
                      }
                    }
                  }
                  if (discount.reduce!=0){
                    _this.gradeDiscount.push(discount)
                    _this.checkedCities2 = ['满减优惠']
                  }
                  dieselDiscount += +oilDiscount
                }else if (response.data.dieselDiscount=="每升优惠"){
                  let oilDiscount = 0;
                  let discount = {type:"每升优惠",full:0,reduce:0}
                  for (let i = 1; i <= dieselRule.length; i++){
                    // 将满减条件加入等级优惠列表
                    discount.full = dieselRule[i-1].dieselRule1
                    _this.gradeDiscount.push(discount)
                    if (dieselRule.length>1){
                      if (item.amount >= dieselRule[dieselRule.length-1].dieselRule1){
                        oilDiscount = (item.liters * dieselRule[gasolineRule.length-1].dieselRule3).toFixed(2);
                        discount.reduce = dieselRule[i-1].dieselRule3
                        break;
                      }
                      if (item.amount >= dieselRule[i-1].dieselRule1 && item.amount < dieselRule[i].dieselRule1){
                        oilDiscount = (item.liters * dieselRule[i-1].dieselRule3).toFixed(2)
                        discount.reduce = dieselRule[i-1].dieselRule3
                      }
                    }else {
                      if (item.amount >= dieselRule[i-1].dieselRule1){
                        oilDiscount = (item.liters * dieselRule[i-1].dieselRule3).toFixed(2)
                        discount.reduce = dieselRule[i-1].dieselRule3
                      }
                    }
                  }
                  if (discount.reduce!=0){
                    _this.gradeDiscount.push(discount)
                    _this.checkedCities2 = ['每升优惠']
                  }
                  dieselDiscount += +oilDiscount
                }else {
                  dieselDiscount = 0;
                }
              }
            }
            if (item.oilType == "天然气"){
              let naturalGasRule = JSON.parse(response.data.naturalGasRule);
              if (response.data.preferential == '自定义优惠' && response.data.status == 'qy'){
                if (response.data.naturalGasDiscount=="满减优惠"){
                  let oilDiscount = 0;
                  let discount = {type:"满减优惠",full:0,reduce:0}
                  for (let i = 1; i <= naturalGasRule.length; i++){
                    // 将满减条件加入等级优惠列表
                    discount.full = naturalGasRule[i-1].naturalGasRule1
                    if (naturalGasRule.length>1){
                      if (item.amount >= naturalGasRule[naturalGasRule.length-1].naturalGasRule1){
                        oilDiscount = (item.amount/naturalGasRule[naturalGasRule.length-1].naturalGasRule1 *
                          naturalGasRule[naturalGasRule.length-1].naturalGasRule2).toFixed(2);
                        discount.reduce = naturalGasRule[i-1].naturalGasRule2
                        break;
                      }
                      if (item.amount >= naturalGasRule[i-1].naturalGasRule1 && item.amount < naturalGasRule[i].naturalGasRule1){
                        oilDiscount = (item.amount/naturalGasRule[i-1].naturalGasRule1 * naturalGasRule[i-1].naturalGasRule2).toFixed(2);
                        discount.reduce = naturalGasRule[i-1].naturalGasRule2
                      }
                    }else {
                      if (item.amount >= naturalGasRule[i-1].naturalGasRule1){
                        oilDiscount = (item.amount/naturalGasRule[i-1].naturalGasRule1 * naturalGasRule[i-1].naturalGasRule2).toFixed(2);
                        discount.reduce = naturalGasRule[i-1].naturalGasRule2
                      }
                    }
                  }
                  if (discount.reduce!=0){
                    _this.gradeDiscount.push(discount)
                    _this.checkedCities2 = ['满减优惠']
                  }
                  naturalGasDiscount += +oilDiscount
                }else if (response.data.naturalGasDiscount=="每单位优惠"){
                  let oilDiscount = 0;
                  let discount = {type:"每单位优惠",full:0,reduce:0}
                  for (let i = 1; i <= naturalGasRule.length; i++){
                    // 将满减条件加入等级优惠列表
                    discount.full = naturalGasRule[i-1].naturalGasRule1
                    if (naturalGasRule.length>1){
                      if (item.amount >= naturalGasRule[naturalGasRule.length-1].naturalGasRule1){
                        oilDiscount = (item.liters * naturalGasRule[gasolineRule.length-1].naturalGasRule3).toFixed(2)
                        discount.reduce = naturalGasRule[i-1].naturalGasRule3
                        break;
                      }
                      if (item.amount >= naturalGasRule[i-1].naturalGasRule1 && item.amount < naturalGasRule[i].naturalGasRule1){
                        oilDiscount = (item.liters * naturalGasRule[i-1].naturalGasRule3).toFixed(2)
                        discount.reduce = naturalGasRule[i-1].naturalGasRule3
                      }
                    }else {
                      if (item.amount >= naturalGasRule[i-1].naturalGasRule1){
                        oilDiscount = (item.liters * naturalGasRule[i-1].naturalGasRule3).toFixed(2)
                        discount.reduce = naturalGasRule[i-1].naturalGasRule3
                      }
                    }
                  }
                  if (discount.reduce!=0){
                    _this.gradeDiscount.push(discount)
                    _this.checkedCities2 = ['每单位优惠']
                  }
                  naturalGasDiscount += +oilDiscount
                }else {
                  naturalGasDiscount = 0;
                }
              }
            }
          })

          let oilActualPay = _this.oilActualPay;
          _this.oilDiscount = gasolineDiscount + dieselDiscount + naturalGasDiscount
          _this.oilActualPay = oilActualPay - _this.oilDiscount;
          // 储值卡余额
          // 如果总金额为0 则表示没有使用囤油卡
          if (oilActualPay == 0){
            oilActualPay = _this.oilAmount - _this.oilDiscount;
          }
          if (_this.balance>=(_this.oilAmount - _this.oilDiscount)){
            _this.consumeAmount = _this.oilAmount - _this.oilDiscount;
            _this.oilActualPay = 0;
          }else {
            _this.consumeAmount = _this.balance;
            _this.oilActualPay = oilActualPay - _this.oilDiscount - _this.balance;
          }
        })
      },
      // 选择会员
      chooseUser(data){
        this.dialogVisiblevip = false
        this.isMember = true;
        this.map.payUser = data.mobile;
        this.map.userId = data.id;
        this.balance = this.member.cardBalance;
        this.getGrade(data.gradeId)
        this.changeRefuelMoney();
        this.handleChange();
        this.preferentialData.storeId = data.storeId;
        this.preferentialData.userId = data.id;
        this.preferentialData.gradeId = data.gradeId;
        if (this.oilOrder.length>0){
          // this.oilOrder.forEach(item => {
          //   this.preferentialData.oilName = item.oilName;
          //   this.preferentialData.oilPrice = item.oilPrice;
          //   this.preferentialData.oilLiters = item.liters;
          // })
          this.preferential();
        }
      },
      // 调用优惠参数接口
      preferential(){
        let _this = this;
        // _this.fullReduction = 0;
        let fullReduction = 0;
        let oilActualPay = _this.oilActualPay
        _this.fullReduction = 0;
        _this.oilOrder.forEach(item1 => {
          _this.preferentialData.oilName = item1.oilName;
          _this.preferentialData.oilPrice = item1.oilPrice;
          _this.preferentialData.oilLiters = item1.liters;
          selectPreferential(_this.preferentialData).then( response => {
            if (response.data.length>0){
              response.data.forEach(item => {
                let discount = {type:item.name,full:0,reduce:0,discount:0}
                let activeList = item.activeDiscountChildList;
                for (let i = 1;i<=activeList.length;i++){
                  if (activeList.length>0){
                    if (activeList[0].discount != null){
                      //   折扣营销
                      if (item1.amount>=activeList[0].amount){
                        discount.full = activeList[0].amount;
                        discount.discount = activeList[0].discount;
                        fullReduction = item1.amount - item1.amount * (activeList[0].discount / 10);
                      }else {
                        fullReduction = 0
                      }
                    }else {
                      //   满减
                      if (item1.amount>=activeList[0].amount){
                        discount.full = activeList[0].amount;
                        discount.reduce = activeList[0].deductionAmount;
                        fullReduction = activeList[0].deductionAmount;
                      }else {
                        fullReduction = 0
                      }
                    }
                  }else {
                    _this.fullReduction = 0;
                    _this.oilActualPay = oilActualPay - _this.oilDiscount - _this.fullReduction - _this.balance
                  }
                }
                if (discount.reduce!=0 || discount.discount!=0){
                  _this.fullReduceDiscount.push(discount)
                  _this.checkedCities1 = [item.name]
                }
              })
            }
            _this.fullReduction += +fullReduction
            _this.oilActualPay = oilActualPay - _this.oilDiscount - _this.fullReduction - _this.balance
          })
        })
        // selectPreferential(data).then( response => {
        //   _this.oilOrder.forEach(item1 => {
        //     if (response.data.length>0){
        //       response.data.forEach(item => {
        //         let discount = {type:item.name,full:0,reduce:0,discount:0}
        //         let activeList = item.activeDiscountChildList;
        //         for (let i = 1;i<=activeList.length;i++){
        //           if (activeList.length>0){
        //             if (activeList[0].discount != null){
        //               //   折扣营销
        //               if (item1.amount>=activeList[0].amount){
        //                 discount.full = activeList[0].amount;
        //                 discount.discount = activeList[0].discount;
        //                 fullReduction = item1.amount - item1.amount * (activeList[0].discount / 10);
        //               }else {
        //                 fullReduction = 0
        //               }
        //             }else {
        //               //   满减
        //               if (item1.amount>=activeList[0].amount){
        //                 discount.full = activeList[0].amount;
        //                 discount.reduce = activeList[0].deductionAmount;
        //                 fullReduction = activeList[0].deductionAmount;
        //               }else {
        //                 fullReduction = 0
        //               }
        //             }
        //           }
        //         }
        //         if (discount.reduce!=0 || discount.discount!=0){
        //           _this.fullReduceDiscount.push(discount)
        //           _this.checkedCities1 = [item.name]
        //         }
        //       })
        //     }
        //     _this.fullReduction += +fullReduction
        //   })
        //   let oilActualPay = _this.oilActualPay
        //   _this.oilActualPay = oilActualPay - _this.oilDiscount - _this.fullReduction
        // })
      },
      // 查询该会员是否可使用优惠券
      queryCoupon(list,id){

      },
      // 选择会员信息
      handleChoose(data){
        this.isSure = false;
        this.member = data;
        this.refuelMoney = JSON.parse(data.refuelMoney)
        this.dialogVisibleMember = false;
      },
      // 清空商品订单列表
      empty(){
        this.goodsOrder = [];
        this.goodsTotal = 0;
        this.goodsAmount = 0;
        this.goodsActualPay = 0;
        this.goodsDiscount = 0;
      },
      // 获取当前账户信息
      getStaff(){
        staffInfo().then( response => {
          this.staff = response.data;
          this.map.staffId = this.staff.id;
        })
      },
      // 选择员工信息
      chooseStaff(data){
        this.staff = data;
        this.map.staffId = this.staff.id;
      },
      // 删除商品列表信息
      delGoods(index){
        this.goodsOrder.splice(index,1)
      },
      // 添加商品列表信息
      changeGoods(val){
        let result = true;
        let goods = this.goodsOrder;
        let _this = this;
        if (this.goodsOrder.length>0){
          let amount = 0;
          for (let i = 0; i<goods.length; i++){
            if (_this.isMember){
              amount += goods[i].memberPrice * goods[i].num
            }else {
              amount += goods[i].retailPrice * goods[i].num
            }
            if (goods[i].id == val.id){
              goods[i].num = goods[i].num + 1;
              this.goodsTotal += 1;
              result = false;
              break;
            }else {
              result = true;
            }
          }
          this.goodsAmount = amount;
          this.goodsActualPay = this.goodsAmount - this.goodsDiscount;
        }else {
          result = true;
        }
        if (result){
          val.num = 1;
          if (_this.isMember){
            this.goodsAmount += val.memberPrice
          }else {
            this.goodsAmount += val.retailPrice
          }
          this.goodsActualPay = this.goodsAmount - this.goodsDiscount;
          this.goodsOrder.push(val);
          this.goodsTotal += 1;
        }
        this.goods = ""
      },
      // 立即结算
      settlement(){
        this.authCode = ""
        this.seekZero = 0;
        this.isPay = true
        this.dialogVisiblej = true
      },
      // 重置油品订单
      resetting(){
        this.oilOrder = [];
        this.oilActualPay = 0;
        this.oilTotal = 0;
        this.oilAmount = 0;
        this.oilDiscount = 0;
        this.consumeAmount = 0;
        this.consumeRefuelMoney = 0;
        this.fullReduction = 0;
        if (this.member.refuelMoney!=null){
          this.refuelMoney = JSON.parse(this.member.refuelMoney)
        }
        this.amount = 0;
      },
      // 获取员工列表
      getStaffList(){
        queryStaffs().then( response => {
          this.staffList = response.data
        })
      },
      // 油品订单信息
      getOilOrder(){
        this.dialogVisibleamount = false
        this.form.oilType = this.oilType;
        // 计算油的升数
        if (this.select == "元"){
          let num = this.form.amount/this.form.oilPrice
          this.form.liters = (Math.ceil(num*100)/100).toFixed(2)
        }else {
          this.form.liters = this.form.amount
          this.form.amount = this.form.oilPrice * this.form.amount
        }
        // 获取油号信息
        // let name1 = this.getName(this.oilNameList,this.form.oilName);
        // this.form.oilType = name1;
        this.oilOrder.push(this.form)

        if (this.select == "元"){
          this.oilAmount = +this.form.amount + this.oilAmount;
          if (this.balance!=0){
            if (this.balance>=(this.oilAmount - this.oilDiscount)){
              this.consumeAmount = this.oilAmount - this.oilDiscount;
              this.oilActualPay = 0;
            }else {
              this.consumeAmount = this.balance;
              this.oilActualPay = this.oilAmount - this.oilDiscount - this.balance;
            }
          }else {
            this.oilActualPay = this.oilAmount - this.oilDiscount;
          }
        }else {
          this.oilAmount = this.form.amount + this.oilAmount;
          this.oilActualPay = this.oilAmount - this.oilDiscount;
        }

        this.oilTotal += 1;
        this.select = "元";
        if (this.isMember){
          this.getGrade(this.member.gradeId)
          this.changeRefuelMoney();
          if (this.oilOrder.length>0){
            // this.oilOrder.forEach(item => {
            //   this.preferentialData.oilName = item.oilName;
            //   this.preferentialData.oilPrice = item.oilPrice;
            //   this.preferentialData.oilLiters = item.liters;
            // })
            this.preferential();
          }
        }
      },
      // 囤油卡变化后总金额的变化
      changeRefuelMoney(){
        let _this = this;
        _this.consumeRefuelMoney = 0;
        _this.oilActualPay = 0;
        _this.oilOrder.forEach(item => {
          let conRefMon = 0;
          let oilActualPay = 0;
          if (_this.refuelMoney!=null){
            let result = false;
            for (let i = 0;i < _this.refuelMoney.length;i++){
              // 囤油卡升数变化
              if (_this.refuelMoney[i].oilType==item.oilType){
                if ((_this.refuelMoney[i].refuelMoney-item.liters)>=0){
                  conRefMon = item.liters
                  oilActualPay = 0;
                }else {
                  conRefMon = _this.refuelMoney[i].refuelMoney
                  oilActualPay = item.amount - (_this.refuelMoney[i].refuelMoney * item.oilPrice).toFixed(2)
                }
                result = true;
              }else {
                if (result==false){
                  oilActualPay = item.amount
                }
              }
            }
          }
          _this.consumeRefuelMoney += +conRefMon
          _this.oilActualPay += +oilActualPay
        })
      },
      // 选择“元”或“L”
      changeSelect(){
        if(this.select == "元"){
          this.rise = [
            {value:"￥100"},
            {value:"￥150"},
            {value:"￥200"},
            {value:"￥300"},
          ];
        }else {
          this.rise = [
            {value:"100L"},
            {value:"150L"},
            {value:"200L"},
            {value:"300L"},
          ];
        }
      },
      // 改变加油金额
      changeAmount(amount){
        if (this.select == "元"){
          this.amount = amount.slice(1)
          this.form.amount = this.amount
        }else {
          this.amount = amount.slice(0,3)
          this.form.amount = this.amount
        }
      },
      // 获取油号名称
      getName(oilNameList,id){
        let name = ""
        let _this = this;
        if(oilNameList!=null && oilNameList!=""){
          oilNameList.forEach(item => {
            if (item.id == id){
              name = item.oilName;
              _this.oilType = item.oilType;
            }
          })
        }
        return name;
      },
      // 获取油号信息
      getOilName(){
        getOilNameList().then( response => {
          this.oilNameList = response.data;
        })
      },
      // 根据手机号查询会员信息
      getUser(){
        if(this.select1=="会员手机号"){
          getUserVoMobile({mobile:this.userNo}).then( response => {
            if (response.data!=null){
              this.member = response.data
            }else {
              this.$modal.msgError("会员信息不存在")
            }
          })
        }else {
          getUserVoName({name:this.userNo}).then( response => {
            this.memberList = response.data
          })
          this.dialogVisibleMember = true;
        }
      },
      // 查询所有商品信息
      getGoods(){
        listgoods().then( response => {
          this.goodsList = response.data
        })
      },
      // 加油金额
      refuel(data){
        this.select = "元";
        this.amount = 0
        this.dialogVisibleamount = true;
        getOilNumberById(data.numberId).then( response => {
          this.form = response.data;
          this.gunList.forEach(item => {
            if (item.id==data.id){
              this.form.gunName = item.gunName
            }
          })
        })
        // getOilNumGunById(id).then( response => {
        //   this.form = response.data;
        // })
      },
      // 确定收款
      collection(){
        // JSON.parse()
        this.map.seekZero = this.seekZero;
        this.map.oilAmount = this.oilAmount;
        this.map.goodsAmount = this.goodsAmount;
        this.map.oilActualPay = this.oilActualPay;
        this.map.goodsActualPay = this.goodsActualPay;
        this.map.oilDiscount = this.oilDiscount;
        this.map.goodsDiscount = this.goodsDiscount;
        this.map.goodsNum = this.goodsTotal;
        this.map.oilOrder = JSON.stringify(this.oilOrder);
        this.map.goodsOrder = JSON.stringify(this.goodsOrder);
        this.map.authCode = this.authCode;
        this.map.allAmount = this.oilActualPay + this.goodsActualPay;
        this.map.consumeAmount = this.consumeAmount;
        this.updateRefuelMoney();
        this.map.refuelMoney = JSON.stringify(this.refuelMoney)

        let _this = this;
        addLJGoods(_this.map).then( response => {
          if (response.data.oilOrder!=null){
            _this.orderNo = response.data.oilOrder.orderNo;
            if (response.data.oilOrder.orderStatus == "paid"){
              _this.isPaySuccess = true;
            }
          }
          if (response.data.goodsOrder!=null){
            if (response.data.goodsOrder.status == "paid"){
              _this.isPaySuccess = true;
            }
          }
        })
        this.loading = true;
        _this.queryPayStatus();
        let timer = setInterval(function () {
          if (_this.isQuery == false) {
            _this.loading = false;
            _this.isPay = false;
            clearInterval(_this.timer);
          }
        },500)
        setTimeout(function (){
          clearInterval(timer);
        },30000)

        this.authCode = "";
        if (_this.isPaySuccess == true){
          _this.oilAmount = 0;
          _this.oilActualPay = 0;
          _this.oilDiscount = 0;
          _this.goodsAmount = 0;
          _this.goodsActualPay = 0;
          _this.goodsDiscount = 0;
          _this.consumeAmount = 0;
          _this.consumeRefuelMoney = 0;
          _this.oilTotal = 0;
          _this.goodsTotal = 0;
          _this.isMember = false;
        };
        this.map = {
          allAmount:0,
            // 用户支付条码信息
            authCode:'',
            // 油品订单
            oilOrder:"",
            // 商品订单
            goodsOrder:"",
            // 支付方式
            payType:"WECHAT",
            // 油品订单金额
            oilAmount:0,
            // 商品订单金额
            goodsAmount:0,
            // 油品实付金额
            oilActualPay:0,
            // 商品实付金额
            goodsActualPay:0,
            // 付款用户
            payUser:"",
            // 油品优惠金额
            oilDiscount:0,
            // 商品优惠金额
            goodsDiscount:0,
            // 优惠券id
            couponId:"",
            // 提成金额
            commissionAmount:0,
            // 使用积分数量
            usePoint:0,
            // 积分金额
            pointAmount:0,
            // 终端
            terminal:"PC",
            // 商品数量
            goodsNum:0,
            // 会员消费金额（储值卡需要减少的金额）
            consumeAmount:0,
        };
      },
      updateRefuelMoney(){
        let _this = this;
        _this.oilOrder.forEach(item => {
          if (_this.refuelMoney!=null){
            _this.refuelMoney.forEach(i => {
              if (i.oilType==item.oilType){
                if ((i.refuelMoney-item.liters)>=0){
                  let refuelMoney = i.refuelMoney;
                  i.refuelMoney = refuelMoney-item.liters
                }else {
                  i.refuelMoney = 0
                }
              }
            })
          }
        })
      },
      // 查询订单支付状态
      queryPayStatus(){
        let _this = this;
        _this.timer = setInterval(function (){
          oilOrder({orderNo:_this.orderNo}).then( response => {
            if (response.data!=null){
              if (response.data.orderStatus == "unpaid"){
                _this.isQuery = true;
              }
              if (response.data.orderStatus == "paid"){
                _this.isPaySuccess = true;
                _this.isQuery = false;
              }
              if (response.data.orderStatus == "payFail"){
                _this.isPaySuccess = false;
                _this.isQuery = false;
              }
            }
          })
          goodsOrder({orderNo:_this.orderNo}).then( response => {
            if (response.data!=null){
              if (response.data.status == "unpaid"){
                _this.isQuery = true;
              }
              if (response.data.status == "paid"){
                _this.isPaySuccess = true;
                _this.isQuery = false;
              }
              if (response.data.status == "payFail"){
                _this.isPaySuccess = false;
                _this.isQuery = false;
              }
            }
          })
        },500)
      },
      handClose(){
        if(this.isPaySuccess){
          this.oilAmount = 0;
          this.oilActualPay = 0;
          this.oilDiscount = 0;
          this.goodsAmount = 0;
          this.goodsActualPay = 0;
          this.goodsDiscount = 0;
          this.consumeAmount = 0;
          this.consumeRefuelMoney = 0;
          this.oilTotal = 0;
          this.goodsTotal = 0;
          this.isMember = false;
        }
        this.isPay = true;
        this.dialogVisiblej = false
        this.isPaySuccess = false;
      },
      // 支付方式
      payMethod(payType){
        this.map.payType = payType;
      },
      // 获取支付方式
      getPayList(){
        getDicts("payment_type").then( response => {
          this.payList = response.data;
        })
      //   获取油号列表信息
        listOilNumGun().then( response => {
          this.oilNumList = response.data
        })
      //   获取油号油枪对应信息
        getOilNumGun({oilNum : "全部"}).then( response => {
          this.oilNumGunList = response.data
        })
      },
      handleClose(done) {
        this.$confirm('确认关闭？')
          .then(_ => {
            done();
          })
          .catch(_ => {});
      },
      handleChange(value) {
        let goods = this.goodsOrder;
        let num = 0;
        let amount = 0;
        let _this = this;
        goods.forEach(item => {
          num += item.num
          if (_this.isMember){
            amount += item.memberPrice*item.num;
          }else {
            amount += item.retailPrice*item.num;
          }
        })
        this.goodsTotal = num;
        this.goodsAmount = amount;
        this.goodsActualPay = this.goodsAmount - this.goodsDiscount;
      },
      handleClick(tab, event) {
        let oilNum = ""
        this.oilNumList.forEach(item => {
          if (item.oilName == tab.name){
            oilNum = item.numberId
          }
        })
        if (tab.label == "全部"){
          oilNum = ""
        }
        this.getList(oilNum)
        // getOilNumGun({oilNum : oilNum}).then( response => {
        //   this.oilNumGunList = response.data
        // })
      },
      gocomponents(index){
        this.leftindex = index
      },
      // 获取优惠券列表信息
      getCouponList(){
        listCardFavorableRecord().then(response => {
          this.couponList = response.data.records
        })
        let map = {
          page:1,
          pageSize:20,
        }
        listUserGrade(map).then(response => {
          this.gradeList = response.data.records
        })
      },
      // 获取油枪列表信息
      getList(numberId){
        getOilGun({numberId:numberId}).then(response => {
          this.gunList = response.data.records;
        })
      },
    },

  }
</script>

<style scoped lang="scss">
  .but{
    width: 150px;
    height: 50px;
    border-radius: 50px;
    font-size: 20px;
  }
  .amountBlue{
    color: #00afff;
    font-weight: bold;
  }
  .amount{
    display: flex;
    justify-content: space-between;
    font-size: 16px;
    width: 100%;
    padding: 0 10px;
    margin: 10px auto;
    height: 50px;
    line-height: 50px;
    background-color: #f6f6f6;
    border-radius: 5px;
  }
  .app-center{
    width: 100%;
    display: flex;
    box-sizing: border-box;
    padding: 10px;
  }
  .center-left{
    width: 33%;
    border-radius: 8px;
    overflow: hidden;
    height: 98vh;
    position: relative;
  }
  .bottom-posi{
    width: 100%;
    position: absolute;
    bottom: 0px;
  }
  .center-app{
    width: 33%;
    border-radius: 8px;
    overflow: hidden;
    /*background: white;*/

  }
  .center-right{
    width: 33%;
    border-radius: 8px;
    overflow: hidden;
    margin: 0px 10px;



  }
  .center-top{
    width: 100%;
    height: 86vh;
    background: white;
    margin-bottom: 10px;
    box-sizing: border-box;
    padding: 10px;
    position: relative;

  }
  .center-top-title{
    box-sizing: border-box;
    padding: 10px 0px;
    padding-bottom: 15px;
    border-bottom: 1px solid #ececec;
    font-size: 18px;
    margin-bottom: 10px;
  }
  .center-top-tab{
    box-sizing: border-box;
    padding: 15px 0px;

  }
  .center-top-input{
    width: 100%;
    height: 60px;
    background: #f8f8f8;
    border-radius: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
  input{
    width: 90%;
    font-size: 18px;
    border: none;
    outline: none;
    background-color:transparent;
  }

  }
  .center-top-data{
    width: 100%;
    border-radius: 8px;
    overflow: hidden;
    margin-top: 10px;


    /*background-color: #f8f8f8;*/
  }
  .center-top-of{
    width: 100%;
    /*background-color: #99a9bf;*/
    height: 70vh;
    overflow: auto;


  }
  .wrap-wrap{
    display: flex;
    flex-wrap: wrap;
  }
  .of-box{
    width: 31%;
    margin-right: 10px;
    margin-bottom: 10px;
    border-radius: 8px;
    box-sizing: border-box;
    background-color: #b4d5ff;
    height: 110px;
    padding: 10px;
    color: #3e4f60;
  }
  .of-title{
    font-weight: bold;
    font-size: 22px;
    text-align: center;
    margin: 13px;
  }
  .data-top{
    width: 100%;
    background-color: #ededed;
    box-sizing: border-box;
    padding: 15px 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
  }
  .data-top-box{
    width: 100%;
    /*background-color: #ededed;*/
    box-sizing: border-box;
    padding: 15px 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
  }

  .data-top-three{
    width: 55%;
    display: flex;
    align-items: center;
    justify-content: space-between;

  }
  .data-top-title{
    width: 45%;
    overflow: hidden;
  }
  .content-top-bottom{
    position: absolute;
    bottom:-16px;
    width: 98%;
    border-top: 1px solid #ececec;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transform: translate(-50%,-50%);
    left: 50%;
    color: #2c3e50;
    font-size: 18px;
    box-sizing: border-box;
    padding: 15px ;
    background-color: white;


  }
  .center-left-top{
    width: 100%;
    background: #5393ff;
    height: 70px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .center-vh{
    /*height: 68vh;*/
  }
  .center-left-hj{
    background: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-sizing: border-box;
    padding: 15px;
    margin-bottom: 2px;
  }
  .center-left-th{
    background: white;
    box-sizing: border-box;
    padding: 15px;
    margin: 10px auto;
  }
  .center-left-wrap{
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    /*margin-top: 280px;*/
  }
  .wrap-box{
    width: 31%;
    background: #ffffff;
    border-radius: 8px;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 10px;

  }
  .wrap-box :hover{
    /*background: #00afff !important;*/
    width: 100%;
    height: 100%;
    border-radius: 8px;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #00afff;
    cursor: pointer;
    /*color: white;*/
  }

  .center-left-bottom{
    width: 100%;
    background-color: white;
    border-radius: 8px;
    box-sizing: border-box;
    padding: 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
  }
  .bottom-qk{
    border: 1px solid #99a9bf;
    box-sizing: border-box;
    padding: 14px 20px;
    border-radius: 50px;
    color: #99a9bf;
    margin: 15px 0px ;
  }
  .bottom-qd{
    border: 1px solid #13ce66;
    background: #13ce66;
    box-sizing: border-box;
    padding: 14px 20px;
    border-radius: 50px;
    color: #ffffff;

    margin: 15px 10px ;
  }
  .bottom-gd{
    border: 1px solid #5393ff;
    background: #5393ff;
    box-sizing: border-box;
    padding: 14px 20px;
    border-radius: 50px;
    color: #ffffff;

    margin: 15px 10px ;
  }

  .bottom-price{
    font-size: 26px;
    font-weight: bold;
  }
  .price-red{
    color: red;
  }
  .center-left-lv{
    width: 60%;
    height: 80px;
    background-color: #13ce66;
    color: white;
    border-radius: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
  }
  .th-box{
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #f6f8f9;
    box-sizing: border-box;
    padding: 10px 0px;
  }
  .hj-box{
    width: 33%;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .bule{
    font-weight: 700;
    color: #5393ff !important;
  }
  .vip-bottom{
    border: 1px solid #ffffff;
    box-sizing: border-box;
    padding: 5px 15px;
    border-radius: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    cursor: pointer;
  }
  .el-row {
    margin-top: 20px;
    margin-bottom: 20px;
    &:last-child {
      margin-bottom: 0;
    }
  }
  .el-col {
    border-radius: 2px;
    text-align: center;
    font-size: 20px;
    height: 50px;
    line-height: 50px;
  }
  .bg-purple-dark {
    background: #eeeeee;
  }
  .bg-purple {
    background: #d3dce6;
  }
  .bg-purple-light {
    background: #e5e9f2;
  }
  .grid-content {
    height: 50px;
    font-size: 20px;
    width: 120px;
    border-radius: 4px;
    min-height: 36px;
  }
  .row-bg {
    padding: 10px 0;
    background-color: #eeeeee;
  }
  .elBut{
    width: 85px;
    height: 50px;
    font-size: 18px;
  }
  .addr{
    color: grey;
    font-size: 12px;
  }
</style>
