⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cookie.js

📁 设置POS机资料、班次资料、收银员资料等。   2)灵活、细分的权限管理
💻 JS
字号:
//从cookie中读取数据
//显示已浏览过的产品
function initView()
{
   var value=getCookie("showView");
   if(value==null||value=='undefined')
   {   
     document.getElementById("showView").innerHTML = "<div style='padding:20px;'><a href='http://www.paipai.com/' target='_blank'><u>找我喜爱的商品,GO>></u></a></div>";
   }
   else
   {
	 var showHtml="";
     var aryPro=value.split('{|}');
	 var showL=4;
	 var nowL=aryPro.length-1;
	 var temp;
	 var compareValue="";
	 if(nowL>showL) nowL=showL;
     for (var i=0; i < nowL; i++)
	 {
        temp=aryPro[i].split('{:}'); 
		if(temp[1]&&temp[1]!="undefined"){
			showHtml+="<ul>";
			showHtml+='<li><a href="http://auction1.paipai.com/'+temp[1]+'" target="_blank"><img src="http://image.paipai.com/cgi-bin/showimg?uin='+temp[2]+'&filename='+temp[3]+'&type=2" onload="ResizeImage(this,50,50)" alt="'+temp[0]+'" /></a></li>';
			showHtml+="<li>"+temp[4]+"</li>";
			showHtml+="</ul>";
			compareValue+=temp[1];
		}
	 }
	 if(nowL>0&&location.hash==""){
		 showHtml+="<div style=\"clear:both;border-top:1px dashed #ccc;padding:5px 0;margin:0 10px\"><img src=\"http://pics.paipai.com/newsys/search/search_btn_compare.gif\" hspace=\"5\" /><a href=\"#\" onclick=\"doCompare()\">对比</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"#\" onClick=\"clearCookie('showView');initView();\">清除</a></div>";
		 showHtml+='<input type="hidden" name="goodscmp_itemids" value="'+compareValue+'">';
		 showHtml+='<input type="hidden" name="goodscmp_nums"  value="'+nowL+'">';
	 }
	 document.getElementById("showView").innerHTML = showHtml;
   }
}

//从cookie中读取数据
//显示已发布的产品
function initClass()
{
   var value=getCookie("sortUsed"); 
   var obj=document.getElementById("old_commodity_type");
   if(value==null||value=='undefined') {   
		uploadInit();
   }  else   {
		// 清空市列表选择框的内容
		obj.options.length = 1;
		//增加标签和值
		var aryClass=value.split('|');
		var SelectOption ;
		for (i=0; i<aryClass.length; i++)
		{
			if(arrData[aryClass[i]]){
				SelectOption=new Option(arrData[aryClass[i]][0],aryClass[i]);
				obj.options[i+1]=SelectOption;
			}
		}
   }
}

//加入浏览产品
//包括产品名称和地址,并设置为一天后过期
function addProduct(name,path,uin,logoname,price){
 if(name==""||path==""||name=="undefined"||name=="null") return ;
  var value=getCookie("showView");
  var isadd=1;
  var newvalue;
  if(value==null||value=='undefined')
  {
      newvalue=""+name+"{:}"+path+"{:}"+uin+"{:}"+logoname+"{:}"+price+"{|}";
  } 
  else 
  {
	  clearCookie("showView");      
      var tmp="";
	  var newvalue="";
      var strAry=value.split("{|}");
	  var allowLength=strAry.length-1;
	  if(allowLength>4) allowLength=4;
      for(var i=0;i<allowLength;i++)
       {
			var temAry=strAry[i].split("{:}");
			if(temAry[1]==path)
			{
				  isadd=0;
				  newvalue=""+temAry[0]+"{:}"+temAry[1]+"{:}"+temAry[2]+"{:}"+temAry[3]+"{:}"+temAry[4]+"{|}" + newvalue;
			}
			else
				  newvalue+=""+temAry[0]+"{:}"+temAry[1]+"{:}"+temAry[2]+"{:}"+temAry[3]+"{:}"+temAry[4]+"{|}";
      }
      if(isadd==1)
          newvalue=""+name+"{:}"+path+"{:}"+uin+"{:}"+logoname+"{:}"+price+"{|}"+newvalue;

  }
  var now = new Date();
  var saveday = new Date(now.getTime() + 24*60*60*1000);
  setCookie("showView",newvalue,saveday);   
}

