<template>
    <app-layout>
        <view v-if="!search" class="tab-info">
            <view class='main-center tab'>
                <view @click="tabStatus(1)" :class="['tab-item','tab-left',`${status==1?'active': ''}`]">订单列表</view>
                <view @click="tabStatus(2)" :class="['tab-item','tab-right',`${status==2?'active': ''}`]">售后订单</view>
            </view>
        </view>
        <view v-if="search" class="search-item main-between cross-center">
            <view class="search-input">
                <image class="search-icon" src='/static/image/icon/icon-search.png'></image>
                <input :focus="!msg" @confirm='searchMethod' confirm-type='search' v-model='keyword' placeholder-style='color:#999999;font-size:13px;' @blur="getFocus=false" @focus="getFocus=true" placeholder='请输入订单号/商品名称/收货人姓名搜索'></input>
                <image v-if="getFocus && keyword.length > 0" @click="clearSearch" class="search-clear" src="../image/clear.png"></image>
            </view>
            <view @click="cancelSeacrch">取消</view>
        </view>
        <view v-if="!searchResult && search && list.length == 0" class="search-history">
            <view v-if="candidate.length != 0" class='main-between search-title'>
                <view>历史搜索</view>
                <view @click="clear">
                    <image class="delete-icon" src="/static/image/icon/delete.png"></image>
                </view>
            </view>
            <view class='flex-wrap candidate-list'>
                <view @click="keywordSearch(item)" class="keyword-item box-grow-0" v-for="item in candidate" :key="item">
                    <text class="t-omit">{{item}}</text>
                </view>
            </view>
        </view>
        <view v-if="!search" class="search-area main-between cross-center">
            <view class="search main-center" @click="toSearch">
                <image class="icon-search" src="/static/image/icon/icon-search.png"></image>
                <text>搜索</text>
            </view>
            <view class="choose" @click='toTime'>
                <text v-if="date_start == ''">汇总</text>
                <text v-else-if="date_start == today && date_end == today+' 23:59:59'">今日</text>
                <text v-else-if="date_start == yesterday && date_end == yesterday+' 23:59:59'">昨日</text>
                <text v-else-if="date_start == weekday && date_end == today+' 23:59:59'">7日</text>
                <text v-else>自定义</text>
                <image src='./../image/open.png'></image>
            </view>
        </view>
        <view v-if="!search && status==1" class="main-between navs-info">
            <view @click="tab(-1)" class="box-grow-1 main-center cross-center navs">
                <text :class="[`${_num==-1?'active':'nav-text'}`]">全部</text>
            </view>
            <view @click="tab(0)" class="box-grow-1 main-center cross-center navs">
                <text :class="[`${_num==0?'active':'nav-text'}`]">待付款</text>
            </view>
            <view @click="tab(1)" class="box-grow-1 main-center cross-center navs">
                <text :class="[`${_num==1?'active':'nav-text'}`]">待发货</text>
            </view>
            <view @click="show=!show" v-if="active" class="box-grow-1 main-center navs more-navs">
                <text :class="[`${_num==active.value?'active':'nav-text'}`]">{{active.name}}</text>
                <image src="./../image/more-active.png"></image>
            </view>
            <view @click="show=!show" v-if="!active" class="box-grow-1 main-center navs more-navs">
                <text class="nav-text">更多状态</text>
                <image src="./../image/more.png"></image>
            </view>
        </view>
        <view v-if="!search && status==2" class="main-between navs-info">
            <view @click="tab(-1)" class="box-grow-1 main-center cross-center navs">
                <text :class="[`${_num==-1?'active':'nav-text'}`]">全部</text>
            </view>
            <view @click="tab(0)" class="box-grow-1 main-center cross-center navs">
                <text :class="[`${_num==0?'active':'nav-text'}`]">待审核</text>
            </view>
            <view @click="tab(1)" class="box-grow-1 main-center cross-center navs">
                <text :class="[`${_num==1?'active':'nav-text'}`]">待买家处理</text>
            </view>
            <view @click="tab(2)" class="box-grow-1 main-center cross-center navs">
                <text :class="[`${_num==2?'active':'nav-text'}`]">待卖家处理</text>
            </view>
        </view>
        <view v-if="!search && show" class="more-menu">
            <view @click="chooseItem(item.value)" v-for="item in menu" :key="item.value">{{item.name}}</view>
        </view>
        <view v-if="!search" class="search-palce"></view>
        <!-- 订单信息 -->
        <view>
            <view class="order-item" v-for="item in list" :key="item.id">
                <view @click="toDetail(item.order_id,status)">
                    <view class="main-between order-info" v-if="status ==1">
                        <view style="width: 80%">
                            <view>订单号 {{item.order_no}}</view>
                            <view v-if="item.seller_remark && item.seller_remark != null" class="remark-info">商家备注 {{item.seller_remark}}</view>
                        </view>
                        <view v-if="item.is_sale == 1">已完成</view>
                        <view v-else-if="item.cancel_status == 2">待退款</view>
                        <view v-else-if="item.is_send == 0 && item.is_pay == 1 && item.detailExpress && item.detailExpress.length > 0">部分发货</view>
                        <view v-else-if="item.is_pay == 0">待付款</view>
                        <view v-else-if="item.is_send == 0">待发货</view>
                        <view v-else-if="item.is_confirm == 0">待收货</view>
                        <view v-else-if="item.is_confirm == 1">已收货</view>
                    </view>
                    <view class="main-between order-info" v-if="status ==2">
                        <view>订单号 {{item.order_no}}</view>
                        <view class="status-txt">{{item.refund_status_cn}}</view>
                    </view>
                    <view class="dir-left-nowrap cross-center order-user" v-if="status ==1">
                        <view>{{item.name ? item.name : item.nickname}}</view>
                        <view>{{item.mobile}}</view>
                        <view v-if="item.mobile" @click.stop='toCall(item.mobile)' class="to-tel dir-left-nowrap cross-center">
                            <image src='./../image/tel.png'></image>
                            <text>联系收货人</text>
                        </view>
                    </view>
                    <view class="dir-left-nowrap cross-center order-user" v-if="status ==2">
                        <view>{{item.order.name}}</view>
                        <view>{{item.order.mobile}}</view>
                        <view v-if="item.order.mobile" @click.stop='toCall(item.order.mobile)' class="to-tel dir-left-nowrap cross-center">
                            <image src='./../image/tel.png'></image>
                            <text>联系收货人</text>
                        </view>
                    </view>
                    <view v-for="goods in item.detail" class="goods" :key="goods.id">
                        <image class="goods-img" :src='goods.goods_info.goods_attr.pic_url ? goods.goods_info.goods_attr.pic_url : goods.goods_info.goods_attr.cover_pic'></image>
                        <view v-if="item.type == 1" class="goods-status">退货退款</view>
                        <view v-if="item.type == 2" class="goods-status">换货</view>
                        <view class='t-omit-two goods-name'>{{goods.goods_info.goods_attr.name}}</view>
                        <view class="goods-attr t-omit">
                            <text v-for="attr in goods.attr_list" :key="attr.attr_id">{{attr.attr_group_name}}:{{attr.attr_name}}</text>
                        </view>
                        <view class="goods-num">x{{goods.num}}</view>
                        <view class="goods-price">￥{{goods.total_price}}</view>
                    </view>
                    <view class="dir-right-nowrap">
                        <view class="price-info">
                            <text class="other">合计</text>
                            <text v-if="status == 1">￥{{item.total_pay_price}}</text>
                            <text v-if="status == 2">￥{{item.refund_price}}</text>
                            <text v-if="status == 1" class="other">(含运费￥{{item.express_price}})</text>
                        </view>
                    </view>
                </view>
                <view class="dir-right-nowrap menu-button">
                    <view @click.stop="toAgreeCancel(item)" v-if="item.cancel_status == 2" class="handle-btn other">同意</view>
                    <view @click.stop="beNotRefund(item)" v-if="item.cancel_status == 2" class="handle-btn">拒绝</view>
                    <view @click.stop="toChange(item)" v-if="item.cancel_status == 0 && item.is_pay == 0 && item.is_send == 0" class="handle-btn other">修改价格</view>
                    <view @click.stop="toConfirm(item)" v-if="item.cancel_status == 0 && item.is_confirm == 0 && item.is_send == 1 && item.is_confirm_show == 1" class="handle-btn other">确认收货</view>
                    <view @click.stop="toExpress(item,2)" v-if="item.cancel_status == 0 && item.is_send == 1 && item.is_confirm == 0 && item.express_no" class="handle-btn other">修改物流信息</view>
                    <view @click="toExpressInfo(item)" v-if="item.cancel_status == 0 && item.is_send == 1 && item.is_confirm == 0 && item.detailExpress.length > 0" class="handle-btn other">查看物流</view>
                    <view @click.stop="toSend(item)" v-if="item.address && item.cancel_status == 0 && item.is_send == 0 && item.is_pay == 1" class="handle-btn other">发货</view>
                    <view @click.stop="toSend(item)" v-else-if="item.is_send == 0 && item.is_pay == 1 && item.detailExpress && item.detailExpress.length > 0" class="handle-btn other">发货</view>
                    <view @click.stop="toSend(item)" v-else-if="item.address && item.cancel_status == 0 && item.is_send == 0 && item.pay_type == 2" class="handle-btn other">发货</view>
                    <view @click="toChangeAddress(item)" v-if="item.address && item.cancel_status == 0 && item.is_send == 0 && item.is_pay == 1" class="handle-btn">修改地址</view>
                    <view @click.stop="toRefundOrder(item.order_no)" v-if="item.have_refund == 1 && status == 1 && item.is_sale == 0" class="handle-btn">售后中</view>
                    <view @click.stop="toCancelorder(item)" v-if="item.sign != 'gift' && item.is_send == 0 && item.cancel_status == 0" class="handle-btn">取消订单</view>
                    <view @click.stop="toConfirm(item)" v-if="item.status == 2 && item.is_send == 1 && item.is_confirm == 0 && status == 2 && item.type == 1" class="handle-btn other">确认收货</view>
                    <view @click.stop="toRefund(item)" v-if="item.status == 2 && item.is_send == 1 && item.is_confirm == 1 && item.is_refund == 0 && status == 2 && item.type == 1" class="handle-btn other">退款</view>
                    <view @click.stop="toSend(item)" data-send="1" v-if="item.is_confirm == 0 && status == 2 && item.is_send == 1 && item.type == 2" class="handle-btn other">发货</view>
                    <view @click.stop="refundHandle(2,item,1)" v-if="item.status == 2 && status == 2 && item.status_cn != '换货 卖家已发货' && item.status_cn != '退货退款 卖家已退款'" :class="['handle-btn', `${_num == 1 || _num == -1?'other':''}`]">取消售后</view>
                    <view @click="toExpressInfo(item)" v-if="status == 2 && item.detailExpress.length > 0 && item.status == 2" class="handle-btn">物流详情</view>
                    <view @click.stop="refundHandle(1,item)" v-if="item.status == 1 && status == 2" class="handle-btn other">同意</view>
                    <view @click.stop="refundHandle(2,item)" v-if="item.status == 1 && status == 2" class="handle-btn">拒绝</view>
                    <view @click.stop="lookAbout(item)" v-if=" status == 2" class="handle-btn">售后理由</view>
                    <view @click.stop="makeRemark(item)" class="handle-btn">备注</view>
                </view>
            </view>
        </view>
        <view class='no-tip' v-if="list.length == 0">
            <image :src='adminImg.no_order'></image>
            <view>没有任何订单哦~</view>
        </view>
        <view :class="['bottom-place', `${iphone_x? 'iphone_x':''}`]"></view>
        <view :class="['main-between bottom-tab', `${iphone_x? 'iphone_x':''}`]">
            <view class="box-grow-1 tab-nav-item" @click="toRedirect('/pages/app_admin/index/index')">
                <image class="tab-icon" src="./../image/index.png"></image>
                <view>首页</view>
            </view>
            <view class="box-grow-1 tab-nav-item active" @click="reload">
                <image class="tab-icon" src="./../image/order-active.png"></image>
                <view>订单</view>
            </view>
            <view class="box-grow-1 tab-nav-item" @click="toRedirect('/pages/app_admin/goods/goods')">
                <image class="tab-icon" src="./../image/goods.png"></image>
                <view>商品</view>
            </view>
            <view class="box-grow-1 tab-nav-item" @click="toRedirect('/pages/app_admin/setting/setting')">
                <image class="tab-icon" src="./../image/setting.png"></image>
                <view>设置</view>
            </view>
        </view>
        <view @touchmove.stop.prevent="" class="bg cross-center" v-if="chooseTime || isRefund || noRefund || changePrice || cancelOrder || callPhone || isSend || notRefund || isReason || openAddress || noAddress || beRemark || confirmOrder">
            <!-- 选时间 -->
            <view class="dialog" v-if="chooseTime">
                <view class="dialog-title">筛选时间</view>
                <view class="flex-wrap main-between time-area">
                    <view @click="change(0)" data-time='0' :class="[`${time == 0 ? 'active':'' }`, 'dialog-choose-item']">汇总</view>
                    <view @click="change(1)" data-time='1' :class="[`${time == 1 ? 'active':'' }`, 'dialog-choose-item']">今日</view>
                    <view @click="change(2)" data-time='2' :class="[`${time == 2 ? 'active':'' }`, 'dialog-choose-item']">昨日</view>
                    <view @click="change(3)" data-time='3' :class="[`${time == 3 ? 'active':'' }`, 'dialog-choose-item']">7日</view>
                    <view @click="change(4)" data-time='4' :class="[`${time == 4 ? 'active':'' }`, 'dialog-choose-item']">自定义</view>
                    <view class="dialog-choose-item" style='border: 0'></view>
                </view>
                <view class="choose-time" v-if="custom">
                    <view class="time-title">起始时间</view>
                    <view class="year-1">年</view>
                    <view class="month-1">月</view>
                    <view class="day-1">日</view>
                    <view class="year-2">年</view>
                    <view class="month-2">月</view>
                    <view class="day-2">日</view>
                    <picker-view :value="start" class="picker-view" @change="startChange">
                        <picker-view-column>
                            <view v-for="(item,idx) in years" :key="item"
                                  :class="[{
                                  'sure-color': startVal[0] === idx,
                                  'cardinal-color': startVal[0] === idx + 1 || startVal[0] === idx - 1,
                                  'even-color': startVal[0] === idx + 2 || startVal[0] === idx - 2,
                                  }]">{{item}}</view>
                        </picker-view-column>
                        <picker-view-column>
                            <view v-for="(item,idx) in months" :key="item"
                                  :class="[{
                                  'sure-color': startVal[1] === idx,
                                  'cardinal-color': startVal[1] === idx + 1 || startVal[1] === idx - 1,
                                  'even-color': startVal[1] === idx + 2 || startVal[1] === idx - 2,
                                  }]">{{item}}</view>
                        </picker-view-column>
                        <picker-view-column>
                            <view v-for="(item,idx) in days" :key="item"
                                  :class="[{
                                  'sure-color': startVal[2] === idx,
                                  'cardinal-color': startVal[2] === idx + 1 || startVal[2] === idx - 1,
                                  'even-color': startVal[2] === idx + 2 || startVal[2] === idx - 2,
                                  }]">{{item}}</view>
                        </picker-view-column>
                    </picker-view>
                    <view class="time-title">结束时间时间</view>
                    <picker-view  :value="end" indicator-style="height: 36px;color: #446dfd;font-size:14px;"class="picker-view" @change="endChange">
                        <picker-view-column>
                            <view v-for="(item,idx) in years" :key="item"
                                  :class="[{
                                  'sure-color': endVal[0] === idx,
                                  'cardinal-color': endVal[0] === idx + 1 || endVal[0] === idx - 1,
                                  'even-color': endVal[0] === idx + 2 || endVal[0] === idx - 2,
                                  }]">{{item}}</view>
                        </picker-view-column>
                        <picker-view-column>
                            <view v-for="(item,idx) in months" :key="item"
                                  :class="[{
                                  'sure-color': endVal[1] === idx,
                                  'cardinal-color': endVal[1] === idx + 1 || endVal[1] === idx - 1,
                                  'even-color': endVal[1] === idx + 2 || endVal[1] === idx - 2,
                                  }]">{{item}}</view>
                        </picker-view-column>
                        <picker-view-column>
                            <view v-for="(item,idx) in days" :key="item"
                                  :class="[{
                                  'sure-color': endVal[2] === idx,
                                  'cardinal-color': endVal[2] === idx + 1 || endVal[2] === idx - 1,
                                  'even-color': endVal[2] === idx + 2 || endVal[2] === idx - 2,
                                  }]">{{item}}</view>
                        </picker-view-column>
                    </picker-view>
                </view>
                <view class="main-center btn-area">
                    <view class="submit-btn" @click='cancel'>取消</view>
                    <view class="line"></view>
                    <view class="submit-btn be-submit" @click='toChoose'>确认</view>
                </view>
            </view>
            <!-- 退款 -->
            <view class="dialog" v-if="isRefund">
                <view class="dialog-title">退款</view>
                <view class="main-center refund-pay" v-if="status == 1">￥{{detail.total_pay_price}}</view>
                <view class="main-center cross-center refund-pay" v-if="status == 2">￥
                    <input class="refund-price" type='digit' v-model="refund_price"></input>
                </view>
                <view class="main-center refund-tip">是否确认退款给买家</view>
                <view class="main-center btn-area">
                    <view class="submit-btn" @click='cancel'>取消</view>
                    <view class="line"></view>
                    <view class="submit-btn be-submit" v-if="status == 1" @click='cancelSubmit'>确认</view>
                    <view class="submit-btn be-submit" v-if="status == 2" @click='agree'>确认</view>
                </view>
            </view>
            <view class="dialog-bg" :style="{'display': `${noRefund || notRefund ? 'block' : 'none'}`}"></view>
            <!-- 拒绝退款 -->
            <view class="dialog" v-if="noRefund || notRefund">
                <view v-if="noRefund" class="dialog-title">拒绝取消</view>
                <view v-if="notRefund" class="dialog-title">拒绝售后</view>
                <textarea fixed class="textarea" v-model="about" placeholder="请输入拒绝理由" placeholder-style="color:#999999;font-size:14px" auto-focus />
                <view class="main-center btn-area">
                    <view class="submit-btn" @click='cancel'>取消</view>
                    <view class="line"></view>
                    <view v-if="noRefund" class="submit-btn be-submit" @click='noCancel'>确认</view>
                    <view v-if="notRefund" class="submit-btn be-submit" @click='decline(0)'>确认</view>
                </view>
            </view>
            <!-- 备注 -->
            <view class="dialog" v-if="beRemark">
                <view class="dialog-title">备注</view>
                <view class="remark-input">
                    <input maxlength="15" v-model="remark" placeholder="请输入备注内容(限15个字符)">
                </view>
                <view class="main-center btn-area">
                    <view class="submit-btn" @click='cancel'>取消</view>
                    <view class="line"></view>
                    <view class="submit-btn be-submit" @click='toRemark'>确认</view>
                </view>
            </view>
            <!-- 改价 -->
            <view class="dialog" v-if="changePrice">
                <view v-if="changePrice" class="dialog-title">修改价格</view>
                <view v-if="changePrice" class="dir-left-nowrap change-price-item">
                    <view class="label">商品总价</view>
                    <view class="money">￥</view>
                    <input fixed type="digit" class="price-input" @input="priceInput" :focus="changePrice?true:false" v-model='price'></input>
                </view>
                <view v-if="changePrice" class="dir-left-nowrap change-price-item">
                    <view class="label">运费</view>
                    <view class="money">￥</view>
                    <input fixed type="digit" class="price-input" @input="expressInput" focus v-model='express'></input>
                </view>
                <view v-if="changePrice" class="dir-left-nowrap change-price-item">
                    <view class="label">合计</view>
                    <view class="total-money">{{total}}</view>
                </view>
                <view v-if="changePrice" class="main-center btn-area">
                    <view class="submit-btn" @click='cancel'>取消</view>
                    <view class="line"></view>
                    <view class="submit-btn be-submit" @click='submitChange'>确认</view>
                </view>
            </view>
            <!-- 取消订单 -->
            <view class="dialog" v-if="cancelOrder">
                <view class="main-center cancel-tip">确定取消该订单?</view>
                <view class="main-center btn-area">
                    <view class="submit-btn" @click='cancel'>取消</view>
                    <view class="line"></view>
                    <view class="submit-btn be-submit" @click='cancelSubmit'>确认</view>
                </view>
            </view>
            <!-- 售后确认收货 -->
            <view class="dialog" v-if="confirmOrder">
                <view class="main-center cancel-tip">是否确认收货?</view>
                <view class="main-center btn-area">
                    <view class="submit-btn" @click='cancel'>取消</view>
                    <view class="line"></view>
                    <view class="submit-btn be-submit" v-if="status == 1" @click='beOrderConfirm'>确认</view>
                    <view class="submit-btn be-submit" v-else @click='beConfirm'>确认</view>
                </view>
            </view>
            <!-- 打电话  -->
            <view class="dialog" v-if="callPhone">
                <view class="main-center cancel-tip">{{mobile}}</view>
                <view class="main-center btn-area">
                    <view class="submit-btn" @click='cancel'>取消</view>
                    <view class="line"></view>
                    <view class="submit-btn be-submit" @click='call'>确认</view>
                </view>
            </view>
            <!-- 提示 -->
            <view class="dialog" v-if="noAddress">
                <view class="main-center dir-top-nowrap cancel-tip" style="text-align: center">
                    <view>您还没有退货地址</view>
                    <view>请先设置</view>
                </view>
                <view class="main-center btn-area">
                    <view class="submit-btn" @click='noAddress=false'>取消</view>
                    <view class="line"></view>
                    <view class="submit-btn be-submit" @click='toRefundAdd'>去设置</view>
                </view>
            </view>
            <!-- 理由 -->
            <view class="dialog" v-if="isReason">
                <view class="dialog-title">售后理由</view>
                <view class="reason">
                    <view class="reason-title">申请原因</view>
                    <view class="reason-content">{{detail.remark}}</view>
                    <view v-if="detail.pic_list.length > 0" class="reason-title">图片</view>
                    <view class="dir-left-wrap reason-img" v-if="detail.pic_list.length > 0">
                        <image @click='look(item)' v-for="item in detail.pic_list" :key="item" :src="item"></image>
                    </view>
                </view>
                <view class="main-center btn-area other-btn-area">
                    <view class="submit-btn be-submit" @click='cancel'>确认</view>
                </view>
            </view>
            <!-- 选地址 -->
            <view class="dialog" v-if="openAddress">
                <view class="dialog-title">选择退货地址</view>
                <view class="add-list">
                    <view class="add-item" v-for="item in address" :key="item.id">
                        <image v-if="item.id == addressId" @click='chooseAddress(item.id)' src="./../image/active.png"></image>
                        <image v-else @click='chooseAddress(item.id)' src="/static/image/icon/form-er.png"></image>
                        <view @click='chooseAddress(item.id)' class="add-info">
                            <view class="main-between">
                                <view class="add-name">{{item.name}}</view>
                                <view>{{item.mobile}}</view>
                            </view>
                            <view>{{item.address}}{{item.address_detail}}</view>
                        </view>
                    </view>
                </view>
                <view class="main-center btn-area other-btn-area">
                    <view class="submit-btn" @click='cancel'>取消</view>
                    <view class="line"></view>
                    <view class="submit-btn be-submit" @click='decline(1)'>确认</view>
                </view>
            </view>
            <!-- 选择配送员 -->
            <view class="dialog" v-if="isSend && detail.send_type == 2">
                <view class="dialog-title">选择配送员</view>
                <view class="add-list">
                    <view class="add-item delivery-item" v-for="item in cityList" :key="item.id">
                        <view @click='chooseDelivery(item)' class="add-info">
                            <view class="main-between">
                                <view class="add-name">{{item.name}}</view>
                                <image style="left: 0" v-if="item.id == deliveryId" @click='chooseDelivery(item)' src="./../image/active.png"></image>
                                <image style="left: 0" v-else @click='chooseDelivery(item)' src="/static/image/icon/form-er.png"></image>
                            </view>
                        </view>
                    </view>
                </view>
                <view class="main-center btn-area other-btn-area">
                    <view class="submit-btn" @click='cancel'>取消</view>
                    <view class="line"></view>
                    <view class="submit-btn be-submit" @click='toSendType'>确认</view>
                </view>
            </view>
        </view>
    </app-layout>
