$(document).ready(function(){
// TODO: 这里只有男的
// $.post("getProductList.action", {
// "product.flag": 0,
// }, function(data){
// $("#rightcolumn").html(data);
// });
});
var juedu = 0;
var isHalf = false;
function setback(){
var strSelect = document.getElementById("martyBack").value;
// alert("back:"+strSelect);
document.getElementById("back").value=strSelect;
turnRound(0);
}
function setToEmpty(){
//alert("hello");
document.getElementById("hat").value=0;
document.getElementById("cloth").value=0;
document.getElementById("trousers").value=0;
document.getElementById("shoe").value=0;
document.getElementById("glasses").value=0;
document.getElementById("bag").value=0;
document.getElementById("earing").value=0;
document.getElementById("necklace").value=0;
turnRound(0);
}
/*
* 转动
*/
function turnRound(view){
juedu += parseInt(view);
var sex = document.getElementById("gender").value;
var waist = document.getElementById("waist").value;
var height = document.getElementById("height").value;
var age = document.getElementById("age").value;
var fuse = document.getElementById("skinColor").value;
var fase = document.getElementById("hairColor").value;
var faxing = document.getElementById("hairStyle").value;
//alert("faxing:"+faxing);
var back = document.getElementById("back").value;
var hat = document.getElementById("hat");
var cloth = document.getElementById("cloth");
var trousers = document.getElementById("trousers");
var shoe = document.getElementById("shoe");
var glasses = document.getElementById("glasses");
var bag = document.getElementById("bag");
var earing = document.getElementById("earing");
var necklace = document.getElementById("necklace");
document.getElementById("view").value = juedu;
if(!isHalf)
cppService.tryOutShirts(age, sex, waist, height, fuse, fase, faxing, back, hat.value, cloth.value, trousers.value, shoe.value, glasses.value, bag.value, earing.value, necklace.value, juedu, getBack);
else
cppService.tryOutShirtsHalfAlpha(age, sex, waist, height, fuse, fase, faxing, back, hat.value, cloth.value, trousers.value, shoe.value, glasses.value, bag.value, earing.value, necklace.value, juedu, getBack);
$("#layer4").show();
}
/*
*半身
*/
function halfBody(){
var back=1;
isHalf = true;
juedu = 0;
var sex = document.getElementById("gender").value;
var waist = document.getElementById("waist").value;
var height = document.getElementById("height").value;
var age = document.getElementById("age").value;
var fuse = document.getElementById("skinColor").value;
var fase = document.getElementById("hairColor").value;
var faxing = document.getElementById("hairStyle").value;
var back = document.getElementById("back").value;
var hat = document.getElementById("hat");
var cloth = document.getElementById("cloth");
var trousers = document.getElementById("trousers");
var shoe = document.getElementById("shoe");
var glasses = document.getElementById("glasses");
var bag = document.getElementById("bag");
var earing = document.getElementById("earing");
var necklace = document.getElementById("necklace");
cppService.tryOutShirtsHalfAlpha(age, sex, waist,height,fuse,fase,faxing,back,hat.value,cloth.value,trousers.value,shoe.value,glasses.value,bag.value,earing.value,necklace.value,0,getBack);
/*var model = document.getElementById("3dman");
image = "${pageContext.request.contextPath}/upload/3dpic/"+"loading.gif";
var src_pic = "<h1 class='loading'><img id='pic' src='"+image+"' /> 更换视角中,请稍后…</h1>";
model.innerHTML = src_pic;*/
}
/*
* 恢复视图
*/
function revert(){
isHalf= false;
juedu = 0;
makeModel();
}
function makeModel(){
if(isHalf == true){
halfBody();
}else{
// var isTryOn=document.getElementById("isTryOn").value;
// if(isTryOn==0){
//var modelsMap=DWRUtil.getValues("form1");
// var back = 1;
// cppService.makeModelPassParameter2(modelsMap,back,getBack);
// }else{
// if(isHalf == true){
// halfBody();
//}else{
//var modelsMap=DWRUtil.getValues("form1");
// var back = 1;
// cppService.makeModelPassParameter2(modelsMap,back,getBack);
var sex = document.getElementById("gender").value;
var waist = document.getElementById("waist").value;
var height = document.getElementById("height").value;
var age = document.getElementById("age").value;
var fuse = document.getElementById("skinColor").value;
var fase = document.getElementById("hairColor").value;
var faxing = document.getElementById("hairStyle").value;
var back = document.getElementById("back").value;
var hat = document.getElementById("hat");
var cloth = document.getElementById("cloth");
var trousers = document.getElementById("trousers");
var shoe = document.getElementById("shoe");
var glasses = document.getElementById("glasses");
var bag = document.getElementById("bag");
var earing = document.getElementById("earing");
var necklace = document.getElementById("necklace");
//document.getElementById("view").value = view;
cppService.tryOutShirts(age, sex, waist,height,fuse,fase,faxing,back,hat.value,cloth.value,trousers.value,shoe.value,glasses.value,bag.value,earing.value,necklace.value,0,getBack);
/*var model = document.getElementById("3dman");
image = "${pageContext.request.contextPath}/upload/3dpic/"+"loading.gif";
var src_pic = "<h1 class='loading'><img id='pic' src='"+image+"' /> 更换视角中,请稍后…</h1>";
model.innerHTML = src_pic;*/
//}
// }
}
}
function showPic(){
$("#layer4").hide();
$("#replaceMan").hide();
$("#3dman").show();
$("#pic").show();
}
function getBack(msg){
var model = document.getElementById("3dman");
image = ctx + "/upload/3dpic/" + msg;
var src_pic = "<img id='pic' style='display:none' οnlοad='showPic();' src='" + image + "' />";
model.innerHTML = src_pic;
var smallmodel = document.getElementById("picImg");
var src="<img id='smallpic' width=/"92/" style='position:relative;left:6px; top:-28px;' height=/"208/" src='"+image+"' /><p style=/"text-align:center/">我的模特</p>";
smallmodel.innerHTML = src;
}
function tryOnCloth(productId, productType,xclick,str){
var model = document.getElementById("3dman");
var replaceMan = document.getElementById("replaceMan");
replaceMan.innerHTML = model.innerHTML;
$("#replaceMan").show();
$("#3dman").hide();
var id = productId;
var hat = document.getElementById("hat");
var cloth = document.getElementById("cloth");
var trousers = document.getElementById("trousers");
var shoe = document.getElementById("shoe");
var glasses = document.getElementById("glasses");
var bag = document.getElementById("bag");
var earing = document.getElementById("earing");
var necklace = document.getElementById("necklace");
var view = document.getElementById("view").value;
if(trousers.value == cloth.value && (productType ==1||productType==2)){
trousers.value = "0";
cloth.value = "0";
}
switch(parseInt(productType)){
case 0: // hat
if( hat.value==id )
return false;
hat.value = id;
break;
case 1: // cloth
if( cloth.value==id )
return false;
cloth.value = id;
break;
case 2: // trousers
if( trousers.value==id )
return false;
trousers.value = id;
break;
case 3: // shoe
if( shoe.value==id )
return false;
shoe.value = id;
break;
case 4: // glasses
if( glasses.value==id )
return false;
glasses.value = id;
break;
case 5: // bag
if( bag.value==id )
return false;
bag.value = id;
break;
case 6: // earing
if( earing.value==id )
return false;
earing.value = id;
break;
case 7: // necklace
if( necklace.value==id )
return false;
necklace.value = id;
break;
case 8: // 套装
if( cloth.value == id || trousers.value == id )
return false;
cloth.value = id;
trousers.value = id;
break;
}
insertTryRecord(id,productType,xclick,str);
if(xclick==1){//在分页中点击
var id = "#" + productId;
var image = document.getElementById(productId);
$(id).TransferTo({
duration: 600,
to: 'clothCenter',
image: image.src,
complete: function(){
turnRound(0);
}
});
}
if(xclick==2){//在插入中点击
id = "#" + productId+"s";
var ss=productId+"s";
var image = document.getElementById(ss);
$(id).TransferTo({
duration: 600,
to: 'clothCenter',
image: image.src,
complete: function(){
turnRound(0);
}
});
}
return false;
}
var tryabc = new Array(); // 放试穿衣服记录的数组
var idArray = new Array(); // 放试穿衣服记录ID的数组
var index=0;
var currentStartRecords = 0;
/**
* 插入试衣记录
*/
function insertTryRecord(id,productType,xclick,str){
/*
*id 产品id
* productType 产品类型
* xclick 在哪里点击,1,在分页处点击;2,在记录处点击
* str 图片的地址
*/
var len = idArray.length;
for(var i=0 ; i<len; i++){
//防止重复插入
if(idArray[i] == id)
return false;
}
idArray[len] = id;
var iddown=id+"s";//为记录图片分配id,加s用于区别分页页面分配的id
var recordchoice =document.getElementById("recordchoice");//获取图片字符串
var recordsCount =document.getElementById("recordsCount");//记录的条数
var strHtml = "<a href=/"javascript:void(0);/" οnclick=/"return tryOnCloth("+id+","+productType+",2);/">" +
"<img id='"+iddown+"' src='"+str+"' /></a>";//拼图片字符串
//alert("strHtml:"+strHtml);
if(recordsCount.value < 6 ){
recordchoice.innerHTML += strHtml;
recordsCount.value = parseInt(recordsCount.value) + 1;
tryabc[index]=strHtml;
index ++;
}else{
recordsCount.value = parseInt(recordsCount.value) + 1;
recordchoice.innerHTML = "";
var iIndex = index;
tryabc[iIndex] = strHtml;
index ++;
//alert("index:"+index);
var startRecords = document.getElementById("startRecords");
//alert("startRecords.value:"+startRecords.value);
startRecords.value = parseInt(startRecords.value) +1;
//alert("abc.length:"+abc.length);
for(var i=startRecords.value; i<tryabc.length; i++){//先清空图片字符串,然后再遍历字数组
//alert(abc[i]);
recordchoice.innerHTML = recordchoice.innerHTML + tryabc[i];
}
}
currentStartRecords = document.getElementById("startRecords").value;
}
function navPage(page,flag){
// alert("$(/"#category/").val():"+$("#category").val());
$(document).ready(function(){
// 右面搜索结果的ajax页面
// alert("hello:"+$("#category").val());
//alert("hello:"+$("#MartysmallCategory").val());
// alert("color:"+$("#MartyColor").val());
// alert("design:"+$("#MartyDesign").val());
$.post("getProductList.action", {
"product.supplier.id":$("#supplierid").val(),//产品品牌
"product.intermdeiatecategory":$("#Martyintermdeiatecategory").val(),//产品中类
"product.smallCategory":$("#MartysmallCategory").val(),//产品小类
"product.smallsmallcategory":$("Martysmallsmallcategory").val(),//产品小小类
"product.color":$("#MartyColor").val(),//颜色
"product.design":$("#MartyDesign").val(),//图案
"product.feature":$("#Martyfeature").val(),//质地
"product.size":$("#Martysize").val(),//尺码
"priceRange.minPrice":$("#MartyminPrice").val(),//最低价
"priceRange.maxPrice":$("#MartymaxPrice").val(),//最高价
"product.publishTime":$("#MartypublishTime").val(),//上架时间
"martyStr":$("#martyStrsss").val(),//时间标识
"martyProductTypeFirstName":$("#ProductTypeFirst").val(),
"martyProductTypeSencondName":$("#ProductTypeSencond").val(),
"martyProductTypeThirdtName":$("#ProductTypeThird").val(),
"supplieridName":$("#supplieridNa").val(),
"product.flag": flag,
"page.currentPage": page,
"product.category":$("#category").val()//产品大类
}, function(data){
// alert(data);
$("#martyRight").html(data);
});
});
}
function getPage(i,flag){
var page = document.getElementsByName("pageRequest")[i].value;
navPage(page,flag);
}
/*
* 添加到衣柜
*/
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 lookRecordLeft(){
var recordchoice = document.getElementById("recordchoice");
currentStartRecords = parseInt(currentStartRecords) -1;
if( currentStartRecords < 0 ){
currentStartRecords = 0;
return false;
}
recordchoice.innerHTML = "";
for(var i=currentStartRecords; i<(parseInt(currentStartRecords)+6); i++){
recordchoice.innerHTML = recordchoice.innerHTML + tryabc[i];
}
return true;
}
function lookRecordRight(){
var recordchoice = document.getElementById("recordchoice");
var currentEndRecords = parseInt(currentStartRecords) + 6;
if( currentEndRecords >= tryabc.length )
return false;
currentStartRecords = parseInt(currentStartRecords) + 1;
recordchoice.innerHTML = "";
for(var i=currentStartRecords; i<(parseInt(currentStartRecords)+6); i++){
recordchoice.innerHTML = recordchoice.innerHTML + tryabc[i];
}
return true;
}