/* $id : common.js 4865 2007-01-31 14:04:10z paulgao $ */ function addtocart1(goodsid, parentid) { var goods = new object(); var spec_arr = new array(); var fittings_arr = new array(); var number = 1; var formbuy = document.forms['ecs_formbuy']; var quick = 0; // 检查是否有商品规格 if (formbuy) { spec_arr = getselectedattributes(formbuy); if (formbuy.elements['number']) { number = formbuy.elements['number'].value; } quick = 1; } goods.quick = quick; goods.spec = spec_arr; goods.goods_id = goodsid; goods.number = number; goods.parent = (typeof(parentid) == "undefined") ? 0 : parseint(parentid); ajax.call('flow.php?step=add_to_cart', 'goods=' + $.tojson(goods), addtocartresponse1, 'post', 'json'); } function addtocartresponse1(result) { if (result.error > 0) { // 如果需要缺货登记,跳转 if (result.error == 2) { if (confirm(result.message)) { location.href = 'user.php?act=add_booking&id=' + result.goods_id + '&spec=' + result.product_spec; } } // 没选规格,弹出属性选择框 else if (result.error == 6) { openspediv1(result.message, result.goods_id, result.parent); } else { alert(result.message); } } else { var cartinfo = document.getelementbyid('ecs_cartinfo'); var cart_url = 'flow.php?step=cart'; if (cartinfo) { cartinfo.innerhtml = result.content; } if (result.one_step_buy == '1') { location.href = cart_url; } else { location.href = cart_url; } } } //生成属性选择层 function openspediv1(message, goods_id, parent) { var _id = "spediv"; var m = "mask"; if (docele(_id)) document.removechild(docele(_id)); if (docele(m)) document.removechild(docele(m)); //计算上卷元素值 var scrollpos; if (typeof window.pageyoffset != 'undefined') { scrollpos = window.pageyoffset; } else if (typeof document.compatmode != 'undefined' && document.compatmode != 'backcompat') { scrollpos = document.documentelement.scrolltop; } else if (typeof document.body != 'undefined') { scrollpos = document.body.scrolltop; } var i = 0; var sel_obj = document.getelementsbytagname('select'); while (sel_obj[i]) { sel_obj[i].style.visibility = "hidden"; i++; } // 新激活图层 var newdiv = document.createelement("div"); newdiv.id = _id; newdiv.style.position = "absolute"; newdiv.style.zindex = "10000"; newdiv.style.width = "300px"; newdiv.style.height = "260px"; newdiv.style.top = (parseint(scrollpos + 200)) + "px"; newdiv.style.left = (parseint(document.body.offsetwidth) - 200) / 2 + "px"; // 屏幕居中 newdiv.style.overflow = "auto"; newdiv.style.background = "#fff"; newdiv.style.border = "3px solid #59b0ff"; newdiv.style.padding = "5px"; //生成层内内容 newdiv.innerhtml = '

' + select_spe + "

"; for (var spec = 0; spec < message.length; spec++) { newdiv.innerhtml += '
' + message[spec]['name'] + '
'; if (message[spec]['attr_type'] == 1) { for (var val_arr = 0; val_arr < message[spec]['values'].length; val_arr++) { if (val_arr == 0) { newdiv.innerhtml += "" + message[spec]['values'][val_arr]['label'] + ' [' + message[spec]['values'][val_arr]['format_price'] + ']
'; } else { newdiv.innerhtml += "" + message[spec]['values'][val_arr]['label'] + ' [' + message[spec]['values'][val_arr]['format_price'] + ']
'; } } newdiv.innerhtml += ""; } else { for (var val_arr = 0; val_arr < message[spec]['values'].length; val_arr++) { newdiv.innerhtml += "" + message[spec]['values'][val_arr]['label'] + ' [' + message[spec]['values'][val_arr]['format_price'] + ']
'; } newdiv.innerhtml += ""; } } newdiv.innerhtml += "
[" + btn_buy + "]  [" + is_cancel + "]
"; document.body.appendchild(newdiv); // mask图层 var newmask = document.createelement("div"); newmask.id = m; newmask.style.position = "absolute"; newmask.style.zindex = "9999"; newmask.style.width = document.body.scrollwidth + "px"; newmask.style.height = document.body.scrollheight + "px"; newmask.style.top = "0px"; newmask.style.left = "0px"; newmask.style.background = "#fff"; newmask.style.filter = "alpha(opacity=30)"; newmask.style.opacity = "0.40"; document.body.appendchild(newmask); } //获取选择属性后,再次提交到购物车 function submit_div1(goods_id, parentid) { var goods = new object(); var spec_arr = new array(); var fittings_arr = new array(); var number = 1; var input_arr = document.getelementsbytagname('input'); var quick = 1; var spec_arr = new array(); var j = 0; for (i = 0; i < input_arr.length; i ++ ) { var prefix = input_arr[i].name.substr(0, 5); if (prefix == 'spec_' && ( ((input_arr[i].type == 'radio' || input_arr[i].type == 'checkbox') && input_arr[i].checked))) { spec_arr[j] = input_arr[i].value; j++ ; } } goods.quick = quick; goods.spec = spec_arr; goods.goods_id = goods_id; goods.number = number; goods.parent = (typeof(parentid) == "undefined") ? 0 : parseint(parentid); ajax.call('flow.php?step=add_to_cart', 'goods=' + $.tojson(goods), addtocartresponse1, 'post', 'json'); document.body.removechild(docele('spediv')); document.body.removechild(docele('mask')); var i = 0; var sel_obj = document.getelementsbytagname('select'); while (sel_obj[i]) { sel_obj[i].style.visibility = ""; i++; } } /* * * 添加商品到购物车 */ function addtocart(goodsid, parentid) { var goods = new object(); var spec_arr = new array(); var fittings_arr = new array(); var number = 1; var formbuy = document.forms['ecs_formbuy']; var quick = 0; // 检查是否有商品规格 if (formbuy) { spec_arr = getselectedattributes(formbuy); if (formbuy.elements['number']) { number = formbuy.elements['number'].value; } quick = 1; } goods.quick = quick; goods.spec = spec_arr; goods.goods_id = goodsid; goods.number = number; goods.parent = (typeof(parentid) == "undefined") ? 0 : parseint(parentid); ajax.call('flow.php?step=add_to_cart', 'goods=' + $.tojson(goods), addtocartresponse, 'post', 'json'); } /** * 再次购买 */ function repurchase(order_id) { var cart_url = 'flow.php?step=cart&type=5'; ajax.call('flow.php?step=repurchase', 'order_id=' + order_id, function(data){ if (data.error == 0) { location.href = cart_url; } else { console.log(data); alert(data.message); } }, 'post', 'json'); } /** * 获得选定的商品属性 */ function getselectedattributes(formbuy) { var spec_arr = new array(); var j = 0; for (i = 0; i < formbuy.elements.length; i ++ ) { var prefix = formbuy.elements[i].name.substr(0, 5); if (prefix == 'spec_' && ( ((formbuy.elements[i].type == 'radio' || formbuy.elements[i].type == 'checkbox') && formbuy.elements[i].checked) || formbuy.elements[i].tagname == 'select')) { spec_arr[j] = formbuy.elements[i].value; j++ ; } } return spec_arr; } /* * * 处理添加商品到购物车的反馈信息 */ function addtocartresponse(result) { if (result.error > 0) { // 如果需要缺货登记,跳转 if (result.error == 2) { if (confirm(result.message)) { location.href = 'user.php?act=add_booking&id=' + result.goods_id + '&spec=' + result.product_spec; } } // 没选规格,弹出属性选择框 else if (result.error == 6) { openspediv(result.message, result.goods_id, result.parent); } else { alert(result.message); } } else { var cartinfo = document.getelementbyid('ecs_cartinfo'); var cart_url = 'flow.php?step=cart'; if (cartinfo) { cartinfo.innerhtml = result.content; } if (result.one_step_buy == '1') { location.href = cart_url; } else { switch(result.confirm_type) { case '1' : if (confirm(result.message)) location.href = cart_url; break; case '2' : if (!confirm(result.message)) location.href = cart_url; break; case '3' : location.href = cart_url; break; default : easydialog.open({ container : 'cart_show' }); break; } } } } /* * * 添加商品到收藏夹 */ function collect(goodsid) { ajax.call('user.php?act=collect', 'id=' + goodsid, collectresponse, 'get', 'json'); } /* * * 处理收藏商品的反馈信息 */ function collectresponse(result) { alert(result.message); } /* * * 处理会员登录的反馈信息 */ function signinresponse(result) { toggleloader(false); var done = result.substr(0, 1); var content = result.substr(2); if (done == 1) { document.getelementbyid('member-zone').innerhtml = content; } else { alert(content); } } /* * * 评论的翻页函数 */ function gotopage(page, id, type) { ajax.call('comment.php?act=gotopage', 'page=' + page + '&id=' + id + '&type=' + type, gotopageresponse, 'get', 'json'); } function gotopageresponse(result) { document.getelementbyid("ecs_comment").innerhtml = result.content; } /* * * 商品购买记录的翻页函数 */ function gotobuypage(page, id) { ajax.call('goods.php?act=gotopage', 'page=' + page + '&id=' + id, gotobuypageresponse, 'get', 'json'); } function gotobuypageresponse(result) { document.getelementbyid("ecs_bought").innerhtml = result.result; } /* * * 取得格式化后的价格 * @param : float price */ function getformatedprice(price) { if (currencyformat.indexof("%s") > - 1) { return currencyformat.replace('%s', advformatnumber(price, 2)); } else if (currencyformat.indexof("%d") > - 1) { return currencyformat.replace('%d', advformatnumber(price, 0)); } else { return price; } } /* * * 夺宝奇兵会员出价 */ function bid(step) { var price = ''; var msg = ''; if (step != - 1) { var frm = document.forms['formbid']; price = frm.elements['price'].value; id = frm.elements['snatch_id'].value; if (price.length == 0) { msg += price_not_null + '\n'; } else { var reg = /^[\.0-9]+/; if ( ! reg.test(price)) { msg += price_not_number + '\n'; } } } else { price = step; } if (msg.length > 0) { alert(msg); return; } ajax.call('snatch.php?act=bid&id=' + id, 'price=' + price, bidresponse, 'post', 'json') } /* * * 夺宝奇兵会员出价反馈 */ function bidresponse(result) { if (result.error == 0) { document.getelementbyid('ecs_snatch').innerhtml = result.content; if (document.forms['formbid']) { document.forms['formbid'].elements['price'].focus(); } newprice(); //刷新价格列表 } else { alert(result.content); } } /* * * 夺宝奇兵最新出价 */ function newprice(id) { ajax.call('snatch.php?act=new_price_list&id=' + id, '', newpriceresponse, 'get', 'text'); } /* * * 夺宝奇兵最新出价反馈 */ function newpriceresponse(result) { document.getelementbyid('ecs_price_list').innerhtml = result; } /* * * 返回属性列表 */ function getattr(cat_id) { var tbodies = document.getelementsbytagname('tbody'); for (i = 0; i < tbodies.length; i ++ ) { if (tbodies[i].id.substr(0, 10) == 'goods_type')tbodies[i].style.display = 'none'; } var type_body = 'goods_type_' + cat_id; try { document.getelementbyid(type_body).style.display = ''; } catch (e) { } } /* * * 截取小数位数 */ function advformatnumber(value, num) // 四舍五入 { var a_str = formatnumber(value, num); var a_int = parsefloat(a_str); if (value.tostring().length > a_str.length) { var b_str = value.tostring().substring(a_str.length, a_str.length + 1); var b_int = parsefloat(b_str); if (b_int < 5) { return a_str; } else { var bonus_str, bonus_int; if (num == 0) { bonus_int = 1; } else { bonus_str = "0." for (var i = 1; i < num; i ++ ) bonus_str += "0"; bonus_str += "1"; bonus_int = parsefloat(bonus_str); } a_str = formatnumber(a_int + bonus_int, num) } } return a_str; } function formatnumber(value, num) // 直接去尾 { var a, b, c, i; a = value.tostring(); b = a.indexof('.'); c = a.length; if (num == 0) { if (b != - 1) { a = a.substring(0, b); } } else { if (b == - 1) { a = a + "."; for (i = 1; i <= num; i ++ ) { a = a + "0"; } } else { a = a.substring(0, b + num + 1); for (i = c; i <= b + num; i ++ ) { a = a + "0"; } } } return a; } /* * * 根据当前shiping_id设置当前配送的的保价费用,如果保价费用为0,则隐藏保价费用 * * return void */ function set_insure_status() { // 取得保价费用,取不到默认为0 var shippingid = getradiovalue('shipping'); var insure_fee = 0; if (shippingid > 0) { if (document.forms['theform'].elements['insure_' + shippingid]) { insure_fee = document.forms['theform'].elements['insure_' + shippingid].value; } // 每次取消保价选择 if (document.forms['theform'].elements['need_insure']) { document.forms['theform'].elements['need_insure'].checked = false; } // 设置配送保价,为0隐藏 if (document.getelementbyid("ecs_insure_cell")) { if (insure_fee > 0) { document.getelementbyid("ecs_insure_cell").style.display = ''; setvalue(document.getelementbyid("ecs_insure_fee_cell"), getformatedprice(insure_fee)); } else { document.getelementbyid("ecs_insure_cell").style.display = "none"; setvalue(document.getelementbyid("ecs_insure_fee_cell"), ''); } } } } /* * * 当支付方式改变时出发该事件 * @param pay_id 支付方式的id * return void */ function changepayment(pay_id) { // 计算订单费用 calculateorderfee(); } function getcoordinate(obj) { var pos = { "x" : 0, "y" : 0 } pos.x = document.body.offsetleft; pos.y = document.body.offsettop; do { pos.x += obj.offsetleft; pos.y += obj.offsettop; obj = obj.offsetparent; } while (obj.tagname.touppercase() != 'body') return pos; } function showcatalog(obj) { var pos = getcoordinate(obj); var div = document.getelementbyid('ecs_catalog'); if (div && div.style.display != 'block') { div.style.display = 'block'; div.style.left = pos.x + "px"; div.style.top = (pos.y + obj.offsetheight - 1) + "px"; } } function hidecatalog(obj) { var div = document.getelementbyid('ecs_catalog'); if (div && div.style.display != 'none') div.style.display = "none"; } function sendhashmail() { ajax.call('user.php?act=send_hash_mail', '', sendhashmailresponse, 'get', 'json') } function sendhashmailresponse(result) { alert(result.message); } /* 订单查询 */ function orderquery() { var order_sn = document.forms['ecsorderquery']['order_sn'].value; var reg = /^[\.0-9]+/; if (order_sn.length < 10 || ! reg.test(order_sn)) { alert(invalid_order_sn); return; } ajax.call('user.php?act=order_query&order_sn=s' + order_sn, '', orderqueryresponse, 'get', 'json'); } function orderqueryresponse(result) { if (result.message.length > 0) { alert(result.message); } if (result.error == 0) { var div = document.getelementbyid('ecs_order_query'); div.innerhtml = result.content; } } function display_mode(str) { document.getelementbyid('display').value = str; settimeout(dosubmit, 0); function dosubmit() {document.forms['listform'].submit();} } function display_mode_wholesale(str) { document.getelementbyid('display').value = str; settimeout(dosubmit, 0); function dosubmit() { document.forms['wholesale_goods'].action = "wholesale.php"; document.forms['wholesale_goods'].submit(); } } /* 修复ie6以下版本png图片alpha */ function fixpng() { var arversion = navigator.appversion.split("msie") var version = parsefloat(arversion[1]) if ((version >= 5.5) && (document.body.filters)) { for(var i=0; i" img.outerhtml = strnewhtml i = i-1 } } } } function hash(string, length) { var length = length ? length : 32; var start = 0; var i = 0; var result = ''; filllen = length - string.length % length; for(i = 0; i < filllen; i++) { string += "0"; } while(start < string.length) { result = stringxor(result, string.substr(start, length)); start += length; } return result; } function stringxor(s1, s2) { var s = ''; var hash = 'abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz'; var max = math.max(s1.length, s2.length); for(var i=0; i]*?src=\"([^\>]*?)\"[^\>]*?(reload=\"1\")?(?:charset=\"([\w\-]+?)\")?><\/script>/ig; var arr = new array(); while(arr = p.exec(s)) appendscript(arr[1], '', arr[2], arr[3]); return s; } function $$(id) { return document.getelementbyid(id); } function appendscript(src, text, reload, charset) { var id = hash(src + text); if(!reload && in_array(id, evalscripts)) return; if(reload && $$(id)) { $$(id).parentnode.removechild($$(id)); } evalscripts.push(id); var scriptnode = document.createelement("script"); scriptnode.type = "text/javascript"; scriptnode.id = id; //scriptnode.charset = charset; try { if(src) { scriptnode.src = src; } else if(text) { scriptnode.text = text; } $$('append_parent').appendchild(scriptnode); } catch(e) {} } function in_array(needle, haystack) { if(typeof needle == 'string' || typeof needle == 'number') { for(var i in haystack) { if(haystack[i] == needle) { return true; } } } return false; } var pmwinposition = new array(); var useragent = navigator.useragent.tolowercase(); var is_opera = useragent.indexof('opera') != -1 && opera.version(); var is_moz = (navigator.product == 'gecko') && useragent.substr(useragent.indexof('firefox') + 8, 3); var is_ie = (useragent.indexof('msie') != -1 && !is_opera) && useragent.substr(useragent.indexof('msie') + 5, 3); function pmwin(action, param) { var objs = document.getelementsbytagname("object"); if(action == 'open') { for(i = 0;i < objs.length; i ++) { if(objs[i].style.visibility != 'hidden') { objs[i].setattribute("oldvisibility", objs[i].style.visibility); objs[i].style.visibility = 'hidden'; } } var clientwidth = document.body.clientwidth; var clientheight = document.documentelement.clientheight ? document.documentelement.clientheight : document.body.clientheight; var scrolltop = document.body.scrolltop ? document.body.scrolltop : document.documentelement.scrolltop; var pmwidth = 800; var pmheight = clientheight * 0.9; if(!$$('pmlayer')) { div = document.createelement('div');div.id = 'pmlayer'; div.style.width = pmwidth + 'px'; div.style.height = pmheight + 'px'; div.style.left = ((clientwidth - pmwidth) / 2) + 'px'; div.style.position = 'absolute'; div.style.zindex = '999'; $$('append_parent').appendchild(div); $$('pmlayer').innerhtml = '
' + '
' + '
' + '' + '
'; } $$('pmlayer').style.display = ''; $$('pmlayer').style.top = ((clientheight - pmheight) / 2 + scrolltop) + 'px'; if(!param) { pmframe.location = 'pm.php'; } else { pmframe.location = 'pm.php?' + param; } } else if(action == 'close') { for(i = 0;i < objs.length; i ++) { if(objs[i].attributes['oldvisibility']) { objs[i].style.visibility = objs[i].attributes['oldvisibility'].nodevalue; objs[i].removeattribute('oldvisibility'); } } hiddenobj = new array(); $$('pmlayer').style.display = 'none'; } } var pmwindragstart = new array(); function pmwindrag(e, op) { if(op == 1) { pmwindragstart = is_ie ? [event.clientx, event.clienty] : [e.clientx, e.clienty]; pmwindragstart[2] = parseint($$('pmlayer').style.left); pmwindragstart[3] = parseint($$('pmlayer').style.top); doane(e); } else if(op == 2 && pmwindragstart[0]) { var pmwindragnow = is_ie ? [event.clientx, event.clienty] : [e.clientx, e.clienty]; $$('pmlayer').style.left = (pmwindragstart[2] + pmwindragnow[0] - pmwindragstart[0]) + 'px'; $$('pmlayer').style.top = (pmwindragstart[3] + pmwindragnow[1] - pmwindragstart[1]) + 'px'; doane(e); } else if(op == 3) { pmwindragstart = []; doane(e); } } function doane(event) { e = event ? event : window.event; if(is_ie) { e.returnvalue = false; e.cancelbubble = true; } else if(e) { e.stoppropagation(); e.preventdefault(); } } /* * * 添加礼包到购物车 */ function addpackagetocart(packageid) { var package_info = new object(); var number = 1; package_info.package_id = packageid package_info.number = number; ajax.call('flow.php?step=add_package_to_cart', 'package_info=' + $.tojson(package_info), addpackagetocartresponse, 'post', 'json'); } /* * * 处理添加礼包到购物车的反馈信息 */ function addpackagetocartresponse(result) { if (result.error > 0) { if (result.error == 2) { if (confirm(result.message)) { location.href = 'user.php?act=add_booking&id=' + result.goods_id; } } else { alert(result.message); } } else { var cartinfo = document.getelementbyid('shoppingcarnone'); var cart_url = 'flow.php?step=cart'; if (cartinfo) { cartinfo.innerhtml = result.content; } if (result.one_step_buy == '1') { location.href = cart_url; } else { switch(result.confirm_type) { case '1' : if (confirm(result.message)) location.href = cart_url; break; case '2' : if (!confirm(result.message)) location.href = cart_url; break; case '3' : location.href = cart_url; break; default : easydialog.open({ container : 'cart_show' }); break; } } } } function setsuitshow(suitid) { var suit = document.getelementbyid('suit_'+suitid); if(suit == null) { return; } if(suit.style.display=='none') { suit.style.display=''; } else { suit.style.display='none'; } } /* 以下四个函数为属性选择弹出框的功能函数部分 */ //检测层是否已经存在 function docele() { return document.getelementbyid(arguments[0]) || false; } //生成属性选择层 function openspediv(message, goods_id, parent) { var _id = "spediv"; var m = "mask"; if (docele(_id)) document.removechild(docele(_id)); if (docele(m)) document.removechild(docele(m)); //计算上卷元素值 var scrollpos; if (typeof window.pageyoffset != 'undefined') { scrollpos = window.pageyoffset; } else if (typeof document.compatmode != 'undefined' && document.compatmode != 'backcompat') { scrollpos = document.documentelement.scrolltop; } else if (typeof document.body != 'undefined') { scrollpos = document.body.scrolltop; } var i = 0; var sel_obj = document.getelementsbytagname('select'); while (sel_obj[i]) { sel_obj[i].style.visibility = "hidden"; i++; } // 新激活图层 var newdiv = document.createelement("div"); newdiv.id = _id; newdiv.style.position = "absolute"; newdiv.style.zindex = "10000"; newdiv.style.width = "300px"; newdiv.style.height = "260px"; newdiv.style.top = (parseint(scrollpos + 200)) + "px"; newdiv.style.left = (parseint(document.body.offsetwidth) - 200) / 2 + "px"; // 屏幕居中 newdiv.style.overflow = "auto"; newdiv.style.background = "#fff"; newdiv.style.border = "3px solid #59b0ff"; newdiv.style.padding = "5px"; //生成层内内容 newdiv.innerhtml = '

' + select_spe + "

"; for (var spec = 0; spec < message.length; spec++) { newdiv.innerhtml += '
' + message[spec]['name'] + '
'; if (message[spec]['attr_type'] == 1) { for (var val_arr = 0; val_arr < message[spec]['values'].length; val_arr++) { if (val_arr == 0) { newdiv.innerhtml += "" + message[spec]['values'][val_arr]['label'] + ' [' + message[spec]['values'][val_arr]['format_price'] + ']
'; } else { newdiv.innerhtml += "" + message[spec]['values'][val_arr]['label'] + ' [' + message[spec]['values'][val_arr]['format_price'] + ']
'; } } newdiv.innerhtml += ""; } else { for (var val_arr = 0; val_arr < message[spec]['values'].length; val_arr++) { newdiv.innerhtml += "" + message[spec]['values'][val_arr]['label'] + ' [' + message[spec]['values'][val_arr]['format_price'] + ']
'; } newdiv.innerhtml += ""; } } newdiv.innerhtml += "
[" + btn_buy + "]  [" + is_cancel + "]
"; document.body.appendchild(newdiv); // mask图层 var newmask = document.createelement("div"); newmask.id = m; newmask.style.position = "absolute"; newmask.style.zindex = "9999"; newmask.style.width = document.body.scrollwidth + "px"; newmask.style.height = document.body.scrollheight + "px"; newmask.style.top = "0px"; newmask.style.left = "0px"; newmask.style.background = "#fff"; newmask.style.filter = "alpha(opacity=30)"; newmask.style.opacity = "0.40"; document.body.appendchild(newmask); } //获取选择属性后,再次提交到购物车 function submit_div(goods_id, parentid) { var goods = new object(); var spec_arr = new array(); var fittings_arr = new array(); var number = 1; var input_arr = document.getelementsbytagname('input'); var quick = 1; var spec_arr = new array(); var j = 0; for (i = 0; i < input_arr.length; i ++ ) { var prefix = input_arr[i].name.substr(0, 5); if (prefix == 'spec_' && ( ((input_arr[i].type == 'radio' || input_arr[i].type == 'checkbox') && input_arr[i].checked))) { spec_arr[j] = input_arr[i].value; j++ ; } } goods.quick = quick; goods.spec = spec_arr; goods.goods_id = goods_id; goods.number = number; goods.parent = (typeof(parentid) == "undefined") ? 0 : parseint(parentid); ajax.call('flow.php?step=add_to_cart', 'goods=' + $.tojson(goods), addtocartresponse, 'post', 'json'); document.body.removechild(docele('spediv')); document.body.removechild(docele('mask')); var i = 0; var sel_obj = document.getelementsbytagname('select'); while (sel_obj[i]) { sel_obj[i].style.visibility = ""; i++; } } // 关闭mask和新图层 function cancel_div() { document.body.removechild(docele('spediv')); document.body.removechild(docele('mask')); var i = 0; var sel_obj = document.getelementsbytagname('select'); while (sel_obj[i]) { sel_obj[i].style.visibility = ""; i++; } } //弹出确认框 function poplayer(poptitle,container){ var fragment = document.createdocumentfragment(), wrap = document.createelement('div'), back = document.createelement('div'), box = document.createelement('div'), headcont = document.createelement('div'), h4 = document.createelement('h4'), span = document.createelement('span'), popcont = document.createelement('div'); wrap.classname = 'pop-wrap'; back.classname = 'back-layer'; box.classname = 'pop-box'; headcont.classname = 'head-cont'; span.classname = 'close'; popcont.classname = 'pop-cont'; h4.innerhtml = poptitle; span.innerhtml = 'x'; popcont.innerhtml = container; headcont.appendchild(h4); headcont.appendchild(span); box.appendchild(headcont); box.appendchild(popcont); wrap.appendchild(back); wrap.appendchild(box); fragment.appendchild(wrap); document.body.appendchild(fragment); document.queryselector('.close').addeventlistener('click',function(){ document.body.removechild(wrap) }) } //提示框 function poptips(mes,type) { var type = type || ''; type == 'suc' ? type = ' success' : type = ' error'; var newele = document.createelement('div'); newele.classname = 'pop-tip' + type; newele.innerhtml = mes; document.body.appendchild(newele); settimeout(function(){ document.body.removechild(newele); },2500) }