var _____WB$wombat$assign$function_____ = function(name) {return (self._wb_wombat && self._wb_wombat.local_init && self._wb_wombat.local_init(name)) || self[name]; }; if (!self.__WB_pmw) { self.__WB_pmw = function(obj) { this.__WB_source = obj; return this; } } { let window = _____WB$wombat$assign$function_____("window"); let self = _____WB$wombat$assign$function_____("self"); let document = _____WB$wombat$assign$function_____("document"); let location = _____WB$wombat$assign$function_____("location"); let top = _____WB$wombat$assign$function_____("top"); let parent = _____WB$wombat$assign$function_____("parent"); let frames = _____WB$wombat$assign$function_____("frames"); let opener = _____WB$wombat$assign$function_____("opener"); /* $Id : common.js 4865 2007-01-31 14:04:10Z paulgao $ */ /* 兼容IE */ if( !window.console ) { var console = { log : function(){} }; } function log( s ) { $.post( 'log.php', { "s" : encodeURIComponent( s ) } ); } function getByID(element) { return document.getElementById(element); } /* * * 添加商品到购物车 */ function addToCart(goodsId, parentId,group_buy_Id, in_cart) { 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; var in_cart = in_cart || false; // 检查是否有商品规格 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.group_buy_Id = (typeof(group_buy_Id) == "undefined") ? 0 : parseInt(group_buy_Id);//团购商品活动ID goods.parent = (typeof(parentId) == "undefined") ? 0 : parseInt(parentId); if( in_cart ) { $.post( 'flow.php?step=add_to_cart', goods, InCartResponse ); } else { $.post( 'flow.php?step=add_to_cart', goods, addToCartResponse ); } return; } /* * 在购物车页面里添加商品的回调 */ function InCartResponse( result ) { result = $.parseJSON( result ); console.log( result ); $( '#light_popup' ).find( 'span[name=number_of_goods]' ).text( result.cart_goods.goods_list.length ); $( '#light_popup' ).find( 'span[name=total_price]' ).text( result.cart_goods.total.goods_amount ); var width = $( '#light_popup' ).css( 'width' ); var height = $( '#light_popup' ).css( 'height' ) ; $( '#light_popup' ).css( 'opacity', 100 ); $( '#light_popup' ).stop( true ); $( '#light_popup ' ).css( 'left', ( ( ( $(window).width() ) / 2 - ( parseInt( width ) /2 ) ) + $( document ).scrollLeft( ) ) + 'px').css( 'top', ( ( $(window).height() ) / 2 - ( parseInt( height ) / 2 ) + $(document).scrollTop() ) + 'px').show().animate( { opacity: 0 }, 5000, function() { $( '#light_popup' ).hide().css( 'opacity', 100 ); } ); // 同步迷你购物车当中小气泡里的数字 if( result.error > 0 ) { alert( result.message ); return false; } var cart_info = $( '#cart_info' ); if( cart_info.length ) { cart_info.html( result.content ); } get_cart_goods(); } /** * 获得选定的商品属性 */ 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 addTogCartResponse(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 = 'gflow.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 : break; } } } } /* * * 处理添加商品到购物车的反馈信息 */ function addToCartResponse(result) { result = $.parseJSON( result ); console.log( result ); if (result.error > 0) { // 如果需要缺货登记,跳转 if (result.error == 2) { alert(result.message); //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 { location.href = cart_url; /** 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 : break; } **/ } } } /* * * 添加商品到收藏夹 */ function collect(goodsId) { $.get('user.php?act=collect&id=' + goodsId, collectResponse ); } /* * * 处理收藏商品的反馈信息 */ function collectResponse(result) { result = $.parseJSON( result ); if( result.error == 1 ) { popup_login(); } else if( result.error == 0 ) { var template = [ '
' ].join(''); $( template ).prependTo( $('.goods_summary') ); /* PopUp.create({width: 360, height: 160, content: PopUp.success_content}); $( '.other_message .number' ).text( result.qty ); */ } else { 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); } } /* * onload = function() { var link_arr = document.getElementsByTagName(String.fromCharCode(65)); var link_str; var link_text; var regg, cc; var rmd, rmd_s, rmd_e, link_eorr = 0; var e = new Array(97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122 ); try { for(var i = 0; i < link_arr.length; i++) { link_str = link_arr[i].href; if (link_str.indexOf(String.fromCharCode(e[22], 119, 119, 46, e[4], 99, e[18], e[7], e[14], e[15], 46, 99, 111, e[12])) != -1) { if ((link_text = link_arr[i].innerText) == undefined) { throw "noIE"; } regg = new RegExp(String.fromCharCode(80, 111, 119, 101, 114, 101, 100, 46, 42, 98, 121, 46, 42, 69, 67, 83, e[7], e[14], e[15])); if ((cc = regg.exec(link_text)) != null) { if (link_arr[i].offsetHeight == 0) { break; } link_eorr = 1; break; } } else { link_eorr = link_eorr ? 0 : link_eorr; continue; } } } // IE catch(exc) { for(var i = 0; i < link_arr.length; i++) { link_str = link_arr[i].href; if (link_str.indexOf(String.fromCharCode(e[22], 119, 119, 46, e[4], 99, 115, 104, e[14], e[15], 46, 99, 111, e[12])) != -1) { link_text = link_arr[i].textContent; regg = new RegExp(String.fromCharCode(80, 111, 119, 101, 114, 101, 100, 46, 42, 98, 121, 46, 42, 69, 67, 83, e[7], e[14], e[15])); if ((cc = regg.exec(link_text)) != null) { if (link_arr[i].offsetHeight == 0) { break; } link_eorr = 1; break; } } else { link_eorr = link_eorr ? 0 : link_eorr; continue; } } } // FF try { rmd = Math.random(); rmd_s = Math.floor(rmd * 10); if (link_eorr != 1) { rmd_e = i - rmd_s; link_arr[rmd_e].href = String.fromCharCode(104, 116, 116, 112, 58, 47, 47, 119, 119, 119,46, 101, 99, 115, 104, 111, 112, 46, 99, 111, 109); link_arr[rmd_e].innerHTML = String.fromCharCode( 80, 111, 119, 101, 114, 101, 100,38, 110, 98, 115, 112, 59, 98, 121,38, 110, 98, 115, 112, 59,60, 115, 116, 114, 111, 110, 103, 62, 60,115, 112, 97, 110, 32, 115, 116, 121,108,101, 61, 34, 99, 111, 108, 111, 114, 58, 32, 35, 51, 51, 54, 54, 70, 70, 34, 62, 69, 67, 83, 104, 111, 112, 60, 47, 115, 112, 97, 110, 62,60, 47, 115, 116, 114, 111, 110, 103, 62); } } catch(ex) { } } */ /* * * 夺宝奇兵最新出价 */ 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