{extend name="default/base" /}
{block name="title"}我的订单 - {__block__}{/block}
{block name="css"}
<link rel="stylesheet"  href="__MOBILE__/css/orders.css?v={$v}">
{/block}
{block name="header"}
	<div id="info_list">
    <header style="background:#ffffff;" class="ui-header ui-header-positive wst-header wst-headero">
        <i class="ui-icon-return" onclick="location.href='{:url('mobile/users/index')}'"></i><h1>我的订单</h1>
    </header>
{/block}
{block name="main"}
    <input type="hidden" name="" value="" id="currPage" autocomplete="off">
    <input type="hidden" name="" value="" id="totalPage" autocomplete="off">
    <input type="hidden" name="" value="{$type}" id="type" autocomplete="off">

    <script id="shopList" type="text/html">
    {{# for(var i = 0; i < d.length; i++){ }}
            <div class="order-item">
                <div class="ui-row-flex ui-whitespace item-head" onclick="getOrderDetail({{d[i].orderId}})">
                    <div class="ui-col order-tr o-status">
                        {{ d[i].status }}
                        {{# if($.inArray(d[i].orderStatus,[-1,-3])!=-1){ }}
						{{# if(d[i].payType==1 && d[i].isPay==1) { }} 
                            {{# if(d[i].isRefund==1) { }} 
                            (已退款)
                            {{# }else{ }} 
                            (未退款)
                            {{# } }}
						{{# } }} 
                        {{# } }}
                    </div>
                </div>

                {{# for(var g=0;g<d[i].list.length;g++){ }}
                <div class="ui-row-flex ui-whitespace border-b" onclick="getOrderDetail({{d[i].orderId}})">
                    <div class="ui-col">
                        <img src="__RESOURCE_PATH__/{{d[i].list[g].goodsImg}}" class="o-Img">
                    </div>
                    <div class="ui-col ui-col-3 o-gInfo">
                        <p class="o-gName ui-nowrap-multi ui-whitespace">{{d[i].list[g].goodsName}}</p>

                        {{# if(d[i].list[g].isSpec==1){ }}
                        <p class="o-gSpec ui-nowrap-flex ui-whitespace">规格：{{d[i].list[g].goodsSpecNames}}</p>
                        {{# } }}

                    </div>
                    <div class="ui-col order-tr" style="word-break:break-all;">￥{{d[i].list[g].goodsPrice}}<br>x{{d[i].list[g].goodsNum}}</div>
                </div>
                {{#  } }}


                <div class="ui-btn-wrap" style="padding:5px 0px;overflow:hidden;">
                <div class="o-oListMoney">
                   订单总价：<span>¥ {{d[i].realTotalMoney}}</span>
                </div>
                {{# if(d[i].orderStatus==-2){ }}
                    <button class="ui-btn o-btn" onclick="choicePay('{{d[i].pkey}}');">
                        立即付款
                    </button>
                {{# } }}
                
                {{# if(d[i].orderStatus==0 && d[i].noticeDeliver==0 ){ }}
                    <button class="ui-btn o-btn o-cancel-btn" onclick="WST.dialog('您确定要提醒发货吗?','noticeDeliver({{d[i].orderId}})')">
                        提醒发货
                    </button>
                {{# } }}

                {{# if(d[i].orderStatus==-2 || d[i].orderStatus==0){ }}
                    <button class="ui-btn o-btn o-cancel-btn" onclick="showCancelBox('cancelOrder({{d[i].orderId}})')">
                        取消订单
                    </button>
                {{# } }}

                {{# if((d[i].orderStatus!=-1 || d[i].orderStatus==1) && d[i].orderStatus!=-2 && d[i].isComplain==0 ){ }}
                    <button class="ui-btn o-btn o-cancel-btn" onclick="complain({{d[i].orderId}})">
                        投诉
                    </button>
                {{# } }}

                {{# if(d[i].orderStatus==2 && d[i].isAppraise==0) { }}
                    <button class="ui-btn o-btn" onclick="toAppr({{d[i].orderId}})">
                        评价
                    </button>
                {{# } }}
                {{# if(d[i].isAppraise==1){ }}
                    <button class="ui-btn o-btn" onclick="toAppr({{d[i].orderId}})">
                        查看评价
                    </button>
                {{# } }}

                {{# if(d[i].orderStatus==1){  }}
                    <button class="ui-btn o-btn o-cancel-btn" onclick="showRejectBox('rejectOrder({{d[i].orderId}})')">
                        拒收
                    </button>
                    <button class="ui-btn o-btn" onclick="WST.dialog('你确定已收货吗?','receive({{d[i].orderId}})')">
                            确认收货
                    </button>
                {{# } }}
                {{ d[i]['hook']?d[i]['hook']:"" }}
                </div>
                <div class="wst-clear"></div>
            </div>
    {{#  } }}
    </script>

    <section class="ui-container" id="shopBox">
        <div class="ui-tab">
	        <ul class="ui-tab-nav order-tab">
	            <li class="tab-item {if $type==''}tab-curr{/if}" type="" >全部</li>
	            <li class="tab-item {if $type=='waitPay'}tab-curr{/if}" type="waitPay" >待付款</li>
	            <li class="tab-item {if $type=='waitDeliver'}tab-curr{/if}" type="waitDeliver" >待发货</li>
	            <li class="tab-item {if $type=='waitReceive'}tab-curr{/if}" type="waitReceive" >待收货</li>
	            <li class="tab-item {if $type=='waitAppraise'}tab-curr{/if}" type="waitAppraise" >待评价</li>
	            <li class="tab-item {if $type=='finish'}tab-curr{/if}" type="finish" >已完成</li>
	            <li class="tab-item {if $type=='abnormal'}tab-curr{/if}" type="abnormal" >取消拒收</li>
	        </ul>
		</div>

        <div id="order-box">

        </div>

    </section>
    {:hook('mobileDocumentOrderList')}
    </div>

<script type="text/html" id="detailBox">
           <div id="detailBox">
            <div class="detail-head" style="margin-top:0;">
            {{# if($.inArray(d.orderStatus,[-2,0,1,2])!=-1){ }}
            <div class="wst-or-process">
                <div class="ui-row-flex">
                    {{# if(d.payType==1) { }}
                    <div class="ui-col ui-col process"><p class="line">
                        <span {{# if($.inArray(d.orderStatus,[-2,0,1,2])!=-1){ }}class="active"{{# } }}></span>
                        <span {{# if($.inArray(d.orderStatus,[0,1,2])!=-1){ }}class="active"{{# } }}></span>
                        <p class="icon"><i class="ui-icon-success-block {{# if($.inArray(d.orderStatus,[-2,0,1,2])!=-1){ }}active{{# } }}"></i></p>
                    <div class="wst-clear"></div></p><p>待付款</p></div>
                    {{# } }}
                    <div class="ui-col ui-col process"><p class="line">
                        <span {{# if($.inArray(d.orderStatus,[0,1,2])!=-1){ }}class="active"{{# } }}></span>
                        <span {{# if($.inArray(d.orderStatus,[1,2])!=-1){ }}class="active"{{# } }}></span>
                        <p class="icon"><i class="ui-icon-success-block {{# if($.inArray(d.orderStatus,[0,1,2])!=-1){ }}active{{# } }}"></i></p>
                    <div class="wst-clear"></div></p><p>待发货</p></div>
                    <div class="ui-col ui-col process"><p class="line">
                        <span {{# if($.inArray(d.orderStatus,[1,2])!=-1){ }}class="active"{{# } }}></span>
                        <span {{# if(d.orderStatus==2){ }}class="active"{{# } }}></span>
                        <p class="icon"><i class="ui-icon-success-block {{# if($.inArray(d.orderStatus,[1,2])!=-1){ }}active{{# } }}"></i></p>
                    <div class="wst-clear"></div></p><p>已发货</p></div>
                    <div class="ui-col ui-col process"><p class="line">
                        <span {{# if(d.orderStatus==2){ }}class="active"{{# } }}></span>
                        <span {{# if(d.orderStatus==2){ }}class="active"{{# } }}></span>
                        <p class="icon"><i class="ui-icon-success-block {{# if(d.orderStatus==2){ }}active{{# } }}"></i></p>
                    <div class="wst-clear"></div></p><p>已收货</p></div>
                </div>
            </div>
            {{# } }}
            
            <div class="ui-row-flex">
                <div class="ui-col ui-col wst-or-term"><span class="wst-or-describe">订单状态：</span>
                <span class="o-status">{{d.status}}
                {{# if($.inArray(d.orderStatus,[-1,-3])!=-1){ }}
                    {{# if(d.payType==1 && d.isPay==1) { }} 
                    {{# if(d.isRefund==1) { }} 
                    (已退款)
                    {{# }else{ }} 
                    (未退款)
                    {{# } }}
                    {{# } }} 
                {{# } }}</span></div>
            </div>
            <div class="ui-row-flex">
                <div class="ui-col ui-col wst-or-term"><span class="wst-or-describe">订单编号：</span>{{d.orderNo}}</div>
            </div>
            <div class="ui-row-flex">
                <div class="ui-col ui-col wst-or-term"><span class="wst-or-describe">下单时间：</span>{{d.createTime}}</div>
            </div>
            </div>


            <div class="detail-head">
            {{# if(d.userName){ }}
                <div class="ui-row-flex">
                    <div class="ui-col ui-col wst-or-term"><span class="wst-or-describe">收货人：</span>{{d.userName}} <span class="d-utel">{{d.userPhone}}</span></div>
                </div>
                <div class="ui-row-flex">
                    <div class="ui-col ui-col wst-or-term"><span class="wst-or-describe">收货地址：</span><span class="d-uaddr">{{d.userAddress}}<i></i></span></div>
                </div>
            {{# } }}
                <div class="ui-row-flex">
                    <div class="ui-col ui-col wst-or-term"><span class="wst-or-describe">支付信息：</span>{{d.payInfo}}</div>
                </div>
                <div class="ui-row-flex">
                    <div class="ui-col ui-col wst-or-term"><span class="wst-or-describe">配送信息：</span>{{d.deliverInfo}}</div>
                </div>
            {{# if(WST.blank(d.expressNo)!=''){ }}
                <div class="ui-row-flex">
                    <div class="ui-col ui-col wst-or-term"><span class="wst-or-describe">快递公司：</span>{{d.expressName}}</div>
                </div>
                <div class="ui-row-flex">
                    <div class="ui-col ui-col wst-or-term"><span class="wst-or-describe">快递号：</span>{{d.expressNo}}</div>
                </div>
            {{# } }}
                <div class="ui-row-flex">
                    <div class="ui-col ui-col wst-or-term"><span class="wst-or-describe">发票信息：</span>{{# if(d.isInvoice==1) { }}需要{{# } else{ }}不需要{{# } }}</div>
                </div>
            {{# if(d.isInvoice==1) { }}
                <div class="ui-row-flex">
                    <div class="ui-col ui-col wst-or-term"><span class="wst-or-describe">发票抬头：</span>{{d.invoiceClient}}</div>
                </div>
            {{#
                 var inv_json = JSON.parse(d.invoiceJson);
                 var inv_code = (inv_json!=null && inv_json.invoiceCode!=undefined)?inv_json.invoiceCode:'';
                 if(inv_json!=null && inv_json.type!=undefined && inv_json.type==0){
             }}
                <div class="ui-row-flex">
                    <div class="ui-col ui-col wst-or-term"><span class="wst-or-describe">发票税号：</span>{{inv_code}}</div>
                </div>
            {{# } }}
            {{# } }}
                <div class="ui-row-flex">
                    <div class="ui-col ui-col wst-or-term" style="word-break: break-all;"><span class="wst-or-describe">订单备注：</span>{{d.orderRemarks}}</div>
                </div>
            </div>

            {{# if(d.isRefund==1){ }}
            <div class="detail-head">
                <div class="ui-row-flex">
                    <div class="ui-col ui-col wst-or-term"><span class="wst-or-describe">退款金额：</span>¥ {{d.backMoney}}</div>
                </div>
                <div class="ui-row-flex">
                    <div class="ui-col ui-col wst-or-term"><span class="wst-or-describe">退款备注：</span>{{d.refundRemark}}</div>
                </div>
                <div class="ui-row-flex">
                    <div class="ui-col ui-col wst-or-term"><span class="wst-or-describe">退款时间：</span>{{d.refundTime}}</div>
                </div>
            </div>
            {{# } }}


            <div class="detail-head">
            {{# for(var i=0;i<d.goods.length;i++){ }}
            <div class="ui-row-flex ui-whitespace border-b d-goodsitme" onclick="javascript:WST.intoGoods({{d.goods[i].goodsId}})">
                <div class="ui-col">
                    <img src="__RESOURCE_PATH__/{{d.goods[i].goodsImg}}" class="o-Img">
                </div>
                <div class="ui-col ui-col-3 o-gInfo">
                    <p class="o-gName ui-nowrap-multi ui-whitespace">{{d.goods[i].goodsName}}</p>
                    <p class="o-gSpec d-gSpec">
                    {{# if(d.goods[i].goodsSpecNames){ }}
                    {{d.goods[i].goodsSpecNames.replace(/@@_@@/g,'<br />')}}
                    {{# } }}
                    </p>
                </div>
                <div class="ui-col order-tr" style="word-break:break-all;padding:5px 0;">
                    {{# if(d.goods[i].goodsCode=='gift'){ }}
                    【赠品】
                    {{# }else{ }}
                    <p>¥ {{d.goods[i].goodsPrice}}</p><p>x {{d.goods[i].goodsNum}}</p>
                    {{# } }}
                </div>
            </div>
            {{# if(d.goods[i].goodsType==1 && d.orderStatus==2){ }}
                {{# for(var e=0;e<d.goods[i].extraJson.length;e++){ }}
                <div class="ui-row-flex ui-row-flex-ver d-uInfo">
                    <div class="ui-col">
                        <p>卡券号：{{d.goods[i].extraJson[e].cardNo}}</p>
                        <p>卡券密码：{{d.goods[i].extraJson[e].cardPwd}}</p>
                    </div>
                </div>
                {{# } }}
            {{# } }}
            {{# } }}
            </div>

            <div class="detail-head">
                <div class="ui-row-flex">
                    <div class="ui-col ui-col wst-or-term"><span class="wst-or-describe2">获得积分</span><span class="o-status2">{{d.orderScore}} 个</span></div>
                </div>
                <div class="ui-row-flex">
                    <div class="ui-col ui-col wst-or-term"><span class="wst-or-describe2">商品总额</span><span class="o-status2">¥ {{d.goodsMoney}}</span></div>
                </div>
                <div class="ui-row-flex">
                    <div class="ui-col ui-col wst-or-term"><span class="wst-or-describe2">运费</span><span class="o-status2">¥ {{d.deliverMoney}}</span></div>
                </div>
                <div class="ui-row-flex">
                    <div class="ui-col ui-col wst-or-term"><span class="wst-or-describe2">积分抵扣金额</span><span class="o-status2">¥ -{{d.scoreMoney}}</span></div>
                </div>
                {{# if(d.useScore>0){ }}
                <div class="ui-row-flex">
                    <div class="ui-col ui-col wst-or-term"><span class="wst-or-describe2">使用积分数</span><span class="o-status2">{{d.useScore}} 个</span></div>
                </div>
                {{# } }}
                {{ d['hook']?d['hook']:"" }}
                <div class="ui-row-flex">
                    <div class="ui-col ui-col wst-or-term2"><span class="wst-or-describe2">实付款</span><span class="o-status2"><span style="font-size:0.13rem;">¥ </span>{{d.realTotalMoney}}</span></div>
                </div>
            </div>
         </div>
</script>
 {/* 遮盖层  */}
    <div class="wst-cover" id="cover"></div>
    {/* 订单详情层  */}
    <div class="wst-fr-box" id="frame">
        <div class="title" id="boxTitle"><span>订单详情</span><i class="ui-icon-close-page" onclick="javascript:dataHide();"></i><div class="wst-clear"></div></div>
        <div class="content" id="content">

        </div>
    </div>
{/block}
{block name="include"}
{include file="default/dialog" /}<!-- 对话框模板 -->
<div class="ui-dialog" id="cancelBox">
    <div class="ui-dialog-cnt">
        <div class="ui-dialog-bd">
            <div class="ui-dialog-bd-title">请选择您取消订单的原因:</div>
            <select id='reason' onchange='javascript:changeReasonType(this.value)'>
               {volist name=":WSTDatas('ORDER_CANCEL')" id="vo"}
               <option value='{$vo["dataVal"]}'>{$vo["dataName"]}</option>
               {/volist}
            </select>
       <div id='rejectTrs' style='display:none'>
                 原因<font color='red'>*</font>：
                 <textarea id='contentd' style='width:99%;height:80px;' maxLength='200'></textarea>
            </div>
             <p class="cancel-btn-box">
                <button id="wst-event1" type="button" class="ui-btn-s wst-dialog-b1" data-role="button">取消</button>&nbsp;&nbsp;
                <button id="wst-event0" type="button" class="ui-btn-s wst-dialog-b2">确定</button>
            </p>
        </div>
    </div>        
</div>



<div class="ui-dialog" id="rejectBox">
    <div class="ui-dialog-cnt">
        <div class="ui-dialog-bd">
            请选择您拒收订单的原因:
            <select id='reject' onchange='javascript:changeRejectType(this.value)'>
               {volist name=":WSTDatas('ORDER_REJECT')" id="vo"}
               <option value='{$vo["dataVal"]}'>{$vo["dataName"]}</option>
               {/volist}
            </select>
            <br />
            <div id='rejectTr' style='display:none'>
                 原因<font color='red'>*</font>：
                 <textarea id='contents' style='width:99%;height:80px;' maxLength='200'></textarea>
            </div>

            <label class="cancel-btn-box">
            <button id="wst-event1" type="button" class="ui-btn-s wst-dialog-b1" data-role="button">取消</button>&nbsp;&nbsp;
            <button id="wst-event3" type="button" class="ui-btn-s wst-dialog-b2">确定</button>
            </label>
        </div>
    </div>        
</div>

{/block}
{block name="js"}
<script type='text/javascript' src='__MOBILE__/js/jquery.min.js'></script>
<script type='text/javascript' src='__MOBILE__/users/orders/orders_list.js?v={$v}'></script>
<script>
var orderId = "{$orderId}";
var currPage = totalPage = 0;
var loading = false;
$(document).ready(function(){
  getOrderList();
  WST.initFooter('user');
  backPrevPage(WST.U('mobile/users/index'));
  // Tab切换卡
  $('.tab-item').click(function(){
      $(this).addClass('tab-curr').siblings().removeClass('tab-curr');
      var type = $(this).attr('type');
      $('#type').val(type);
      reFlashList();
  });
  // 弹出层
  var w = WST.pageWidth();
  $("#frame").css('top',0);
  $("#frame").css('right',-w);

    $(window).scroll(function(){  
        if (loading) return;
        if ((5 + $(window).scrollTop()) >= ($(document).height() - $(window).height())) {
            currPage = Number( $('#currPage').val() );
            totalPage = Number( $('#totalPage').val() );
            if( totalPage > 0 && currPage < totalPage ){
            	getOrderList();
            }
        }
    });
  if(orderId>0){
      getOrderDetail(orderId);
  }
});
</script>
{/block}