前面讲了1-6章,大概是关于前台部分功能,剩下一部分,现在也一起放上去,废话少说,直接上代码。
如果有什么疑问可以,找我,各位,我的扣是2360248-666
个人信息更新部分
public function update(){
$user = session("user");
$data['phone'] = $_POST['phone'];
$data['qq'] = $_POST['qq'];
$data['telephone'] = $_POST['telephone'];
$data['wechat'] = $_POST['wechat'];
$data['blog'] = $_POST['blog'];
$data['address'] = $_POST['address'];
$data['code'] = $_POST['code'];
$data['jurisdiction'] = $_POST['jurisdiction'];
$data['userid'] = $user['id'];
$info = M('contact_information')->where("userid=".$user['id'])->field('userid')->find();
if(empty($info)){
$s = M('contact_information')->add($data);
$this->assign("sysCall","添加成功!");
$this->assign("sysUrl",$_SERVER['HTTP_REFERER']);
$this->display("Login/loginInfo");
}else{
$d = M('contact_information')->where("userid=".$user['id'])->save($data);
$this->assign("sysCall","修改成功!");
$this->assign("sysUrl",$_SERVER['HTTP_REFERER']);
$this->display("Login/loginInfo");
}
}
修改内心独白
public function update(){
$mod = M("contact_information");
$user = session('user');
$data['monologue'] = $_POST['monologue'];
$data['userid'] = $user['id'];
$con = M('contact_information')->where("userid=".$user['id'])->field('userid')->find();
if(empty($con)){
D('UserParams')->where('userid='.$user['id'])->save(array('monolog'=>'1'));
$s = M('contact_information')->add($data);
$this->assign("sysCall","添加成功!");
$this->assign("sysUrl",$_SERVER['HTTP_REFERER']);
$this->display("Login/loginInfo");
}else{
$d = M('contact_information')->where("userid=".$user['id'])->save($data);
$this->assign("sysCall","修改成功!");
$this->assign("sysUrl",$_SERVER['HTTP_REFERER']);
$this->display("Login/loginInfo");
}
}
查询公告列表
public function index() {
$sql = "select no.id,no.type,no.title,no.display,no.views,no.addtime,ry.typename from yyw_notice no,yyw_notice_category ry where no.type=ry.id order by no.addtime desc limit 5";
$res = M()->query($sql);
$this->assign('data', $res);
$this->display();
}
public function activity($typeid) {
$where['b.typeid'] = $typeid;
$where['a.display'] = '1';
$info = D('Notice')
->field('a.id,a.type,a.title,a.content,a.display,a.views,a.addtime,b.typename')
->alias('a')
->join('yyw_notice_category as b on a.type=b.typeid','left')
->order("a.addtime desc")
->where($where)
->select();
$this->assign('activity',$info);
$this->display('Activity/index');
}
public function showActivity($id) {
$info = D('Notice')->where('id='.$id)->select();
// $info[0]['content'] = htmlentities($info[0]['content']);
$this->assign('info',$info);
$this->display('activity/showActivity');
}
//提供公告列表界面
public function lists($typeid='') {
$search = array();
$search['display'] = array('eq', 1);
if(!empty($typeid)){
$search['type'] = array('eq', $typeid);
}
//做标示输出class属性
$this->assign('iTag', $typeid);
//查到类型名称,列表
//$page->
$list = D('NoticeCategory')->field(array('typeid', 'typename'))->limit(6)->select();
$total = D('Notice')->where($search)->count();
$page = new \Think\Page($total, 10);
$data = D('Notice')->field(array('id', 'title', 'addtime'))->where($search)->order('addtime desc')->limit($page->firstRow, $page->listRows)->select();
//查询最新日记
$newDiary = D('Diary')->scope('show,new')->limit(10)->select();
$this->assign('newdiary',$newDiary);
//推荐会员
$userList = new UserListController();
$userList->recommend();
$this->assign('showPage', $page->show());
$this->assign('list', $list);
$this->assign('data', $data);
$this->display('lists');
}
//查看公告详细内容 并提供浏览次数的修改 并且找到他的上一篇跟下一篇
public function detail() {
$mod = D('Notice');
//先修改指定id的浏览次数
$views = $mod->field(array('id', 'views'))->find($_GET['id']);
$views['views']++;
$mod->data($views)->save();
//侧边栏的类别标题
$list = D('NoticeCategory')->field(array('typeid', 'typename'))->limit(6)->select();
$find = $mod->find($_GET['id']);
//显示把字符串转为HTML实体
$find['content'] = htmlspecialchars_decode($find['content'], ENT_HTML5);
//先取得他所有的字段
$fields = $mod->field('content', true)->find();
$resField = array_keys($fields);
//相关文章
$data = $mod->field(array('id', 'title'))->where('display=1')->order($resField[rand(0, count($resField))])->limit(8)->select();
//上方导航的 首页 >> $typename >> 正文
$type = D('NoticeCategory')->field(array('typeid', 'typename'))->where('typeid='.$find['type'])->find();
//dump($type);
//有了这个id号,找他的属于的类别,所有类别下的。上一篇 下一篇
$pointer = $mod->field(array('id'))->where('type='.$find['type'])->select();
$xMaxs = array();
$xMins = array();
foreach($pointer as $v) {
if($v['id'] > $_GET['id']) {
$xMaxs[] = $v['id'];
}
if($v['id'] < $_GET['id']){
$xMins[] = $v['id'];
}
}
$next = min($xMaxs);//下一条
$prev = max($xMins);//上一条
if($next){
$nextInfo = $mod->field(array('id', 'title'))->where('type='.$find['type'])->find($next);
$this->assign('next', $nextInfo);
}else{
$this->assign('next', '');
}
if($prev){
$prevInfo = $mod->field(array('id', 'title'))->where('type='.$find['type'])->find($prev);
$this->assign('prev', $prevInfo);
}else{
$this->assign('prev', '');
}
$this->assign('list', $list);
$this->assign('find', $find);
$this->assign('data', $data);
$this->assign('type', $type);
$this->display('detail');
}
}
查询积分记录列表
public function index() {
$mod = D('order');
$staTime = strtotime($_REQUEST['startDate']);
$endTime = strtotime($_REQUEST['endDate']);
//拼装搜索条件
$search = array();
$urlList= array();
$search['uid'] = array('eq', session('user')['id']);
$search['is_pay'] = array('eq', 1);
if($_REQUEST['startDate']) {
$search['addtime'] = array('egt', $staTime);
$urlList[] = "startDate={$_REQUEST['startDate']}";
}
if($_REQUEST['endDate']) {
$search['addtime'] = array('elt', $endTime);
$urlList[] = "endDate={$_REQUEST['endDate']}";
}
if($_REQUEST['startDate'] && $_REQUEST['endDate']) {
$search['addtime'] = array('between', array($staTime, $endTime));
$urlList[] = "startDate={$_REQUEST['startDate']}";
$urlList[] = "endDate={$_REQUEST['endDate']}";
}
if($_REQUEST['skeyword']) {
$search['order_name'] = array('like', "%{$_REQUEST['skeyword']}%");
$urlList[] = "skeyword={$_REQUEST['skeyword']}";
}
if(count($urlList) > 0) {
$url = '&'.implode('&', $urlList);
}
$newPoints = $mod->order('id desc')->limit(1)->where('uid='.session('user')['id'].' and is_pay=1')->select();
$total = $mod->where($search)->count();
$page = new \Home\Org\ShowPage($total, 5, $url);
$list = $mod
->field('a.orderno,a.order_id,a.pay_time,a.sum_money,a.order_name,b.uid_money,b.par_money,b.gran_money')
->alias('a')
->order('a.pay_time desc')
->join('yyw_consumption as b on a.order_id = b.order_id','left')
->limit($page->limit)
->where($search)
->select();
$this->assign('showPage', $page->fpage(array(0, 3, 4, 5, 6, 7, 8)));
$this->assign('list', $list);
$this->assign('newPoints', $newPoints[0]['points']);
$this->assign('skeyword', $_REQUEST['skeyword']);
$this->assign('startDate', $_REQUEST['startDate']);
$this->assign('endDate', $_REQUEST['endDate']);
$this->display();
}
}
检查是否支付成功
public function check_pay(){
$order = D('order')->where(['orderno'=>$_POST['orderno'],'is_pay'=>1])->find();
// var_dump($order);exit;
if (!empty($order) && $order['ordername']!=='vip300终身会员') {
if ($order['download_id']=='0') {
/*将单号存入cookie*/
cookie('tran_sn'.$order['file_id'],$order['tran_sn'],86400);
}
$data['error']=1;
$data['url']=U('User/view',['act'=>'userInfo']);
}
// else if (!empty($order) && $order['file_id']=='0' && $order['download_id']!=='0') {
// $data['error']=1;
// $data['url']=U('article/addArticle');
// }
else{
$data['error']=0;
$data['url']='';
}
echo json_encode($data);
}
}