You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
103 lines
2.2 KiB
PHTML
103 lines
2.2 KiB
PHTML
2 years ago
|
<?php
|
||
|
/**
|
||
|
* Created by PhpStorm.
|
||
|
* User: xmy 280564871@qq.com
|
||
|
* Date: 2017/4/5
|
||
|
* Time: 19:47
|
||
|
*/
|
||
|
|
||
|
namespace Admin\Controller;
|
||
|
|
||
|
use Admin\Model\PointShopModel;
|
||
|
|
||
|
class PointShopController extends ThinkController
|
||
|
{
|
||
|
|
||
|
|
||
|
public function _initialize()
|
||
|
{
|
||
|
$this->meta_title = "积分商城";
|
||
|
return parent::_initialize(); // TODO: Change the autogenerated stub
|
||
|
}
|
||
|
|
||
|
public function lists($p=1)
|
||
|
{
|
||
|
$model = new PointShopModel();
|
||
|
$data = $model->getLists("","create_time desc",$p);
|
||
|
$this->assign("data",$data['data']);
|
||
|
|
||
|
//分页
|
||
|
$count = $data['count'];
|
||
|
|
||
|
if(isset($_REQUEST['row'])) {$row = $_REQUEST['row'];}else{$row = 10;}
|
||
|
$page = set_pagination($count,$row);
|
||
|
if($page) {$this->assign('_page', $page);}
|
||
|
|
||
|
$this->m_title = '积分商城';
|
||
|
$this->assign('commonset',M('Kuaijieicon')->where(['url'=>'PointType/lists','status'=>1])->find());
|
||
|
|
||
|
|
||
|
$this->display();
|
||
|
}
|
||
|
|
||
|
public function add()
|
||
|
{
|
||
|
if (IS_POST) {
|
||
|
$model = new PointShopModel();
|
||
|
if(I('post.point')<0){
|
||
|
$this->error("价格不能小于0");
|
||
|
}
|
||
|
$result = $model->saveData();
|
||
|
if ($result !== false) {
|
||
|
$this->success("添加成功!", U('lists'));
|
||
|
} else {
|
||
|
$this->error("添加失败:" . $model->getError());
|
||
|
}
|
||
|
} else {
|
||
|
|
||
|
$this->m_title = '积分商城';
|
||
|
$this->assign('commonset',M('Kuaijieicon')->where(['url'=>'PointType/lists','status'=>1])->find());
|
||
|
|
||
|
|
||
|
$this->display();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
public function edit($id)
|
||
|
{
|
||
|
$model = new PointShopModel();
|
||
|
if (IS_POST) {
|
||
|
if(I('post.point')<0){
|
||
|
$this->error("价格不能小于0");
|
||
|
}
|
||
|
$result = $model->saveData($id);
|
||
|
if ($result !== false) {
|
||
|
$this->success("编辑成功!", U('lists'));
|
||
|
} else {
|
||
|
$this->error("编辑失败:" . $model->getError());
|
||
|
}
|
||
|
} else {
|
||
|
$data = $model->getData($id);
|
||
|
$this->assign("data",$data);
|
||
|
|
||
|
|
||
|
$this->m_title = '积分商城';
|
||
|
$this->assign('commonset',M('Kuaijieicon')->where(['url'=>'PointType/lists','status'=>1])->find());
|
||
|
|
||
|
|
||
|
$this->display();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public function delete($ids){
|
||
|
$model = new PointShopModel();
|
||
|
$map['id'] = ['in',$ids];
|
||
|
$result = $model->where($map)->delete();
|
||
|
if ($result !== false){
|
||
|
$this->success("删除成功!", U('lists'));
|
||
|
}else{
|
||
|
$this->error("删除失败");
|
||
|
}
|
||
|
}
|
||
|
}
|