<template>
    <div>
        <div class="app-container">
            <el-form
                :model="queryParams"
                ref="queryForm"
                :inline="true"
                v-show="showSearch"
            >
                <el-form-item label="订单编号" prop="orderIndex">
                    <el-input
                        v-model="queryParams.orderIndex"
                        placeholder="请输入订单编号"
                        maxlength="30"
                        clearable
                        size="small"
                        @keyup.enter.native="handleQuery"
                    />
                </el-form-item>

                <el-form-item
                    label="服务主题"
                    prop="goodsName"
                    style="margin-left: 30px"
                >
                    <el-input
                        v-model="queryParams.goodsName"
                        placeholder="请输入服务主题"
                        maxlength="30"
                        clearable
                        size="small"
                        @keyup.enter.native="handleQuery"
                    />
                </el-form-item>
                <el-form-item label="服务类型" style="margin-left: 30px">
                    <el-cascader
                        v-model="queryParams.categoryId"
                        :options="categoryList"
                        :props="optionProps"
                        size="small"
                        clearable
                    ></el-cascader>
                </el-form-item>

                <el-form-item label="顾客手机号" prop="serverId">
                    <el-input
                        v-model="queryParams.memberPhone"
                        placeholder="请输入顾客手机号"
                        maxlength="11"
                        clearable
                        size="small"
                        @keyup.enter.native="handleQuery"
                    />
                </el-form-item>
                <!-- <el-form-item label="核销码" prop="orderVerificationCode">
                    <el-input
                        v-model="queryParams.orderVerificationCode"
                        placeholder="请输入核销码"
                        maxlength="30"
                        clearable
                        size="small"
                        @keyup.enter.native="handleQuery"
                    />
                </el-form-item> -->

                <el-form-item
                    label="状态"
                    prop="orderState"
                    style="margin-left: 30px"
                >
                    <el-select
                        v-model="queryParams.orderState"
                        placeholder="请选择"
                        size="small"
                    >
                        <el-option
                            v-for="item in statusOptions"
                            :key="item.decodeValue"
                            :label="item.decodeValue"
                            :value="item.decodeId"
                        >
                        </el-option>
                    </el-select>
                </el-form-item>
                <el-form-item label="下单日期" prop="createTime">
                    <el-date-picker
                        v-model="dateRange"
                        type="daterange"
                        value-format="yyyy-MM-dd"
                        range-separator="至"
                        start-placeholder="开始日期"
                        end-placeholder="结束日期"
                        style="width: 280px"
                        size="small"
                    >
                    </el-date-picker>
                </el-form-item>
                <el-form-item style="margin-left: 30px">
                    <el-button
                        type="primary"
                        icon="el-icon-search"
                        size="mini"
                        @click="handleQuery"
                        >搜索</el-button
                    >
                    <el-button
                        icon="el-icon-refresh"
                        size="mini"
                        @click="resetQuery"
                        >重置</el-button
                    >
                </el-form-item>
            </el-form>
            <el-row>
                <el-input
                    v-model="form.orderVerificationCode"
                    style="width: 200px; margin-left: 930px; margin-right: 10px"
                    placeholder="请输入核销码"
                    maxlength="30"
                    clearable
                    size="small"
                />
                <el-button
                    type="primary"
                    size="mini"
                    @click="verifyGroupOrder(form.orderVerificationCode)"
                    >核销</el-button
                >
            </el-row>

            <el-row :gutter="10" class="mb8">
                <right-toolbar
                    :showSearch.sync="showSearch"
                    @queryTable="getList"
                ></right-toolbar>
            </el-row>

            <el-table
                v-loading="loading"
                :data="orderList"
                @selection-change="handleSelectionChange"
            >
                <!-- <el-table-column label="序号" type="index" /> -->
                <el-table-column
                    label="订单编号"
                    align="center"
                    prop="orderIndex"
                    width="180px"
                    show-overflow-tooltip
                />

                <el-table-column
                    label="服务编号"
                    align="center"
                    prop="goodsIndex"
                    width="180px"
                    show-overflow-tooltip
                />
                <el-table-column
                    label="服务主题"
                    align="center"
                    prop="goodsName"
                    width="120px"
                    show-overflow-tooltip
                />
                <el-table-column
                    label="服务类型"
                    align="center"
                    prop="categoryName"
                    width="80px"
                />
                <el-table-column
                    label="规格描述"
                    align="center"
                    prop="specificationDesc"
                    width="150px"
                    show-overflow-tooltip
                />
                <el-table-column
                    label="次数(剩余/购买）"
                    align="center"
                    prop="times"
                    width="120"
                >
                </el-table-column>
                <el-table-column
                    label="价格"
                    align="center"
                    prop="specificationCurrentPrice"
                    width="80px"
                />

                <el-table-column
                    label="订单金额"
                    align="center"
                    prop="orderAmount"
                    width="80px"
                />
                <el-table-column
                    label="支付金额"
                    align="center"
                    prop="totalAmount"
                    width="80px"
                />

                <el-table-column
                    label="顾客手机号"
                    align="center"
                    prop="memberPhone"
                    width="120px"
                    show-overflow-tooltip
                />

                <el-table-column
                    label="下单时间"
                    align="center"
                    prop="createTime"
                    width="150"
                    show-overflow-tooltip
                />

                <el-table-column
                    label="状态 "
                    align="center"
                    width="150"
                    prop="refStatus"
                >
                <template slot-scope="scope">
                <el-tag type="danger" v-if="scope.row.orderState=='099'" size="medium">{{scope.row.refStatus}}</el-tag>
                <el-tag type="success" v-if="scope.row.orderState=='000'" size="medium">{{scope.row.refStatus}}</el-tag>
                <el-tag type="primary" v-if="scope.row.orderState=='001'" size="medium">{{scope.row.refStatus}}</el-tag>
                <el-tag type="warning" v-if="scope.row.orderState=='002'" size="medium">{{scope.row.statusName}}</el-tag>
                 <el-tag type="warning" v-if="scope.row.orderState=='003'" size="medium">{{scope.row.refStatus}}</el-tag>
                <el-tag type="success" v-if="scope.row.orderState=='004'" size="medium">{{scope.row.refStatus}}</el-tag>
                <el-tag type="danger" v-if="scope.row.orderState=='005'" size="medium">{{scope.row.refStatus}}</el-tag>
                <el-tag type="danger" v-if="scope.row.orderState=='006'" size="medium">{{scope.row.refStatus}}</el-tag>
                <el-tag type="info" v-if="scope.row.orderState=='007'" size="medium">{{scope.row.refStatus}}</el-tag>
            </template>
                </el-table-column>
                <el-table-column
                    label="操作"
                    align="center"
                    class-name="small-padding fixed-width"
                    fixed="right"
                    width="220"
                >
                    <template slot-scope="scope">
                        <el-button
                            size="mini"
                            type="text"
                            icon="el-icon-view"
                            @click="toSee(scope.row)"
                            v-hasPermi="['system:order:edit']"
                            >查看</el-button
                        >

                            <el-button
                            v-if="scope.row.orderState == '001'"
                                size="mini"
                                type="text"
                                icon="el-icon-edit"
                                @click="toVerifyOrder(scope.row)"
                                v-hasPermi="['system:order:edit']"
                                >核销订单</el-button
                            >
                            <!-- <el-button
                                v-if="scope.row.orderState == '001'
                                ||scope.row.orderState == '002'
                                ||scope.row.orderState == '003'
                                ||scope.row.orderState == '004'
                                ||scope.row.orderState == '005'"
                                size="mini"
                                type="text"
                                icon="el-icon-coordinate"
                                @click="editRefund(scope.row)"
                                v-hasPermi="['system:order:edit']"
                                >退款</el-button
                            > -->
                            <el-button
                                size="mini"
                                type="text"
                                icon="el-icon-circle-check"
                                @click="doRefund(scope.row)"
                                v-hasPermi="['shop:audit:audit']"
                                v-if="scope.row.orderState == '005'&& scope.row.status=='001'"
                                >审核退款
                            </el-button>
                    </template>
                </el-table-column>
            </el-table>

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

        <!-- 预约核销弹框 -->
        <el-dialog
            title="预约核销"
            :visible.sync="open"
            width="800px"
            append-to-body
        >
            <el-form
                :model="form"
                label-width="80px"
                ref="userForm"
                :inline="true"
                label-position="left"
                :rules="rules"
            >
                <el-row style="margin-left: 50px">
                    <el-col
                        :span="24"
                        style="font-size: 14px; margin-bottom: 15px"
                    >
                        <!-- <el-col :span="12">
                            <el-input
                                label="核销码"
                                v-model="form.orderVerificationCode"
                                placeholder="请输入核销码"
                                maxlength="30"
                                clearable
                                size="small"
                                @keyup.enter.native="handleQuery"
                            />
                             <span style="text-align: left; margin-right: 10px"
                                >核销码</span
                            >{{ order.orderVerificationCode }}
                        </el-col> -->
                        <el-col :span="12"
                            >顾客购买<span
                                style="
                                    font-weight: 400;
                                    font-size: 20px;
                                    color: #8400ff;
                                "
                                >{{ order.groupTimes }}</span
                            >次服务， 已经使用<span
                                style="
                                    font-weight: 400;
                                    font-size: 18px;
                                    color: #0000ff;
                                "
                                >{{
                                    order.groupTimes - order.groupRemainingTimes
                                }}</span
                            >次， 剩余<span
                                style="
                                    font-weight: 700;
                                    font-size: 16px;
                                    color: #d9001b;
                                "
                                >{{ order.groupRemainingTimes }}</span
                            >次</el-col
                        >
                    </el-col>
                    <el-card
                        :span="24"
                        style="
                            background-color: #f2f2f2;
                            color: white;
                            color: #333333;
                            margin-bottom: 20px;
                        "
                    >
                        <el-col
                            :span="24"
                            style="font-size: 16px; margin-bottom: 15px"
                        >
                            {{ order.goodsName }}
                        </el-col>
                        <el-col
                            :span="24"
                            style="font-size: 14px; margin-bottom: 15px"
                        >
                            <span
                                style="
                                    color: #7f7f7f;
                                    text-align: left;
                                    margin-right: 10px;
                                "
                                >服务类别
                            </span>
                            <span style="color: #333333; text-align: left"
                                >{{
                                    order.parentName == null
                                        ? ""
                                        : order.parentName + "-"
                                }}{{ order.categoryName }}</span
                            >
                        </el-col>
                        <el-col
                            :span="24"
                            style="font-size: 14px; margin-bottom: 15px"
                        >
                            <span
                                style="
                                    color: #7f7f7f;
                                    text-align: left;
                                    margin-right: 10px;
                                "
                                >规格
                            </span>
                            <span style="color: #333333; text-align: left">{{
                                order.specificationDesc
                            }}</span>
                        </el-col>
                    </el-card>
                    <el-card
                        :span="24"
                        style="
                            background-color: #f2f2f2;
                            color: white;
                            color: #333333;
                            margin-bottom: 15px;
                        "
                    >
                        <el-col
                            :span="24"
                            style="font-size: 14px; margin-bottom: 15px"
                        >
                            <span
                                style="
                                    color: #7f7f7f;
                                    text-align: left;
                                    margin-right: 10px;
                                "
                                >顾客信息
                            </span>
                            <span style="color: #333333; text-align: left">
                                  {{
                                    memberOrderAddress.name
                                        ?(memberOrderAddress.name.length>1?
                                         memberOrderAddress.name.replace(
                                              memberOrderAddress.name.substring(
                                                  1,
                                                  2
                                              ),
                                              "*"
                                          ):memberOrderAddress.name+"*"
                                        )
                                        : ""
                                }}
                            </span>
                            <span>
                                {{
                                    memberOrderAddress.phone
                                        ? memberOrderAddress.phone.replace(
                                              memberOrderAddress.phone.substring(
                                                  3,
                                                  7
                                              ),
                                              "****"
                                          )
                                        : ""
                                }}
                            </span>
                        </el-col>
                        <el-col
                            :span="24"
                            style="font-size: 14px; margin-bottom: 15px"
                        >
                            <span
                                style="
                                    color: #7f7f7f;
                                    text-align: left;
                                    margin-right: 10px;
                                "
                                >服务地址
                            </span>
                            <span style="color: #333333; text-align: left"
                                ><i class="el-icon-location-information" />{{
                                    memberOrderAddress.address
                                }}{{ memberOrderAddress.detailed }}</span
                            >
                        </el-col>
                        <el-col
                            :span="24"
                            style="font-size: 14px; margin-bottom: 15px"
                        >
                            <span
                                style="
                                    color: #7f7f7f;
                                    text-align: left;
                                    margin-right: 10px;
                                "
                                >备注
                            </span>
                            <span style="color: #333333; text-align: left">{{
                                order.memo
                            }}</span>
                        </el-col>
                    </el-card>
                    <el-col :span="24">
                        <el-form-item
                            label="核销码"
                            prop="orderVerificationCode"
                        >
                            <el-input
                                label="核销码"
                                v-model="form.orderVerificationCode"
                                placeholder="请输入核销码"
                                maxlength="30"
                                clearable
                                size="small"
                                :disabled="orderVerificationCodeIsInput"
                            />
                        </el-form-item>
                    </el-col>
                    <el-col :span="24">
                        <el-form-item label="上门时间" prop="appointmentTime">
                            <el-date-picker
                                v-model="form.appointmentTime"
                                type="datetime"
                                value-format="yyyy-MM-dd HH:mm:ss"
                                placeholder="选择日期时间"
                                :picker-options="pickerOptions"
                            >
                            </el-date-picker>
                        </el-form-item>
                    </el-col>

                    <el-col :span="24">
                        <el-form-item label="备注" prop="remark">
                            <el-input
                                type="textarea"
                                :rows="6"
                                maxlength="200"
                                style="width: 600px"
                                placeholder="请填写备注，如备注本次服务人员姓名等"
                                show-word-limit
                                v-model="form.remark"
                            >
                            </el-input>
                        </el-form-item>
                    </el-col>
                    <el-col
                        :span="24"
                        style="
                            font-family: 'Nunito Sans', sans-serif;
                            font-weight: 400;
                            font-style: normal;
                            font-size: 12px;
                            color: #333333;
                            margin-left: 80px;
                        "
                    >
                        注：此备注信息不展示给顾客
                    </el-col>
                    <el-col :span="24" style="margin-left: 53%">
                        <el-button @click="open = false">取 消</el-button>
                        <el-button type="primary" @click="submitVerifyOrderTime"
                            >确 定</el-button
                        >
                    </el-col>
                </el-row>
            </el-form>
        </el-dialog>

        <!-- 退款弹框 -->
        <el-dialog
            title="退款"
            :visible.sync="refundap"
            width="600px"
            :close-on-click-modal="false"
        >
            <el-form
                :model="refundParams"
                label-width="100px"
                ref="refundForm"
                :inline="true"
                label-position="left"
                style="margin-left: 100px"
                :rules="rules"
            >
                <el-form-item label="退款金额" prop="refundMoney">
                    <el-input v-model="refundParams.refundMoney"></el-input>
                </el-form-item>

                <el-form-item label="退款原因" prop="refundReason">
                    <el-input v-model="refundParams.refundReason"></el-input>
                </el-form-item>
            </el-form>
            <div slot="footer">
                <el-button @click="refundap = false">取 消</el-button>
                <el-button type="primary" @click="handleRefund"
                    >确 定</el-button
                >
            </div>
        </el-dialog>

          <!-- 审核退款原因对话框 -->
        <el-dialog
            :title="title"
            :visible.sync="auditRefundOpen"
            width="600px"
            append-to-body
        >
            <el-form ref="auditRefundForm" :model="auditRefundForm" label-width="120px">
                <el-form-item label="团购次数">
                    <div>{{ auditRefundForm.groupTimes }}次</div>
                </el-form-item>

                <el-form-item label="已使用次数">
                    <div style="color: red">
                        {{ auditRefundForm.groupTimes - auditRefundForm.groupRemainingTimes }}次
                    </div>
                </el-form-item>

                <el-form-item label="团购总价">
                    <div>{{ auditRefundForm.totalAmount }}元</div>
                </el-form-item>

                <el-form-item label="申请退款金额">
                    <div>{{ auditRefundForm.payMoney }}元</div>
                </el-form-item>

                <el-form-item label="申请退款原因">
                    <div>{{ auditRefundForm.refundReason }}</div>
                </el-form-item>

                <el-divider></el-divider>

                <el-form-item label="审核结果">
                    <el-radio v-model="auditRefundForm.status" label="002"
                        >同意退款</el-radio
                    >
                </el-form-item>

                <el-form-item label="审核退款金额" v-if="auditRefundForm.status == '002'">
                    <el-input-number
                        v-model="auditRefundForm.refundMoney"
                        :min="0"
                        :max="999999.99"
                        maxlength="9"
                        @keyup.native="clearNoNum"
                        clearable
                        placeholder="可填写的最大数值为999999.99"
                    >
                        <template slot="append">元</template>
                    </el-input-number>
                </el-form-item>

                <el-form-item label="审核结果描述">
                    <el-input
                        type="textarea"
                        :rows="3"
                        maxlength="100"
                        show-word-limit
                        v-model="auditRefundForm.refundResult"
                        placeholder="请输入审核结果描述"
                    />
                </el-form-item>
            </el-form>
            <div slot="footer" class="dialog-footer">
                <el-button type="primary" @click="submitAuditRefund">确 定</el-button>
                <el-button @click="cancelAuditRefund">取 消</el-button>
            </div>
        </el-dialog>


        <!-- 详情弹框 -->
        <el-dialog
            title="订单详情"
            :visible.sync="orderOpen"
            width="950px"
            :close-on-click-modal="false"
            :modal-append-to-body="false"
        >
        <div style="width: 900px; margin: 0 auto; word-spacing: 2em">
        <el-row :gutter="20">
            <el-col :span="24">
                <el-card style="margin-top: 10px">
                    <el-row :gutter="10">
                        <el-col :span="8">
                            <span>订单状态 </span
                            ><span
                                style="
                                    letter-spacing: normal;
                                    color: #333333;
                                    line-height: normal;
                                    font-weight: 700;
                                "
                                >{{ order.refStatus }}</span
                            >
                        </el-col>
                        <el-col :span="16" style="cursor: pointer">
                            <span style="color: rgb(64, 158, 255);" @click="seeOrderStatus()">订单跟踪></span>
                        </el-col>
                    </el-row>
                </el-card>
            </el-col>

            <el-col :span="24">
                <el-card>
                    <el-row :gutter="10">
                        <el-col :span="3">服务主题</el-col>
                        <el-col :span="21" style="margin-bottom: 20px; cursor: pointer">
                            <span  style="color: rgb(64, 158, 255);" @click="toServerProject"
                                >{{ order.goodsName }}></span
                            >
                        </el-col>

                        <!-- <el-col :span="2">
                            <span>{{ order.serverName }}</span>
                        </el-col>
                        <el-col :span="3">
                            <span>{{ order.serverPhone }}</span>
                        </el-col>
                        <el-col :span="3">
                            <span>{{ this.serverUser.serverLevel }}</span>
                        </el-col>
                        <el-col :span="3">
                            <span>{{ this.serverUser.serverAge }}年工龄</span>
                        </el-col>
                        <el-col :span="3">
                            <span>好评率 </span><span class="span-color" >{{ this.serverUser.rate }}</span>
                        </el-col> -->
                    </el-row>
                </el-card>
            </el-col>

            <el-col :span="24">
                <el-card>
                    <el-row :gutter="10">
                        <el-col :span="12">
                            <span>顾客信息</span>
                            <span class="span-color-size">
                                {{
                                    member.name
                                        ? member.name.length > 1
                                            ? member.name.replace(
                                                  member.name.substring(1, 2),
                                                  "*"
                                              )
                                            : member.name + "*"
                                        : ""
                                }}
                                {{ member.phone }}
                            </span>
                            <!-- <span>
                                {{
                                    member.phone
                                        ? member.phone.replace(
                                              member.phone.substring(3, 7),
                                              "****"
                                          )
                                        : ""
                                }}
                            </span> -->
                        </el-col>
                        <el-col :span="12">
                            <span class="span-color-size"
                                ><i class="el-icon-location-information" />{{
                                    member.address
                                }}{{ member.detailed }}</span
                            >
                        </el-col>
                        <el-col :span="24" style="margin-top: 20px">
                            <span>备注 </span
                            ><span class="span-color-size">
                                {{ order.memo }}</span
                            >
                        </el-col>
                    </el-row>
                </el-card>
            </el-col>

            <el-col :span="24">
                <el-card>
                    <el-row :gutter="10">
                        <el-col :span="12">
                            <span>订单编号</span><span class="span-detailed-info"> {{ order.orderIndex }} </span>
                            <el-button
                                size="mini"
                                class="orderIndex"
                                :data-clipboard-text="order.orderIndex"
                                >复制</el-button
                            >
                        </el-col>

                        <el-col :span="12" style="margin-bottom: 20px">
                            <span>下单时间</span><span  class="span-detailed-info"> {{ order.createTime }}</span>
                        </el-col>

                        <el-col :span="12">
                            <span>服务类别 </span
                            ><span class="span-detailed-info">
                                {{
                                    order.parentName == null
                                        ? ""
                                        : order.parentName + "—"
                                }}{{ order.categoryName }}</span
                            >
                        </el-col>
                        <el-col :span="12" style="margin-bottom: 20px">
                            <span>规格描述</span><span class="span-detailed-info"> {{ order.specificationDesc }}</span>
                        </el-col>

                        <el-col :span="12">
                            <span>次数 </span
                            ><span class="span-color"
                                >{{ order.groupTimes }}
                            </span>
                        </el-col>
                        <el-col :span="12">
                            <span>订单金额 </span
                            ><span class="span-color"
                                >￥{{ order.orderAmount }}</span
                            >
                        </el-col>
                    </el-row>
                </el-card>
            </el-col>

            <el-col :span="24" v-if="order.beanAmount">
                <el-card>
                    <el-row :gutter="10">
                        <el-col :span="24">
                            <span>优金豆</span
                            ><span style="color: #d9001b">
                                -￥{{ order.beanAmount / 100 }}</span
                            >
                        </el-col>
                    </el-row>
                </el-card>
            </el-col>
            <el-col :span="24" v-if="order.couponAmount">
                <el-card>
                    <el-row :gutter="10">
                        <el-col :span="24">
                            <span>优惠券</span
                            ><span style="color: #d9001b">
                                -￥{{ order.couponAmount }}</span
                            >
                        </el-col>
                    </el-row>
                </el-card>
            </el-col>
            <el-col>
                <el-card
                    :span="24"
                    style="background-color: rgb(127, 127, 127); color: white"
                >
                    <el-row :gutter="10">
                        <el-col :span="12">
                            <span>订单实付 ￥{{ order.totalAmount }}</span>
                        </el-col>
                    </el-row>
                </el-card>
            </el-col>

            <el-col :span="24" v-if="orderVerificationRecordList.length > 0">
                <el-row style="margin-bottom: 10px">
                    <b>核销记录</b>
                </el-row>
                <el-card
                    v-for="item in orderVerificationRecordList"
                    :key="item.orderVerificationRecordId"
                >
                    <el-row :gutter="10">
                        <el-col :span="12">
                            <span
                                >核销时间
                                {{
                                    item.createTime
                                        | dateFormat("yyyy-MM-DD HH:mm")
                                }}
                            </span>
                        </el-col>

                        <el-col :span="12" style="margin-bottom: 20px">
                            <span
                                >上门时间
                                {{
                                    item.appointmentTime
                                        | dateFormat("yyyy-MM-DD HH:mm")
                                }}</span
                            >
                        </el-col>

                        <el-col :span="12">
                            <span>核销码 {{ item.orderVerificationCode }}</span>
                        </el-col>
                        <el-col :span="12" style="margin-bottom: 20px">
                            <span>备注 {{ item.remark }}</span>
                            <span v-if="item.qrCodeUrl">
                                <el-button
                                    size="mini"
                                    type="primary"
                                    class="gatePass"
                                    @click="
                                        getAccessPasscode(
                                            item.orderVerificationCode
                                        )
                                    "
                                    >门岗通行证
                                </el-button>
                            </span>
                            <span v-else>
                                <el-button
                                    size="mini"
                                    type="primary"
                                    class="gatePass"
                                    @click="
                                        getOrSaveAccessPasscode(
                                            item.orderVerificationCode
                                        )
                                    "
                                    >门岗通行证
                                </el-button>
                            </span>
                        </el-col>

                        <el-col :span="12" style="margin-bottom: 20px">
                        </el-col>
                    </el-row>
                </el-card>
            </el-col>

            <el-col :span="24" v-if="refundOpen">
                <el-row style="margin-bottom: 10px">
                    <b>退款信息 </b>
                </el-row>
                <el-card>
                    <el-row :gutter="10">
                        <el-col :span="12" style="margin-bottom: 10px">
                            <span
                                >退款金额
                                {{
                                    refund === undefined ? "" : refund.payMoney
                                }}
                                元</span
                            >
                        </el-col>
                    </el-row>
                    <el-row :gutter="10" style="margin-bottom: 10px">
                        <el-col :span="24">
                            <span
                                >退款原因
                                {{
                                    refund === undefined
                                        ? ""
                                        : refund.refundReason
                                }}</span
                            >
                        </el-col>
                    </el-row>
                    <el-row :gutter="10">
                        <el-col :span="24">
                            <span
                                >审核结果
                                {{
                                    refund === undefined
                                        ? ""
                                        : refund.refundResult
                                }}</span
                            >
                        </el-col>
                    </el-row>
                </el-card>
            </el-col>
        </el-row>

        <!--订单跟踪-->
        <el-dialog title="订单跟踪" :visible.sync="recordOpen" width="600px"  :modal-append-to-body="true" :append-to-body="true">
            <ul>
                <li :key="item.id" v-for="item in orderRecord">
                    <el-row>
                        <el-col :span="12">
                            {{ item.operateInfo }}
                            <!-- {{ checkCode(item) }} -->
                        </el-col>

                        <el-col :span="12">
                            {{ item.createTime }}
                        </el-col>
                    </el-row>

                    <el-divider></el-divider>
                </li>
            </ul>
        </el-dialog>
        <!--门岗通行证二维码-->
        <el-dialog  title="" 
                            :visible.sync="qrCodeOpen" 
                            width="410px"
                            :modal-append-to-body="true" 
                            :append-to-body="true"
                            :show-close="false"
                            ref="refDia"
                            >
                            <div ref="reference" 
                            :style="'background-image:url('+urlBg+');background-repeat:no-repeat;background-size:100% 100%;height:595px;width:380px;background-color: rgba(0, 0, 0, 0)'"
                            >
                                <el-row class="qrCodeDialog" style="margin-top:-20px;">
                                    <div style="font-size:25px;color:#fff;padding-bottom:5px;margin-top:30px;">
                                        门岗通行证
                                    </div>
                                </el-row>
                                <el-row class="qrCodeDialog">
                                    <div style="font-size:16px;color:#fff;padding-bottom:30px;">
                                        优鲜信家政/维修服务平台
                                    </div>
                                </el-row>
                                <el-row class="qrCodeDialog">
                                    <!-- <el-image
                                        style="width: 300px; height: 300px;"
                                        :src="this.qrCodeUrl"
                                        :preview-src-list="this.qrCodeUrls">
                                    </el-image> -->
                                    <img :src=" 'data:image/png;base64,' + this.qrCodeUrl ">
                                </el-row>
                                <el-row class="qrCodeDialog">
                                    <div style="font-size:15px;color:rgb(0, 0, 0);padding-bottom:5px;">
                                        进小区时请服务人员主动向门岗<span style="font-family:newHelvetica;">出</span>示此二维
                                    </div>
                                </el-row>
                                <el-row class="qrCodeDialog">
                                    <div style="font-size:15px;color:rgb(0, 0, 0);padding-bottom:5px;">
                                        码，请门岗保<span style="font-family:newHelvetica;">安</span>微信扫码确认服务人员身份。
                                    </div>
                                </el-row>
                                <el-row class="qrCodeDialog">
                                    <div style="font-size:16px;color:#ff511b;padding-bottom:100px;font-weight: bold;">
                                        此码只可使用一次，请勿给他人使用。
                                    </div>
                                </el-row>
                                <el-row class="qrCodeDialog"  style="position: absolute;top:279px;left:180px;">
                                    <div>
                                        <el-image :src="logoImage" style="border-radius:10px;width:60px;height:60px;"></el-image>
                                    </div>
                                </el-row>
                                <el-row class="qrCodeDialog" style="position: absolute;top:660px;left:152px;">
                                    <el-button size="mini" type="primary" class="el-icon-download"  @click="toImage()"> 下载图片</el-button>
                                </el-row>
                            </div>
                </el-dialog>

    </div>
        </el-dialog>
    </div>
