|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Admin\Controller;
|
|
|
|
|
|
|
|
use Think\Controller;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 猜你喜欢控制器
|
|
|
|
* @author 鹿文学
|
|
|
|
*/
|
|
|
|
class GuessController extends ThinkController {
|
|
|
|
|
|
|
|
const model_name = 'Guess';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 猜你喜欢列表
|
|
|
|
* @author 鹿文学
|
|
|
|
*/
|
|
|
|
public function lists(){
|
|
|
|
|
|
|
|
if(!empty($_REQUEST['title'])) {$extend['title']=$_REQUEST['title'];}
|
|
|
|
|
|
|
|
|
|
|
|
$this->m_title = '猜你喜欢';
|
|
|
|
$this->m_url = 'Guess/lists';
|
|
|
|
$this->assign('commonset',M('Kuaijieicon')->where(['url'=>'Merchandise/lists','status'=>1])->find());
|
|
|
|
|
|
|
|
$extend['status'] = 1;
|
|
|
|
|
|
|
|
parent::lists(self::model_name,$_GET['p'],$extend);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 添加猜你喜欢
|
|
|
|
* @author 鹿文学
|
|
|
|
*/
|
|
|
|
public function add() {
|
|
|
|
if(IS_POST) {
|
|
|
|
|
|
|
|
$notice = D(self::model_name);
|
|
|
|
|
|
|
|
if(!empty($_REQUEST['start_time']) && !empty($_REQUEST['end_time'])) {
|
|
|
|
if(strtotime($_REQUEST['start_time'])>=strtotime($_REQUEST['end_time'])) {
|
|
|
|
$this->error('开始时间必须小于结束时间');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(empty($_POST['start_time'])) {
|
|
|
|
$this->error('开始时间不能为空');
|
|
|
|
}
|
|
|
|
|
|
|
|
!empty($_POST['start_time']) || $_POST['start_time'] = date('Y-m-d H:i');
|
|
|
|
|
|
|
|
if($notice->update($_POST)) {
|
|
|
|
$this->success('新增成功',U('lists'));
|
|
|
|
} else {
|
|
|
|
$this->error($notice->getError());
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
$this->meta_title = '新增链接';
|
|
|
|
|
|
|
|
$this->m_title = '猜你喜欢';
|
|
|
|
$this->m_url = 'Guess/lists';
|
|
|
|
$this->assign('commonset',M('Kuaijieicon')->where(['url'=>'Notice/lists','status'=>1])->find());
|
|
|
|
|
|
|
|
|
|
|
|
$this->display();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 编辑猜你喜欢
|
|
|
|
* @author 鹿文学
|
|
|
|
*/
|
|
|
|
public function edit() {
|
|
|
|
if(IS_POST) {
|
|
|
|
|
|
|
|
$notice = D(self::model_name);
|
|
|
|
|
|
|
|
if(!empty($_REQUEST['start_time']) && !empty($_REQUEST['end_time'])) {
|
|
|
|
if(strtotime($_REQUEST['start_time'])>=strtotime($_REQUEST['end_time'])) {
|
|
|
|
$this->error('开始时间必须小于结束时间');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(empty($_POST['start_time'])) {
|
|
|
|
$this->error('开始时间不能为空');
|
|
|
|
}
|
|
|
|
|
|
|
|
if($notice->update($_POST)) {
|
|
|
|
$this->success('编辑成功',U('lists'));
|
|
|
|
} else {
|
|
|
|
$this->error($notice->getError());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
$map['id'] = $_REQUEST['id'];
|
|
|
|
$data = D(self::model_name)->where($map)->find();
|
|
|
|
// if(!empty($data['icon'])) {
|
|
|
|
// $data['icon_data'] = explode(',', $data['icon']);
|
|
|
|
// }
|
|
|
|
if(!empty($data['icon'])) {
|
|
|
|
$valueArr = explode(',', $data['icon']);
|
|
|
|
$str = '';
|
|
|
|
foreach ($valueArr as $key1 => $value1) {
|
|
|
|
$a = get_cover($value1, 'path');
|
|
|
|
$str .= $a.',';
|
|
|
|
}
|
|
|
|
$data['valuedata'] = rtrim($str, ',');
|
|
|
|
}
|
|
|
|
$this->assign('data',$data);
|
|
|
|
|
|
|
|
$this->meta_title = '编辑链接';
|
|
|
|
|
|
|
|
$this->m_title = '猜你喜欢';
|
|
|
|
$this->m_url = 'Guess/lists';
|
|
|
|
$this->assign('commonset',M('Kuaijieicon')->where(['url'=>'Notice/lists','status'=>1])->find());
|
|
|
|
|
|
|
|
|
|
|
|
$this->display();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 删除猜你喜欢
|
|
|
|
* @param array/integer $ids 要删除的猜你喜欢编号
|
|
|
|
* @author 鹿文学
|
|
|
|
*/
|
|
|
|
public function del($ids=null){
|
|
|
|
$model = M('Model')->getByName(self::model_name); /*通过Model名称获取Model完整信息*/
|
|
|
|
parent::del($model["id"],$ids);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 更改猜你喜欢优先级
|
|
|
|
* @param integer $id 猜你喜欢编号
|
|
|
|
* @param integer $value 优先级数值
|
|
|
|
* @author 鹿文学
|
|
|
|
*/
|
|
|
|
public function change_value($id,$value) {
|
|
|
|
if(IS_POST) {
|
|
|
|
if(!is_numeric($id) || $id<1) {$this->ajaxReturn(['status'=>0,'info'=>'数据有误'],'json');}
|
|
|
|
if(!is_numeric($value) || $value<1) {$this->ajaxReturn(['status'=>0,'info'=>'请输入正整数'],'json');}
|
|
|
|
|
|
|
|
$result = D(self::model_name)->where(['id'=>$id])->setField('sort',$value);
|
|
|
|
if($result) {
|
|
|
|
$this->ajaxReturn(['status'=>1,'info'=>'排序修改成功'],'json');
|
|
|
|
} else {
|
|
|
|
$this->ajaxReturn(['status'=>0,'info'=>'排序修改失败'],'json');
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
$this->ajaxReturn(['status'=>0,'info'=>'请求有误'],'json');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|