query("insert into web_scene(sceneName,sceneTitle,scenePic) values('".$sceneName."','".$sTitle."','')"); }else{ $sceneName=1; $db->query("insert into web_scene(sceneName,sceneTitle,scenePic,sceneDefault) values('".$sceneName."','".$sTitle."','','y')"); } $json_data.="\"code\":\"0\",\"msg\":\"\","; break; case "search_scene": $str=""; $sql="select * from web_scene order by (sceneName + 1)"; $res=$db->query($sql); while($msg=$db->fetch_array($res)){ if(file_exists("../attachments/scene/".$msg["scenePic"].".jpg")){ $picState="y"; }else{ $picState="n"; } $str.="{\"id\":\"".$msg["id"]."\",\"sceneName\":\"".$msg["sceneName"]."\",\"sceneTitle\":\"".$msg["sceneTitle"]."\",\"scenePic\":\"".$msg["scenePic"]."\",\"sceneState\":\"".$picState."\",\"sceneDefault\":\"".$msg["sceneDefault"]."\"},"; } $json_data.="\"code\":\"0\",\"msg\":\"\",\"data\":[".substr($str,0,-1)."],"; break; case "update_sceneDefault": if($sid){ $db->query("update web_scene set sceneDefault='n' where sceneDefault='y'"); $db->query("update web_scene set sceneDefault='y' where id='".$sid."'"); $json_data.="\"code\":\"0\",\"msg\":\"\","; }else{ $json_data.="\"code\":\"-1\",\"msg\":\"无效访问!\","; } break; case "del_scene": if($sid){ $tmp=get_db_msg("select * from web_scene where id='".$sid."'"); $db->query("delete from web_scene where id='".$sid."'"); //先删除图片 $pic="../attachments/scene/".$tmp["scenePic"].".jpg"; if(file_exists($pic)){ unlink($pic); } $json_data.="\"code\":\"0\",\"msg\":\"\","; }else{ $json_data.="\"code\":\"-1\",\"msg\":\"无效访问!\","; } break; //上传图片 case "save_scenePic": $up_image=$_FILES["up_file"]; $tmp=get_db_msg("select * from web_scene where id='".$id."'"); if($tmp["id"]){ if($tmp["scenePic"]){ //先删除图片 $pic="../attachments/scene/".$tmp["scenePic"].".jpg"; if(file_exists($pic)){ unlink($pic); } }else{ $db->query("update web_scene set scenePic='".$tmp["sceneName"]."' where id='".$id."'"); } move_uploaded_file($up_image["tmp_name"], "../attachments/scene/".$tmp["sceneName"].".jpg"); $json_data.="\"code\":0,\"msg\":\"\","; }else{ $json_data.="\"code\":\"-1\",\"msg\":\"数据不存在!\","; } break; case "get_sceneDetail": $tmp=get_db_msg("select * from web_scene where id='".$id."'"); if($tmp["id"]){ $pic="../attachments/scene/".$tmp["scenePic"].".jpg"; $str=''; $sql="select * from web_scene_hotspots where sid='".$tmp["id"]."'"; $res=$db->query($sql); while($msg=$db->fetch_array($res)){ if($msg["hot_type"]=="info"){ $str.='{"id":"'.$msg["id"].'","pitch": '.$msg["hot_pitch"].', "yaw": '.$msg["hot_yaw"].',"type": "'.$msg["hot_type"].'","text": "'.$msg["khno"].'","sceneId": ""},'; }else{ $str.='{"id":"'.$msg["id"].'","pitch": '.$msg["hot_pitch"].', "yaw": '.$msg["hot_yaw"].',"type": "'.$msg["hot_type"].'","text": "'.$msg["hot_title"].'","sceneId": ""},'; } } //场景列表 $str2=''; $sql2="select sceneName,sceneTitle from web_scene"; $res2=$db->query($sql2); while($msg2=$db->fetch_array($res2)){ $str2.='{"sceneName":"'.$msg2["sceneName"].'","sceneTitle":"'.$msg2["sceneTitle"].'"},'; } //款号列表 $str3=''; $sql3="select id,no from web_kh"; $res3=$db->query($sql3); while($msg3=$db->fetch_array($res3)){ $str3.='{"id":"'.$msg3["id"].'","khno":"'.$msg3["no"].'"},'; } $json_data.="\"code\":0,\"msg\":\"\",\"pic\":\"".$pic."\",\"data\":[".substr($str,0,-1)."],\"sceneList\":[".substr($str2,0,-1)."],\"khnoList\":[".substr($str3,0,-1)."],"; }else{ $json_data.="\"code\":\"-1\",\"msg\":\"数据不存在!\","; } break; case "add_hotSpot": if(!$sid || !$hot_type || !$khno){ $json_data.="\"code\":\"-1\",\"msg\":\"数据参数不足!\","; }else{ $db->query("insert into web_scene_hotspots(sid,hot_type,hot_title,hot_sceneId,khno,hot_pitch,hot_yaw) values('".$sid."','".$hot_type."','','','".$khno."','".$hot_pitch."','".$hot_yaw."')"); $htid=$db->insert_id(); $json_data.="\"code\":0,\"msg\":\"\",\"htid\":\"".$htid."\","; } break; case "add_hotSpot2": if(!$sid || !$hot_type || !$title){ $json_data.="\"code\":\"-1\",\"msg\":\"数据参数不足!\","; }else{ $db->query("insert into web_scene_hotspots(sid,hot_type,hot_title,hot_sceneId,khno,hot_pitch,hot_yaw) values('".$sid."','".$hot_type."','".$title."','".$sceneId."','','".$hot_pitch."','".$hot_yaw."')"); $htid=$db->insert_id(); $json_data.="\"code\":0,\"msg\":\"\",\"htid\":\"".$htid."\","; } break; case "del_hotSpot": if(!$htid){ $json_data.="\"code\":\"-1\",\"msg\":\"数据参数不足!\","; }else{ $db->query("delete from web_scene_hotspots where id='".$htid."'"); $json_data.="\"code\":0,\"msg\":\"\","; } break; } } $json_data=substr($json_data,0,-1)."}"; echo $json_data; ?>