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


前台页面

<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
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值