var webroot = "http://open.pcpop.com/"; function StringBuilder() { this._stringBuffer = []; } StringBuilder.prototype = { append: function(str) { this._stringBuffer.push(str); return this; }, empty: function() { this._stringBuffer = []; }, toString: function() { return this._stringBuffer.join(""); } }; //电商点击统计 //修改JS包括:单品JS、团购JS、比价JS、今日降价排行JS、推荐产品JS、热门产品JS // 电商ID 频道ID, 电商自增ID , 前台产品ID 频道页ID, 子类名 品牌名 块ID var GetEbCountStr = function (ShopID, ChannelID, B2BProductId, ProductSN, ChannelPageID, SubCateGorySN, BrandSN, pageblockId, tourl) { var Count = "SendElectricPV('" + ChannelID + "','" + ChannelPageID + "', '" + pageblockId + "','" + ShopID + "','0','" + B2BProductId + "','" + SubCateGorySN + "','" + BrandSN + "','" + ProductSN + "','" + tourl + "');"; return Count; } //发送电商PV的统计 var SendElectricPV = function(siteid, pageid, pbid, mallid, shopid, eb2bproductid, F_SubcategorySN, F_BrandSN, F_ProductSN, tourl) { //添加参数兼容 if (tourl == null) tourl = ""; //调用pv统计方法 var clickpvtrack = new ClickPvTrack(); clickpvtrack.cid = siteid; clickpvtrack.cpid = pageid; clickpvtrack.bdid = mallid; clickpvtrack.spid = shopid; clickpvtrack.ckpid = eb2bproductid; clickpvtrack.scid = F_SubcategorySN; clickpvtrack.bid = F_BrandSN; clickpvtrack.pid = F_ProductSN; clickpvtrack.pbid = pbid; //页块id clickpvtrack.cpurl = tourl; clickpvtrack.track(); } var script = null; var jsonp = function(args) { script = document.createElement("script"); script.setAttribute("charset", "utf-8"); script.setAttribute("type", "text/javascript"); script.setAttribute("src", args.url); script.onload = script.onreadystatechange = function() { if (!this.readyState || this.readyState == "loaded" || this.readyState == "complete") { if (typeof args.callBack == "function") args.callBack(args.args); //回调函数 script.onload = script.onreadystatechange = null; try { script.parentNode && script.parentNode.removeChild(jsonp); } catch (e) { }; } }; window.setTimeout('headAppendChild()', 1); } var headAppendChild = function() { document.getElementsByTagName("head")[0].appendChild(script); } var EBSubString = function(str, len) { var strlen = 0; var s = ""; for (var i = 0; i < str.length; i++) { var nowlen = 0; if (str.charCodeAt(i) > 128) { nowlen = 2; } else { nowlen = 1; } if (strlen + nowlen <= len) { s += str.charAt(i); strlen += nowlen; } else { return s; } } return s; } var EBCountString = function(str) { var strlen = 0; for (var i = 0; i < str.length; i++) { var nowlen = 0; if (str.charCodeAt(i) > 128) { nowlen = 2; } else { nowlen = 1; } strlen += nowlen; } return strlen; } function HTMLDeCode(str) { var s = ""; if (str.length == 0) return ""; s = str.replace(/>/g, "&"); s = s.replace(/</g, "<"); s = s.replace(/>/g, ">"); s = s.replace(/ /g, " "); s = s.replace(/'/g, "\'"); s = s.replace(/"/g, "\""); s = s.replace(/
/g, "\n"); return s; } //----页面上已经定义的变量------ //var par_pageprocount //每页显示产品数 //var par_width //宽度 //var par_height //高度 //var par_siteType //站点编号 //var par_divid //填充到id为divid的div //var par_pagetype //页面类别 function WorthBuyJs(par_pageprocount, par_width, par_height, par_siteType, par_siteID, par_divid, par_pagetype, par_classEngName, par_subCategorySN, par_totalDiffCount, par_json, par_pageblockId) { this.totalCount = par_json == null ? 0 : par_json.length; //总产品数 this.pagecount = par_json == null ? 0 : parseInt(par_json.length % par_pageprocount == 0 ? par_json.length / par_pageprocount : par_json.length / par_pageprocount + 1); //总页数 this.curPage = 1; //当前显示到第几页 this.height = par_height == 0 ? 205 * par_pageprocount + 28 : par_height; //高度,如果外部没有传入,则计算(每个产品占195) this.width = par_width == 0 ? 198 : par_width; this.pageData = []; //当前页产品json this.siteID = (par_siteType == "2" || par_siteType == "4" || par_siteType == "6") ? "2" : "1"; //站点编号 1.泡泡 2.168 this.siteName = this.siteID == 1 ? "泡泡网" : "IT168"; this.classEngName = par_classEngName; //大类英文名 this.subCategorySN = par_subCategorySN; //子类编号 this.totalDiffCount = par_totalDiffCount; //子类下有降价幅度的总数 this.pageblockId = par_pageblockId == "" ? "0" : par_pageblockId; //页面块id //显示产品 this.ShowProduct = function() { this.getPageProductData(); //获取当前页数据; //绑定《值得购买》部分初始产品表列 var liHtml = ""; for (var i = 0; i < this.pageData.length; i++) { var proJson = this.pageData[i]; //获取链接 var productUrl = ""; var ebProductUrl = proJson.EBProductUrl; var priceUrl = ""; var imgUrl = ""; var productImgSN = proJson.productImgSN; var regex = /^0+/; var iProductImgSN = parseInt(productImgSN.replace(regex, "")); //去掉开头所有的0 if (par_siteType == "2" || par_siteType == "4" || par_siteType == "6") { //it168的 priceUrl = "http://product.it168.com/detail/doc/" + proJson.productSN + "/index.shtml#business"; imgUrl = "http://image.it168.com/n/160x120/" + parseInt(iProductImgSN / 1000000) + "/" + parseInt(iProductImgSN / 1000) + "/" + productImgSN + ".jpg"; productUrl = "http://product.it168.com/detail/doc/" + proJson.productSN + "/index.shtml"; } else { //泡泡网的 产品链接 和图片链接 priceUrl = "http://product.pcpop.com/" + proJson.productSN + "/index.html#EBBuy"; //泡泡网的链接 imgUrl = "http://img5.pcpop.com/ProductImages/160x120/" + parseInt(iProductImgSN / 1000000) + "/" + parseInt(iProductImgSN / 1000) + "/" + productImgSN + ".jpg"; productUrl = "http://product.pcpop.com/" + proJson.productSN + "/index.html"; //泡泡网的链接 } //取最低价 var GaCountStr = ""; var Indexhtml = ""; if (proJson.priceList != null && proJson.priceList.length > 0) { var lowProJson = proJson.priceList[0]; GaCountStr = GetEbCountStr(lowProJson.siteid, par_siteID, lowProJson.ebProductID, proJson.productSN, par_pagetype, lowProJson.subCategorySN, lowProJson.brandSN, this.pageblockId, ebProductUrl); Indexhtml = '最低¥' + lowProJson.price + ' (' + lowProJson.EBName + ')'; } liHtml += "
  • "; liHtml += "
    "; liHtml += ''; liHtml += '直降'; liHtml += ""; liHtml += '' + proJson.DownPrice + '元'; liHtml += ""; liHtml += ''; liHtml += ' ' + proJson.productName + ''; liHtml += "
    " liHtml += '

    '; liHtml += '

    '; liHtml += '

    '; liHtml += Indexhtml; liHtml += '  去比价

    '; liHtml += "
  • "; } document.getElementById("WorthBuyUL" + par_divid).innerHTML = liHtml; } //获取当前页产品 this.getPageProductData = function() { var j = 0; this.pageData = []; //初始化 document.getElementById("outerdiv" + par_divid).style.height = this.height + "px"; //设置总高度(按传入的每页产品数计算) for (var i = (this.curPage - 1) * par_pageprocount; i < ((this.curPage - 1) * par_pageprocount + parseInt(par_pageprocount)); i++) { if (i == this.totalCount) {//如果当前循环已经超出总数,则退出循环,并重新计算本页高度 var nowHeight = 205 * j + 28; //j为当前页产品数(一般为最后一页不足传入的个数时用) document.getElementById("outerdiv" + par_divid).style.height = nowHeight + "px"; break; } this.pageData[j++] = par_json[i]; } } //初始化 this.init = function() { if (par_json == null) { return; } //落地页url var jiangjiaUrl = ""; if (this.siteID == 1) //拼泡泡地址 { jiangjiaUrl = (this.classEngName == "" ? "http://jiangjia.pcpop.com/" : "http://jiangjia.pcpop.com/rmjj/" + this.classEngName + "_c" + this.subCategorySN + ".shtml"); } else//拼168地址 { jiangjiaUrl = (this.classEngName == "" ? "http://jiangjia.it168.com/" : "http://jiangjia.it168.com/rmjj/" + this.classEngName + "_c" + this.subCategorySN + ".shtml"); } //获取子类产品总数显示 var totalCountShow = "" if (this.classEngName != "")//为空时说明该类别没有在落地页显示的范围内,不显示总数 { totalCountShow = "(" + this.totalDiffCount + ")"; } //加载外框 var outerHtml = ""; outerHtml += "
    "; outerHtml += "
    今日降价" + totalCountShow + " 更多>>
    "; outerHtml += "
    "; outerHtml += "
    "; outerHtml += " "; outerHtml += "
    "; outerHtml += "
    "; document.getElementById(par_divid).innerHTML = outerHtml; document.getElementById(par_divid).style.display = "block"; //显示产品 this.ShowProduct(); } }var WorthBuyJslcd_gou=new WorthBuyJs('2','238','0','2','4','lcd_gou','45','zjpj','0215','0',null,'');WorthBuyJslcd_gou.init(); document.write('');