You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
316 lines
11 KiB
316 lines
11 KiB
<?php
|
|
|
|
defined('IN_IA') or exit('Access Denied');
|
|
class CultivateClassModuleUniapp extends Uniapp
|
|
{
|
|
/**
|
|
* 获取子页面全部自己分类
|
|
*/
|
|
public function getCultivateClassChildList()
|
|
{
|
|
global $_W, $_GPC;
|
|
|
|
$cc_id = $_GPC['cc_id'];
|
|
$storeid = $_GPC['storeid'];
|
|
|
|
if (!empty($storeid)) {
|
|
$list = Category::getStoreCategoryAll($storeid, $cc_id);
|
|
} else {
|
|
$list = Category::getChildCategoryAll($cc_id, ['id', 'name']);
|
|
}
|
|
|
|
$this->renderSuccess('数据返回成功', $list);
|
|
}
|
|
|
|
/**
|
|
* 获取子级分类数据
|
|
*/
|
|
public function getCultivateClassInfo()
|
|
{
|
|
global $_W, $_GPC;
|
|
|
|
$cc_id = $_GPC['cc_id'];
|
|
|
|
$list = Category::getSingleCategory($cc_id, ['id', 'name', 'advs']);
|
|
|
|
if ($list['advs']) {
|
|
$list['advs'] = unserialize($list['advs']);
|
|
foreach ($list['advs'] as &$val) $val['thumb'] = tomedia($val['thumb']);
|
|
}
|
|
|
|
$field = ['video_link', 'id', 'title', 'likeids', 'likenum', 'share','video_cover'];
|
|
$videoRes = Category::categoryVideoAll($list['id'], $field, true, $_W['mid']);
|
|
$list['video'] = $videoRes['list'];
|
|
|
|
$this->renderSuccess('数据返回成功', $list);
|
|
}
|
|
|
|
/**
|
|
* 获取招聘工作分类
|
|
*/
|
|
public function cultivateClassList()
|
|
{
|
|
global $_GPC;
|
|
if ($_GPC['job_type']) {
|
|
$list = Category::getCategoryRecruit($_GPC['job_type']);
|
|
$this->renderSuccess('数据返回成功', $list);
|
|
}
|
|
$this->renderError('分类参数不存在');
|
|
}
|
|
|
|
/**
|
|
* 获取商品类型分类
|
|
*/
|
|
public function getStoreCategory()
|
|
{
|
|
$list = Category::getStoreCategory();
|
|
$this->renderSuccess('数据返回成功', $list);
|
|
}
|
|
|
|
/**
|
|
* 获取商品类型子集分类
|
|
*/
|
|
public function getStoreCategoryChild()
|
|
{
|
|
global $_W, $_GPC;
|
|
$cc_id = $_GPC['cc_id'];
|
|
if (empty($cc_id) || !is_numeric($cc_id)) $this->renderError('缺少分类id');
|
|
$list = Category::getChildCategoryAll($cc_id, ['id', 'name']);
|
|
if ($list) $this->renderSuccess('数据返回成功', $list);
|
|
else $this->renderSuccess(2, '数据为空');
|
|
}
|
|
|
|
/**
|
|
* Comment: 分类视频点赞操作
|
|
* Author: whj
|
|
* Date: 2023/6/30 10:12
|
|
*/
|
|
public function fabulous()
|
|
{
|
|
global $_W, $_GPC;
|
|
#1、参数接收
|
|
$id = $_GPC['id'];
|
|
if (empty($id) || !is_numeric($id)) $this->renderError('缺少参数:id');//视频id
|
|
#2、获取帖子的点赞信息
|
|
$info = pdo_get(PDO_NAME . "cultivate_class_video", ['id' => $id], ['likeids', 'likenum']);
|
|
$ids = unserialize($info['likeids']);
|
|
$num = count($ids);
|
|
#3、判断是否为重复操作
|
|
if (is_array($ids) && $num > 0) {
|
|
if (in_array($_W['mid'], $ids)) {
|
|
#4、取消点赞的操作
|
|
$ids = array_flip($ids);
|
|
unset($ids[$_W['mid']]);
|
|
$ids = array_flip($ids);
|
|
$likenum = $info['likenum'] - 1;
|
|
} else {
|
|
$ids = array_values($ids);//初始化数组 重新生成键值 从0开始
|
|
$ids[$num] = $_W['mid'];
|
|
$likenum = $info['likenum'] + 1;
|
|
}
|
|
} else {
|
|
$ids[$num] = $_W['mid'];
|
|
$likenum = $info['likenum'] + 1;
|
|
}
|
|
#5、点赞成功的操作
|
|
$res = pdo_update(PDO_NAME . "cultivate_class_video", ['likeids' => serialize($ids), 'likenum' => $likenum], ['id' => $id]);
|
|
if ($res) $this->renderSuccess();
|
|
$this->renderError();
|
|
}
|
|
|
|
/**
|
|
* Comment: 分享时记录分享数量
|
|
* Author: zzw
|
|
* Date: 2023/6/30 10:30
|
|
*/
|
|
public function shareNum()
|
|
{
|
|
global $_W, $_GPC;
|
|
#1、参数获取
|
|
$id = $_GPC['id'] or $this->renderError('缺少参数:id');
|
|
#2、获取当前分享数量
|
|
$shareNum = pdo_getcolumn(PDO_NAME . "cultivate_class_video", ['id' => $id], 'share');
|
|
$totalNum = intval($shareNum) + 1;
|
|
#2、修改分享数量
|
|
pdo_update(PDO_NAME . "cultivate_class_video", ['share' => $totalNum], ['id' => $id]);
|
|
|
|
$this->renderSuccess('记录成功');
|
|
}
|
|
|
|
/**
|
|
* Comment: 评论接口
|
|
* Author: whj
|
|
* Date: 2023/6/30 10:30
|
|
*/
|
|
public function comment()
|
|
{
|
|
global $_W,$_GPC;
|
|
//判断是否绑定手机
|
|
$mastmobile = unserialize($_W['wlsetting']['userset']['plugin']);
|
|
if (empty($_W['wlmember']['mobile']) && in_array('private',$mastmobile)){
|
|
$this->renderError('未绑定手机号');
|
|
}
|
|
#1、参数接收
|
|
$video_id = $_GPC['video_id'] OR $this->renderError('缺少参数:video_id') ;//视频id
|
|
$text = $_GPC['text'] OR $this->renderError('请输入评论内容!') ;//评论内容
|
|
$pid = $_GPC['pid'] ?: 0;//父id
|
|
$oneid = $_GPC['oneid'] ?: 0;//第1级评论id
|
|
//判断文本内容是否非法
|
|
$textRes = Filter::init($text,$_W['source'],1);
|
|
if ($textRes['errno'] == 0) $this->renderError($textRes['message']);
|
|
#2、判断用户是否为黑名单用户
|
|
$this->checkBlack();
|
|
#3、评论信息拼装
|
|
$data['uniacid'] = $_W['uniacid'];
|
|
$data['aid'] = $_W['aid'];
|
|
$data['video_id'] = $video_id;
|
|
$data['content'] = base64_encode($text);
|
|
$data['mid'] = $_W['mid'];
|
|
$data['pid'] = $pid;
|
|
$data['oneid'] = $oneid;
|
|
$data['createtime'] = time();
|
|
//判断是否需要审核
|
|
$settings = Setting::wlsetting_read('comment_set');
|
|
if($settings['videoComment'] == 1) $data['status'] = 1;
|
|
#4、保存评论内容
|
|
$res = pdo_insert(PDO_NAME."cultivate_class_comment",$data);
|
|
if($res){
|
|
$cid = pdo_insertid();
|
|
# 回复帖子消息推送
|
|
if (!empty($pid)) {
|
|
$parentRes = pdo_get(PDO_NAME .'cultivate_class_comment',['id' => $pid],'mid');
|
|
Category::setReplyModelInfo($video_id,$cid,$_W['mid'],$parentRes['mid']);
|
|
}
|
|
$this->renderSuccess('评论成功',['cid' => $cid,'amid' => $data['mid']]);
|
|
} else {
|
|
$this->renderError('评论失败,请稍后重试');
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
* Comment: 编辑或删除评论信息
|
|
* Author: wlf
|
|
* Date: 2022/02/09 11:25
|
|
*/
|
|
public function changeComment(){
|
|
global $_W,$_GPC;
|
|
$this->checkBlack();
|
|
$id = $_GPC['id'] OR $this->renderError('缺少参数:id');//评论id
|
|
$type = $_GPC['type'] ? : 0; // 1修改 0删除
|
|
if($type > 0){
|
|
$text = $_GPC['text'] OR $this->renderError('请输入修改内容!');//评论内容
|
|
//判断文本内容是否非法
|
|
$textRes = Filter::init($text,$_W['source'],1);
|
|
if($textRes['errno'] == 0){
|
|
$this->renderError($textRes['message']);
|
|
}
|
|
$data['content'] = base64_encode($text);
|
|
//判断是否需要审核
|
|
$set = Setting::agentsetting_read('pocket');// <-- replace --> //
|
|
if($set['comment_reply'] == 1) $data['status'] = 0;
|
|
$res = pdo_update(PDO_NAME .'cultivate_class_comment',$data,['id' => $id]);
|
|
|
|
}else{
|
|
$res = $this->treeDeleteComment($id);
|
|
}
|
|
if($res > 0){
|
|
$this->renderSuccess('操作成功');
|
|
}else{
|
|
$this->renderError('操作失败,请稍后重试');
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 递归删除评论
|
|
* @param $id
|
|
* @return false|mixed
|
|
*/
|
|
protected function treeDeleteComment($id)
|
|
{
|
|
global $_W;
|
|
if (empty($id)) return false;
|
|
$arr = pdo_getall(PDO_NAME . 'cultivate_class_comment' , ['uniacid' => $_W['uniacid'] , 'pid' => $id]);
|
|
if (empty($arr)) return pdo_delete(PDO_NAME . 'cultivate_class_comment' , ['uniacid' => $_W['uniacid'] , 'id' => $id]);
|
|
foreach ($arr as $key => $value) {
|
|
if (!$this->treeDeleteComment($value['id'])) return false;
|
|
}
|
|
return pdo_delete(PDO_NAME . 'cultivate_class_comment' , ['uniacid' => $_W['uniacid'] , 'id' => $id]);
|
|
}
|
|
|
|
/**
|
|
* Comment: 判断用户是否被加入黑名单
|
|
* Author: wlf
|
|
* Date: 2020/06/28 16:28
|
|
*/
|
|
public function checkBlack(){
|
|
global $_W;
|
|
$flag = pdo_getcolumn(PDO_NAME.'pocket_blacklist',array('uniacid'=>$_W['uniacid'],'mid'=>$_W['mid'],'aid'=>$_W['aid']),'id');
|
|
if(!empty($flag)){
|
|
$tips = $_W['wlsetting']['userset']['black_desc'] ? : '您被禁止评论,请联系客服';
|
|
$this->renderError($tips);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 获取视频评论
|
|
* @return void
|
|
*/
|
|
public function getVideoComment()
|
|
{
|
|
global $_W,$_GPC;
|
|
|
|
$mid = $_W['mid'];
|
|
$oneid = $_GPC['oneid'] ?: 0;
|
|
$pindex = $_GPC['pindex'] ?: 1;
|
|
$psize = $_GPC['psize'] ?: 10;
|
|
$video_id = $_GPC['video_id'];
|
|
if (empty($video_id) || !is_numeric($video_id)) $this->renderError('缺少参数:video_id');
|
|
|
|
// 第一级评论
|
|
$commentWhere = ['aid' => $_W['aid'],'video_id' => $video_id,'oneid' => $oneid, 'status' => 1];
|
|
|
|
$commentData = Category::getVideoComment($commentWhere,$mid,$pindex,$psize);
|
|
$list = $commentData['list'];
|
|
$total = $commentData['total'];
|
|
$this->renderSuccess('数据返回成功',['list' => $list,'total' => $total]);
|
|
}
|
|
|
|
/**
|
|
* Comment: 分类视频点赞操作
|
|
* Author: whj
|
|
* Date: 2023/6/30 10:12
|
|
*/
|
|
public function commentFabulous()
|
|
{
|
|
global $_W, $_GPC;
|
|
#1、参数接收
|
|
$id = $_GPC['id'];
|
|
if (empty($id) || !is_numeric($id)) $this->renderError('缺少参数:id');//视频id
|
|
#2、获取帖子的点赞信息
|
|
$info = pdo_get(PDO_NAME . "cultivate_class_comment", ['id' => $id], ['likeids', 'likenum']);
|
|
$ids = unserialize($info['likeids']);
|
|
$num = count($ids);
|
|
#3、判断是否为重复操作
|
|
if (is_array($ids) && $num > 0) {
|
|
if (in_array($_W['mid'], $ids)) {
|
|
#4、取消点赞的操作
|
|
$ids = array_flip($ids);
|
|
unset($ids[$_W['mid']]);
|
|
$ids = array_flip($ids);
|
|
$likenum = $info['likenum'] - 1;
|
|
} else {
|
|
$ids = array_values($ids);//初始化数组 重新生成键值 从0开始
|
|
$ids[$num] = $_W['mid'];
|
|
$likenum = $info['likenum'] + 1;
|
|
}
|
|
} else {
|
|
$ids[$num] = $_W['mid'];
|
|
$likenum = $info['likenum'] + 1;
|
|
}
|
|
#5、点赞成功的操作
|
|
$res = pdo_update(PDO_NAME . "cultivate_class_comment", ['likeids' => serialize($ids), 'likenum' => $likenum], ['id' => $id]);
|
|
if ($res) $this->renderSuccess();
|
|
$this->renderError();
|
|
}
|
|
}
|