Example #1
0
 public function index()
 {
     $root = array();
     $root['response_code'] = 1;
     $root['kf_phone'] = $GLOBALS['m_config']['kf_phone'];
     //客服电话
     $root['kf_email'] = $GLOBALS['m_config']['kf_email'];
     //客服邮箱
     //关于我们(填文章ID)
     $root['about_info'] = intval($GLOBALS['m_config']['about_info']);
     $root['version'] = VERSION;
     //接口版本号int
     $root['page_size'] = PAGE_SIZE;
     //默认分页大小
     $root['program_title'] = $GLOBALS['m_config']['program_title'];
     $root['site_domain'] = str_replace("/mapi", "", SITE_DOMAIN . APP_ROOT);
     //站点域名;
     $root['site_domain'] = str_replace("http://", "", $root['site_domain']);
     //站点域名;
     $root['site_domain'] = str_replace("https://", "", $root['site_domain']);
     //站点域名;
     /*虚拟的累计项目总个数,支持总人数,项目支持总金额*/
     $virtual_effect = $GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "deal where is_effect = 1 and is_delete=0");
     $virtual_person = $GLOBALS['db']->getOne("select sum((support_count+virtual_person)) from " . DB_PREFIX . "deal_item");
     $virtual_money = $GLOBALS['db']->getOne("select sum((support_count+virtual_person)*price) from " . DB_PREFIX . "deal_item");
     $root['virtual_effect'] = $virtual_effect;
     //项目总个数
     $root['virtual_person'] = $virtual_person;
     //累计支持人
     $root['virtual_money'] = number_format($virtual_money, 2);
     //筹资总金额
     /*虚拟的累计项目总个数,支持总人数,项目支持总金额 结束*/
     /*取6个推荐项目*/
     $index_list = $GLOBALS['db']->getAll(" select * from " . DB_PREFIX . "deal where is_effect=1 and is_recommend=1 order by sort desc limit 0,6");
     $deal_list = array();
     $time = time();
     foreach ($index_list as $k => $v) {
         if ($v['image'] != '') {
             $v['image'] = get_abs_img_root_wap(get_spec_image($v['image'], 900, 480, 1));
         }
         if ($v['start_time'] > $time) {
             $tmp_start_day = ceil(($v['start_time'] - $time) / 86400);
             $v['show'] = "还有" . $tmp_start_day . "天开始";
         } elseif ($time > $v['end_time']) {
             $v['show'] = "已过期";
         } else {
             $tmp_end_day = ceil(($v['end_time'] - $time) / 86400);
             $v['show'] = "剩余" . $tmp_end_day . "天";
         }
         $deal_list[] = $v;
     }
     $GLOBALS['tmpl']->assign('deal_list', $deal_list);
     /*取3个专题*/
     $topic_list = $GLOBALS['db']->getAll("select * from " . DB_PREFIX . "zhuanti where state=1 order by sort desc limit 0,3");
     //获取所有分类
     $cates = getCateList();
     $GLOBALS['tmpl']->assign('topic_list', $topic_list);
     $GLOBALS['tmpl']->assign('cates', $cates);
     $GLOBALS['tmpl']->display("index.html");
 }
