121 lines
3.3 KiB
PHP
121 lines
3.3 KiB
PHP
<?php
|
||
// +------------------------------------------------+
|
||
// |http://www.cjango.com |
|
||
// +------------------------------------------------+
|
||
// | 修复BUG不是一朝一夕的事情,等我喝醉了再说吧! |
|
||
// +------------------------------------------------+
|
||
// | Author: 小陈叔叔 <Jason.Chen> |
|
||
// +------------------------------------------------+
|
||
namespace app\mobile\controller;
|
||
|
||
use app\common\model\Experience as ExperienceModel;
|
||
use app\common\service\Experience as ExperienceService;
|
||
|
||
class Experience extends _Init
|
||
{
|
||
|
||
public function index()
|
||
{
|
||
$map = [
|
||
'pid' => 0,
|
||
'status' => 1,
|
||
];
|
||
$this->list = ExperienceModel::where($map)->order('id desc')->paginate(10);
|
||
|
||
if (IS_AJAX) {
|
||
if (count($this->list) > 0) {
|
||
return $this->success($this->fetch('experience/lists'));
|
||
} else {
|
||
return $this->error('已经到最后一页');
|
||
}
|
||
}
|
||
return $this->fetch();
|
||
}
|
||
|
||
/**
|
||
* 提交评论
|
||
* @param [type] $id [description]
|
||
* @return [type] [description]
|
||
*/
|
||
public function detail()
|
||
{
|
||
if (IS_POST) {
|
||
$content = $this->request->post('content');
|
||
$id = $this->request->post('id');
|
||
$res = ExperienceService::comment($id, UID, $content);
|
||
if ($res === true) {
|
||
$this->vo = ExperienceModel::get($id);
|
||
return $this->success($this->fetch('experience/comment'));
|
||
} else {
|
||
return $this->back($res);
|
||
}
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 点赞
|
||
* @param [type] $id [description]
|
||
* @return [type] [description]
|
||
*/
|
||
public function tags($id)
|
||
{
|
||
$res = ExperienceService::tags(UID, $id);
|
||
if ($res === true) {
|
||
$this->vo = ExperienceModel::get($id);
|
||
return $this->success($this->fetch('experience/tags'));
|
||
} else {
|
||
return $this->error($res);
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 我的分享
|
||
* @return [type] [description]
|
||
*/
|
||
public function mine()
|
||
{
|
||
$map = [
|
||
'pid' => 0,
|
||
'uid' => UID,
|
||
'status' => 1,
|
||
];
|
||
$this->list = ExperienceModel::where($map)->order('id desc')->paginate(10);
|
||
|
||
if (IS_AJAX) {
|
||
if (count($this->list) > 0) {
|
||
return $this->success($this->fetch('experience/minelists'));
|
||
} else {
|
||
return $this->error('已经到最后一页');
|
||
}
|
||
}
|
||
return $this->fetch();
|
||
}
|
||
|
||
public function add()
|
||
{
|
||
if (IS_POST) {
|
||
self::checkVip('添加信息');
|
||
$data = $this->request->post();
|
||
$res = ExperienceService::add($data, UID);
|
||
if ($res === true) {
|
||
return $this->success('添加成功!', url('Experience/index'));
|
||
} else {
|
||
return $this->error('添加失败!');
|
||
}
|
||
} else {
|
||
return $this->fetch();
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 删除
|
||
* @param [type] $id [description]
|
||
* @return [type] [description]
|
||
*/
|
||
public function del($id)
|
||
{
|
||
$res = ExperienceService::del($id, UID);
|
||
return $this->back($res);
|
||
}
|
||
}
|