ajax订单支付,提示订单过期 (传递data为json格式)

来源:互联网 发布:爱奇艺视频for mac版 编辑:程序博客网 时间:2024/03/28 17:43


前台页面

<script>function ordering(shopid){var array=new Array();$("input[name='myid']").each(function(){if($(this).val()){array.push($(this).val());}})flag= 1;$.ajax({ type:'get',                                        async : false,url: "{:U('checkcartAjax')}", dataType: "json",data:"id="+array,success: function(msg){                                            //alert(msg);                                            //alert(msg.msgid);//alert(msg.html);                                            if(msg.msgid=='1004'){                                                 $("#jian2").html("促销商品:"+msg.html+' 已结束')$("#jian2").css("display",'block');function times(){$("#jian2").css("display",'none');clearInterval(timer);  } timer=setInterval(times,3000);                                             flag= 0;                                                                        }      //location.reload();}}); if(flag == 1){if(array.length >0){//window.location.href="index.php?s=/addon/WeiSite/WeiSite/orderlist/id/"+array;}else{alert('请选择商品');}} }function js_method(){javascript:void(0);return false;}</script>        <div class="pull-right qjs_right">        <a href="javascript:ordering()" >去结算</a>        </div>


 后台

//ajax 购物车提交前进行判断是否 存在过期促销商品    public function checkcartAjax(){    //商品促销  '$orderid'  'ORDER94490270'$id = I('id');$orderid=explode(',',$id); $shop_list = array();//var_dump($orderid);foreach($orderid as $val){if($val){$shop_list[]=M('shopp_cart')->where('id='.$val)->find();}}//var_dump($shop_list);die();if($shop_list){foreach($shop_list as $key=>$val){$specialPrice=M('goodsshop')->where('id='.$val['shopid'])->getField('promotion_id');$goodsname = M('goodsshop')->where('id='.$val['shopid'])->getField('goods_name');//var_dump(M('goodsshop')->getLastSql());die();//var_dump($specialPrice);die();if($specialPrice!='0'){$promo_state = M('goodspromotion')->where('id='.$specialPrice)->getField('state');//var_dump($promo_state);die();if($promo_state =='2' ){echo json_encode(array('msgid'=>'1004','html'=>$goodsname));exit();}}}}//echo json_encode(array('msgid'=>'1004','html'=>'8888'));    }


0 0
原创粉丝点击