'".$s_zsh."' group by zsh order by zsh limit 0,1"); if($tmp["zsh"]){ $json_data.="\"code\":100,"; $json_data.="\"zsh\":\"".$tmp["zsh"]."\","; $json_data.="\"tid\":\"".$tid."\","; }else{ $json_data.="\"code\":0,\"msg\":\"数据准备中,请稍后......\","; } break; default: //取得默认展厅 if(!$s_tid){ $tmp=get_db_msg("select id from ".$table_pre."kh_tb_t limit 0,1"); $s_tid=$tmp["id"]; } $s_tid=$s_tid>0?$s_tid:0; if($s_tid){ $tid_con="and tid='".$s_tid."'"; }else{ $tid_con=''; } //取得展厅选项信息 $tmp_tid=""; $tid_ct=0; $q="select * from ".$table_pre."kh_tb_t"; $r=$db->query($q); while($m=$db->fetch_array($r)){ $tmp_tid.="{\"no\":\"".$m["id"]."\",\"title\":\"".$m["title"]."\"},"; $tid_ct++; } $tmp_tid=deel_end($tmp_tid); $json_data.="\"select_tid_ct\":\"".$tid_ct."\",\"select_tid\":{\"no\":\"s_tid\",\"title\":\"选择展厅\",\"value\":\"".$s_tid."\",\"op\":[".$tmp_tid."]},"; //展示号选项 $tmp_zsh=""; $q="select zsh from ".$table_pre."kh_tb where tid=".$s_tid." group by zsh order by zsh"; $r=$db->query($q); while($m=$db->fetch_array($r)){ $tmp_zsh.="{\"no\":\"".$m["zsh"]."\",\"title\":\"".$m["zsh"]."\"},"; } $tmp_zsh=deel_end($tmp_zsh); $json_data.="\"select_zsh\":{\"no\":\"s_zsh\",\"title\":\"选择展示号\",\"value\":\"".$s_zsh."\",\"op\":[".$tmp_zsh."]},"; //是否启用设计师 if($sys_enable_tb=="y"){ $json_data.="\"code_enable\":\"y\","; if($s_zsh){ $m=get_db_msg("select zsh,pic from ".$table_pre."kh_tb where zsh='".$s_zsh."' ".$tid_con." group by zsh order by zsh desc limit 0,1"); }else{ $m=get_db_msg("select zsh,pic from ".$table_pre."kh_tb where is_show='y' ".$tid_con." group by zsh order by zsh desc limit 0,1"); $s_zsh=0; } //当前展示号 $this_zsh=$m["zsh"]>0?$m["zsh"]:0; $json_data.="\"this_zsh\":\"".$this_zsh."\","; $json_data.="\"this_tid\":\"".$s_tid."\","; $str=""; if($m["zsh"]>0){ $query="select iid,color from ".$table_pre."kh_tb where zsh='".$m["zsh"]."' ".$tid_con." order by ord"; $res=$db->query($query); $style_title_color=get_set("style_title_color"); $ka_color=get_set("ka_color"); while($msg=$db->fetch_array($res)){ $m_kh=get_db_msg("select * from ".$table_pre."kh where id='".$msg["iid"]."'"); if($m_kh["ka"]=="y"){ $c=$ka_color; }else{ $c=get_set_value_dote($style_title_color,$m_kh["kh_dj"]); } if($msg["iid"]>0){ //图片获取规则 if($msg["color"]){ $pic=get_kh_color_picture($m_kh["no"],$msg["color"]); $con_color_tmp=" and color='".$msg["color"]."'"; $color_str=$msg["color"]."-".get_cate_title_no("color",$msg["color"]); }else{ $pic=get_kh_picture($m_kh["no"],$m_kh["main_pic"],$m_kh["color"],$flag_pad_offline); $con_color_tmp=""; $color_str=""; } if($pic){ $arr_pic_set=out_good_pic_set_arr($pic,140,140); $pic_w=$arr_pic_set[0]; $pic_h=$arr_pic_set[1]; }else{ $pic_w=$pic_h=0; } $n1=0; //----取得评价 $tmp=get_db_msg("select sum(race) 'num' from ".$table_pre."client_pj where khid='".$msg["iid"]."' "); $pj_num=add_0($tmp["num"]); $tmp=get_db_msg("select count(*) 'num' from ".$table_pre."client_pj where khid='".$msg["iid"]."' "); $pj_clients=add_0($tmp["num"]); //----取得订单 $tmp=get_db_msg("select sum(num) 'num' from ".$table_pre."order where iid='".$msg["iid"]."' and _key='".$_key."'".$con_color_tmp); $order_num=add_0($tmp["num"]); $tmp=get_db_msg("select count(distinct uid) 'num' from ".$table_pre."order where iid='".$msg["iid"]."' and _key='".$_key."'".$con_color_tmp); $order_clients=add_0($tmp["num"]); // $ppf=$pj_clients>0?keep_float($pj_num/$pj_clients,1):0; $str.="{\"id\":\"".$m_kh["id"]."\",\"xh\":\"".get_kh_xh($m_kh,$msg["color"])."\",\"kh\":\"".$m_kh["no"]."\",\"color\":\"".$color_str."\",\"price\":\"".deel_num($m_kh["price"])."\",\"picsrc\":\"".$pic."\",\"pic_w\":\"".$pic_w."\",\"pic_h\":\"".$pic_h."\",\"fontcolor\":\"".$c."\",\"js\":\"".$order_num."\",\"jsrs\":\"".$order_clients."\",\"ppf\":\"".$ppf."\",\"ppfrs\":\"".$pj_clients."\"},"; } } if($str) $str=substr($str,0,-1); } $json_data.="\"all_kh\":[".$str."],"; // $arr_zsh1=array(); $q1="select zsh from ".$table_pre."kh_tb where tid='".$s_tid."' and zsh<".$this_zsh." group by zsh order by zsh desc limit 0,2"; $r1=$db->query($q1); while($m1=$db->fetch_array($r1)){ $arr_zsh1[]=$m1["zsh"]; } $arr_zsh2=array(); $q1="select zsh from ".$table_pre."kh_tb where tid='".$s_tid."' and zsh>".$this_zsh." group by zsh order by zsh limit 0,2"; $r1=$db->query($q1); while($m1=$db->fetch_array($r1)){ $arr_zsh2[]=$m1["zsh"]; } if(count($arr_zsh1)<2 && count($arr_zsh2)<2){ $query="select zsh,pic,title from ".$table_pre."kh_tb where tid='".$s_tid."' group by zsh order by zsh"; }else if(count($arr_zsh1)<2){ if($arr_zsh1[0]>0) $query="select zsh,pic,title from ".$table_pre."kh_tb where tid='".$s_tid."' and zsh>='".$arr_zsh1[0]."' group by zsh order by zsh limit 0,5"; else $query="select zsh,pic,title from ".$table_pre."kh_tb where tid='".$s_tid."' group by zsh order by zsh limit 0,5"; }else if(count($arr_zsh2)<2){ if($arr_zsh2[0]>0) $q1="select count(distinct zsh) 'num' from ".$table_pre."kh_tb where tid='".$s_tid."' and zsh<='".$arr_zsh2[0]."'"; else $q1="select count(distinct zsh) 'num' from ".$table_pre."kh_tb where tid='".$s_tid."'"; $m1=get_db_msg($q1); $limit_s=($m1["num"]-5)>0?($m1["num"]-5):0; if($arr_zsh2[0]>0) $query="select zsh,pic,title from ".$table_pre."kh_tb where tid='".$s_tid."' and zsh<='".$arr_zsh2[0]."' group by zsh order by zsh limit ".$limit_s.",5"; else $query="select zsh,pic,title from ".$table_pre."kh_tb where tid='".$s_tid."' group by zsh order by zsh limit ".$limit_s.",5"; }else{ $query="select zsh,pic,title from ".$table_pre."kh_tb where tid='".$s_tid."' and zsh>='".$arr_zsh1[1]."' group by zsh order by zsh limit 0,5"; } // $strzsh=""; $count=0; $re=$db->query($query); while ($rows=$db->fetch_array($re)) { $arr_tmp=array(); $tmp=get_db_msg("select count(distinct iid,color) 'num' from ".$table_pre."kh_tb where zsh=".$rows['zsh']." and tid=".$s_tid); $r=$db->query("select * from ".$table_pre."kh_tb where zsh=".$rows['zsh']." and tid=".$s_tid); $i=0; while ($m1=$db->fetch_array($r)) { $arr_tmp[$i]['titile']=$m1['titile']; $arr_tmp[$i]['pic']=$m1['pic']; $arr_tmp[$i]['iid']=$m1['iid']; $arr_tmp[$i]['color']=$m1['color']; $i++; } $tmp2=get_db_msg("select * from ".$table_pre."kh where id='".$arr_tmp[0]["iid"]."' limit 0,1"); if($rows['pic']!=""){ $pic2="../attachments/".$rows['pic']; } if($tmp['num']==1 && $rows['pic']==""){ if($arr_tmp[0]["color"]){ $pic2=get_kh_color_picture($tmp2["no"],$arr_tmp[0]["color"]); }else{ $pic2=get_kh_picture($tmp2["no"],$tmp2["main_pic"],$tmp2["color"]); } } $info=""; foreach ($arr_tmp as $key => $value) { $tmp=get_db_msg("select no from ".$table_pre."kh where id=".$value["iid"]); $info.=$tmp['no']; if ($value['color']) { $info.=",".get_cate_title_no("color",$value['color']); }else{ $info.=""; } $info.="|"; } if($info) $info=substr($info,0,-1); if($pic2){ $arr_pic_set2=out_good_pic_set_arr($pic2,120,120); $pic_w2=$arr_pic_set2[0]; $pic_h2=$arr_pic_set2[1]; }else{ $pic_w2=$pic_h2=0; } $strzsh.="{\"zsh\":\"".$rows['zsh']."\",\"picsrc\":\"".$pic2."\",\"pic_w\":\"".$pic_w2."\",\"pic_h\":\"".$pic_h2."\",\"kh_detail\":\"".$info."\"},"; $count++; } $json_data.="\"zshcount\":\"".$count."\",\"all_zsh\":[".substr($strzsh,0,-1)."],"; $json_data.="\"code\":100,"; }else{ $json_data.="\"code\":\"0\",\"msg\":\"对不起,目前只有IPAD支持该功能!\","; } break; } $json_data=substr($json_data,0,-1)."}"; echo $json_data; ?>