$(document).ready(function(){
$("#information").hide();//个人信息
$("#goodloadceng").hide();//"系统加载中"显示层
$("#modifycode").hide();//修改密码
$("#notebookA").hide();//地址薄
$("#addlpk").hide();//礼品卡
$("#addbzd").hide();//包装袋
$("#wjdc").hide();//问卷调查
$("#Layer2").hide();//vip修改模特
$("#createmd").hide();//vip创建模特1216
//只加载一次
var isNewProductLoaded = false;
$("#myyigui").Accordion({
headerSelector: '.header',
panelSelector: '.panel',
panelHeight: 650,
speed: 400
});
$("#shoucangtitle").click(function(){
//alert("hello");
$.post("vipyiguilist.action",{},function(data){
//alert("data:"+data);
$("#vipyigui").html(data);
setWardrobsTotalRecords();
});
});
/*
* 最新产品
*/
$("#newProduct").click(function(){
if (!isNewProductLoaded) {
$.get("getLastestProductList.action", {
"product.flag": 0,
"product.category":1
}, function(data){
$("#newProductPanel").html(data);
});
isNewProductLoaded = true;
}
});
$("#goodloadceng").ajaxStart(function(){
$(this).show();
});
$("#goodloadceng").ajaxStop(function(){
$(this).hide();
});
$("#myLatestBuy").click(function(){
$.post("/verfy/back.jsp");
});
// alert("i am in ready");
//模特库列表 在页面加载的时候向div中注值
$.post("vipGetModelList.action",{},function(data){
//$("#modelNumber").html(data);
$("#mymodelM").html(data);
setModelsTotalRecords();
});
/*
* 我的衣柜列表
*/
$.post("vipyiguilist.action",{},function(data){
//alert("data:"+data);
$("#vipyigui").html(data);
setWardrobsTotalRecords();
});
});
//模特分页
function navPages(page){
$(document).ready(function(){
// 右面搜索结果的ajax页面
names=$("#modelName").val();
modelName="%"+names+"%";
//alert("modelName:"+modelName);
//alert($("#gender").val());
$.post("vipModelList.action",{
"page.currentPage": page,
'models.gender':$("#gender").val(),
'models.name':modelName},
function(data){
$("#mymodelM").html(data);
setModelsTotalRecords();
});
});
}
function getPages(){
var page = $("#pageRequests").val();
// TODO: 对页码的验证
//alert("page:"+page);
navPages(page);
}
function navPage(page){
$(document).ready(function(){
// 右面搜索结果的ajax页面
var price =$("#price").val();
//alert("price:"+price);
var priceReg = /^(/d*)-(/d*)$/;
priceReg.test(price);
minPrice = RegExp.$1;
//alert("minPrice:"+minPrice);
maxPrice = RegExp.$2;
// "priceRange.maxPrice":maxPrice,
// "priceRange.minPrice":minPrice,
// "product.publishTime":publishTimes,
// alert($("#pushTime").val());
$.get("getLastestProductList.action", {
"product.flag": $("#productflag").val(),
"priceRange.maxPrice":maxPrice,
"product.publishTime":$("#pushTime").val(),
"page.currentPage": page,
"product.category":1,
"str":$("#pushTime").val()
}, function(data){
$("#newProductPanel").html(data);
});
});
}
function getPage(){
var page = $("#pageRequest").val();
// TODO: 对页码的验证
navPage(page);
}
//收藏柜
function vipNavPage(page){
$(document).ready(function(){
// 右面搜索结果的ajax页面
$.get("vipyiguilist.action", {
"page.currentPage": page
}, function(data){
$("#vipyigui").html(data);
});
});
}
function vipGetPage(){
var page = $("#vipyiguiGo").val();
//alert($("#vipyiguiGo").val());
// TODO: 对页码的验证
$(document).ready(function(){
// 右面搜索结果的ajax页面
$.get("vipyiguilist.action", {
"page.currentPage": page
}, function(data){
$("#vipyigui").html(data);
});
});
}
var isOpen=false;
//在同一时间内只允许展开一个层.
/*
* 打开一个对话框
*/
function openDialog(str,content,action,width,height){
/*
* str 父层
* content 内容层
* action 处理iframe src的url
* width iframe 的宽度
* height iframe的高度
*/
// alert("str:"+str);
//alert("hi");
if(!isOpen){
$(str).OpenVertically(1000);/*打开的时间间隔为一秒*/
$(str).Draggable(
{
zIndex: 1000,
ghosting: true,
opacity: 0.7/*透明*/
});
/*600,480*/
var html="<iframe id='f+"+str+"+f' src='"+action+"' width='"+width+"' frameborder='0' height='"+height+"' scrolling=/"no/" ></iframe>";
$(content).html(html);
$(content).show();
isOpen=true;
}
}
/*
* 关闭一个对话框
*/
function closeDialog(str,content){
/*str 父层
*content 内容层
*/
//alert('dd');
$(content).hide();
$(str).CloseVertically(1000);
$(str).DraggableDestroy();
$(str).hide();
isOpen=false;
}
/*
* 模特库
*/
function vipdelModel(modelId,modelName){
//alert("modelId:"+modelId);
if(confirm('确定删除选定的记录吗?'))
{
$.post("vipDelModel.action",{"modelId":modelId},function(data){
$("#mymodelM").html(data);
setModelsTotalRecords();
});
var str=document.getElementById("modelForDEL").value;
//alert(str);
//alert(modelId);
if(str==modelName){
document.getElementById("modelTestShirt").innerHTML="一格标准模特";
document.getElementById("genders").value=0;
document.getElementById("waistLine").value=80;
document.getElementById("height").value=170;
document.getElementById("age").value=20;
document.getElementById("skinColor").value=1;
document.getElementById("hairColor").value=1;
document.getElementById("hairStyle").value=1;
document.getElementById("cloth").value=0;
document.getElementById("trousers").value=0;
document.getElementById("shoe").value=0;
document.getElementById("hat").value=0;
document.getElementById("glasses").value=0;
document.getElementById("bag").value=0;
document.getElementById("earing").value=0;
document.getElementById("necklace").value=0;
document.getElementById("view").value=1;
document.getElementById("back").value=1;
juedu=0;
document.getElementById("modelForDEL").value="";
//alert(juedu);
var modelPic=document.getElementById("3dman");
var webPic=document.getElementById("picWebForDel").value;
image=webPic+"/img/modelpic/man.jpg";
var src_pic ="<img id='pic' src='"+image+"' />";
modelPic.innerHTML=src_pic;
}
}
}
function deleteModelsAll(id){
var OneAreInUpdate=document.getElementById("hiddenOrShowDe").value;
//alert(OneAreInUpdate);
if(OneAreInUpdate!=""){
alert("有模特正在修改不能删除");
return false;
}else{
if(confirm('确定删除选定的记录吗?'))
{
var allcheck=document.getElementsByName(id);
//alert("allcheck:"+allcheck);
for(var i=0;i<allcheck.length;i++)
{
var modelId=allcheck[i].value;
$.post("vipDelModel.action",{"modelId":modelId},function(){
});
}
$.post("vipGetModelList.action",{},function(data){
$("#mymodelM").html(data);
setModelsTotalRecords();
});
document.getElementById("modelTestShirt").innerHTML="一格标准模特";
document.getElementById("genders").value=0;
document.getElementById("waistLine").value=80;
document.getElementById("height").value=170;
document.getElementById("age").value=20;
document.getElementById("skinColor").value=1;
document.getElementById("hairColor").value=1;
document.getElementById("hairStyle").value=1;
document.getElementById("cloth").value=0;
document.getElementById("trousers").value=0;
document.getElementById("shoe").value=0;
document.getElementById("hat").value=0;
document.getElementById("glasses").value=0;
document.getElementById("bag").value=0;
document.getElementById("earing").value=0;
document.getElementById("necklace").value=0;
document.getElementById("view").value=1;
document.getElementById("back").value=1;
juedu=0;
document.getElementById("modelForDEL").value="";
//alert(juedu);
var modelPic=document.getElementById("3dman");
var webPic=document.getElementById("picWebForDel").value;
image=webPic+"/img/modelpic/man.jpg";
var src_pic ="<img id='pic' src='"+image+"' />";
modelPic.innerHTML=src_pic;
}
}
}
function getModelsList(){
//alert("hao");
$.post("vipGetModelList.action",{},function(data){
$("#mymodelM").html(data);
setModelsTotalRecords();
});
}
//根据性别与创建日期来查询模特
function getModelsByGender(){
//alert("ss");
names=$("#modelName").val();
modelName="%"+names+"%";
//alert("modelName:"+modelName);
//alert($("#gender").val());
$.post("vipModelList.action",{
'models.gender':$("#gender").val(),
'models.name':modelName},
function(data){
$("#mymodelM").html(data);
setModelsTotalRecords();
});
}
/*
* 收藏衣柜
*/
//删除一个收藏
function deleteWardrobes(wardrobsId){
if(confirm("确定删除选定的收藏吗?")){
$.post("vipyiguiDelete.action",{"wardId":wardrobsId},function(data){
// alert("data:"+data);
$("#vipyigui").html(data);
setWardrobsTotalRecords();
});
}
}
//增加一个收藏
function saveToWardrobes(productId,userId){
if(userId==""||userId==null){
alert("您还没有登录,请您先登录!");
return false;
}else{
wardrobesServie.doInsertWardrobe(productId,userId,getBackInt);
}
}
function getBackInt(msg){
if(msg==0)
alert("产品已经成功地收藏到衣柜!");
}
//统计衣柜件数
function setWardrobsTotalRecords(){
var numModelList=document.getElementById("wardTotalRecords").value;
//alert("numModelList:"+numModelList);
var numVip=document.getElementById("wardrobsNumber");
//alert("numVip:"+numVip);
numVip.innerHTML=numModelList;
}
//统计模特个数
function setModelsTotalRecords(){
var numModelList=document.getElementById("totalRecords").value;
//alert("numModelList:"+numModelList);
var numVip=document.getElementById("modelNumber");
//alert("numVip:"+numVip);
numVip.innerHTML=numModelList;
}
//模特全选与全不选
function selectedAll(x){
// alert("x:"+x);
var allcheck=document.getElementsByName("ids");
// alert("allcheck:"+allcheck);
if(x==1){
for(var i=0;i<allcheck.length;i++)
{
allcheck[i].checked=true;
}
}
if(x==2){
for(var i=0;i<allcheck.length;i++){
allcheck[i].checked=false;
}
}
}
//最新产品 条件查询
function vipProducList(){
//价格范围
var price =$("#price").val();
//alert("price:"+price);
var priceReg = /^(/d*)-(/d*)$/;
priceReg.test(price);
minPrice = RegExp.$1;
//alert("minPrice:"+minPrice);
maxPrice = RegExp.$2;
//alert("maxPrice:"+maxPrice);
//document.getElementById("maxPriceForSearch").value=maxPrice;
//上架时间
var str=$("#pushTime").val();
//alert("str:"+str)
if(str==''||str==null){
var today = new Date();
var year = today.getFullYear();
var month = today.getMonth();
var dat = today.getDate();
dat -= Number(str);
// alert("dat:"+dat);
var today = new Date(year,month,dat);
// alert("today:"+today);
var publishTime = ""+today.getFullYear()+"-" +(today.getMonth()+1)+"-"+today.getDate();
publishTimes = publishTime;
}else{
publishTimes='';
}
// alert("publishTimes:"+publishTimes);
$.post("getLastestProductList.action", {
"product.flag": $("#productflag").val(),
"priceRange.maxPrice":maxPrice,
"priceRange.minPrice":minPrice,
"product.publishTime":publishTimes,
"product.category":1,
"str":str
},function(data){
$("#newProductPanel").html(data);
});
}
//我的衣柜条件查询
/*
* 得重新写一个action
*/
function vipWardrobesList(){
//价格范围
var price =$("#wardPrice").val();
//alert("price:"+price);
//允许不选价格查询
if(price!=null && price!=''){
var priceReg = /^(/d*)-(/d*)$/;
priceReg.test(price);
minPrice = RegExp.$1;
// alert("minPrice:"+minPrice);
maxPrice = RegExp.$2;
//alert("maxPrice:"+maxPrice);
}else{
minPrice ='';
maxPrice ='';
}
//上架时间
var str=$("#wardSaveTime").val();
//alert("str:"+str)
//允许不选时间查询
if(str!=null && str!==''){
var today = new Date();
var year = today.getFullYear();
var month = today.getMonth();
var dat = today.getDate();
dat -= Number(str);
//alert("dat:"+dat);
var today = new Date(year,month,dat);
// alert("today:"+today);
var publishTime = ""+today.getFullYear()+"-" +(today.getMonth()+1)+"-"+today.getDate();
publishTimes = publishTime;
//alert("publishTimes:"+publishTimes);
}else{
publishTimes='';
}
$.post("vipyiguilistOther.action",
{
"wardrobes.choosetime":publishTimes,
"wardrobes.productType":$("#wardType").val(),
"priceRange.maxPrice":maxPrice,
"priceRange.minPrice":minPrice
},function(data){
$("#vipyigui").html(data);
});
}