Userqy.php
9.04 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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
<?php
/**
* tpshop
* ============================================================================
* 版权所有 2015-2027 深圳搜豹网络科技有限公司,并保留所有权利。
* 网站地址: http://www.tp-shop.cn
* ----------------------------------------------------------------------------
* 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用 .
* 不允许对程序代码以任何形式任何目的的再发布。
* ============================================================================
* Author: IT宇宙人
* Date: 2015-09-09
*/
namespace app\manager\controller;
use think\AjaxPage;
use think\Page;
class Userqy extends Base
{
/*列表*/
public function imglist()
{
$pagenum = I('pagenum/d', 10);
$type = I('type');
$key_word = I('key_word') ? trim(I('key_word')) : ''; // 关键词搜索
$cur_page = I('p/d', 0);//当前页数
$typelist = M('qy_imgtype')->order('ordid asc')->select();
$this->assign("typelist", $typelist);
$this->assign('key_word', $key_word);
$this->assign('pagenum', $pagenum);
$this->assign('type', $type);
$this->assign('cur_page', $cur_page);
return $this->fetch();
}
public function ajaximglist()
{
$type_id = I('type_id');
$key_word = I('key_word');
$key_word = I('key_word') ? trim(I('key_word')) : ''; // 关键词搜索
$cur_page = I('p/d', 0);//当前页数
if ($cur_page <= 0) {
$cur_page = 1;
}
$pagenum = I('pagenum/d', 10);
$where = " 1=1 ";
if ($type_id) {
$where .= " and a.type_id=" . $type_id;
}
if ($key_word) {
$where .= " and a.title like '%$key_word%'";
}
$model = M('qy_imglist');
$count = $model->alias('a')->join('qy_imgtype b', 'a.type_id=b.id', 'left')
->where($where)->count();
$Page = new AjaxPage($count, $pagenum);
$show = $Page->show();
$List = $model->alias('a')->join('qy_imgtype b', 'a.type_id=b.id', 'left')
->where($where)->order("a.billdate desc")
->field('a.*,b.typename')
->limit($Page->firstRow . ',' . $Page->listRows)->select();
$oldurl = U('manager/Userqy/imglist', array(
"key_word" => $key_word,
"pagenum" => $pagenum,
"p" => $cur_page,
));
$this->assign('oldurl', urlencode($oldurl));
$this->assign('key_word', $key_word);
$this->assign('pagenum', $pagenum);
$this->assign('type_id', $type_id);
$this->assign('cur_page', $cur_page);
$this->assign('List', $List);
$this->assign('page', $show);// 赋值分页输出
$this->assign('pager', $Page);
return $this->fetch();
}
public function addimg()
{
$typelist = M('qy_imgtype')->order('ordid asc')->select();
$this->assign("typelist", $typelist);
$getId = I('id');
if ($getId) {
$info = M('qy_imglist')->where(array('id' => $getId))->find();
if ($info) {
}
} else {
$info["isshow"] = 1;
}
$this->assign("info", $info);
return $this->fetch();
}
//提交保存
public function imghandle()
{
$postdata = I('POST.');
$getId = $postdata['id'];
if ($getId) {
unset($postdata['id']);
$mid = session('manager_id');
$rr = M("manager_admin")->where("manager_id", $mid)->find();
$postdata['editman'] = $rr['manager_name'];
$postdata['editdate'] = time();
M('qy_imglist')->where(array('id' => $getId))->save($postdata);
return json(['code' => 1]);
}
$postdata['billdate'] = time();
M('qy_imglist')->save($postdata);
return json(['code' => 1]);
//新增
}
/**
* 模板类型列表
* @return wxsendtype
*/
public function imgtype()
{
$model = M('qy_imgtype');
$list = array();
$pagenum = 20;//每页显示多少条
if ((int)I('pagenum/s') > 0) {
$pagenum = I('pagenum/s');
}
$keywords = I('keywords/s');
if ($keywords) {
$where['typename'] = array(['like', '%' . $keywords . '%']);;
}
$count = $model->where($where)->count();
$Page = $pager = new Page($count, $pagenum);
$list = $model->where($where)->limit($Page->firstRow . ',' . $Page->listRows)->order('ordid asc')->select();
$show = $Page->show();
$this->assign('keywords', $keywords);
$this->assign('list', $list);// 赋值数据集
$this->assign('page', $show);// 赋值分页输出
$this->assign('pager', $pager);
$this->assign('pagenum', $pagenum);
$this->assign('oldurl', urlencode(curPageURL()));
return $this->fetch();
}
//添加微信模板
public function addimgtype()
{
$oldurl = I('oldurl/s');
if ($oldurl) {
$oldurl = urldecode(urldecode($oldurl));
}
$getstoid = getAdmStoId();
$id = I('id');
$wxsend = M('qy_imgtype')->where(array('id' => $id))->find();
if (empty($wxsend)) {
$getmaxordid = 1;
$maxordid = M('qy_imgtype')->max('ordid');
if ($maxordid) {
$getmaxordid = $maxordid + 1;
}
$wxsend['ordid'] = $getmaxordid;
}
if (IS_POST) {
$data = input('post.');
if ($id) {
$data['id'] = $id;
M("qy_imgtype")->update($data);
} else {
$sendlist = M('qy_imgtype')->where(array('id' => $id))->find();
if ($sendlist) {
$this->error('该分类已存在!', U('Manager/Userqy/addimgtype'));
exit();
} else {
M("qy_imgtype")->insert($data);
}
}
if ($oldurl) {
$this->success("操作成功!!!", $oldurl);
} else {
$this->success("操作成功!!!", U('Manager/Userqy/addimgtype'));
}
exit;
}
$this->assign('wxsend', $wxsend);
return $this->fetch('', getAdmStoId());
}
//删除
public function delimgtype()
{
$getid = I('id/d');
$modelist = M('qy_imglist')->where(array('type_id' => $getid))->count();
if ($modelist > 0) {
$return_arr = array('status' => -1, 'msg' => '删除失败,此类型已存在记录', 'data' => '',); //$return_arr = array('status' => -1,'msg' => '删除失败','data' =>'',);
$this->ajaxReturn($return_arr);
}
$deltype = M("qy_imgtype")->where(array('id' => $getid))->delete();
if ($deltype) {
$return_arr = array('status' => 1, 'msg' => '操作成功', 'data' => '',); //$return_arr = array('status' => -1,'msg' => '删除失败','data' =>'',);
} else {
$return_arr = array('status' => -1, 'msg' => '删除失败', 'data' => '',);
}
$this->ajaxReturn($return_arr);
}
public function delimglist()
{
$getid = I('id/d');
$modelist = M('qy_imglist')->where(array('id' => $getid))->count();
if (empty($modelist)) {
$return_arr = array('status' => -1, 'msg' => '删除失败,存在记录', 'data' => '',);
$this->ajaxReturn($return_arr);
}
$deltype = M("qy_imglist")->where(array('id' => $getid))->delete();
if ($deltype) {
$return_arr = array('status' => 1, 'msg' => '操作成功', 'data' => '',);
} else {
$return_arr = array('status' => -1, 'msg' => '删除失败', 'data' => '',);
}
$this->ajaxReturn($return_arr);
}
/**
* 初始化编辑器链接
* 本编辑器参考 地址 http://fex.baidu.com/ueditor/
*/
private
function initEditor()
{
$this->assign("URL_upload", U('admin/Ueditor/imageUp', array('savepath' => 'goods', 'savepath1' => getERPId()))); // 图片上传目录
$this->assign("URL_imageUp", U('admin/Ueditor/imageUp', array('savepath' => 'goods', 'savepath1' => getERPId()))); // 不知道啥图片
$this->assign("URL_fileUp", U('admin/Ueditor/fileUp', array('savepath' => 'goods', 'savepath1' => getERPId()))); // 文件上传s
$this->assign("URL_scrawlUp", U('admin/Ueditor/scrawlUp', array('savepath' => 'goods', 'savepath1' => getERPId()))); // 图片流
$this->assign("URL_getRemoteImage", U('admin/Ueditor/getRemoteImage', array('savepath' => 'goods', 'savepath1' => getERPId()))); // 远程图片管理
$this->assign("URL_imageManager", U('admin/Ueditor/imageManager', array('savepath' => 'goods', 'savepath1' => getERPId()))); // 图片管理
$this->assign("URL_getMovie", U('admin/Ueditor/getMovie', array('savepath' => 'goods', 'savepath1' => getERPId()))); // 视频上传
$this->assign("URL_Home", "");
}
}