Ejemplo n.º 1
0
 public function index()
 {
     $page = intval($GLOBALS['request']['page']);
     $city_name = strim($GLOBALS['request']['city_name']);
     //城市名称
     if ($page == 0) {
         $page = 1;
     }
     $page_size = PAGE_SIZE;
     $limit = ($page - 1) * $page_size . "," . $page_size;
     $event_list = $GLOBALS['db']->getAll("select * from " . DB_PREFIX . "deal_event order by sort desc limit " . $limit);
     $count = $GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "deal_event");
     foreach ($event_list as $k => $v) {
         $now = get_gmtime();
         $event_list[$k]['end_time'] = $v['event_end_time'];
         $event_list[$k]['url'] = url("shop", "deal_event#show", array("id" => $v['id']));
         $event_list[$k]['event_end_time'] = to_date($v['event_end_time'], 'Y-m-d');
         $event_list[$k]['icon'] = get_abs_img_root(make_img($v['icon'], 592, 215, 1));
         $event_list[$k]['sheng_time_format'] = to_date($v['event_end_time'] - $now, "d天h小时i分");
     }
     $page_total = ceil($count / $page_size);
     $root = array();
     $root['return'] = 1;
     $root['item'] = $event_list;
     $root['page'] = array("page" => $page, "page_total" => $page_total, "page_size" => $page_size);
     $root['page_title'] = "活动专题";
     $root['city_name'] = $city_name;
     output($root);
 }
