News.php
3.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
<?php
/**
* tpshop
* ============================================================================
* 版权所有 2015-2027 深圳搜豹网络科技有限公司,并保留所有权利。
* 网站地址: http://www.tp-shop.cn
* ----------------------------------------------------------------------------
* 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用 .
* 不允许对程序代码以任何形式任何目的的再发布。
* ============================================================================
* Author: 当燃
* Date: 2015-09-09
*/
namespace app\admin\controller;
use think\Page;
use app\admin\logic\ArticleCatLogic;
use think\Db;
use qcloudcos\Conf;
use qcloudcos\Myqcloudcos;
class News extends Base {
public function _initialize()
{
parent::_initialize();
}
public function newslist(){
$Article = M('news');
$pagenum=20;//每页显示多少条
$list = array();
$p = input('p/d', 1);
$size = input('size/d', $pagenum);
$where = array();
/*--添加门店ID--*/
$keywords = trim(urldecode(urldecode(I('keywords'))));
$keywords && $where['title'] = array('like', '%' . $keywords . '%');
$res = $Article->where($where)->order('add_time desc')->page("$p,$size")->select();
$count = $Article->where($where)->count();// 查询满足要求的总记录数
$pager = new Page($count,$size);// 实例化分页类 传入总记录数和每页显示的记录数
$page = $pager->show();//分页显示输出
$this->assign('keywords',$keywords);
$this->assign('list',$res);// 赋值数据集
$this->assign('page',$page);// 赋值分页输出
$this->assign('pager',$pager);
$this->assign('store_id',getAdmStoId());
$this->assign('pagenum',$pagenum);
$this->assign('oldurl',urlencode(curPageURL()));
// upload_ylp_log('文章列表');
return $this->fetch('',getAdmStoId());
}
public function newsdetail(){
$newsid = I('newsid/d');
if($newsid){
$info = D('news')->where('article_id', $newsid)->find();
if ($info)
{
M('news')->where('article_id',$newsid)->setInc('click',1);
$readnews=M('news_readlist')->where(array('store_id'=>getAdmStoId(),'admin_id'=>getAdminId(),'news_id'=>$info['article_id']))->find();
if (empty($readnews)) {
$data['store_id']=getAdmStoId();
$data['admin_id']=getAdminId();
$data['news_id']=$info['article_id'];
$data['add_time']=time();
M('news_readlist')->save($data);
}
}
}
$this->assign('info',$info);
return $this->fetch('',getAdmStoId());
}
public function readnews(){
$newsid = I('newsid/d');
if($newsid)
{
$data['store_id']=getAdmStoId();
$data['admin_id']=getAdminId();
$data['news_id']=$newsid;
$data['add_time']=time();
M('news_readlist')->save($data);
return "1";
}
}
}