</template>

<script>
import {
    listGroupOrder,
    getOrder,
    getAddress,
    getOrderByVerificationCode,
} from "@/api/system/order";
import { handleVerifyGroupOrder } from "@/api/system/orderVerificationRecord";
import { merchantRefund } from "@/api/merchant/merchant";
import { categoryTree } from "@/api/basic/category";
import { getInfo } from "@/api/login";
import { listCode } from "@/api/system/dict/code";
import { getRefundInfo, doRefund } from "@/api/order/adminOrder";
import { getUser } from "../../../api/system/ServiceUserService";
import { listRecord } from "../../../api/system/orderRecord";
import { listRefund } from "../../../api/system/orderRefund";
import { listRecordVOByOrderId } from "../../../api/merchant/orderVerificationRecord";
import {
    saveAccessPasscode,
    getByOrderIdAndOrderVerificationCode,
} from "../../../api/merchant/accessPasscode";
import { mapGetters } from "vuex";
import html2canvas from "html2canvas";
import ClipboardJS from "clipboard";


export default {
    name: "order",
    data() {
        return {
            // 审核退款表单
            auditRefundForm: {},
            // 审核退款弹框控制
            auditRefundOpen: false,
            // 核销码是否可输入
            orderVerificationCodeIsInput: true,
            // 日期范围
            dateRange: [],
            //服务类别筛选框
            serviceOptions: [],
            //服务状态筛选框
            statusOptions: [],
            // 遮罩层
            loading: true,
            // 导出遮罩层
            exportLoading: false,
            // 选中数组
            ids: [],
            // 非单个禁用
            single: true,
            // 非多个禁用
            multiple: true,
            // 显示搜索条件
            showSearch: true,
            // 总条数
            total: 0,
            // 订单主表格数据
            orderList: [],
            // 弹出层标题
            title: "",
            // 是否显示核销弹出层
            open: false,
            //订单详情
            orderOpen:false,
            // 顾客订单地址信息
            memberOrderAddress: {},
            // 订单信息
            order: {},
             refundOpen: false,
             refundap:false,
            order: {},
            activeNames: ["1"],
            imgSrc: "",
            goodsList: [],
            member: {},
            serverUser: {},
            recordOpen: false,
            qrCodeOpen: false,
            qrCodeUrl: null,
            qrCodeUrls: [],
            orderRecord: [],
            refStatusOptions: [],
            refund: {},
            clipboard: null,
            orderVerificationRecordOpen: false,
            orderVerificationRecordList: [],
            // 查询参数
            queryParams: {
                pageNum: 1,
                pageSize: 10,
                orderIndex: null,
                memberId: null,
                merchantId: null,
                merchantIndex: "",
                goodsName: "",
                categoryId: [],
                categoryName: null,
                memberPhone: "",
                orderState: null,
                orderVerificationCode: "",
            },
            // 团购订单最大可退金额
            maxGroupRefundMoney: 0,
            // 表单参数
            form: {},
            // 表单校验
            rules: {
                refundMoney: [
                    {
                        required: true,
                        message: "退款金额不能为空",
                        trigger: "blur",
                    },
                ],
            },
            refStatusOptions: [],
            timeForm: {
                serverId: null,
            },
            timeOpen: false,
            timeOptions: [],
            //追加服务选择框
            addStatusOptions: [
                {
                    label: "全部",
                    value: "",
                },
                {
                    label: "是",
                    value: "1",
                },
                {
                    label: "否",
                    value: "0",
                },
            ],
            refundParams: {
                orderId: null,
                refundMoney: "",
                refundReason: "",
            },
            refundOpen: false,
            categoryList: [],
            appointmentStartTime: null,
            optionProps: {
                value: "categoryId",
                label: "categoryName",
                children: "childrenCategory",
            },
            logoImage:require('../../../assets/logo/logo.png'),
            urlBg : require('../../../assets/images/card-bg.png'),
            // 表单校验
            rules: {
                orderVerificationCode: [
                    {
                        required: true,
                        message: "核销码不能为空",
                        trigger: "blur",
                    },
                ],
                appointmentTime: [
                    {
                        required: true,
                        message: "上门服务时间不能为空",
                        trigger: "blur",
                    },
                ],
            },
            pickerOptions:{
                disabledDate(time) {
                var dateTime = new Date() ;
               dateTime = dateTime.setDate(dateTime.getDate()-1);
             return time.getTime() <  new Date(dateTime) ;

          },
            },
        };
        
    },
     computed: {
        ...mapGetters(["dict"]),
    },
    created() {

        if (this.$route.query.pageNum) {
            console.log(this.queryParams.pageNum)
            this.queryParams.pageNum = parseInt(this.$route.query.pageNum)
            console.log(this.queryParams.pageNum)
         }

        if (this.$route.query.orderIndex) {
            this.queryParams.orderIndex = this.$route.query.orderIndex
        }

        if (this.$route.query.goodsName) {
            this.queryParams.goodsName = this.$route.query.goodsName
        }

        // if (this.$route.query.categoryId) {
        //     this.queryParams.categoryId = this.$route.query.categoryId
        // }

        if (this.$route.query.memberPhone) {
            this.queryParams.memberPhone = this.$route.query.memberPhone
        }

        if (this.$route.query.orderState) {
            this.queryParams.orderState = this.$route.query.orderState
        }

        if (this.$route.query.params) {
             if (this.$route.query.params.beginTime) {
                // console.log("==========",this.$route.query.params)
                // console.log("1",this.$route.query.params.beginTime)
                // console.log(typeof(this.dateRange))
                this.dateRange[0]=this.$route.query.params.beginTime
                this.dateRange[1]=this.$route.query.params.endTime
                console.log("-------",this.dateRange)
             }

        }

        this.getStatus();
        this.queryCategory();
        // this.getList();
    },

 mounted() {
        this.clipboard = new ClipboardJS(".orderIndex");
        this.clipboard.on("success", (e) => {
            this.$message.success("复制成功");
            e.clearSelection();
        });

 
    },
        destroyed() {
        // 销毁Clipboard实例，避免在其它页面或组件中实例化Clipboard后造成再次监听，产生重复回调
        this.clipboard.destroy();
    },

    methods: {
        // 处理服务主体名称
        handleMerchantType(merchantType) {
            if (merchantType === 0) {
                return "商家";
            }
            if (merchantType === 1) {
                return "个体";
            }
            return "-";
        },

        // 查询服务类型
        queryCategory() {
            categoryTree()
                .then((res) => {
                    if (res.code == 200) {
                        this.categoryList = res.data;

                        if (this.$route.query.categoryId) {
                    //             this.queryParams.categoryId= [36,37]

                        for(var i=0 ;i<this.categoryList.length;i++){
                            for(var t=0 ;t<this.categoryList[i].childrenCategory.length;t++){
                                if(this.categoryList[i].childrenCategory[t].categoryId == this.$route.query.categoryId){
                                    console.log("=======")
                                    console.log(this.categoryList[i].childrenCategory[t])

                                    this.queryParams.categoryId= [this.categoryList[i].categoryId,this.categoryList[i].childrenCategory[t].categoryId]
                                    console.log(this.queryParams.categoryId)
                                    // this.categoryId[0]=this.$route.query.categoryList[i].categoryId
                                    // this.categoryId[1]=this.$route.query.categoryList[i].childrenCategory[t].categoryId
                                }
                            }



                     }
                    }
                     this.getList();
                    } else {
                        this.$message.error("获取分类列表失败");
                    }
                })
                .catch((err) => {
                    this.$message.error("获取分类列表失败");
                });
        },

        // 提交预约核销
        submitVerifyOrderTime() {
            handleVerifyGroupOrder(this.form).then((res) => {
                if (res.code == "200") {
                    this.$modal.msgSuccess("核销成功");
                    this.form={};
                    this.open = false;
                    this.getList();
                }
            });
        },

        // 详情页面跳转
        toSee(row) {
            // this.$router.push({
            //     path: "/order/groupDetail",
            //     query: { id: row.orderId },
            // });
            getOrder(row.orderId).then((response) => {
            this.order = response.data;
            this.queryAdress();
            this.getServicceUser();
            this.getRefStatus();
            this.getRefund();
            this.getOrderVerificationRecordList();
        });
        //显示详情弹框
            this.orderOpen=true;
        },

        // 查询团购订单列表
        getList() {

             this.$store.state.tagsView.visitedViews.forEach(element => {
                if (this.$route.path === element.path) {
                    element.query = this.queryParams
                }
            });

            getInfo().then((r) => {
                if (r.roles[0] == "merchant") {
                    if (r.merchant.merchantId != null) {
                        this.queryParams.merchantId = r.merchant.merchantId;
                    }
                }

                if(this.dateRange == null){
                    this.dateRange = ''
                }
                this.loading = true;

                const [searchBegin, searchEnd] = this.dateRange;
                let sBegin = searchBegin;
                let sEnd = searchEnd;
                if (typeof searchBegin == "undefined") {
                var start = new Date()
                        start.setTime(start.getTime()-3600 * 1000 * 24 * 30)
                        this.dateRange = [start,new Date()]
                        sBegin = this.timeStamp2String(start)
                }
                if (typeof searchEnd == "undefined") {
                    sEnd = this.timeStamp2String(new Date())
                            this.dateRange=[sBegin,sEnd]
                }
                this.queryParams.beginTime = sBegin;
                this.queryParams.endTime = sEnd;

                // 级联选择器绑定的参数queryParams.categoryId是一个数组，需要将最后一个层级分类的id 重新赋值给查询参数categoryId
                if (
                    this.queryParams.categoryId &&
                    this.queryParams.categoryId.length > 1
                ) {
                    this.queryParams.categoryId =
                        this.queryParams.categoryId[
                            this.queryParams.categoryId.length - 1
                        ];
                }
                if (this.queryParams.categoryName != null) {
                    this.queryParams.categoryName =
                        this.queryParams.categoryName[0].toString();
                }
                // 查询家政团购订单列表
                this.queryParams.orderType = "003";
                // 传参调用接口
                listGroupOrder(
                    this.addDateRange(this.queryParams, this.dateRange)
                ).then((response) => {
                    this.orderList = response.rows;
                    this.total = response.total;
                    this.loading = false;
                });
            });
        },
        // 取消按钮
        cancel() {
            this.open = false;
            this.reset();
        },
        // 表单重置
        reset() {
            this.dateRange = null;
            this.queryParams = {
                pageNum: 1,
                pageSize: 10,
                orderIndex: null,
                memberId: null,
                merchantId: null,
                merchantIndex: "",
                goodsName: "",
                categoryId: [],
                memberPhone: "",
                orderState: null,
                orderVerificationCode: "",
            };
            this.form ={}
        },
        // 搜索按钮操作
        handleQuery() {
            this.queryParams.pageNum = 1;
            this.getList();
        },
        // 重置按钮操作
        resetQuery() {
            this.reset();
            this.handleQuery();
        },
        // 多选框选中数据
        handleSelectionChange(selection) {
            this.ids = selection.map((item) => item.orderId);
            this.single = selection.length !== 1;
            this.multiple = !selection.length;
        },

        editRefund() {
            this.$message.warning("退款功能暂未开通");
        },
        async handleRefund() {
            await this.$refs.refundForm.validate();

            const { code } = await merchantRefund(this.refundParams);
            if (code === 200) {
                this.$modal.msgSuccess("操作成功");
            }
        },
        // 核销订单按钮
        toVerifyOrder(row) {
            this.form = JSON.parse(JSON.stringify(row));
            this.open = true;
            this.orderVerificationCodeIsInput = false;
            this.form.orderVerificationCode = "";
            getOrder(row.orderId).then((response) => {
                this.order = response.data;
                this.queryOrderAdress();
            });
        },
        // 获取订单状态
        getStatus() {
            let param = {
                codeValue: "订单状态",
            };
            listCode(param).then((res) => {
                this.statusOptions = res.rows;
            });
        },
        // 查询订单地址
        queryOrderAdress() {
            getAddress(this.order.orderId).then((res) => {
                this.memberOrderAddress = res.data;
            });
        },

        // 输入核销码进行核销
        verifyGroupOrder(orderVerificationCode) {
            this.form={}
            this.form.orderVerificationCode =orderVerificationCode;
            if (!orderVerificationCode) {
                return this.$modal.msgError("核销码不能为空!");
            }
            getOrderByVerificationCode(orderVerificationCode).then(
                (response) => {
                    if (response.code === 200 && response.data) {
                        this.order = response.data;
                        if (this.order.orderState !== '001') {
                            return this.$modal.msgError("只有待服务的订单才可进行核销操作！");
                        }
                        this.open = true;
                        this.orderVerificationCodeIsInput = true;
                        this.queryOrderAdress();
                        this.form.orderId = this.order.orderId;
                    } else {
                         return this.$modal.msgError("核销码所属订单信息不存在!");
                    }
                }
            ) .catch((err) => {
                this.$modal.msgError(err);
            });
        },
        substringName(name){
            console.log("+++++++++++++++++++++++++++++++")
            if(name == null){
                return ""
            }
            if(name.charCodeAt==1){
                return name
            }
            if(name.charCodeAt>1){
                return name.replace(name.substring(
                                                  1,
                                                  2
                                              ),
                                              "*"
                                          )
            }

        },
        timeStamp2String(datetime){

            var year = datetime.getFullYear();
            var month = datetime.getMonth() + 1 < 10 ? "0" + (datetime.getMonth() + 1) : datetime.getMonth() + 1;
            var date = datetime.getDate() < 10 ? "0" + datetime.getDate() : datetime.getDate();
            var hour = datetime.getHours()< 10 ? "0" + datetime.getHours() : datetime.getHours();
            var minute = datetime.getMinutes()< 10 ? "0" + datetime.getMinutes() : datetime.getMinutes();
            var second = datetime.getSeconds()< 10 ? "0" + datetime.getSeconds() : datetime.getSeconds();
            return year + "-" + month + "-" + date+" "+hour+":"+minute+":"+second;
        },

        // 审核退款
        doRefund(row) {
            // this.$message.error("退款功能暂未开通");
            // return;
            getRefundInfo({
                orderId: row.orderId,
            })
                .then((res) => {
                    if (res.code == 200) {
                        this.auditRefundForm = res.data;
                        this.auditRefundForm.totalAmount = row.totalAmount;
                        this.auditRefundForm.groupTimes = row.groupTimes;
                        this.auditRefundForm.groupRemainingTimes = row.groupRemainingTimes;
                        this.auditRefundForm.refundMoney = ((row.totalAmount / row.groupTimes) * row.groupRemainingTimes).toFixed(2);
                        this.maxGroupRefundMoney = this.auditRefundForm.refundMoney;
                        this.auditRefundOpen = true;
                        this.title = "退款审核";
                    } else {
                        this.$message.error("获取退款信息失败");
                    }
                })
                .catch((err) => {
                    console.log(err);
                    this.$message.error("获取退款信息失败");
                });
        },
        //控制只能输入数字
        clearNoNum(obj) {
            var t = obj.target.value.charAt(0);
            //先把非数字的都替换掉，除了数字和.
            obj.target.value = obj.target.value.replace(/[^\d.]/g, "");
            //第一位0开头，0后面为数字，则过滤掉0，取后面的数字
            obj.target.value = obj.target.value.replace(/^0+(\d)/, "$1");
            //必须保证第一个为数字而不是.
            obj.target.valuee = obj.target.value.replace(/^\./g, "");
            //保证只有出现一个.而没有多个.
            obj.target.value = obj.target.value.replace(/\.{2,}/g, ".");
            //保证.只出现一次，而不能出现两次以上
            obj.target.value = obj.target.value
                .replace(".", "$#$")
                .replace(/\./g, "")
                .replace("$#$", ".");
            obj.target.value = obj.target.value.replace(
                /^(\-)*(\d+)\.(\d\d).*$/,
                "$1$2.$3"
            ); //只能输入两个小数
            //如果第一位是负号，则允许添加   如果不允许添加负号 可以把这块注释掉
            // if (t == '-') {
            //   obj.target.value = '-' + obj.target.value;
            // }
        },
        /** 提交审核退款按钮 */
        submitAuditRefund() {
            if (
                this.auditRefundForm.refundResult == null ||
                this.auditRefundForm.refundResult == ""
            ) {
                return this.$message.error("审核结果描述必填");
            }
            if (this.auditRefundForm.refundMoney != null && this.auditRefundForm.refundMoney > this.maxGroupRefundMoney) {
                return this.$message.error("审核退款金额不可大于团购订单最大可退金额");
            }
            if (this.auditRefundForm.status == null || this.auditRefundForm.status == "") {
                return this.$message.error("审核结果必选");
            }
            doRefund(this.auditRefundForm)
                .then((res) => {
                    if (res.code == 200) {
                         // 关闭退款框
                        this.auditRefundOpen = false;
                        this.$message.success("审核完成");
                        // 刷新页面
                        location.reload();
                        this.getList();
                        this.auditRefundForm = {};
                        location.reload();
                    } else {
                        this.$message.error(res.msg);
                    }
                })
                .catch((err) => {
                    console.log(err);
                    // this.$message.error("操作失败")
                });
        },
        // 取消审核退款按钮
        cancelAuditRefund() {
            this.auditRefundOpen = false;
            this.resetAuditRefundForm();
        },
        // 审核退款表单重置
        resetAuditRefundForm() {
            this.auditRefundForm = {
                orderId: null,
                refundMoney: null,
                refundReason: null,
                refundResult: null,
                status: null,
            };
            this.resetForm("auditRefundForm");
        },
        checkCode({ preState, nowState }) {
            let result = nowState;
            switch (nowState) {
                case "000":
                    result = "提交订单";
                    break;
                case "001":
                    result = preState === "001" ? "已核销一次服务" : "支付成功";
                    break;
                case "002":
                    result = preState === "001" ? "开始服务" : "追加服务";
                    break;
                case "003":
                    result = "完成服务";
                    break;
                case "004":
                    result =
                        preState === "005" ? "顾客取消平台退款" : "确认完成";
                    break;
                case "005":
                    result = "顾客申请平台退款";
                    break;
                case "006":
                    result = preState === "005" ? "平台已退款" : "商家已退款";
                    break;
                case "007":
                    result = "平台拒绝退款";
                    break;
                case "099":
                    result = "未支付取消订单";
                    break;
            }
            return result;
        },
        toServerProject() {
            this.$router.push("/merchant/groupService");
        },
        queryAdress() {
            getAddress(this.order.orderId).then((res) => {
                this.member = res.data;
            });
        },
        getServicceUser() {
            if (!this.order.serverId) {
                return;
            }
            getUser(this.order.serverId).then((res) => {
                this.serverUser = res.data;
                this.serverUser.rate =
                    parseFloat(this.serverUser.rate || 0) + "%";
                let params = {
                    codeValue: "服务等级",
                };
                listCode(params).then((res) => {
                    for (let i in res.rows) {
                        if (
                            this.serverUser.serverLevel == res.rows[i].decodeId
                        ) {
                            this.serverUser.serverLevel =
                                res.rows[i].decodeValue;
                        }
                    }
                });
            });
        },
        seeOrderStatus() {
            listRecord(this.order).then((res) => {
                this.orderRecord = res.rows;
                this.recordOpen = true;
            });
        },
        /** 获取订单退款子状态和信息*/
        getRefStatus() {
            let param = {
                codeValue: "退款状态",
            };
            listCode(param).then((res) => {
                this.refStatusOptions = res.rows;
            });
        },
        getRefund() {
            listRefund({ ...this.order, createTime: null }).then((res) => {
                this.refund = res.rows[0];
                if (this.refund) {
                    this.refundOpen = true;
                }
            });
        },
        // 查询订单核销记录列表
        getOrderVerificationRecordList() {
            const orderVerificationRecord = {
                orderId: this.order.orderId,
            };
            listRecordVOByOrderId(orderVerificationRecord).then((res) => {
                this.orderVerificationRecordList = res.rows;
                this.orderVerificationRecordOpen = true;
            });
        },
        toImage () {
            html2canvas( this.$refs.reference, {
                width:380,
                height:596,
                backgroundColor: null,
                useCORS: true // 解决文件跨域问题
            }).then(canvas => {
                console.log(this.$refs.reference)
                const url = canvas.toDataURL('image/png') // 生成的图片
                if (window.navigator.msSaveOrOpenBlob) {
                        const bstr = atob(url.split(',')[1])
                        let n = bstr.length
                        const u8arr = new Uint8Array(n)
                        while (n--) {
                        u8arr[n] = bstr.charCodeAt(n)
                        }
                        const blob = new Blob([u8arr])
                        window.navigator.msSaveOrOpenBlob(blob, '门岗通行证' + '.' + 'png')
                    } else {
                        // 这里就按照chrome等新版浏览器来处理
                        const a = document.createElement('a')
                        a.href = url
                        a.setAttribute('download', '门岗通行证')
                        a.click()
                    }
            })   
        },
        // 调用门岗通行证获取或保存接口
        getOrSaveAccessPasscode(orderVerificationCode) {
            this.$refs.refDia.$refs.dialog.style.backgroundColor="rgb(0, 0, 0,0)"
            this.$refs.refDia.$refs.dialog.style.WebkitBoxShadow="0 0px 0px rgb(0 0 0 / 30%)"
            this.$refs.refDia.$refs.dialog.style.boxShadow="0px"
            let accessPasscodeParam = {
                orderId: this.order.orderId,
                orderIndex: this.order.orderIndex,
                merchantId: this.order.merchantId,
                orderVerificationCode: orderVerificationCode,
            };
            saveAccessPasscode(accessPasscodeParam)
                .then((res) => {
                    if (res.code == "200" && res.data) {
                        this.qrCodeOpen = true;
                        this.qrCodeUrl = res.data.qrCodeUrl;
                        this.qrCodeUrls.push(res.data.qrCodeUrl);
                    } else {
                        this.$modal.msgError(res.msg);
                    }
                })
                .catch((err) => {
                    console.log(err);
                });
        },
        // 根据订单ID和核销码查询门岗二维码信息
        getAccessPasscode(orderVerificationCode) {
            this.$refs.refDia.$refs.dialog.style.backgroundColor="rgb(0, 0, 0,0)"
            this.$refs.refDia.$refs.dialog.style.WebkitBoxShadow="0 0px 0px rgb(0 0 0 / 30%)"
            this.$refs.refDia.$refs.dialog.style.boxShadow="0px"
            let accessPasscodeQueryParam = {
                orderId: this.order.orderId,
                orderVerificationCode: orderVerificationCode,
            };
            getByOrderIdAndOrderVerificationCode(accessPasscodeQueryParam)
                .then((res) => {
                    if (res.code == "200" && res.data) {
                        this.qrCodeOpen = true;
                        this.qrCodeUrl = res.data.qrCodeUrl;
                        this.qrCodeUrls.push(res.data.qrCodeUrl);
                    } else {
                        this.$modal.msgError(res.msg);
                    }
                })
                .catch((err) => {
                    console.log(err);
                });
        },
        // 下载门岗通行证二维码图片
        handleDownQrCodeImg() {
            // 文件名
            let downloadName = '门岗二维码' + this.order.orderIndex + '.png';
            // base64
            let imgData = 'data:image/png;base64,' + this.qrCodeUrl;
            // 调用下载方法
            this.downloadFile(downloadName, imgData);
        },
        //下载
        downloadFile(fileName, content) {
            let aLink = document.createElement("a");
            let blob = this.base64ToBlob(content); //new Blob([content]);

            let evt = document.createEvent("HTMLEvents");
            evt.initEvent("click", true, true); //initEvent 不加后两个参数在FF下会报错  事件类型，是否冒泡，是否阻止浏览器的默认行为
            aLink.download = fileName;
            aLink.href = URL.createObjectURL(blob);

            // aLink.dispatchEvent(evt);
            //aLink.click()
            aLink.dispatchEvent(
                new MouseEvent("click", {
                    bubbles: true,
                    cancelable: true,
                    view: window,
                })
            ); //兼容火狐
        },
        //base64转blob
        base64ToBlob(code) {
            let parts = code.split(";base64,");
            let contentType = parts[0].split(":")[1];
            let raw = window.atob(parts[1]);
            let rawLength = raw.length;

            let uInt8Array = new Uint8Array(rawLength);

            for (let i = 0; i < rawLength; ++i) {
                uInt8Array[i] = raw.charCodeAt(i);
            }
            return new Blob([uInt8Array], { type: contentType });
        },
    },
};
</script>

<style scoped>
.el-card {
  margin-bottom: 20px;
  background-color: #f4f4f4;
  color:#737373;
  font-size:14px;

}

li {
  list-style-type: none;
}
ul {
  padding-inline-start: 0px;
}
.span-color{
    font-size:16px;
    font-weight: bold;
    color: #F59A23;
}
.span-color-size {
    font-size:16px;
    font-weight: bold;
    color: #f59a23;
    line-height: 14px;
}
.span-detailed-info{
    color:black;
}
.gatePass {
    margin-left: 300px;
}

.qrCodeDialog {
    display: flex;
    justify-content: center;
    align-items: center;
}
</style>
