1
0

first commit

This commit is contained in:
2020-08-06 14:58:51 +08:00
commit 17096657dc
780 changed files with 92857 additions and 0 deletions

View File

@@ -0,0 +1,135 @@
<?php
// +------------------------------------------------+
// |http://www.cjango.com |
// +------------------------------------------------+
// | 修复BUG不是一朝一夕的事情等我喝醉了再说吧 |
// +------------------------------------------------+
// | Author: 小陈叔叔 <Jason.Chen> |
// +------------------------------------------------+
namespace app\mobile\controller;
use app\common\model\Experience as ExperienceModel;
use app\common\model\MemberInfo as MemberInfoModel;
use app\common\service\Experience as ExperienceService;
class Experience extends _Init
{
public function _initialize()
{
parent::_initialize();
$this->nav = 5;
}
public function checkVip($title)
{
$info = MemberInfoModel::get(UID);
if (!$info->is_vip) {
return $this->error('您还不是vip不能' . $title, url('vip/index'));
}
}
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($id)
{
parent::shareArticle();
if (IS_POST) {
self::checkVip('评论');
$content = $this->request->post('content');
$res = ExperienceService::comment($id, UID, $content);
return $this->back($res);
} else {
$this->info = ExperienceModel::get($id);
$this->info->setInc('click');
return $this->fetch();
}
}
/**
* 点赞
* @param [type] $id [description]
* @return [type] [description]
*/
public function tags($id)
{
self::checkVip('点赞');
$res = ExperienceService::tags(UID, $id);
if ($res === true) {
return $this->success();
} 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);
}
}