|
|
|
<?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);
|
|
|
|
// if(!empty($data['cover'])) {
|
|
|
|
// $data['cover_data'] = explode(',', $data['cover']);
|
|
|
|
// }
|
|
|
|
if(!empty($data['cover'])) {
|
|
|
|
$valueArr = explode(',', $data['cover']);
|
|
|
|
$str = '';
|
|
|
|
foreach ($valueArr as $key1 => $value1) {
|
|
|
|
$a = get_cover($value1, 'path');
|
|
|
|
$str .= $a.',';
|
|
|
|
}
|
|
|
|
$data['valuedata'] = rtrim($str, ',');
|
|
|
|
}
|
|
|
|
$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("删除失败");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|