123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122 |
- var orderStatus=mobile.getUrlVars("orderStatus");
- mui.init();
- var tap=[0,0,0,0];
- mui.ready(function(){
- if(orderStatus){
- $('[orderStatus="'+orderStatus+'"]').addClass('mui-active');
- $('[orderStatus="'+orderStatus+'"]').siblings().removeClass('mui-active');
- tap[$('[orderStatus="'+orderStatus+'"]').index()]=1;
- $("#item"+($('[orderStatus="'+orderStatus+'"]').index()+1)).addClass('mui-active');
- $("#item"+($('[orderStatus="'+orderStatus+'"]').index()+1)).siblings().removeClass('mui-active');
- }
- getList();
- mui('#segmentedControls').on('tap','.mui-control-item:not(.mui-active)',function(e){
- if(tap[$(this).index()]==0){
- orderStatus = $(this).attr('orderStatus');
- tap[$('[orderStatus="'+orderStatus+'"]').index()]=1;
- getList();
- }
- });
- $(".mui-control-content").on("tap",".product-detail",function(e){
- e.stopPropagation();
- if ($(this).attr("product_type")=="10"){
- location.href=base+"/mobile/productDetail.jsp?id="+$(this).attr("data-id");
- }else if ($(this).attr("product_type")=="20"){
- location.href=base+"/mobile/cutProductDetail.jsp?id="+$(this).attr("data-id");
- }
- });
- $(".mui-control-content").on("tap",".fukuan",function(e){
- e.stopPropagation();
- location.href=base+"/mobile/userOrderDetail.jsp?id="+$(this).parents(".mui-table-view").attr("data-id");
- });
- $(".mui-control-content").on("tap",".pingjia",function(e){
- e.stopPropagation();
- location.href=base+"/mobile/userOrderComment.jsp?id="+$(this).parents(".mui-table-view").attr("data-id");
- });
- });
- function getList(){
- orderStatus=orderStatus==null?'':orderStatus;
- mobile.ajaxPost(base+'/userOrder/getList',{orderStatus:orderStatus=='all'?'':orderStatus},function(json){
- var html=[];
- console.info(json.data);
- if(json.data&&json.data.length>0){
- $.each(json.data,function(id,item){
- if(item.order_status=="99"){
- return;
- }
- if(orderStatus=="30"&&item.comment_flag=="1"){
- return;
- }
- html.push('<ul class="mui-table-view fs14 mt10 product" data-id="'+item.id+'">');
- html.push('<li class="mui-table-view-cell items">');
- html.push('<span class="item">'+item.create_time+'</span>');
- if(item.order_status=="10"){
- html.push(' <span class="main-color">待付款</span>');
- }else if(item.order_status=="20"){
- html.push(' <span class="main-color">待使用</span>');
- }else if(item.order_status=="30"){
- html.push(' <span class="main-color">交易完成</span>');
- }
- html.push('</li>');
- $.each(item.list,function(id2,item2){
- html.push('<li class="mui-table-view-cell mui-media product-detail" product_type="'+item2.product_type+'" data-id="'+item2.id+'">');
- html.push('<div class="product-img mui-pull-left">');
- html.push('<img src="'+imgUrl+item2.product_main_img+'">');
- if(item2.order_hour<=0){
- html.push('<span class="img-icon">免预约</span>')
- }
- html.push('</div>');
- html.push('<div class="mui-media-body pl10">');
- html.push('<p class="product-merchant mui-ellipsis">'+item2.merchant_name+'</p>');
- html.push('<p class="product-title mui-ellipsis-2 fs12">'+item2.product_name+'</p>');
- html.push('<p class="product-price items">');
- html.push('<em class="item"><b>¥</b>'+item2.product_price+'<span class="del-line color3 ml5">'+item2.product_old_price+'元</span></em>');
- html.push('<span class="color2 fs14">x'+item2.product_qty+'</span></p>');
- html.push('</div>');
- html.push('</li>');
- });
- if(item.order_status=="10"){
- html.push('<li class="mui-table-view-cell">');
- html.push('<div class="mui-pull-right">');
- html.push('<button type="button" class="fukuan mui-btn mui-btn-primary">去付款</button>');
- html.push('</div>');
- html.push('</li>');
- }if(item.order_status=="20"){
- html.push('<li class="mui-table-view-cell">');
- html.push('<div class="mui-pull-right">');
- if (item.list[0]&&item.list[0].order_num&&!item.order_date) {
- html.push('<button type="button" class="fukuan mui-btn mui-btn-primary">去预约</button>');
- }else {
- html.push('<button type="button" class="fukuan mui-btn mui-btn-primary">去使用</button>');
- }
- html.push('</div>');
- html.push('</li>');
- }else if(item.order_status=="30"){
- if(item.comment_flag!="1"){
- html.push('<li class="mui-table-view-cell">');
- html.push('<div class="mui-pull-right">');
- html.push('<button type="button" class="pingjia mui-btn mui-btn-primary">去评价</button>');
- html.push('</div>');
- html.push('</li>');
- }
- }
-
- html.push('</ul>');
- });
- }
- $("#item"+($('[orderStatus="'+orderStatus+'"]').index()+1)).html(html.join(""));
- if($("#item"+($('[orderStatus="'+orderStatus+'"]').index()+1)+" .mui-table-view").length==0){
- mobile.tip("#item"+($('[orderStatus="'+orderStatus+'"]').index()+1)+"","您还没有相关订单",'','');
- }
- });
- }
- function updateStatus(id,orderStatus){
- mobile.ajaxPost(base+'/userOrder/updateStatus',{
- id:id,orderStatus:orderStatus
- },function(json){
- layer.open({content: '操作成功',time: 3});
- getList();
- });
- }
|