</template>

<script>
    import { mapState } from "vuex";
    const date = new Date()
    const years = []
    const months = []
    const days = []

    for (let i = 2015; i <= date.getFullYear(); i++) {
        years.push(i)
    }

    for (let i = 1; i <= 12; i++) {
        months.push(i)
    }

    for (let i = 1; i <= 31; i++) {
        days.push(i)
    }
    export default {
        data() {
            return {
                cancelRefund: false,
                time_start: [],
                noAddress: false,
                years: years,
                months: months,
                days: days,
                status: '1',
                _num: '-1',
                getFocus: false,
                more_list: false,
                cityList: [],
                deliveryId: '0',
                delivery: '',
                addressId: '0',
                refund_price: 0,
                page: 1,
                notRefund: false,
                openAddress: false,
                isReason: false,
                menu: [
                    {
                        name: '待收货',
                        value: '2'
                    },
                    {
                        name: '待退款',
                        value: '4'
                    },
                    {
                        name: '已收货',
                        value: '9'
                    },
                    {
                        name: '已完成',
                        value: '3'
                    }
                ],
                active: null,
                show: false,
                start: [],
                end: [],
                startVal: [],
                endVal: [],
                search: false,
                keyword: '',
                list: [],
                candidate: [],
                date_start: '',
                date_end: '',
                time: 0,
                inSearch: false,
                address: [],
                today: '',
                yesterday: '',
                weekday: '',
                chooseTime: false,
                isRefund: false,
                noRefund: false,
                confirmOrder: false,
                beRemark: false,
                remark: null,
                cancelOrder: false,
                detail: {},
                changePrice: false,
                callPhone: false,
                custom: false,
                mobile: '',
                isSend: false,
                sendType: 0,
                price: 0,
                express: 0,
                msg: false,
                searchResult: false,
                total: 0,
                about: '',
                iphone_x: false,
                loading: false
            }
        },
        computed: {
            ...mapState({
                theme: state => state.mallConfig.theme,
                userInfo: state => state.user.info,
                adminImg: state => state.mallConfig.__wxapp_img.app_admin,
            })
        },
        methods: {
            clearSearch() {
                this.keyword = '';
            },
            reload() {
                uni.showLoading({
                    title: '加载中...'
                });
                this.page = 1;
                this.list = [];
                this.getList();
            },

            makeRemark(data) {
                this.beRemark = true;
                this.detail = data;
                if(data.seller_remark) {
                    this.remark = data.seller_remark
                }
            },

            toRemark() {
                let that = this;
                that.$request({
                    url: that.$api.app_admin.sellerRemark,
                    method: 'post',
                    data: {
                        order_id: that.detail.id,
                        seller_remark: that.remark
                    }
                }).then(response=>{
                    if(response.code == 0) {
                        that.detail.seller_remark =  that.remark;
                        that.cancel();
                    }else {
                        uni.showToast({
                            title: response.msg,
                            icon: 'none',
                            duration: 1000
                        });
                    }
                }).catch(response => {
                });
            },

            toDetail(order_id,status) {
                uni.navigateTo({
                    url: '/pages/app_admin/order-detail/order-detail?id='+order_id+'&status='+status
                })
            },
            toRefundAdd() {
                this.noAddress = false;
                uni.navigateTo({
                    url: `/pages/address/address?manual_btn_bg=#446dfd&is_hide_default_btn=1&is_refund_address=1`,
                })
            },
            toRedirect(url) {
                uni.redirectTo({
                    url: url
                })
            },
            toChangeAddress(item) {
                uni.navigateTo({
                    url: '/pages/app_admin/change-add/change-add?order_no='+item.order_no
                })
            },
            toExpressInfo(item) {
                if(item.detail.length == 1 && item.detailExpress[0].express_no) {
                    uni.navigateTo({
                        url: '/pages/app_admin/express/express?id='+item.id+'&express='+item.detailExpress[0].express+'&express_no='+item.detailExpress[0].express_no+'&customer_name='+item.detailExpress[0].customer_name
                    })                    
                }else {
                    uni.navigateTo({
                        url: '/pages/order/express-list/express-list?order_id='+item.id
                    })
                }
            },
            // 取消
            cancel() {
                this.about = '';
                this.date_start = '';
                this.time = 0;
                this.date_end = '';
                this.isRefund = false;
                this.chooseTime = false;
                this.noRefund = false;
                this.changePrice = false;
                this.cancelOrder = false;
                this.custom = false;
                this.callPhone = false;
                this.isSend = false;
                this.notRefund = false;
                this.openAddress = false;
                this.isReason = false;
                this.confirmOrder = false;
                this.addressId = 0;
                this.beRemark = false;
                this.confirmOrder = false;
                this.remark = null;
            },
            // 切换类别
            tabStatus(e) {
                let that = this;
                that.status = e;
                that.active = null;
                that.list = [];
                that.date_start = '';
                that.date_end = '';
                that.keyword = '';
                that.show = false;
                that.time = 0;
                that._num = '-1';
                that.page = 1;
                uni.showLoading({
                    title: '加载中...'
                });
                that.getList();
            },
            toCall(e) {
                this.mobile = e;
                this.callPhone = !this.callPhone;
            },
            call() {
                uni.makePhoneCall({
                    phoneNumber: this.mobile
                })
                this.callPhone = !this.callPhone;
            },
            toSearch() {
                this.search = true;
                this.list = [];
                this.searchResult = false;
                this.candidate = uni.getStorageSync('keyword');
                this.inSearch = false;
            },
            keywordSearch(e) {
                this.keyword = e;
                this.searchResult = true;
                uni.showLoading({
                    title: '加载中...'
                });
                this.page = 1;
                this.getList();
            },
            beOrderConfirm() {
                let that = this;
                that.$request({
                    url: that.$api.app_admin.confirm,
                    data: {
                        order_id: that.detail.id
                    },
                    method: 'post'
                }).then(response=>{
                    that.$hideLoading();
                    if(response.code == 0) {
                        uni.showToast({
                            title: response.msg,
                            duration: 1000,
                            type: 'success',
                            mask: false
                        });
                        that.cancel();
                        setTimeout(v=>{
                            that.page = 1;
                            uni.showLoading({
                                title: '加载中...'
                            });
                            that.getList();
                        },1000)
                    }else {
                        uni.showToast({
                            title: response.msg,
                            icon: 'none',
                            duration: 1000
                        });
                    }
                }).catch(response => {
                    that.$hideLoading();
                });
            },
            beConfirm(item) {
                let that = this;
                that.$request({
                    url: that.$api.app_admin.shou_huo,
                    data: {
                        refund_order_id: that.detail.id
                    },
                    method: 'post'
                }).then(response=>{
                    that.$hideLoading();
                    if(response.code == 0) {
                        that.cancel();
                        that.page = 1;
                        uni.showLoading({
                            title: '加载中...'
                        });
                        that.getList();
                    }else {
                        uni.showToast({
                            title: response.msg,
                            icon: 'none',
                            duration: 1000
                        });
                    }
                }).catch(response => {
                    that.$hideLoading();
                });
            },
            // 清除搜索记录
            clear() {
                let that = this;
                uni.removeStorage({
                    key: 'keyword',
                    success(res) {
                        that.candidate = [];
                        uni.showToast({
                            title: '清理成功',
                            duration: 1000,
                            type: 'success',
                            mask: false
                        });
                    }
                });
            },
            // 搜索
            searchMethod() {
                var value = uni.getStorageSync('keyword');
                if (this.keyword.length == 0) {
                    return
                } else if (value.length > 0) {
                    value.unshift(this.keyword)
                } else {
                    value = [this.keyword]
                }
                uni.showLoading({
                    title: '加载中...'
                });
                this.page = 1;
                this.getList();
                value.forEach(function(row, index) {
                    if (value[0] == value[index] && index > 0) {
                        value.splice(index, 1)
                    }
                })
                uni.setStorage({
                    key: "keyword",
                    data: value
                })
                this.inSearch = true;
                this.searchResult = true;
            },
            // 取消搜索
            cancelSeacrch() {
                uni.showLoading({
                    title: '加载中...'
                });
                this.search = false;
                this.keyword = '';
                // this.list = [];
                this.page = 1;
                this.getList();
            },
            change(e) {
                let that = this;
                that.time = e;
                that.custom = false;
                if (that.time == 4) {
                    that.custom = true;
                    that.date_end = that.today;
                    that.date_start = that.today + ' 00:00:00';
                }
            },
            // 确认选择时间
            toChoose() {
                let that = this;
                uni.showLoading({
                    title: '加载中...'
                });
                if (that.time != 4) {
                    that.date_start = '';
                    that.date_end = that.today + ' 23:59:59';
                    switch (that.time.toString()) {
                        case '0':
                            that.date_start = '';
                            that.date_end = '';
                            break;
                        case '1':
                            that.date_start = that.today;
                            break;
                        case '2':
                            that.date_start = that.yesterday;
                            that.date_end = that.yesterday + ' 23:59:59';
                            break;
                        case '3':
                            that.date_start = that.weekday;
                            break;
                    }
                    setTimeout(function() {
                        that.page = 1;
                        that.getList();
                        that.chooseTime = false;
                    }, 300)
                } else {
                    let endTime = that.date_end.substring(0, 10)
                    let startTime = that.date_start.substring(0, 10)
                    let end = endTime.split("-");
                    let start = startTime.split("-");
                    if (+end[0] < +start[0]) {
                        uni.showToast({
                            title: '结束时间不应早于开始时间',
                            type: 'none',
                            duration: 1000
                        })
                    } else if (+end[0] == +start[0]) {
                        if (+end[1] < +start[1]) {
                            uni.showToast({
                                title: '结束时间不应早于开始时间',
                                type: 'none',
                                duration: 1000
                            })
                        } else if (+end[1] == +start[1]) {
                            if (+end[2] < +start[2]) {
                                uni.showToast({
                                    title: '结束时间不应早于开始时间',
                                    type: 'none',
                                    duration: 1000
                                })
                            } else {
                                that.page = 1;
                                that.getList();
                                that.chooseTime = false;
                            }
                        } else {
                            that.page = 1;
                            that.getList();
                            that.chooseTime = false;
                        }
                    } else {
                        that.page = 1;
                        that.getList();
                        that.chooseTime = false;
                    }
                }
            },
            startChange: function(e) {
                const val = e.detail.value;
                this.startVal = e.detail.value;
                let years = this.years;
                let year = this.years[val[0]];
                let month = this.months[val[1]];
                let day = this.days[val[2]];
                if (month >= 1 && month <= 9) {
                    month = "0" + month;
                }
                if (day >= 1 && day <= 9) {
                    day = "0" + day;
                }
                this.date_start = year + '-' + month + '-' + day;
            },
            endChange: function(e) {
                const val = e.detail.value;
                this.endVal = e.detail.value;
                let year = this.years[val[0]];
                let month = this.months[val[1]];
                let day = this.days[val[2]];
                if (month >= 1 && month <= 9) {
                    month = "0" + month;
                }
                if (day >= 1 && day <= 9) {
                    day = "0" + day;
                }
                this.date_end = year + '-' + month + '-' + day + " 23:59:59";
            },
            // 打开时间筛选
            toTime() {
                let that = this;
                that.start = [];
                that.end = [];
                let startDay;
                let endDay;
                if (that.date_start) {
                    startDay = that.date_start;
                } else {
                    startDay = that.today;
                }
                if (that.date_end) {
                    endDay = that.date_end;
                } else {
                    endDay = that.today;
                }
                that.years.forEach(function(row, index) {
                    if (startDay.substring(0, 4) == that.years[index]) {
                        that.start[0] = +index
                    }
                })
                that.months.forEach(function(row, index) {
                    if (startDay.substring(5, 7) == that.months[index]) {
                        that.start[1] = +index
                    }
                })
                that.days.forEach(function(row, index) {
                    if (startDay.substring(8, 10) == that.days[index]) {
                        that.start[2] = +index
                    }
                })
                that.startVal = that.start;
                if (that.date_end) {
                    endDay = that.date_end
                }
                that.years.forEach(function(row, index) {
                    if (endDay.substring(0, 4) == that.years[index]) {
                        that.end[0] = +index
                    }
                })
                that.months.forEach(function(row, index) {
                    if (endDay.substring(5, 7) == that.months[index]) {
                        that.end[1] = +index
                    }
                })
                that.days.forEach(function(row, index) {
                    if (endDay.substring(8, 10) == that.days[index]) {
                        that.end[2] = +index
                    }
                })
                that.endVal = that.end;
                that.chooseTime = !that.chooseTime;
                that.show = false;
            },
            // 选择更多状态
            chooseItem(e) {
                let that = this;
                uni.showLoading({
                    title: '加载中...'
                });
                that._num = e;
                that.menu.forEach(function(row, index) {
                    if (row.value == that._num) {
                        that.active = row;
                    }
                })
                that.show = !that.show;
                that.page = 1;
                that.list = [];
                that.getList();
            },
            // 切换状态
            tab(e) {
                this._num = e;
                this.show = false;
                this.active = null;
                this.list = [];
                this.date_start = '';
                this.date_end = '';
                this.keyword = '';
                this.page = 1;
                uni.showLoading({
                    title: '加载中...'
                });
                this.getList();
            },
            getList() {
                let that = this;
                if(that.loading) {
                    return false
                }
                that.loading = true;
                that.about = '';
                let url;
                if (this.status == 1) {
                    url = that.$api.app_admin.order
                } else if (this.status == 2) {
                    url = that.$api.app_admin.refund
                }
                that.$request({
                    url: url,
                    data: {
                        status: that._num,
                        date_end: that.date_end,
                        date_start: that.date_start,
                        page: that.page,
                        keyword: that.keyword
                    }
                }).then(response=>{
                    that.$hideLoading();
                    uni.hideLoading();
                    that.loading = false;
                    if(response.code == 0) {
                        let list = response.data.list;
                        if (that.status == 2) {
                            let status = [];
                            list.forEach(function(row) {
                                row.detail = [row.detail];
                                status = row.status_cn.split(' ');
                                row.refund_status_cn = status[status.length - 1];
                            })
                            let address = response.data.address;
                            address.forEach(function(row, index) {
                                row.address = row.address.replace(/"/g, '')
                                row.address = row.address.replace(/,/g, '')
                                row.address = row.address.replace('[', '')
                                row.address = row.address.replace(']', '')
                            })
                            that.address = address;
                        } else {
                            list.forEach(function(row) {
                                row.order_id = row.id;
                                row.detail.forEach(function(res) {
                                    if (res.refund_status == 1 || res.refund_status == 2) {
                                        row.have_refund = 1;
                                    }
                                })
                            })
                        }
                        that.more_list = false;
                        if (list.length == response.data.pagination.pageSize) {
                            that.more_list = true;
                        }
                        if(that.page == 1) {
                            that.list = list;
                        }else {
                            that.list = that.list.concat(list);
                        }
                        that.page++;
                        that.$forceUpdate();
                    }else {
                        uni.showToast({
                            title: response.msg,
                            icon: 'none',
                            duration: 1000
                        });
                    }
                }).catch(response => {
                    that.loading = false;
                    that.$hideLoading();
                    uni.hideLoading();
                });
            },
            toCancelorder(e) {
                this.detail = e;
                this.cancelOrder = !this.cancelOrder;
            },
            cancelSubmit() {
                let that = this;
                uni.showLoading({
                    title: '加载中...'
                });
                that.$request({
                    url: that.$api.app_admin.cancel,
                    data: {
                        status: 1,
                        remark: '',
                        order_id: that.detail.id
                    },
                    method: 'post'
                }).then(response => {
                    uni.hideLoading();
                    if (response.code == 0) {
                        uni.showToast({
                            title: '取消成功',
                            duration: 2000,
                            type: 'success',
                            mask: false
                        });
                        // that.list = [];
                        that.isRefund = false;
                        that.cancelOrder = false;
                        that.page = 1;
                        uni.showLoading({
                            title: '加载中...'
                        });
                        that.getList();
                    } else {
                        uni.showToast({
                            title: response.msg,
                            icon: 'none',
                            duration: 1000
                        });
                    }
                }).catch(response => {
                    uni.hideLoading();
                    uni.showToast({
                        title: response,
                        icon: 'none',
                        duration: 1000
                    });
                });
            },
            toChange(e) {
                this.detail = e;
                this.changePrice = !this.changePrice;
                this.price = e.total_goods_price;
                this.express = e.express_price;
                this.total = '￥' + e.total_pay_price;
            },
            priceInput: function(e) {
                if (e.detail.value > -0.01) {
                    this.total = '￥' + (+e.detail.value + +this.express).toFixed(2)
                } else {
                    this.total = '数据有误'
                }
            },
            expressInput: function(e) {
                if (e.detail.value > -0.01) {
                    this.total = '￥' + (+e.detail.value + +this.price).toFixed(2)
                } else {
                    this.total = '数据有误'
                }
            },
            // 确认修改价格
            submitChange() {
                let that = this;
                uni.showLoading({
                    title: '加载中...'
                });
                if (that.price > -0.01 && that.express > -0.01) {
                    that.$request({
                        url: that.$api.app_admin.update_price,
                        data: {
                            order_id: that.detail.id,
                            total_price: that.price,
                            express_price: that.express
                        },
                        method: 'post'
                    }).then(response => {
                        uni.hideLoading();
                        if (response.code == 0) {
                            uni.showToast({
                                title: response.msg,
                                duration: 2000,
                                type: 'success',
                                mask: false
                            });
                            that.page = 1;
                            // that.list = [];
                            that.changePrice = false;
                            that.getList();
                        } else {
                            uni.showToast({
                                title: response.msg,
                                icon: 'none',
                                duration: 1000
                            });
                        }
                    }).catch(response => {
                        uni.hideLoading();
                        uni.showToast({
                            title: response,
                            icon: 'none',
                            duration: 1000
                        });
                    });
                } else {
                    if (!that.price || typeof(that.price) != 'number') {
                        uni.showToast({
                            title: '商品总价必须大于等于0',
                            icon: 'none',
                            duration: 1000
                        });
                    } else if (!that.express || typeof(that.express) != 'number') {
                        uni.showToast({
                            title: '运费必须大于等于0',
                            icon: 'none',
                            duration: 1000
                        });
                    }
                }
            },
            toRefundOrder(e) {
                let that = this;
                that.list = [];
                that.more_list = false;
                that.keyword = e;
                that.status = 2;
                that.search = true;
                that.searchMethod();
            },
            toSend(e) {
                let that = this;
                that.detail = e;
                if(that.detail.send_type != 2) {
                    if (that.detail.status_cn) {
                        uni.navigateTo({
                            url: '/pages/app_admin/send/send?order_refund_id=' + that.detail.id + '&id=' + that.detail.order_id
                        })
                    } else {
                        uni.navigateTo({
                            url: '/pages/app_admin/send/send?id=' + that.detail.id
                        })
                    }
                }else {
                    that.isSend = true;
                }
            },
            toExpress(e,is_send) {
                let id = e.id;
                let order_refund_id = e.refund;
                if (id > 0) {
                    uni.navigateTo({
                        url: '/pages/app_admin/send/send?id=' + id + '&is_send=' + is_send
                    })
                } else if (order_refund_id) {
                    uni.navigateTo({
                        url: '/pages/app_admin/send/send?order_refund_id=' + order_refund_id + '&is_send=' + is_send
                    })
                }
            },
            toSendType() {
                let that = this;
                let para;
                if (that.sendType == 1 || that.detail.send_type == 2) {
                    uni.showLoading({
                        title: '加载中...'
                    });
                    para = {
                        is_express: 0,
                        words: '',
                        order_id: that.detail.id
                    };
                    if(that.detail.send_type == 2) {
                        para.man = that.delivery;
                    }
                    that.$request({
                        url: that.$api.app_admin.send,
                        data: para,
                        method: 'post'
                    }).then(response => {
                        uni.hideLoading();
                        if (response.code == 0) {
                            uni.showToast({
                                title: response.msg,
                                type: 'success',
                                mask: false,
                                duration: 2000
                            });
                            // that.list = [];
                            that.page = 1;
                            that.isSend = false;
                            that.sendType = 0;
                            that.getList();
                        } else {
                            uni.showToast({
                                title: response.msg,
                                icon: 'none',
                                duration: 1000
                            });
                        }
                    }).catch(response => {
                        uni.hideLoading();
                        uni.showToast({
                            title: response,
                            icon: 'none',
                            duration: 1000
                        });
                    });
                }
            },
            look(e) {
                uni.previewImage({
                    current: e, // 当前显示图片的http链接
                    urls: [e] // 需要预览的图片http链接列表
                })
            },
            lookAbout(e) {
                this.detail = e;
                this.isReason = true;
            },
            toConfirm(e) {
                this.detail = e;
                this.confirmOrder = !this.confirmOrder;
            },
            toRefund(e) {
                this.detail = e;
                this.refund_price = e.refund_price;
                this.isRefund = !this.isRefund;
            },
            agree() {
                let that = this;
                uni.showLoading({
                    title: '处理中...'
                });
                if (that.detail.refund_price > 0) {
                    that.$request({
                        url: that.$api.app_admin.refund_handle,
                        data: {
                            order_refund_id: that.detail.id,
                            type: that.detail.type,
                            is_agree: 1,
                            refund_price: that.refund_price,
                            merchant_remark: that.about
                        },
                        method: 'post'
                    }).then(response => {
                        uni.hideLoading();
                        if (response.code == 0) {
                            uni.showModal({
                                title: '提示',
                                content: response.msg,
                                showCancel: false,
                                success: function (res) {
                                    if (res.confirm) {
                                        // that.list = [];
                                        that.notRefund = false;
                                        that.openAddress = false;
                                        that.isRefund = false;
                                        that.addressId = 0;
                                        that.page = 1;
                                        uni.showLoading({
                                            title: '加载中...'
                                        });
                                        that.getList();
                                    }
                                }
                            });
                        } else {
                            uni.showToast({
                                title: response.msg,
                                icon: 'none',
                                duration: 1000
                            });
                        }
                    }).catch(response => {
                        uni.hideLoading();
                        uni.showToast({
                            title: response,
                            icon: 'none',
                            duration: 1000
                        });
                    });
                } else {
                    uni.showToast({
                        title: '退款金额需大于零',
                        icon: 'none',
                        duration: 1000
                    });
                }
            },
            refundHandle(type,detail,cancel) {
                if (cancel == 1) {
                    this.cancelRefund = true;
                }
                if (type == 1) {
                    if (this.address.length == 0) {
                        this.noAddress = true;
                    } else {
                        this.detail = detail;
                        this.openAddress = true;
                    }
                } else if (type == 2) {
                    this.detail = detail;
                    this.notRefund = true;
                }
            },

            toAgreeCancel(e) {
                this.detail = e;
                this.isRefund = !this.isRefund;
            },
            decline(type) {
                let that = this;
                if (type == 1) {
                    if (that.addressId < 1) {
                        uni.showToast({
                            title: '请选择地址',
                            icon: 'none',
                            duration: 1000
                        });
                        return false;
                    }
                }
                if (that.cancelRefund) {
                    type = 2;
                }
                uni.showLoading({
                    title: '处理中...'
                });
                that.$request({
                    url: that.$api.app_admin.refund_handle,
                    data: {
                        order_refund_id: that.detail.id,
                        type: that.detail.type,
                        is_agree: type,
                        address_id: that.addressId,
                        refund_price: that.detail.refund_price,
                        merchant_remark: that.about
                    },
                    method: 'post'
                }).then(response => {
                    uni.hideLoading();
                    if (response.code == 0) {
                        uni.showModal({
                            title: '提示',
                            content: response.msg,
                            showCancel: false,
                            success: function (res) {
                                if (res.confirm) {
                                    that.page = 1;
                                    // that.list = [];
                                    that.notRefund = false;
                                    that.cancelOrder = false;
                                    that.openAddress = false;
                                    that.addressId = 0;
                                    that.getList();
                                }
                            }
                        });
                    } else {
                        uni.showToast({
                            title: response.msg,
                            icon: 'none',
                            duration: 1000
                        });
                    }
                }).catch(response => {
                    uni.hideLoading();
                    uni.showToast({
                        title: response,
                        icon: 'none',
                        duration: 1000
                    });
                });
            },
            chooseAddress(e) {
                if (this.addressId == e) {
                    this.addressId = ''
                }else {
                    this.addressId = e
                }
            },
            chooseDelivery(e) {
                if (this.getDeliveryId == e.id) {
                    this.deliveryId = ''
                }else {
                    this.deliveryId = e.id
                    this.delivery = "(" + e.id + ")" + e.name;
                }
            },
            noCancel() {
                let that = this;
                uni.showLoading({
                    title: '处理中...'
                });
                that.$request({
                    url: that.$api.app_admin.cancel,
                    data: {
                        status: 2,
                        remark: that.about,
                        order_id: that.detail.id
                    },
                    method: 'post'
                }).then(response => {
                    uni.hideLoading();
                    if (response.code == 0) {
                        uni.showToast({
                            title: response.msg,
                            type: 'success',
                            mask: false,
                            duration: 2000
                        });
                        // that.list = [];
                        that.page = 1;
                        that.noRefund = false;
                        that.getList();
                    } else {
                        uni.showToast({
                            title: response.msg,
                            icon: 'none',
                            duration: 1000
                        });
                    }
                }).catch(response => {
                    uni.hideLoading();
                    uni.showToast({
                        title: response,
                        icon: 'none',
                        duration: 1000
                    });
                });
            },
            beNotRefund(e) {
                this.detail = e;
                this.noRefund = !this.noRefund;
            },
        },
        onReachBottom: function() {
            if (this.more_list) {
                this.getList();
            }
        },
        onShow: function() {
                // this.list = [];
            this.page = 1;
            this.getList();
        },
        onLoad(options) {
            let that = this;
            that.$showLoading({
                type: 'global',
                text: '加载中...'
            });
            that.status = '1';
            that._num = '-1';
            var myDate = new Date();
            // 今天
            let year = myDate.getFullYear();
            let month = myDate.getMonth() + 1;
            if (month >= 1 && month <= 9) {
                month = "0" + month;
            }
            let now = myDate.getDate();
            that.today = year + "-" + month + "-" + now;
            var timestamp = Date.parse(new Date());
            // 昨天
            let yesterTime = (timestamp / 1000 - 24 * 60 * 60) * 1000;
            let yesterDate = new Date(yesterTime)
            let yester_year = yesterDate.getFullYear();
            let yester_month = yesterDate.getMonth() + 1;
            if (yester_month >= 1 && yester_month <= 9) {
                yester_month = "0" + yester_month;
            }
            let yester_now = yesterDate.getDate();
            that.yesterday = yester_year + "-" + yester_month + "-" + yester_now;
            // 7天
            let weekTime = (timestamp / 1000 - 24 * 60 * 60 * 7) * 1000;
            let weekDate = new Date(weekTime)
            let week_year = weekDate.getFullYear();
            let week_month = weekDate.getMonth() + 1;
            if (week_month >= 1 && week_month <= 9) {
                week_month = "0" + week_month;
            }
            let week_now = weekDate.getDate();
            that.weekday = week_year + "-" + week_month + "-" + week_now;
            uni.getSystemInfo({
                success: function (res) {
                    if(res.model.indexOf('iPhone X') > -1 || res.model.indexOf('iPhone 11') > -1 || res.model.indexOf('iPhone11') > -1 || res.model.indexOf('iPhone12') > -1 || res.model.indexOf('Unknown Device') > -1) {
                        that.iphone_x = true;
                    }
                }
            })
            that.$request({
                url: that.$api.app_admin.delivery
            }).then(response=>{
                if(response.code == 0) {
                    this.cityList = response.data.list;
                    this.deliveryId = response.data.list[0].id;
                    this.delivery = "(" + response.data.list[0].id + ")" + response.data.list[0].name
                }else {
                    uni.showToast({
                        title: response.msg,
                        icon: 'none',
                        duration: 1000
                    });
                }
            }).catch(response => {
                uni.hideLoading();
            });
            if(options.msg) {
                that.msg = true;
            }
            if(options.status > -1) {
                that._num = options.status
            }
            if(options.refund > 0) {
                that.status = 2
            }
            if (options.no) {
                if (options.no.slice(0, 2) == "RE") {
                    that.status = 2;
                }
                that.search = true;
                that.inSearch = true;
                that.keyword = options.no;
                this.getList();
            }
        }
    }
</script>

<style scoped lang="scss">
    .dialog-bg {
        width: 100%;
        height: 100%;
        position: fixed;
        background-color: rgba(0, 0, 0, 0.5);
        left: 0;
        top: 0;
    }

    .tab {
        margin: #{24rpx} auto;
        width: #{320rpx};
        height: #{56rpx};
    }

    .bottom-tab.iphone_x {
        height: #{146rpx};
        padding-bottom: #{50rpx};
    }

    .bottom-tab {
        width: 100%;
        height: #{96rpx};
        background-color: #fff;
        font-size: #{20rpx};
        color: #9096ad;
        padding-top: #{14rpx};
        z-index: 999;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
    }

    .tab-nav-item {
        text-align: center;
    }

    .tab-icon {
        height: #{48rpx};
        width: #{48rpx};
        display: inline-block;
    }

    .tab-nav-item.active {
        color: #446dfd;
    }

    .tab-nav-item view {
        margin-top: #{-5rpx};
    }

    .tab-info {
        background-color: #fff;
        position: fixed;
        z-index: 2;
        top: 0;
        left: 0;
        right: 0;
        height: #{104rpx};
    }

    .tab-item {
        width: #{160rpx};
        text-align: center;
        height: #{56rpx};
        line-height: #{54rpx};
        background-color: #fff;
        color: #666;
        font-size: #{24rpx};
        display: block;
    }

    .tab-item.tab-left {
        border-top-left-radius: #{28rpx};
        border-bottom-left-radius: #{28rpx};
        border: #{2rpx} solid #446dfd;
        border-right: 0;
    }

    .tab-item.tab-right {
        border-top-right-radius: #{28rpx};
        border-bottom-right-radius: #{28rpx};
        border: #{2rpx} solid #446dfd;
        border-left: 0;
    }

    .tab-item.active {
        background-color: #446dfd;
        color: #fff;
    }

    .search-area {
        position: fixed;
        z-index: 3;
        top: #{104rpx};
        left: 0;
        right: 0;
        height: #{88rpx};
        line-height: #{88rpx};
        background-color: #efeff4;
        padding: 0 #{48rpx} 0 #{24rpx};
    }

    .search {
        height: #{56rpx};
        line-height: #{56rpx};
        border-radius: #{28rpx};
        background-color: #fff;
        color: #b2b2b2;
        width: #{528rpx};
        text-align: center;
    }

    .choose {
        color: #446dfd;
        font-size: #{26rpx};
    }

    .choose image {
        width: #{22rpx};
        height: #{12rpx};
        margin-left: #{12rpx};
    }

    .navs-info {
        background-color: #fff;
        border-bottom: #{1rpx} solid #e2e2e2;
        position: fixed;
        z-index: 2;
        top: #{182rpx};
        left: 0;
        right: 0;
        padding-top: #{10rpx};
    }

    .navs {
        height: #{100rpx};
        font-size: #{28rpx};
        color: #666;
        text-align: center;
        position: relative;
    }

    .navs.more-navs {
        line-height: #{100rpx};
    }

    .navs .active {
        color: #446dfd;
        display: inline-block;
        height: #{100rpx};
        line-height: #{102rpx};
        border-bottom: #{2rpx} solid #446dfd;
    }

    .navs image {
        height: #{16rpx};
        width: #{16rpx};
        margin-left: #{16rpx};
        display: block;
        float: right;
        margin-top: #{42rpx};
    }

    .order-item {
        background-color: #fff;
        padding: #{24rpx};
        margin: #{20rpx} #{24rpx} 0;
        border-radius: #{16rpx};
        display: block;
    }

    .order-info {
        font-size: #{24rpx};
        color: #353535;
        margin-bottom: #{24rpx};
        .remark-info {
            margin-top: #{8rpx};
        }
    }

    .order-user {
        height: #{72rpx};
        background-color: #f7f7f7;
        padding-left: #{28rpx};
        font-size: #{24rpx};
        color: #353535;
    }

    .order-user view:first-of-type {
        margin-right: #{32rpx};
    }

    .to-tel {
        color: #446dfd;
        font-size: #{24rpx};
        margin-left: #{20rpx};
        height: #{72rpx};
        line-height: #{72rpx};
    }

    .to-tel image {
        height: 14px;
        width: 14px;
        margin-right: #{12rpx};
        display: inline-block;
    }

    .goods {
        height: #{160rpx};
        margin-top: #{24rpx};
        position: relative;
        font-size: #{24rpx};
        color: #353535;
        margin-bottom: #{24rpx};
        .goods-status {
            height: #{40rpx};
            line-height: #{40rpx};
            color: #fff;
            width: #{160rpx};
            position: absolute;
            bottom: 0;
            left: 0;
            text-align: center;
            background-color: #446dfd;
            border-bottom-left-radius: #{4rpx};
            border-bottom-right-radius: #{4rpx};
        }
        .goods-img {
            height: #{160rpx};
            width: #{160rpx};
            float: left;
            margin-right: #{20rpx};
            border-radius: #{4rpx};
        }
        .goods-attr {
            font-size: #{24rpx};
            color: #999;
            position: absolute;
            top: #{78rpx};
            left: #{180rpx};
            width: 70%;
            text {
                margin-right: #{20rpx};
            }
        }
        .goods-num {
            font-size: #{24rpx};
            color: #999;
            position: absolute;
            top: #{126rpx};
            left: #{180rpx};
        }
        .goods-price {
            font-size: #{24rpx};
            color: #353535;
            position: absolute;
            bottom: 0;
            right: 0;
        }
    }

    .price-info {
        font-size: #{28rpx};
        color: #353535;
    }

    .price-info .other {
        font-size: #{24rpx};
        color: #999;
    }

    .handle-btn {
        height: #{48rpx};
        display: flex;
        align-items: center;
        padding: 0 #{24rpx};
        border-radius: #{24rpx};
        border: #{2rpx} solid #bbb;
        color: #353535;
        font-size: #{24rpx};
        margin-left: #{16rpx};
    }

    .handle-btn.other {
        border: #{2rpx} solid #446dfd;
        color: #446dfd;
    }

    .more-menu {
        position: fixed;
        z-index: 5;
        top: #{270rpx};
        padding-top: #{22rpx};
        right: #{22rpx};
        width: #{196rpx};
        background-color: #fff;
        font-size: #{28rpx};
        color: #666;
        border-bottom: #{1rpx} solid #e0e0e0;
    }

    .more-menu.go-out, .search-history.go-out {
        display: none;
    }

    .more-menu view {
        width: #{196rpx};
        height: #{68rpx};
        line-height: #{68rpx};
        text-align: center;
        border-left: #{1rpx} solid #e0e0e0;
        border-right: #{1rpx} solid #e0e0e0;
    }

    .search-item {
        height: #{96rpx};
        background-color: #efeff4;
        padding: 0 #{24rpx};
        font-size: #{28rpx};
        color: #00c203;
    }

    .search-input {
        height: #{64rpx};
        position: relative;
        width: #{620rpx};
        .search-clear {
            position: absolute;
            right: #{15rpx};
            top: #{21rpx};
            width: #{30rpx};
            height: #{30rpx};
            z-index: 100;
        }
    }

    .search-input .search-icon {
        height: #{22rpx};
        width: #{22rpx};
        position: absolute;
        top: #{21rpx};
        left: #{28rpx};
        z-index: 10;
    }

    .search-input input {
        padding-left: #{62rpx};
        padding-right: #{70rpx};
        background-color: #fff;
        border-radius: #{32rpx};
        height: #{64rpx};
        font-size: #{26rpx};
        color: #353535;
    }

    .search-history {
        position: absolute;
        top: #{96rpx};
        left: 0;
        right: 0;
        height: 100%;
        background-color: #fff;
        padding: #{24rpx} #{4rpx};
        font-size: #{28rpx};
        color: #666;
        z-index: 20;
    }

    .search-title {
        padding: 0 #{20rpx};
        margin-bottom: #{24rpx};
    }

    .keyword-item {
        height: #{64rpx};
        line-height: #{64rpx};
        padding: 0 #{20rpx};
        background-color: #f7f7f7;
        color: #333;
        border-radius: #{32rpx};
        font-size: #{28rpx};
        margin-left: #{20rpx};
        margin-bottom: #{20rpx};
        max-width: 90%;
    }

    .bg {
        background-color: rgba(0, 0, 0, 0.3);
        position: fixed;
        top: 0;
        left: 0;
        height: 100%;
        width: 100%;
        z-index: 100;
    }

    .dialog {
        width: #{620rpx};
        border-radius: #{16rpx};
        margin: 0 auto;
        background-color: #fff;
        z-index: 20;
    }

    .remark-input {
        padding: 0 #{32rpx};
        height: #{80rpx};
        margin-bottom: #{32rpx};
        color: #353535;
        input {
            border-radius: #{16rpx};
            background-color: #F7F7F7;
            height: #{80rpx};
            line-height: #{80rpx};
            padding: 0 #{24rpx};
        }
    }

    .dialog-title {
        font-size: #{32rpx};
        color: #353535;
        width: #{620rpx};
        margin: #{32rpx} auto #{40rpx};
        text-align: center;
    }

    .dialog-choose-item {
        width: #{170rpx};
        height: #{68rpx};
        line-height: #{68rpx};
        text-align: center;
        border-radius: #{34rpx};
        border: #{2rpx} solid #ddd;
        color: #666;
        font-size: #{28rpx};
        margin-bottom: #{16rpx};
    }

    .send-item {
        width: #{180rpx};
        height: #{68rpx};
        line-height: #{66rpx};
        text-align: center;
        border-radius: #{34rpx};
        border: #{2rpx} solid #ddd;
        color: #666;
        background-color: #fff;
        font-size: #{28rpx};
        margin: 0 #{30rpx} #{36rpx};
    }

    .send-item.active {
        color: #fff;
        border: #{2rpx} solid #446dfd;
        background-color: #446dfd;
    }

    .dialog-choose-item.active {
        color: #446dfd;
        border: #{2rpx} solid #446dfd;
    }

    .btn-area {
        height: #{88rpx};
        position: relative;
        border-top: #{2rpx} solid #e2e2e2;
    }

    .btn-area.other-btn-area {
        margin-top: #{10rpx};
    }

    .btn-area .line {
        height: #{32rpx};
        width: #{1rpx};
        background-color: #e2e2e2;
        position: absolute;
        top: #{28rpx};
        left: 0;
        right: 0;
        margin: 0 auto;
    }

    .submit-btn {
        height: #{88rpx};
        line-height: #{88rpx};
        font-size: #{32rpx};
        color: #666;
        width: #{310rpx};
        text-align: center;
    }

    .submit-btn.be-submit {
        color: #446dfd;
    }

    .textarea {
        height: #{252rpx};
        width: #{492rpx};
        padding: #{24rpx} #{32rpx};
        font-size: #{28rpx};
        border-radius: #{16rpx};
        border: #{2rpx} solid #e2e2e2;
        text-align: left;
        margin: #{32rpx} auto;
    }

    .change-price-item {
        position: relative;
        height: #{64rpx};
        line-height: #{64rpx};
        color: #353535;
        font-size: #{28rpx};
        margin-bottom: #{26rpx};
    }

    .change-price-item:first-of-type {
        margin-bottom: #{32rpx};
    }

    .change-price-item:last-of-type {
        margin: #{24rpx} 0 #{34rpx};
    }

    .label {
        height: #{64rpx};
        line-height: #{64rpx};
        text-align: right;
        width: #{178rpx};
    }

    .price-input {
        width: #{298rpx};
        height: #{64rpx};
        margin-left: #{24rpx};
        border-radius: #{32rpx};
        padding-left: #{62rpx};
        background-color: #f7f7f7;
    }

    .money {
        position: absolute;
        left: #{234rpx};
    }

    .time-title {
        margin-left: #{32rpx};
        color: #666;
        font-size: #{28rpx};
        margin-bottom: #{20rpx};
    }

    .choose-time {
        position: relative;
    }

    .year-1 {
        position: absolute;
        left: #{192rpx};
        top: #{146rpx};
    }

    .month-1 {
        position: absolute;
        left: #{380rpx};
        top: #{146rpx};
    }

    .day-1 {
        position: absolute;
        right: #{32rpx};
        top: #{146rpx};
    }

    .year-2 {
        position: absolute;
        left: #{192rpx};
        bottom: #{88rpx};
    }

    .month-2 {
        position: absolute;
        left: #{380rpx};
        bottom: #{88rpx};
    }

    .day-2 {
        position: absolute;
        right: #{32rpx};
        bottom: #{88rpx};
    }

    .reason {
        padding-left: #{32rpx};
    }

    .reason-title {
        font-size: #{28rpx};
        color: #999;
        margin-bottom: #{20rpx};
    }

    .reason-content {
        font-size: #{28rpx};
        color: #353535;
        width: #{556rpx};
        margin-bottom: #{26rpx};
    }

    .reason-img {
        margin-bottom: #{14rpx};
    }

    .reason-img image {
        height: #{180rpx};
        width: #{180rpx};
        margin: 0 #{8rpx} #{8rpx} 0;
    }

    .add-list {
        margin-top: #{50rpx};
        max-height: #{388rpx};
        overflow: auto;
        padding: 0 #{36rpx};
    }

    .add-item {
        padding: #{32rpx} 0;
        margin-left: #{64rpx};
        position: relative;
        font-size: #{28rpx};
        color: #353535;
        border-bottom: #{1rpx} solid #e2e2e2;
    }

    .add-item.delivery-item {
        padding-left: #{64rpx};
        margin-left: 0;
    }

    .add-item:last-of-type {
        border-bottom: 0;
    }

    .add-item image {
        height: #{36rpx};
        width: #{36rpx};
        position: absolute;
        left: #{-66rpx};
        top: 50%;
        margin-top: #{-18rpx};
    }

    .add-item .add-active {
        position: absolute;
        left: #{-64rpx};
        top: 50%;
        margin-top: #{-18rpx};
    }

    .add-item .add-name {
        width: #{220rpx};
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .add-item.delivery-item .add-name {
        width: #{400rpx};
    }

    .no-tip {
        position: fixed;
        top: #{400rpx};
        left: 0;
        right: 0;
        margin: 0 auto;
        color: #666666;
        font-size: #{24rpx};
        width: #{240rpx};
        text-align: center;
    }

    .no-tip image {
        height: #{240rpx};
        width: #{240rpx};
        margin-bottom: #{20rpx};
    }

    .refund-price {
        width: #{160rpx};
        border: #{2rpx} solid #e2e2e2;
        border-radius: #{5rpx};
        font-size: #{32rpx};
        padding: 0 #{5rpx};
    }

    .bottom-place {
        height: #{116rpx};
    }

    .bottom-place.iphone_x {
        height: #{166rpx};
    }

    .delete-icon {
        height: #{34rpx};
        width: #{28rpx};
    }

    .candidate-list {
        max-height: #{420rpx};
        overflow: hidden;
    }

    .icon-search {
        height: #{24rpx};
        width: #{24rpx};
        margin-top: #{16rpx};
    }

    .icon-search+text {
        color:#b2b2b2;
        font-size:#{24rpx};
        margin:0 #{5rpx};
    }

    .search-palce {
        height: #{292rpx};
    }

    .goods-name {
        padding-top: #{5rpx};
    }

    .menu-button {
        margin-top: #{24rpx};
    }

    .time-area {
        margin-bottom: #{24rpx};
        padding: 0 #{32rpx};
    }

    .picker-view {
        width: #{556rpx};
        height: #{216rpx};
        margin: 0 auto #{20rpx};
        text-align: center;
        .sure-color {
            color: #446dfd;
        }
        .cardinal-color {
            color: #999999;
        }
        .even-color {
            color: #cdcdcd;
        }
    }

    .picker-view view {
        line-height: #{72rpx};
    }

    .refund-pay {
        font-size: #{36rpx};
        color: #353535;
        font-weight: bold;
    }

    .refund-tip {
        font-size: #{32rpx};
        color: #353535;
        margin: #{4rpx} 0 #{45rpx};
    }

    .total-money {
        margin-left: #{56rpx};
    }

    .cancel-tip {
        font-size: #{32rpx};
        color: #353535;
        margin: #{74rpx} 0 #{60rpx};
    }

    .send-type {
        margin-bottom: #{24rpx};
        padding: 0 #{32rpx};
    }
</style>