Ejemplo n.º 2
0
 public function index()
 {
     if ($GLOBALS['request']['from'] == "wap") {
         require_once "index_wap.action.php";
         $obj = new index_wap();
         $obj->index();
     } else {
         $root = array();
         $root['return'] = 1;
         $ypoint = $m_latitude = doubleval($GLOBALS['request']['m_latitude']);
         //ypoint
         $xpoint = $m_longitude = doubleval($GLOBALS['request']['m_longitude']);
         //xpoint
         $pi = 3.14159265;
         //圆周率
         $r = 6378137;
         //地球平均半径(米)
         $root['m_latitude'] = $ypoint;
         $root['m_longitude'] = $xpoint;
         $city_id = intval($GLOBALS['request']['city_id']);
         if ($city_id == 0) {
             $city_id = intval($GLOBALS['city_id']);
         }
         $adv_list = $GLOBALS['cache']->get("MOBILE_INDEX_ADVS_" . intval($city_id));
         if ($adv_list === false || true) {
             $advs = $GLOBALS['db']->getAll(" select * from " . DB_PREFIX . "m_adv where mobile_type = 0 and city_id in (0," . intval($city_id) . ") and status = 1 order by sort desc ");
             $adv_list = array();
             foreach ($advs as $k => $v) {
                 $adv_list[$k]['id'] = $v['id'];
                 $adv_list[$k]['name'] = $v['name'];
                 //$adv_list[$k]['img'] = get_abs_img_root(get_spec_image($v['img'],640,120,1));
                 $adv_list[$k]['img'] = get_abs_img_root($v['img']);
                 $adv_list[$k]['type'] = $v['type'];
                 $adv_list[$k]['data'] = $v['data'] = unserialize($v['data']);
                 if ($v['type'] == 1) {
                     $tag_count = count($v['data']['tags']);
                     $adv_list[$k]['data']['count'] = $tag_count;
                 }
                 if (in_array($v['type'], array(9, 10, 11, 12, 13, 22))) {
                     if ($v['type'] == 9 || $v['type'] == 12 || $v['type'] == 13 || $v['type'] == 22) {
                         $adv_list[$k]['data']['cate_name'] = $GLOBALS['db']->getOne("select name from " . DB_PREFIX . "deal_cate where id = " . intval($v['data']['cate_id']));
                     } elseif ($v['type'] == 10) {
                         $adv_list[$k]['data']['cate_name'] = $GLOBALS['db']->getOne("select name from " . DB_PREFIX . "shop_cate where id = " . intval($v['data']['cate_id']));
                     } elseif ($v['type'] == 11) {
                         $adv_list[$k]['data']['cate_name'] = $GLOBALS['db']->getOne("select name from " . DB_PREFIX . "event_cate where id = " . intval($v['data']['cate_id']));
                     }
                     $adv_list[$k]['data']['cate_name'] = $adv_list[$k]['data']['cate_name'] ? $adv_list[$k]['data']['cate_name'] : "全部";
                 }
                 if ($adv_list[$k]['data'] === false) {
                     $adv_list[$k]['data'] = null;
                 }
             }
             $GLOBALS['cache']->set("MOBILE_INDEX_ADVS_" . intval($city_id), $adv_list, 300);
         }
         $root['advs'] = $adv_list;
         $indexs_list = $GLOBALS['cache']->get("MOBILE_INDEX_INDEX_" . intval($city_id));
         if ($indexs_list === false || true) {
             $indexs = $GLOBALS['db']->getAll(" select * from " . DB_PREFIX . "m_index where status = 1 and mobile_type=0 and city_id in (0," . intval($city_id) . ") order by sort desc ");
             $indexs_list = array();
             foreach ($indexs as $k => $v) {
                 $indexs_list[$k]['id'] = $v['id'];
                 $indexs_list[$k]['name'] = $v['name'];
                 $indexs_list[$k]['vice_name'] = $v['vice_name'];
                 $indexs_list[$k]['desc'] = $v['desc'];
                 $indexs_list[$k]['is_hot'] = $v['is_hot'];
                 $indexs_list[$k]['is_new'] = $v['is_new'];
                 $indexs_list[$k]['img'] = get_abs_img_root($v['img']);
                 $indexs_list[$k]['type'] = $v['type'];
                 $indexs_list[$k]['data'] = $v['data'] = unserialize($v['data']);
                 if ($v['type'] == 1) {
                     $tag_count = count($v['data']['tags']);
                     $indexs_list[$k]['data']['count'] = $tag_count;
                 }
                 if (in_array($v['type'], array(9, 10, 11, 12, 13, 22))) {
                     if ($v['type'] == 9 || $v['type'] == 12 || $v['type'] == 13 || $v['type'] == 22) {
                         $indexs_list[$k]['data']['cate_name'] = $GLOBALS['db']->getOne("select name from " . DB_PREFIX . "deal_cate where id = " . intval($v['data']['cate_id']));
                     } elseif ($v['type'] == 10) {
                         $indexs_list[$k]['data']['cate_name'] = $GLOBALS['db']->getOne("select name from " . DB_PREFIX . "shop_cate where id = " . intval($v['data']['cate_id']));
                     } elseif ($v['type'] == 11) {
                         $indexs_list[$k]['data']['cate_name'] = $GLOBALS['db']->getOne("select name from " . DB_PREFIX . "event_cate where id = " . intval($v['data']['cate_id']));
                     }
                     $indexs_list[$k]['data']['cate_name'] = $indexs_list[$k]['data']['cate_name'] ? $indexs_list[$k]['data']['cate_name'] : "全部";
                 }
                 if ($indexs_list[$k]['data'] === false) {
                     $indexs_list[$k]['data'] = null;
                 }
             }
             $GLOBALS['cache']->set("MOBILE_INDEX_INDEX_" . intval($city_id), $indexs_list, 300);
         }
         $root['indexs'] = $indexs_list;
         //推荐商家
         $indexs_supplier = $GLOBALS['cache']->get("MOBILE_INDEX_SUPPLIER_" . intval($city_id));
         if ($indexs_supplier === false) {
             $sql = "select id,name,preview from " . DB_PREFIX . "supplier_location where is_recommend=1  and is_effect=1 ";
             if ($city_id > 0) {
                 $ids = load_auto_cache("deal_city_belone_ids", array("city_id" => $city_id));
                 if ($ids) {
                     $sql .= " and city_id in (" . implode(",", $ids) . ")";
                 }
             }
             $sql .= '  order by sort desc limit 3';
             $indexs_supplier = $GLOBALS['db']->getAll($sql);
             foreach ($indexs_supplier as $k => $v) {
                 $indexs_supplier[$k]['preview'] = get_abs_img_root(make_img($v['preview'], 194, 110, 1));
             }
             $GLOBALS['cache']->set("MOBILE_INDEX_SUPPLIER_" . intval($city_id), $indexs_supplier, 300);
         }
         $root['supplier_list'] = $indexs_supplier;
         //推荐团购
         $indexs_deal = $GLOBALS['cache']->get("MOBILE_INDEX_DEAL_" . intval($city_id));
         if ($indexs_deal === false) {
             $now = get_gmtime();
             //buy_type 0普通团购;2在线订购;3秒杀抢团
             $sql = "select id,name,auto_order,sub_name,brief,cate_id,supplier_id,current_price,origin_price,img,begin_time,end_time,buy_type,buy_count " . ",ypoint,xpoint, 0 as distance " . " from " . DB_PREFIX . "deal where buy_type = 0 and publish_wait = 0 and is_shop=0 and is_recommend=1  and is_effect=1 and buy_status!=2 and begin_time<" . $now . " and (end_time = 0 or end_time > " . $now . ") ";
             if ($city_id > 0) {
                 $ids = load_auto_cache("deal_city_belone_ids", array("city_id" => $city_id));
                 if ($ids) {
                     $sql .= " and city_id in (" . implode(",", $ids) . ")";
                 }
             }
             $sql .= ' order by sort desc limit 10';
             $indexs_deal = $GLOBALS['db']->getAll($sql);
             foreach ($indexs_deal as $k => $v) {
                 $indexs_deal[$k]['current_price'] = round($v['current_price'], 2);
                 $indexs_deal[$k]['origin_price'] = round($v['origin_price'], 2);
                 //$indexs_deal[$k]['img']=get_abs_img_root(make_img($v['img'],108,67,1));
                 $indexs_deal[$k]['img'] = get_abs_img_root(make_img($v['img'], 108, 85, 1));
                 $indexs_deal[$k]['end_time_format'] = to_date($v['end_time']);
                 $indexs_deal[$k]['begin_time_format'] = to_date($v['begin_time']);
                 if (empty($v['brief'])) {
                     $indexs_deal[$k]['brief'] = $v['name'];
                 }
             }
             $GLOBALS['cache']->set("MOBILE_INDEX_DEAL_" . intval($city_id), $indexs_deal, 300);
         }
         $root['deal_list'] = $indexs_deal;
         //推荐商品
         $indexs_supplier_deal = $GLOBALS['cache']->get("MOBILE_INDEX_SUPPLIER_DEAL_" . intval($city_id));
         if ($indexs_supplier_deal === false) {
             //buy_type = 0 普通商品;1积分商品
             $sql = "select id,name,is_hot,sub_name,brief,cate_id,supplier_id,current_price,origin_price,img,begin_time,end_time,buy_type,buy_count from " . DB_PREFIX . "deal where buy_type = 0 and is_shop=1 and is_recommend=1  and is_effect=1  ";
             $sql .= ' order by sort desc limit 10';
             $indexs_supplier_deal = $GLOBALS['db']->getAll($sql);
             foreach ($indexs_supplier_deal as $k => $v) {
                 //$indexs_supplier_deal[$k]['img']=get_abs_img_root(make_img($v['img'],310,262,1));
                 $indexs_supplier_deal[$k]['img'] = get_abs_img_root(make_img($v['img'], 108, 85, 1));
                 $indexs_supplier_deal[$k]['current_price'] = round($v['current_price'], 2);
                 $indexs_supplier_deal[$k]['origin_price'] = round($v['origin_price'], 2);
                 if (empty($v['brief'])) {
                     $indexs_supplier_deal[$k]['brief'] = $v['name'];
                 }
             }
             $GLOBALS['cache']->set("MOBILE_INDEX_SUPPLIER_DEAL_" . intval($city_id), $indexs_supplier_deal, 300);
         }
         $root['supplier_deal_list'] = $indexs_supplier_deal;
         //推荐活动
         $indexs_event = $GLOBALS['cache']->get("MOBILE_INDEX_EVENT_" . intval($city_id));
         if ($indexs_event === false || true) {
             $now = get_gmtime();
             $sql = "select id,name,icon,event_begin_time,event_end_time" . ",ypoint,xpoint, 0 as distance " . " from " . DB_PREFIX . "event where  is_effect=1 and event_begin_time<" . $now . " and (event_end_time = 0 or event_end_time > " . $now . ") ";
             //is_recommend=1  and
             if ($city_id > 0) {
                 $ids = load_auto_cache("deal_city_belone_ids", array("city_id" => $city_id));
                 if ($ids) {
                     $sql .= " and city_id in (" . implode(",", $ids) . ")";
                 }
             }
             $sql .= ' order by sort desc limit 10';
             $indexs_event = $GLOBALS['db']->getAll($sql);
             foreach ($indexs_event as $k => $v) {
                 $indexs_event[$k]['icon'] = get_abs_img_root(make_img($v['icon'], 580, 215, 1));
                 $indexs_event[$k]['event_begin_time_format'] = to_date($v['event_begin_time']);
                 $indexs_event[$k]['event_end_time_format'] = to_date($v['event_end_time']);
                 $indexs_event[$k]['sheng_time_format'] = to_date($v['event_end_time'] - $now, "d天h小时i分");
             }
             $GLOBALS['cache']->set("MOBILE_INDEX_EVENT_" . intval($city_id), $indexs_event, 300);
         }
         $root['event_list'] = $indexs_event;
         //推荐优惠券
         $youhui_list = $GLOBALS['cache']->get("MOBILE_YOUHUI_LIST_" . intval($city_id));
         if ($youhui_list === false) {
             $sql = "select id, supplier_id as merchant_id,description,begin_time,youhui_type,total_num,end_time,name as title,list_brief as content,icon as merchant_logo,create_time,xpoint,ypoint,address as api_address,icon as image_1 " . ",0 as distance " . " from " . DB_PREFIX . "youhui";
             $now = get_gmtime();
             $where = " 1 = 1 and is_effect = 1 and begin_time<" . $now . " and (end_time = 0 or end_time > " . $now . ") ";
             if (intval($city_id) > 0) {
                 $ids = load_auto_cache("deal_city_belone_ids", array("city_id" => intval($city_id)));
                 if ($ids) {
                     $where .= " and city_id in (" . implode(",", $ids) . ")";
                 }
             }
             $sql .= " where " . $where;
             $sql .= " order by sort limit 0,10";
             $youhui_list = $GLOBALS['db']->getAll($sql);
             //$root['youhui_list_sql'] = $sql;
             foreach ($youhui_list as $k => $v) {
                 //$youhui_list[$k]['image_1']=get_abs_img_root($v['image_1']);
                 $youhui_list[$k]['image_1'] = get_abs_img_root(make_img($v['image_1'], 108, 85, 1));
                 $youhui_list[$k]['merchant_logo'] = $youhui_list[$k]['image_1'];
                 $youhui_list[$k]['begin_time'] = to_date($v['begin_time'], "Y-m-d");
             }
             $GLOBALS['cache']->set("MOBILE_YOUHUI_LIST_" . intval($city_id), $youhui_list, 300);
         }
         if ($youhui_list === false) {
             $root['youhui_list'] = array();
         } else {
             $root['youhui_list'] = $youhui_list;
         }
         /*首页推荐分类*/
         $indexs_cate = $GLOBALS['cache']->get("MOBILE_INDEX_QUAN_" . intval($city_id));
         if ($indexs_cate === false) {
             $indexs_cate = $GLOBALS['db']->getAll("select id,name,icon_img,recommend from " . DB_PREFIX . "deal_cate where recommend=1 and is_delete=0 and is_effect=1 and pid=0 order by sort desc limit 7");
             if ($indexs_cate) {
                 foreach ($indexs_cate as $k => $v) {
                     $indexs_cate[$k]['icon_img'] = get_abs_img_root($v['icon_img']);
                 }
             } else {
                 $indexs_cate = array();
             }
         }
         if ($indexs_cate === false) {
             $root['cates'] = array();
         } else {
             $root['cates'] = $indexs_cate;
         }
         $root['city_id'] = $city_id;
         output($root);
     }
 }