Example #2
0
 public function index()
 {
     $is_ap = $_REQUEST['isap'];
     //判断是否是爱前进积分商城
     //积分商城现判断用户合法性
     if ($is_ap == 1) {
         $this->ap_login();
     }
     $page_title = $is_ap == 1 ? "积分商城" : "推荐项目";
     //获取页码
     $p = $_REQUEST['p'] ? intval($_REQUEST['p']) : 1;
     $to_num = ($p - 1) * 10;
     $condition = " d.is_delete = 0 and d.is_effect = 1 ";
     if ($is_ap == 1) {
         $condition .= "and (d.is_ap = 1 or d.is_ap = 2) ";
     } else {
         $condition .= "and (d.is_ap = 0 or d.is_ap = 2) ";
     }
     //积分商城时需判断
     $limit = $to_num . ' , 10';
     /*
              * 增加搜索条件
              * 1.cate 分类搜索
              * 2.status 状态搜索
              *      status=1  已成功
                     status=2  失败
                     status=3  筹资中
                     status=4  长期项目
                     status=0  未开始
                     all 全部
                 3.keyword 关键字搜索
              * */
     if ($_REQUEST['keyword']) {
         //keyword
         $condition .= "and d.name like N'%";
         $condition .= urldecode($_REQUEST['keyword']) . "%' ";
         $page_title = "搜索结果";
     }
     if ($_REQUEST['cate']) {
         //cate
         $cates_condition = $_REQUEST['cate'] !== "all" ? explode(',', $_REQUEST['cate']) : "";
         if ($cates_condition) {
             $condition .= 'and (';
             for ($i = 0; $i < count($cates_condition); $i++) {
                 $condition .= ' d.cate_id = ';
                 $condition .= $cates_condition[$i];
                 if ($i < count($cates_condition) - 1) {
                     $condition .= ' or';
                 }
             }
             $condition .= ")";
         }
         $page_title = "搜索结果";
     }
     if (isset($_REQUEST['status'])) {
         //status
         $status = $_REQUEST['status'] !== "all" ? explode(',', $_REQUEST['status']) : "";
         $status_condition = "";
         if (!empty($status[0])) {
             foreach ($status as $key => $v) {
                 $status_condition .= $this->get_status_condition($v);
                 //获取该状态sql语句
                 if ($key != count($status) - 1) {
                     $status_condition .= ' or ';
                 }
             }
             $condition .= ' and ';
             $condition .= $status_condition;
             $page_title = "搜索结果";
         }
     }
     /*search condition END*/
     //        echo $condition;
     $result = get_deal_list($limit, $condition);
     $index_list = $result['list'];
     $deal_list = array();
     $time = time();
     foreach ($index_list as $k => $v) {
         if ($v['image'] != '') {
             $v['image'] = get_abs_img_root_wap(get_spec_image($v['image'], 560, 220, 1));
         }
         if ($v['start_time'] > $time) {
             $tmp_start_day = ceil(($v['start_time'] - $time) / 86400);
             $v['show'] = "还有" . $tmp_start_day . "天开始";
             $v['showtype'] = 1;
         } elseif ($time > $v['end_time']) {
             $v['show'] = "已过期";
             $v['showtype'] = 2;
         } else {
             $tmp_end_day = ceil(($v['end_time'] - $time) / 86400);
             $v['show'] = $tmp_end_day;
             $v['showtype'] = 3;
         }
         $v['cate_name'] = get_cate($v['cate_id']);
         //如果为积分商城,则将总数*ratio后显示
         if ($is_ap == 1) {
             $v['support_amount'] = (int) $v['support_amount'] * (int) $v['ap_ratio'];
             $v['limit_price'] = (int) $v['limit_price'] * (int) $v['ap_ratio'];
         }
         $deal_list[] = $v;
     }
     //获取页面分页数据
     // $alldealnum = $GLOBALS['db']->getRow(" select count(id) as num from ".DB_PREFIX."deal as d where ".$condition);
     $allPNum = ceil($result['rs_count'] / 10);
     $page = get_pages($allPNum);
     //获取所有分类
     $cates = getCateList();
     //        print_r($deal_list);
     $GLOBALS['tmpl']->assign('page', $page);
     //数量有待验证
     $GLOBALS['tmpl']->assign('result_count', ceil($result['rs_count']));
     $GLOBALS['tmpl']->assign('page_title', $page_title);
     $GLOBALS['tmpl']->assign('cates', $cates);
     $GLOBALS['tmpl']->assign('deal_list', $deal_list);
     if ($is_ap == 1) {
         $GLOBALS['tmpl']->display("ap_deals_index.html");
         exit;
     }
     $GLOBALS['tmpl']->display("deals_index.html");
 }
 public function index()
 {
     $root = array();
     $root['response_code'] = 1;
     $root['kf_phone'] = $GLOBALS['m_config']['kf_phone'];
     //客服电话
     $root['kf_email'] = $GLOBALS['m_config']['kf_email'];
     //客服邮箱
     //关于我们(填文章ID)
     $root['about_info'] = intval($GLOBALS['m_config']['about_info']);
     $root['version'] = VERSION;
     //接口版本号int
     $root['page_size'] = PAGE_SIZE;
     //默认分页大小
     $root['program_title'] = $GLOBALS['m_config']['program_title'];
     $root['site_domain'] = str_replace("/mapi", "", SITE_DOMAIN . APP_ROOT);
     //站点域名;
     $root['site_domain'] = str_replace("http://", "", $root['site_domain']);
     //站点域名;
     $root['site_domain'] = str_replace("https://", "", $root['site_domain']);
     //站点域名;
     /*虚拟的累计项目总个数,支持总人数,项目支持总金额*/
     $virtual_effect = $GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "deal where is_effect = 1 and is_delete=0");
     $virtual_person = $GLOBALS['db']->getOne("select sum((support_count+virtual_person)) from " . DB_PREFIX . "deal_item");
     $virtual_money = $GLOBALS['db']->getOne("select sum((support_count+virtual_person)*price) from " . DB_PREFIX . "deal_item");
     $root['virtual_effect'] = $virtual_effect;
     //项目总个数
     $root['virtual_person'] = $virtual_person;
     //累计支持人
     $root['virtual_money'] = number_format($virtual_money, 2);
     //筹资总金额
     /*虚拟的累计项目总个数,支持总人数,项目支持总金额 结束*/
     /*首页广告*/
     $adv_num = intval($GLOBALS['m_config']['adv_num']) ? $GLOBALS['m_config']['adv_num'] : 5;
     $index_list = $GLOBALS['db']->getAll(" select * from " . DB_PREFIX . "m_adv where status = 1  order by sort asc limit 0,{$adv_num}");
     $adv_list = array();
     foreach ($index_list as $k => $v) {
         if ($v['page'] == 'top') {
             if ($v['img'] != '') {
                 $v['img'] = get_abs_img_root_wap(get_spec_image($v['img'], 720, 396, 1));
             }
             if ($v['type'] == 1) {
                 $v['url'] = url_wap("article#index", array("id" => $v['data']));
             } elseif ($v['type'] == 2) {
                 $v['url'] = $v['data'];
             }
             $adv_list[] = $v;
         }
     }
     $GLOBALS['tmpl']->assign('adv_list', $adv_list);
     /*项目显示以及权限控制*/
     //===============首页项目列表START===================
     $page_size = $GLOBALS['m_config']['page_size'];
     $page = intval($_REQUEST['p']);
     $limit = "";
     $index_pro_num = $GLOBALS['m_config']['index_pro_num'];
     if ($index_pro_num > 0) {
         $limit = "  0,{$index_pro_num}";
     }
     $GLOBALS['tmpl']->assign("current_page", $page);
     //权限控制
     $new_condition = '';
     $hot_conditon = '';
     if (app_conf("INVEST_STATUS") == 1) {
         $new_condition = 'type=0';
         $hot_conditon = 'type=0';
     } elseif (app_conf("INVEST_STATUS") == 2) {
         $new_condition = 'type=1';
         $hot_conditon = 'type=1';
     } else {
         $new_condition = 'type=0';
         $hot_conditon = 'type=1';
     }
     $hot_conditon .= ' and is_hot=1 ';
     //最新的项目
     $deal_new_result = get_deal_list('0,4', $new_condition, 'id desc');
     $GLOBALS['tmpl']->assign("deal_new_list", $deal_new_result['list']);
     //热门的项目
     $deal_hot_result = get_deal_list('0,4', $hot_conditon, 'support_count desc');
     $GLOBALS['tmpl']->assign("deal_hot_list", $deal_hot_result['list']);
     $condition = " d.is_recommend=1 ";
     $now_time = get_gmtime();
     $deal_result = get_deal_list($limit, $condition);
     $deal_list = $deal_result['list'];
     $deal_count = $deal_result['rs_count'];
     //获取当前项目列表下的所有子项目
     $GLOBALS['tmpl']->assign("deal_count", $deal_count);
     $GLOBALS['tmpl']->assign("deal_list", $deal_list);
     $invest_status = app_conf("INVEST_STATUS");
     $GLOBALS['tmpl']->assign("invest_status", $invest_status);
     $GLOBALS['tmpl']->display("index.html");
 }