猫小怪

世人慌慌张张,不过图碎银几两。

 

写项目中积累的一些小笔记(2)

  1. <a href="javascript:void(0)" onclick="history.go(-1)">后退</a> ===>返回 上一页
  2. 返回另一个控制器内的页面
  3. 前台后台页面内内容获取 
    1.   (前台)
  4. 积分兑换(前台)
    1.    $('#morepay').click(function(){
         var payid = {$payid};//前台获取后台的数据,渲染到前台页面
         $.ajax({

            type:"GET",

            url:"{:U('huan')}",

            dataType:"json",

            data:{'payid':payid},

            success:function(json){

               if(json.success == 1){

                  layer.open({content: '兑换成功', time: 3});

               }else{

                  layer.open({content: '积分不足', time: 3});

               }
            },
            error:function(){
               layer.open({content: '发生通信错误,请稍候重试', time: 3});
            }
         });
      });
    2. function huan(){
              $arr = array();
              $pay_id = $_GET['payid'];
              $shop_order_detail = M('shop_order_detail');
              $user_id = $_SESSION['xigua_user_id'];
              $user = M('users');
              $user_jifen = $user -> field("jifen") -> where("user_id='$user_id'") -> find();
              $shop_jifen = $shop_order_detail -> field("jifen") -> where(" pay_id = '$pay_id' ")->find();
              if ( $shop_jifen<$user_jifen ){
                  $data['pay_time']=time();
                  $data['state']=1;//支付成功
                  $data['pay_type']=1;//积分兑换
                   $res = M('shop_order') -> where(" pay_id = ' $pay_id ' ")->save($data);
                  $arr['success'] = 1;
                  $user_fen['jifen'] = $user_jifen['jifen'] -  $shop_jifen['jifen'];
                  $ress = M('users')-> where("user_id='$user_id'") -> save($user_fen);
      //            dump($res);die;
              }else{
                  $arr['success'] = 0;
              }
              echo json_encode($arr);
          }
    3. 判断时间是否相同(时间戳转换为日期格式)  :  date('Y-m-d') == date('Y-m-d',$qtime['login_time'])
    4. 查询单个字段:  $qtime=$user->field('login_time')->where("user_id='$user_id'")->find();
    5. tp3 修改字段值 :  $res = M('users') -> where(" user_id = ' $user_id ' ")->save($data);

posted on 2020-06-08 20:58  猫小怪  阅读(105)  评论(0编辑  收藏  举报

导航