Ejemplo n.º 3
0
 public function index()
 {
     $city_name = strim($GLOBALS['request']['city_name']);
     //城市名称
     $root = array();
     $root['page_title'] = '技师详情';
     //检查用户,用户密码
     $user = $GLOBALS['user_info'];
     $user_id = intval($user['id']);
     $root['return'] = 1;
     if ($user_id > 0) {
         $tech_id = $GLOBALS['request']['tech_id'];
         $root['user_login_status'] = 1;
         $sql = 'SELECT 
                     * 
                   FROM
                     ' . DB_PREFIX . 'user 
                   WHERE id =' . $tech_id;
         $tech = $GLOBALS['db']->getRow($sql);
         $date = date('Y-m-d H:i:s');
         $timestamp = strtotime($date);
         //上个月订单
         $last_month_firstday = strtotime(date('Y', $timestamp) . '-' . (date('m', $timestamp) - 1) . '-01');
         $f_date = date('Y-m-01', $last_month_firstday);
         $last_month_lastday = strtotime("{$f_date} +1 month -1 day");
         $last_month_order_sql = "SELECT count(*) as count FROM " . DB_PREFIX . "deal_order WHERE create_time > " . $last_month_firstday . " AND create_time <  " . $last_month_lastday . " AND technician_id=" . $tech_id;
         $last_month_order_count = $GLOBALS['db']->getRow($last_month_order_sql);
         $root['last_month_order_count'] = $last_month_order_count['count'];
         //未结束订单
         $tach_order_unfinished_sql = "SELECT * FROM " . DB_PREFIX . "deal_order o," . DB_PREFIX . "deal_order_item i WHERE o.id=i.order_id and (o.service_start_time=0 or o.service_start_time>0 and o.service_start_time+o.service_time*60<" . time() . ") AND o.technician_id=" . $tech_id;
         $tach_order_unfinished = $GLOBALS['db']->getAll($tach_order_unfinished_sql);
         foreach ($tach_order_unfinished as $k => $v) {
             $tach_order_unfinished[$k]['img'] = get_abs_img_root(make_img($v['deal_icon'], 108, 85, 1));
             $tach_order_unfinished[$k]['order_time_format'] = $v['order_time'] > 0 ? date('Y-m-d H:i:s', $v['order_time']) : '没有预约时间';
         }
         $root['tach_order_unfinished'] = $tach_order_unfinished;
         //本月订单
         $firstday = strtotime(date("Y-m-01", $timestamp));
         $fi_date = date('Y-m-01', $firstday);
         $lastday = strtotime("{$fi_date} +1 month -1 day");
         $month_order_sql = "SELECT count(*) as count FROM " . DB_PREFIX . "deal_order WHERE create_time > " . $firstday . " AND create_time <  " . $lastday . " AND technician_id=" . $tech_id;
         $month_order_count = $GLOBALS['db']->getRow($month_order_sql);
         $root['month_order_count'] = $month_order_count['count'];
         //总订单数
         $order_sql = "SELECT count(*) as count FROM " . DB_PREFIX . "deal_order WHERE technician_id=" . $tech_id;
         $order_count = $GLOBALS['db']->getRow($order_sql);
         $root['order_count'] = $order_count['count'];
         //地址
         $p = $GLOBALS['db']->getRow("select name from " . DB_PREFIX . "region_conf where id = " . $tech['province_id']);
         $c = $GLOBALS['db']->getRow("select name from " . DB_PREFIX . "region_conf where id = " . $tech['city_id']);
         $tech['addr'] = $p['name'] . '-' . $c['name'] . '-' . $tech['addr_detail'];
         //服务
         $goods_list = $GLOBALS['db']->getAll("select * from fanwe_deal_tech t,fanwe_deal d where t.deal_id=d.id and t.tech_id=" . $tech['id']);
         foreach ($goods_list as $k => $v) {
             $goods_list[$k]['img'] = get_abs_img_root(make_img($v['img'], 108, 85, 1));
         }
         $root['goods_list'] = $goods_list;
         //星级
         for ($i = 0; $i < $tech['service_level_id']; $i++) {
             $tech['tech_level'][] = $i;
         }
         //性别
         if ($tech['sex'] == 1) {
             $tech['sex'] = '男';
         } elseif ($tech['sex'] == 0) {
             $tech['sex'] = '女';
         } else {
             $tech['sex'] = '保密';
         }
         //头像
         $tech['user_avatar'] = get_abs_img_root(get_muser_avatar($tech_id, "big"));
         $root['tech'] = $tech;
     } else {
         $root['user_login_status'] = 0;
     }
     $root['user'] = $user;
     $root['city_name'] = $city_name;
     output($root);
 }