//加入曾发布的产品
//包括产品代码,并设置为1个月后过期
function addClass(dwLeafClassId){
 if(dwLeafClassId==""||dwLeafClassId=="undefined"||dwLeafClassId=="null") return ;
  var value=getCookie("sortUsed");

  var isadd=1;
  if(value==null||value=='undefined')
  {
      value=dwLeafClassId+"|";
  } 
  else 
  {
      clearCookie("sortUsed");      
    	var strAry=value.split("|");
	    for(var i=0;i<strAry.length-1;i++)
		  {
			  if(strAry[i]==dwLeafClassId)
			  {
			  	strAry.splice(i,1);
			  	break;
			  };
	    }    
	    strAry.unshift(dwLeafClassId);
	    if(strAry.length > 10)
	    {
	    	value = strAry.slice(0,10).join("|");
	    }
	    else 
	    {
		    value = strAry.join("|");
	    }
  }
  var now = new Date();
  var saveday = new Date(now.getTime() + 30*24*60*60*1000);
  setCookie("sortUsed",value,saveday);   
}

function SPWriteCookie(name, value, sexpire ,domain, path)
{
	var expire = "";
	var sDomain = "";
	var sPath = "; path=/";  
	
	if(path){
		sPath += path;
	}
	
	if(domain){
		sDomain +="; Domain="+domain;
	}
	
	if(sexpire!= null)
	{
		expire = sexpire;
		expire = "; expires=" + expire.toGMTString();
	}
	document.cookie = name + "=" + escape(value) + expire+sPath+sDomain;
}
//设置cookie
function setCookie(cookieName, cookieValue, expires, path, domain, secure) 
{
	var sdomain="paipai.com";
	SPWriteCookie(cookieName, cookieValue, expires, sdomain );
	//alert("set cookie success:"+document.cookie);
}

//从cookie中读取数据
/* // 这个函数存在bug,已经屏蔽
function getCookie(name){
  var cookieValue = "";
  var search = name + "=";
  if(document.cookie.length > 0)
  { 
    offset = document.cookie.indexOf(search);
    if (offset != -1)
    { 
      offset += search.length;
      end = document.cookie.indexOf(";", offset);
      if (end == -1) end = document.cookie.length;
      cookieValue = unescape(document.cookie.substring(offset, end))
    }
  }
  return cookieValue;
}
*/    
function getCookie(name){
    var cookieValue = "";
    if(document.cookie.length > 0)
    {
        var vec = document.cookie.split(';');
        var search = name + "=";
        for(var i = 0; i < vec.length; ++i)
        {
            vec[i] = vec[i].replace(/(^\s*)|(\s*$)/g, "");
            var offset = vec[i].indexOf(search);
            if(offset != 0)
                continue;
            cookieValue = unescape(vec[i].substring(offset + search.length));
            break;
        }
    }
    return cookieValue;
}

//删除cookie
function clearCookie(cookieName) 
{

 var now = new Date();

 var yesterday = new Date(now.getTime() - 1000 * 60 * 60 * 24);

 setCookie(cookieName, "", yesterday);

}

function setCookie1(name, value, minute)
{
  var expire = "";
  if(minute != null)  
  {
    expire = new Date((new Date()).getTime() + minute * 60000);
    expire = "; expires=" + expire.toGMTString();
  }
  document.cookie = name + "=" + escape(value) + expire;

}

function clearLogin()
{
  setCookie1("uin","",-1000);
  setCookie1("hs","",-1000);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -