2015-07-28 19:00:39 +08:00
|
|
|
<?php
|
|
|
|
|
namespace User\Controller;
|
|
|
|
|
use Think\Controller;
|
|
|
|
|
|
|
|
|
|
/**
|
2016-01-24 11:54:16 +08:00
|
|
|
* @author Zhou Yuyang <1009465756@qq.com> 12:28 2016/1/23
|
|
|
|
|
* @copyright 2105-2018 SRCMS
|
2015-07-28 19:00:39 +08:00
|
|
|
* @homepage http://www.src.pw
|
2016-01-24 11:54:16 +08:00
|
|
|
* @version 1.5
|
2015-07-28 19:00:39 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
class GiftController extends BaseController{
|
|
|
|
|
|
|
|
|
|
public function index(){
|
|
|
|
|
$gift = M('links')->select();
|
2016-01-25 10:53:12 +08:00
|
|
|
$tmodel= M('setting');
|
|
|
|
|
$title = $tmodel->where('id=1')->select();
|
|
|
|
|
$this->assign('title', $title);
|
2015-07-28 19:00:39 +08:00
|
|
|
$this->assign('gift',$gift);
|
|
|
|
|
$this->display();
|
|
|
|
|
}
|
2016-01-24 11:54:16 +08:00
|
|
|
|
|
|
|
|
public function add()
|
|
|
|
|
{
|
|
|
|
|
//默认显示添加表单
|
|
|
|
|
$id = session('userId');
|
|
|
|
|
$gid = I('get.gid',0,'intval');
|
|
|
|
|
if (!IS_POST) {
|
2016-01-25 10:53:12 +08:00
|
|
|
$tmodel= M('setting');
|
|
|
|
|
$title = $tmodel->where('id=1')->select();
|
|
|
|
|
$this->assign('title', $title);
|
2016-01-24 11:54:16 +08:00
|
|
|
$info = M('info')->where('user_id='.$id)->select();
|
|
|
|
|
$gift = M('links')->where('id='.$gid)->select();
|
|
|
|
|
$this->assign('info',$info);
|
|
|
|
|
$this->assign('gift',$gift);
|
|
|
|
|
$this->display();
|
|
|
|
|
}
|
|
|
|
|
if (IS_POST) {
|
|
|
|
|
//如果用户提交数据
|
|
|
|
|
$model = D("order");
|
|
|
|
|
$model->user_id = 1;
|
|
|
|
|
$model->username = 1;
|
2016-01-26 14:09:59 +08:00
|
|
|
if (!$model->field('username,email,password,repassword,gid')->create()) {
|
2016-01-24 11:54:16 +08:00
|
|
|
// 如果创建失败 表示验证没有通过 输出错误提示信息
|
|
|
|
|
$this->error($model->getError());
|
|
|
|
|
exit();
|
|
|
|
|
} else {
|
|
|
|
|
if ($model->add()) {
|
|
|
|
|
$this->success("下单成功", U('index/index'));
|
|
|
|
|
} else {
|
|
|
|
|
$this->error("下单失败");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|