写项目中积累的一些小笔记(2)
- <a href="javascript:void(0)" onclick="history.go(-1)">后退</a> ===>返回 上一页
- 返回另一个控制器内的页面
- 前台后台页面内内容获取
- (前台)
- 积分兑换(前台)
- $('#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});
}
});
}); - 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);
} - 判断时间是否相同(时间戳转换为日期格式) : date('Y-m-d') == date('Y-m-d',$qtime['login_time'])
- 查询单个字段: $qtime=$user->field('login_time')->where("user_id='$user_id'")->find();
- tp3 修改字段值 : $res = M('users') -> where(" user_id = ' $user_id ' ")->save($data);
- $('#morepay').click(function(){
只是一个小菜鸟,在不断完善自己的知识,如有不对,请指出问题