//订单
var webOrder={};
webOrder.getBasePath = function(){
var result = ""
try{a = b}catch(e){
if(e.fileName){//firefox
result = e.fileName;
}else if(e.sourceURL){//safari
result = e.sourceURL;
}else if(e.stacktrace){//opera
var m = e.stacktrace.match(/\(\) in\s+(.*?\:\/\/\S+)/m);
if (m && m[1])
result = m[1]
}
}
if(!result){//IE与chrome
var scripts = document.getElementsByTagName("script");
var reg = /order\/inculde\.js(\W|$)/i
for(var i = 0 , n = scripts.length ; i 0){ID=$(IDBox).text();}else{ID=IDBox;}}
else if(typeof(IDBox)=='number'){ID=IDBox;}
if(!ID)return;
var goodsID=0;
if(typeof(goodsIDBox)=='object'){if(goodsIDBox.size()>0)goodsID=goodsIDBox.text();}
else if(typeof(goodsIDBox)=='string'){if($(goodsIDBox).size()>0){goodsID=$(goodsIDBox).text();}else{goodsID=goodsIDBox;}}
else if(typeof(goodsIDBox)=='number'){goodsID=goodsIDBox;}
var name='';
if(typeof(nameBox)=='object'){if(nameBox.size()>0)name=nameBox.text();}
else if(typeof(nameBox)=='string'){if($(nameBox).size()>0){name=$(nameBox).text();}else{name=nameBox;}}
else if(typeof(nameBox)=='number'){name=nameBox;}
var img=webOrder.getBasePath()+'images/img.gif';
if(typeof(imgBox)=='object'){
if(imgBox.size()>0){
if(imgBox.find('img').size()>0)img=imgBox.find('img').eq(0).attr('src');
else img=imgBox.text();
}
}else if(typeof(imgObj)=='string'){
if($(imgObj).size()>0){
if(imgBox.find('img').size()>0)img=imgBox.find('img').eq(0).attr('src');
else img=imgBox.text();
}else{img=imgObj;}
}
var price=0;
if(typeof(priceBox)=='object'){
if(priceBox.size()>0)if(priceBox.val()){price=priceBox.val();} else {price=priceBox.text();}
price=price.replace(' ','');price=price.replace('$','');price=price.replace('¥','');
}else if(typeof(priceBox)=='string'){
if($(priceBox).size()>0){if($(priceBox).val()){price=$(priceBox).val()}else{price=$(priceBox).text();}}else{price=priceBox;}
price=price.replace(' ','');price=price.replace('$','');price=price.replace('¥','');
}else if(typeof(priceBox)=='number'){price=priceBox;}
var detail='';
if(typeof(detailBox)=='object'){if(detailBox.size()>0)if(detailBox.val()){detail=detailBox.val();} else {detail=detailBox.text();}}
else if(typeof(detailBox)=='string'){
if($(detailBox).size()>0){if($(detailBox).val()){detail=$(detailBox).val()}else{detail=$(detailBox).text();}}
else{detail=detailBox;}}
else if(typeof(detailBox)=='number'){detail=detailBox;}
var num=1;
if(typeof(numBox)=='object'){if(numBox.size()>0)if(numBox.val()){num=numBox.val()} else {num=numBox.text();}}
else if(typeof(numBox)=='string'){
if($(numBox).size()>0){if($(numBox).val()){num=$(numBox).val()}else{num=$(numBox).text();}}
else{num=numBox;}}
else if(typeof(numBox)=='number'){num=numBox;}
if(num<=0)num=1;
if(!$.getCookie('myShoppingCart')){
$.setCookie('myShoppingCart',ID+'#&'+goodsID+'#&'+name+'#&'+img+'#&'+price+'#&'+detail+'#&'+num);
}else{
var temp=$.getCookie('myShoppingCart').split('##');
var has=false;
for(var i=0;i ')
.click(function(){$(this).children('img').attr('src',webOrder.getBasePath()+'../base/checkUpCode/?'+new Date())});
$('#postageBox').hide();$('#payBox').hide();
var myShoppingCart = $.getCookie('myShoppingCart');
myShoppingCart=myShoppingCart.split('##');
for (var i=0; i
jquery插件
$.extend({
//
// //获取页面名称
getPageName:function(){
var fname=window.location.href.match(/.+\/([^?]*)/)[1];
return fname.substring(0,fname.indexOf("."));
},
//获取页面参数
getParameter:function(valueName){
try{
var str=document.location.href;
var a=str.split("?");
a=a[1].split("&");
for(var i=0;i=0) && (str.charCodeAt(i)<=255)){
sum=sum+1;
}else{sum=sum+2;}
if(sum>(len*2))break;
str1+=str.charAt(i);
}
return str1;
},
// js css 动态导入
includePath:'',
include: function(file){
var files = typeof(file)== "string"?[file]:file;
for (var i = 0; i < files.length; i++){
var name = files[i].replace(/^\s|\s$/g, "");
var name=files[i];
var att = name.split('.');
var ext = att[att.length - 1].toLowerCase();
if(ext=='js'){
var fileref=document.createElement('script');//创建标签
fileref.setAttribute("type","text/javascript");//定义属性type的值为text/javascript
fileref.setAttribute("src", $.includePath + name);//文件的地址
document.getElementsByTagName("head")[0].appendChild(fileref);
}else if(ext=='css'){
var fileref=document.createElement("link");
fileref.setAttribute("rel", "stylesheet");
fileref.setAttribute("type", "text/css");
fileref.setAttribute("href", $.includePath + name);
document.getElementsByTagName("head")[0].appendChild(fileref);
}
}
},
// 弹出面板
openMyPannel:function (){
var w=0;
if (arguments[0])w=arguments[0];
else w=500;
var t=0;
if (arguments[1])t=arguments[1];
else t=$(window).scrollTop()+$(window).height()/4;
var zindex=100;
if (arguments[2])zindex=arguments[2];
var jqueryObj=$('');
jqueryObj.appendTo($('Body'));
jqueryObj.html('');
jqueryObj.css({
'position': 'absolute','top': t+'px',
'left': Math.round(($(window).width() - w) / 2)+'px',
'z-index': zindex
})
var bgObj=$('');
bgObj.appendTo($('Body'));
if(arguments[2]){bgObj.css({
'position': 'absolute','background': '#000',
'opacity': '0.0','-moz-opacity': '0.0',
'-khtml-opacity': '0.0','filter': 'alpha(opacity=0)',
'width': '100%',
'height': $(window).height()>$(document).height()?$(window).height():$(document).height()+'px',
'top': '0','left':'0','z-index': zindex-1
})}else{
bgObj.css({
'position': 'absolute','background': '#000',
'opacity': '0.4','-moz-opacity': '0.4',
'-khtml-opacity': '0.4','filter': 'alpha(opacity=40)',
'width': '100%',
'height': $(window).height()>$(document).height()?$(window).height():$(document).height()+'px',
'top': '0','left':'0','z-index': zindex-1
})
}
jqueryObj.data('bg',bgObj);
return jqueryObj;
},
closeMyPannel:function (jqueryObj){
var bgObj=jqueryObj.data('bg');
bgObj.remove();
jqueryObj.remove();
//if($('#myPannelBox').size()>0)$('#myPannelBox').remove();
//if($('#myPannelBoxBg').size()>0)$('#myPannelBoxBg').remove();
},
pannelBgClose:function(jqueryObj){
var bgObj=jqueryObj.data('bg');
bgObj.click(function(){
bgObj.remove();
jqueryObj.remove();
})
},
//重新设置 背景尺寸 在面板 尺寸改变后
pannelBgResize:function(jqueryObj){
var bgObj=jqueryObj.data('bg');
bgObj.css({'height':$(window).height()>$(document).height()?$(window).height():$(document).height()+'px'})
},
/** 小 面板 打开
* 面板背景为透明 点击面板背景 关闭面板 top left 为 按钮 位置 参数 2 3为 偏移
* 参数1 为 传入 button 的 辨别 字符串
参数2 selfClose 是否 点自己 关闭
*/
openLittlePannel:function (button,selfClose){
if(!button)return;
var offset = $(button).offset();
var l=offset.left;
if (arguments[1])l=offset.left+arguments[1];
var t=offset.top;
if (arguments[2])t=offset.top+arguments[2];
var zindex=100;
if (arguments[3])zindex=arguments[3];
var jqueryObj=$('');
jqueryObj.appendTo($('Body'));
jqueryObj.html('');
jqueryObj.css({
'position': 'absolute','top': t+'px',
'left': l+'px',
'z-index': zindex
})
var bgObj=$('');
bgObj.appendTo($('Body'));
bgObj.css({
'position': 'absolute','background': '#000',
'opacity': '0.0','-moz-opacity': '0.0',
'-khtml-opacity': '0.0','filter': 'alpha(opacity=0)',
'width': '100%',
'height': $(window).height()>$(document).height()?$(window).height():$(document).height()+'px',
'top': '0','left':'0','z-index': zindex-1
})
bgObj.click(function(){
bgObj.remove(); jqueryObj.remove()
})
if(selfClose){
jqueryObj.click(function(){bgObj.remove(); jqueryObj.remove();})
}
return jqueryObj;
},
//cookie 操作
setCookie:function(name,value){//两个参数,一个是cookie的名子,一个是值
var Days = 30; //此 cookie 将被保存 30 天
var exp = new Date(); //new Date("December 31, 9998");
exp.setTime(exp.getTime() + Days*24*60*60*1000);
document.cookie = name + "="+ escape (value) + ";expires=" + exp.toGMTString();
},
getCookie:function (name){//取cookies函数
var arr = document.cookie.match(new RegExp("(^| )"+name+"=([^;]*)(;|$)"));
if(arr != null) return unescape(arr[2]); return null;
},
delCookie:function (name){//删除cookie
var exp = new Date();
exp.setTime(exp.getTime() - 1);
var cval=$.getCookie(name);
//if(cval!=null) document.cookie= name + "="+cval+";expires="+exp.toGMTString();
if(cval!=null) document.cookie= name + "=;expires="+exp.toGMTString();
}
})