Ejemplo n.º 4
0
    //On remplit l'image avec des polygones
    for ($i = 0, $imax = mt_rand(3, 5); $i < $imax; $i++) {
        $x = mt_rand(3, 10);
        $poly = array();
        for ($j = 0; $j < $x; $j++) {
            $poly[] = mt_rand(0, $timage[0]);
            $poly[] = mt_rand(0, $timage[1]);
        }
        imageFilledPolygon($image, $poly, $x, imageColorAllocate($image, mt_rand(150, 255), mt_rand(150, 255), mt_rand(150, 255)));
    }
    // Création des pixels gris
    for ($i = 0; $i < $timage[0] * $timage[1] / rand(15, 18); $i++) {
        imageSetPixel($image, rand(0, $timage[0]), rand(0, $timage[1]), $grey);
    }
    // affichage du texte demandé; on le centre en hauteur et largeur (à peu près ^^")
    //imageString($image, 5, ceil($timage[0]-strlen($content)*8)/2, ceil($timage[1]/2)-9, $content, $text_color);
    $longueur_chaine = strlen($content);
    for ($ch = 0; $ch < $longueur_chaine; $ch++) {
        imagettftext($image, 18, mt_rand(-30, 30), 10 * ($ch + 1), mt_rand(18, 20), $text_color, 'res/georgia.ttf', $content[$ch]);
    }
    $type = function_exists('imageJpeg') ? 'jpeg' : 'png';
    @header('Content-Type: image/' . $type);
    @header('Cache-control: no-cache, no-store');
    $type == 'png' ? imagePng($image) : imageJpeg($image);
    ImageDestroy($image);
    exit;
}
$code_genere = generer_code(5);
$_SESSION['cap_nw'] = $code_genere;
make_img($code_genere);
Ejemplo n.º 5
0
 public function index()
 {
     $root = array();
     $root['return'] = 1;
     $city_id = intval($GLOBALS['request']['city_id']);
     $city_name = strim($GLOBALS['request']['city_name']);
     $root['city_id'] = $city_id;
     $root['city_name'] = $city_name;
     $adv_list = $GLOBALS['cache']->get("WAP_INDEX_ADVS_" . intval($city_id));
     //广告列表
     if ($adv_list === false) {
         $sql = " select * from " . DB_PREFIX . "m_adv where mobile_type = 1 and city_id in (0,1," . intval($city_id) . ") and status = 1 order by sort desc ";
         $advs = $GLOBALS['db']->getAll($sql);
         $adv_list = array();
         foreach ($advs as $k => $v) {
             $adv_list[$k]['id'] = $v['id'];
             $adv_list[$k]['name'] = $v['name'];
             $adv_list[$k]['img'] = get_abs_img_root($v['img']);
             //get_abs_img_root(get_spec_image($v['img'],640,100,0));
             //$adv_list[$k]['img2'] = get_spec_image($v['img'],640,100,1);
             $adv_list[$k]['type'] = $v['type'];
             $adv_list[$k]['data'] = $v['data'] = unserialize($v['data']);
             $adv_list[$k]['url'] = getWebAdsUrl($v['type'], $v['data']);
         }
         $GLOBALS['cache']->set("WAP_INDEX_ADVS_" . intval($city_id), $adv_list, 300);
     }
     $root['advs'] = $adv_list;
     //$domain = app_conf("PUBLIC_DOMAIN_ROOT")==''?get_domain().APP_ROOT:app_conf("PUBLIC_DOMAIN_ROOT");
     //$root['get_domain'] = $domain;
     //output($root);
     //首页菜单列表
     $indexs_list = $GLOBALS['cache']->get("WAP_INDEX_INDEX_" . intval($city_id));
     if ($indexs_list === false) {
         $indexs = $GLOBALS['db']->getAll(" select * from " . DB_PREFIX . "m_index where status = 1 and mobile_type = 1 and city_id in (0," . intval($city_id) . ") order by sort desc limit 0,7");
         $indexs_list = array();
         foreach ($indexs as $k => $v) {
             $indexs_list[$k]['id'] = $v['id'];
             $indexs_list[$k]['name'] = $v['name'];
             $indexs_list[$k]['icon_name'] = $v['vice_name'];
             //图标名 http://fontawesome.io/icon/bars/
             $indexs_list[$k]['color'] = $v['desc'];
             //颜色
             $indexs_list[$k]['img'] = get_abs_img_root($v['img']);
             /*
             $indexs_list[$k]['is_hot'] = $v['is_hot'];
             $indexs_list[$k]['is_new'] = $v['is_new'];
             $indexs_list[$k]['img'] = get_abs_img_root($v['img']);
             	
             $indexs_list[$k]['type'] = $v['type'];
             $indexs_list[$k]['data'] = $v['data'] = unserialize($v['data']);
             */
             $indexs_list[$k]['url'] = getWebAdsUrl($v['type'], unserialize($v['data']));
         }
         if (count($indexs_list) == 7) {
             //更多
             $more = array();
             $more['id'] = 0;
             $more['name'] = '更多';
             $more['icon_name'] = "fa fa-bars";
             //http://fontawesome.io/icon/bars/
             $more['color'] = '#45d3bf';
             $url = get_domain() . APP_ROOT . "/" . APP_INDEX . "/index.php?ctl=indexs_more";
             $more['url'] = str_replace("sjmapi", "wap", $url);
             $indexs_list[count($indexs_list)] = $more;
         }
         $GLOBALS['cache']->set("WAP_INDEX_INDEX_" . intval($city_id), $indexs_list, 300);
     }
     $root['indexs'] = $indexs_list;
     //推荐商家
     $indexs_supplier = $GLOBALS['cache']->get("WAP_INDEX_SUPPLIER_" . intval($city_id));
     if ($indexs_supplier === false) {
         $sql = "select id,name,preview from " . DB_PREFIX . "supplier_location where is_recommend=1  and is_effect=1 ";
         if ($city_id > 0) {
             $ids = load_auto_cache("deal_city_belone_ids", array("city_id" => $city_id));
             if ($ids) {
                 $sql .= " and city_id in (" . implode(",", $ids) . ")";
             }
         }
         $sql .= '  order by sort desc limit 3';
         $indexs_supplier = $GLOBALS['db']->getAll($sql);
         foreach ($indexs_supplier as $k => $v) {
             $indexs_supplier[$k]['preview'] = get_abs_img_root(get_spec_image($v['preview'], 194, 118, 1));
         }
         $GLOBALS['cache']->set("WAP_INDEX_SUPPLIER_" . intval($city_id), $indexs_supplier, 300);
     }
     $root['supplier_list'] = $indexs_supplier;
     //推荐团购
     $indexs_deal = $GLOBALS['cache']->get("WAP_INDEX_DEAL_" . intval($city_id));
     if ($indexs_deal === false) {
         $now = get_gmtime();
         //buy_type 0普通团购;2在线订购;3秒杀抢团
         $sql = "select id,name,auto_order,sub_name,brief,cate_id,supplier_id,current_price,origin_price,img,begin_time,end_time,buy_type,buy_count,service_time " . ",ypoint,xpoint, 0 as distance " . " from " . DB_PREFIX . "deal where buy_type = 0 and publish_wait = 0 and is_shop=0 and is_recommend=1  and is_effect=1 and buy_status!=2 and begin_time<" . $now . " and (end_time = 0 or end_time > " . $now . ") ";
         if ($city_id > 0) {
             $ids = load_auto_cache("deal_city_belone_ids", array("city_id" => $city_id));
             if ($ids) {
                 $sql .= " and city_id in (" . implode(",", $ids) . ")";
             }
         }
         $sql .= ' order by sort desc limit 10';
         $indexs_deal = $GLOBALS['db']->getAll($sql);
         foreach ($indexs_deal as $k => $v) {
             $indexs_deal[$k]['current_price'] = round($v['current_price'], 2);
             $indexs_deal[$k]['origin_price'] = round($v['origin_price'], 2);
             $indexs_deal[$k]['img'] = get_abs_img_root(get_spec_image($v['img'], 140, 85, 1));
             $indexs_deal[$k]['end_time_format'] = to_date($v['end_time']);
             $indexs_deal[$k]['begin_time_format'] = to_date($v['begin_time']);
             if (empty($v['brief'])) {
                 $indexs_deal[$k]['brief'] = $v['name'];
                 $indexs_deal[$k]['name'] = $v['sub_name'];
             }
         }
         $GLOBALS['cache']->set("WAP_INDEX_DEAL_" . intval($city_id), $indexs_deal, 300);
     }
     $root['deal_list'] = $indexs_deal;
     //推荐商品
     $indexs_supplier_deal = $GLOBALS['cache']->get("WAP_INDEX_SUPPLIER_DEAL_" . intval($city_id));
     if ($indexs_supplier_deal === false) {
         //buy_type = 0 普通商品;1积分商品
         $sql = "select id,name,is_hot,sub_name,brief,cate_id,supplier_id,current_price,origin_price,img,begin_time,end_time,buy_type,buy_count,service_time from " . DB_PREFIX . "deal where buy_type = 0 and is_shop=1 and is_recommend=1  and is_effect=1  ";
         $sql .= ' order by sort desc limit 10';
         $indexs_supplier_deal = $GLOBALS['db']->getAll($sql);
         foreach ($indexs_supplier_deal as $k => $v) {
             $indexs_supplier_deal[$k]['img'] = get_abs_img_root(get_spec_image($v['img'], 140, 85, 1));
             $indexs_supplier_deal[$k]['current_price'] = round($v['current_price'], 2);
             $indexs_supplier_deal[$k]['origin_price'] = round($v['origin_price'], 2);
             if (empty($v['brief'])) {
                 $indexs_supplier_deal[$k]['brief'] = $v['name'];
                 $indexs_supplier_deal[$k]['name'] = $v['sub_name'];
             }
         }
         $GLOBALS['cache']->set("WAP_INDEX_SUPPLIER_DEAL_" . intval($city_id), $indexs_supplier_deal, 300);
     }
     $root['supplier_deal_list'] = $indexs_supplier_deal;
     //10个商品
     $allgoodslist = $GLOBALS['cache']->get("goodslist_" . intval($city_id));
     if ($allgoodslist === false) {
         //buy_type = 0 普通商品;1积分商品
         $sql = "select id,name,is_hot,sub_name,brief,cate_id,supplier_id,current_price,origin_price,img,begin_time,end_time,buy_type,buy_count,description,service_time from " . DB_PREFIX . "deal where buy_type = 0 and is_shop=1 and is_recommend=1  and is_effect=1  ";
         $sql .= ' order by sort desc limit 10';
         $allgoodslist = $GLOBALS['db']->getAll($sql);
         foreach ($allgoodslist as $k => $v) {
             //$allgoodslist[$k]['img']=get_abs_img_root(make_img($v['img'],310,262,1));
             $allgoodslist[$k]['img'] = get_abs_img_root(make_img($v['img'], 108, 85, 1));
             $allgoodslist[$k]['current_price'] = round($v['current_price'], 2);
             $allgoodslist[$k]['origin_price'] = round($v['origin_price'], 2);
             if (empty($v['brief'])) {
                 $allgoodslist[$k]['brief'] = $v['name'];
             }
         }
         $GLOBALS['cache']->set("goodslist_" . intval($city_id), $allgoodslist, 300);
     }
     $root['allgoodslistallgoodslist'] = $indexs_supplier_deal;
     //10个商品
     //buy_type = 0 普通商品;1积分商品
     $sql = "select id,name,is_hot,sub_name,brief,cate_id,supplier_id,current_price,origin_price,img,begin_time,end_time,buy_type,buy_count,description,service_time from " . DB_PREFIX . "deal where buy_type = 0 and is_shop=1 and is_effect=1  ";
     $sql .= ' order by sort desc limit 10';
     $allgoodslist = $GLOBALS['db']->getAll($sql);
     foreach ($allgoodslist as $k => $v) {
         //$allgoodslist[$k]['img']=get_abs_img_root(make_img($v['img'],310,262,1));
         $allgoodslist[$k]['img'] = get_abs_img_root(make_img($v['img'], 108, 85, 1));
         $allgoodslist[$k]['current_price'] = round($v['current_price'], 2);
         $allgoodslist[$k]['origin_price'] = round($v['origin_price'], 2);
         if (empty($v['brief'])) {
             $allgoodslist[$k]['brief'] = $v['name'];
         }
     }
     $root['allgoodslist'] = $allgoodslist;
     //推荐活动
     $indexs_event = $GLOBALS['cache']->get("WAP_INDEX_EVENT_" . intval($city_id));
     if ($indexs_event === false) {
         $now = get_gmtime();
         $sql = "select id,name,icon,event_begin_time,event_end_time" . ",ypoint,xpoint, 0 as distance " . " from " . DB_PREFIX . "event where is_recommend=1  and is_effect=1 and event_begin_time<" . $now . " and (event_end_time = 0 or event_end_time > " . $now . ") ";
         if ($city_id > 0) {
             $ids = load_auto_cache("deal_city_belone_ids", array("city_id" => $city_id));
             if ($ids) {
                 $sql .= " and city_id in (" . implode(",", $ids) . ")";
             }
         }
         $sql .= ' order by sort desc limit 10';
         $indexs_event = $GLOBALS['db']->getAll($sql);
         foreach ($indexs_event as $k => $v) {
             $indexs_event[$k]['icon'] = get_abs_img_root(get_spec_image($v['icon'], 300, 182, 1));
             $indexs_event[$k]['event_begin_time_format'] = to_date($v['event_begin_time']);
             $indexs_event[$k]['event_end_time_format'] = to_date($v['event_end_time']);
             $indexs_event[$k]['sheng_time_format'] = to_date($v['event_end_time'] - $now, "d天h小时i分");
         }
         $GLOBALS['cache']->set("WAP_INDEX_EVENT_" . intval($city_id), $indexs_event, 300);
     }
     $root['event_list'] = $indexs_event;
     //推荐优惠券
     $youhui_list = $GLOBALS['cache']->get("WAP_YOUHUI_LIST_" . intval($city_id));
     if ($youhui_list === false) {
         $sql = "select id, supplier_id as merchant_id,description,begin_time,youhui_type,total_num,end_time,name as title,list_brief as content,icon as merchant_logo,create_time,xpoint,ypoint,address as api_address,icon as image_1 from " . DB_PREFIX . "youhui";
         $now = get_gmtime();
         $where = "1 = 1 and is_effect = 1 and begin_time<" . $now . " and (end_time = 0 or end_time > " . $now . ") ";
         if (intval($city_id) > 0) {
             $ids = load_auto_cache("deal_city_belone_ids", array("city_id" => intval($city_id)));
             if ($ids) {
                 $where .= " and city_id in (" . implode(",", $ids) . ")";
             }
         }
         $sql .= " where " . $where;
         $sql .= " order by sort limit 0,10";
         $youhui_list = $GLOBALS['db']->getAll($sql);
         //$root['youhui_list_sql'] = $sql;
         foreach ($youhui_list as $k => $v) {
             $youhui_list[$k]['image_1'] = get_abs_img_root(get_spec_image($v['image_1'], 140, 85, 1));
             $youhui_list[$k]['down_count'] = $youhui_list[$k]['sms_count'] + $youhui_list[$k]['print_count'];
             $youhui_list[$k]['begin_time'] = to_date($v['begin_time'], "Y-m-d") . '至' . to_date($v['end_time'], "Y-m-d");
         }
         $GLOBALS['cache']->set("WAP_YOUHUI_LIST_" . intval($city_id), $youhui_list, 300);
     }
     $root['youhui_list'] = $youhui_list;
     //推荐商城
     $indexs_shop_cate = $GLOBALS['cache']->get("WAP_INDEX_SHOP_CATE_" . intval($city_id));
     if ($indexs_shop_cate === false) {
         $indexs_shop_cate = $GLOBALS['db']->getAll("select id,name,cate_img from " . DB_PREFIX . "shop_cate where recommend=1  and is_effect=1 and pid=0  order by sort desc limit 6");
         foreach ($indexs_shop_cate as $k => $v) {
             $indexs_shop_cate[$k]['cate_img'] = get_abs_img_root($v['cate_img']);
         }
         $GLOBALS['cache']->set("WAP_INDEX_SHOP_CATE_" . intval($city_id), $indexs_shop_cate, 300);
     }
     $root['shop_cate_list'] = $indexs_shop_cate;
     /*首页推荐分类*/
     $indexs_cate = $GLOBALS['cache']->get("WAP_INDEX_QUAN_" . intval($city_id));
     if ($indexs_cate === false) {
         $indexs_cate = $GLOBALS['db']->getAll("select id,name,icon_img from " . DB_PREFIX . "deal_cate where recommend=1 and is_delete=0 and is_effect=1 and pid=0 order by sort desc limit 4");
         foreach ($indexs_cate as $k => $v) {
             $indexs_cate[$k]['icon_img'] = get_abs_img_root($v['icon_img']);
         }
         $GLOBALS['cache']->set("WAP_INDEX_QUAN_" . intval($city_id), $indexs_cate, 300);
     }
     $root['cates'] = $indexs_cate;
     /*关键字*/
     $indexs_cate_type = $GLOBALS['cache']->get("WAP_INDEX_CATE_TYPE_" . intval($city_id));
     if ($indexs_cate_type === false) {
         $cate_type_list = $GLOBALS['db']->getAll("select dct.id,dct.name,dctl.cate_id as pid from " . DB_PREFIX . "deal_cate_type as dct left join " . DB_PREFIX . "deal_cate_type_link as dctl on dctl.deal_cate_type_id=dct.id where dct.is_recommend=1 order by sort desc,id desc limit 8");
         $GLOBALS['cache']->set("WAP_INDEX_CATE_TYPE_" . intval($city_id), $cate_type_list, 300);
     }
     $root['cate_type_list'] = $cate_type_list;
     $root['page_title'] = $GLOBALS['m_config']['program_title'];
     $user = $GLOBALS['user_info'];
     if ($user) {
         $root['user'] = $user;
     }
     output($root);
 }