search-高级搜索
<?php if ( ! defined('BASEPATH')) exit('Webmeng Warning ! No direct script access allowed.');
class Search extends CI_Controller {
function __construct()
{
parent::__construct();
$this->load->helper('comfun');
}
public function _remap()
{
$m= $this->uri->rsegment(2); //调用的方法名称
if(method_exists($this,$m)){ //如果存在该方法,则直接调用
call_user_func_array(array($this, $m), array_slice($this->uri->rsegments, 2));
}else{
call_user_func_array(array($this,"_details"),array_slice($this->uri->rsegments, 1)); //调用函数的替代方法*/
}
}
public function _details($id)
{
$id = (int) $id;
$data['id'] = $id;
$content = '';
$app_id = $this->session->userdata('app_id');
if(!$app_id ){
header("Location:".site_url("login"));
}
$status = $this->db->fetch_one("select status from ".WEBMENG_CONMENG."user where id='".$app_id."' ");
if($status!=1){
returnpage("您的账号还未通过审核,请耐心等待!",1);
}
$task_detail = $this->db->fetch("select * from ".WEBMENG_CONMENG."task where uid='".$app_id."' and pid='".$id."' and status=0 and t_status =1 ",true);
if(!empty($task_detail)){ //已存在
$content = $this->db->fetch_one("select content from ".WEBMENG_CONMENG."comment where pid='".$id."' and id='".$task_detail['cid']."' ");
}else{
// 同一个任务 一天只能领取一个任务,一个月只能领取3次
$today = strtotime(date("Y-m-d"));
$sql ="select count(*) from ".WEBMENG_CONMENG."task where opertime>='".$today."' and pid='".$id."' and uid='".$app_id."' and t_status>0 ";
$today_nums= $this->db->fetch_one($sql);
if($today_nums>0){
returnpage("相同任务一天只能领取一次",1);
}
$first_day = strtotime(date('Y-m-01')); //当月第一天
$last_day = strtotime(date('Y-m-t')); //当月最后一天
$sql ="select count(*) from ".WEBMENG_CONMENG."task where opertime>='".$first_day."' and opertime<='".$last_day."' and uid='".$app_id."' and pid='".$id."' and t_status>0 ";
$month_nums= $this->db->fetch_one($sql);
if($month_nums>3){
returnpage("相同任务一个月只能领取3次",1);
}
$p_nums = $this->db->fetch_one("select p_nums from ".WEBMENG_CONMENG."product where id='".$id."' ");
if($p_nums>=1){
$p_nums --;
$this->db->update("product",array("p_nums"=>$p_nums),array("id"=>$id));
}else{
returnpage("任务已领取完",1);
}
$comment_info = $this->db->fetch("select id,content from ".WEBMENG_CONMENG."comment where status=1 and pid='".$id."' order by id asc limit 1 ",true);
$cid = isset($comment_info['id'])?$comment_info['id']:0;
$content = isset($comment_info['content'])?$comment_info['content']:'';
$t_data = array(
'uid' => $app_id,
'pid' => $id,
'cid' => $cid,
'opertime'=> time()
);
$result = $this->db->insert('task',$t_data);
if($result){
if($cid){
$this->db->update("comment",array("status"=>2),array("id"=>$cid));
}
}
get_app_comment_nums($id);// 统计任务条数
}
$data['content'] = $content?$content:'填写有利于此app的评论内容!';
$data['detail'] = $this->db->fetch("select * from ".WEBMENG_CONMENG."product where id='".$id."' ",true);
if(!$data['detail']){ show_404(); }
$data['base'] =base_info();
$this->load->view('search/detail',$data);
}
public function cancel()
{
$pid=(int) $this->input->post('pid',true);
$app_id = $this->session->userdata('app_id');
$task_detail = $this->db->fetch("select * from ".WEBMENG_CONMENG."task where uid='".$app_id."' and pid='".$pid."' and status=0 and t_status =1 ",true);
if(empty($task_detail)){ return ''; }
$result = $this->db->update("task",array("t_status"=>0,"status"=>-1),array("id"=>$task_detail['id']));
if($result){
$this->db->query("update ".WEBMENG_CONMENG."product set p_nums=p_nums+1 where id='".$pid."' ");
$cid = $task_detail['cid'];
if($cid){
$this->db->update("comment",array("status"=>1),array("id"=>$cid));
}
get_app_comment_nums($pid);// 统计任务条数
echo 1;exit();
}
}
public function index()
{
$data['base'] =base_info();
$is_task_show = isset($data['base']['is_task_show'])?$data['base']['is_task_show']:'';
$status_info =array(); //任务状态
//我的任务
$my_task="";
$app_id = $this->session->userdata('app_id');
if($app_id){
$task =$this->db->fetch("select b.*,a.status as task_status from ".WEBMENG_CONMENG."task a left join ".WEBMENG_CONMENG."product b on a.pid=b.id where b.status=1 and a.uid='".$app_id."' and (a.status=0 or a.status=1 ) order by a.id desc ");
// print_r($task);
//操作状态 0已领取 1已申请 2已同意 3已拒绝
if(!empty($task)){
foreach ($task as $v) {
if($v['task_status']==0){
$status_info[$v['id']]= array('msg'=>'进行中','url'=>'');
}else if($v['task_status']==1){
$status_info[$v['id']]= array('msg'=>'审核中','url'=>'javascript:;');
}
}
}
$my_task =$this->_get_my_data($task,$is_task_show);
}
//print_r($status_info);
$data['my_task'] = $my_task;
//任务列表
$task =$this->db->fetch("select * from ".WEBMENG_CONMENG."product where status=1 ");
$data['task'] =$this->_get_data($task,$status_info,$is_task_show);
$this->load->view('search/index',$data);
}
public function _get_data($data,$status_info,$is_task_show)
{
$list='';
if(!empty($data)){
foreach ($data as $v) {
$list .='<div name="gradTask" task_id="255" class="list_box ">';
$list .=' <div class="list_box_left">';
$list .=' <dl class="left" style="width:140px;margin-left:15px;">';
$list .=' <div class="task_ico_cover"></div>';
$list .=' <div class="task_ico_avatar"><img height="120" width="120" src="'.$v['pic'].'"></div>';
$list .=' </dl>';
$list .=' <dl class="left">';
$list .=' <h2>'.$v['p_name'].'</h2>';
$list .=$is_task_show?' <h5>剩余量:'.$v['p_nums'].'</h5>':'';
$list .=' <h3 class="red">¥'.$v['p_price'].'</h3>';
$list .=' </dl>';
$list .=' </div>';
$list .=' <div class="list_box_right" style="padding-top:30px;">';
if(isset($status_info[$v['id']])){ //任务进行中,或审核中的
$url = $status_info[$v['id']]['url']?$status_info[$v['id']]['url']:site_url("list/".$v['id']);
$list .=' <a href="'.$url.'">';
$list .=' <div class="radius butten_red" name="gradTask1" task_id="'.$v['id'].'">'.$status_info[$v['id']]['msg'].'</div>';
$list .=' </a>';
}else{
if($v['p_nums']<1){
$list .=' <a href="javascript:;">';
$list .=' <div class="radius butten_red" name="gradTask1" task_id="'.$v['id'].'">已做完</div>';
$list .=' </a>';
}else{
$list .=' <a href="'.site_url("task/".$v['id']).'">';
$list .=' <div class="radius butten_red" name="gradTask1" task_id="'.$v['id'].'">抢单</div>';
$list .=' </a>';
}
}
$list .=' </div>';
$list .='</div>';
}
}
return $list;
}
public function _get_my_data($data,$is_task_show)
{
$list='';
if(!empty($data)){
foreach ($data as $v) {
$list .='<div name="gradTask" task_id="255" class="list_box ">';
$list .=' <div class="list_box_left">';
$list .=' <dl class="left" style="width:140px;margin-left:15px;">';
$list .=' <div class="task_ico_cover"></div>';
$list .=' <div class="task_ico_avatar"><img height="120" width="120" src="'.$v['pic'].'"></div>';
$list .=' </dl>';
$list .=' <dl class="left">';
$list .=' <h2>'.$v['p_name'].'</h2>';
$list .=$is_task_show?' <h5>剩余量:'.$v['p_nums'].'</h5>':'';
$list .=' <h3 class="red">¥'.$v['p_price'].'</h3>';
$list .=' </dl>';
$list .=' </div>';
$list .=' <div class="list_box_right" style="padding-top:30px;">';
//操作状态 0已领取 1已申请 2已同意 3已拒绝
switch($v['task_status']){
case 0:
$list .=' <a href="'.site_url("list/".$v['id']).'">';
$list .=' <div class="radius butten_red" name="gradTask1" task_id="'.$v['id'].'">进行中</div>';
$list .=' </a>';
break;
case 1:
$list .=' <a href="javascript:;">';
$list .=' <div class="radius butten_red" name="gradTask1" task_id="'.$v['id'].'">审核中</div>';
$list .=' </a>';
break;
case 2:
$list .=' <a href="javascript:;">';
$list .=' <div class="radius butten_red" name="gradTask1" task_id="'.$v['id'].'">已通过</div>';
$list .=' </a>';
break;
case 3:
$list .=' <a href="javascript:;">';
$list .=' <div class="radius butten_red" name="gradTask1" task_id="'.$v['id'].'">未通过</div>';
$list .=' </a>';
break;
}
$list .=' </div>';
$list .='</div>';
}
}
return $list;
}
public function upload()
{
$base64_string = $_POST['base64_string'];
$savename = uniqid().'.jpeg';//localResizeIMG压缩后的图片都是jpeg格式
$savepath =FCPATH. '/data/attachment/image/'.$savename;
$image =$this-> base64_to_img( $base64_string, $savepath );
if($image){
$image = WEB_SITE_URL.'/data/attachment/image/'.$savename;
echo '{"status":1,"content":"上传成功","url":"'.$image.'"}';
}else{
echo '{"status":0,"content":"上传失败"}';
}
}
function base64_to_img( $base64_string, $output_file ) {
$ifp = fopen( $output_file, "wb" );
fwrite( $ifp, base64_decode( $base64_string) );
fclose( $ifp );
return( $output_file );
}
public function apply()
{
$app_id = $this->session->userdata['app_id'];
$status = false;$msg="";
if(!$app_id){
$msg="未登录";
}else{
$pic = $this->input->post("pic",true);
$pid = $this->input->post("pid",true);
$pic = $pic?json_encode($pic):'';
$result = $this->db->update("task",array("pic"=>$pic,"status"=>1),array("uid"=>$app_id,"pid"=>$pid,"t_status"=>1,"status"=>0));
if($result){
$status = true;
$msg="提交成功";
}else{
$msg="提交失败";
}
}
echo json_encode(array('status'=>$status,'msg'=>$msg));exit();
}
function intro()
{
$data['content']=$this->db->fetch_one("select content from ".WEBMENG_CONMENG."aboutus where m_id=321 ",true);
$data['menu'] ="好评任务玩法介绍";
$data['base'] =base_info();
$this->load->view('cn/about',$data);
}
}
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:service@webmeng.net 进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。
以上信息是否解决您的问题?
相关问题
- 阿里云OSS云储存
- JS 早中晚 提示问候代码
- Webmeng X 2025 升级
- webmeng 循环 列出 数据
- PHP判断语句
- 这个工具,节省80%工作量不过分吧
- CodeIgnter 报错 The Encrypt library...
- WebmengWeb 2024 体验版下载
- liunx系统开启推送服务
- Webmeng2024内页升级大全-访问ID分类地区留言 | 推荐
- webmeng第5代升级
- Webmeng登录模块login
- phpstudy配置运行CI4框架
- CI4框架应用三 - app目录
- Webmeng404错误 模板路径
- PHP获取当前页面URL路径
- CI框架中的开启调试模式
- JS如何实现网站中PC端和手机端自动识别并跳转对应的代码
- JS---PC端和移动端的无缝切换
- pc端、手机端网页切换
- 关于smarty限制文字输出字数
- php smarty 限制显示字数,smarty现在显示字数的各种...
- nginx和apache的区别,选择哪个好?
- Webmeng系统在Nginx下载伪静态写法
- ci 地址去掉index.php,CI框架去掉index.php的方
- search-高级搜索
- Webmeng 2022 V13.0.1 下载地址
- wap手机网页html通过特殊链接:打电话,发短信,发邮件详细教程
- Webmeng分类导航标签,模板
- Webmeng模板路径
- Webmeng内页导航
- Webmeng三级分类
- Webmeng控制器统计实现
- PHP安装扩展mcrypt以及相关依赖项 【PHP安装PECL扩展...
- Webmeng配置字段调用
- 调用Webmeng统计数据
- PHP单页统计方法
- .PHP后缀去除方法
- WebmengSAAS 商品管理 - 新增商品
- Webmengshop 支付宝配置
餐厅介绍
自助餐厅
用户评论