• cookie应用——UI中查询条件的保存


    var cookieOperate = {
                cookieNames: {
                    companyCNName:"_companyCNName",
                    companyENName:"_companyENName",
                    status:"_ctatus",
                    anywords:"_anywords",
                    isExistingCustomers:"_isExistingCustomers",
                    city:"_city",
                    toDeliverGroupList:"_toDeliverGroupList",
                    isDistribution:"_isDistribution",
                    industry:"_industry",
                    source:"_source",
                    minConversionTime:"_minConversionTime",
                    maxConversionTime:"_maxConversionTime",
                    minDeliverTime:"_minDeliverTime",
                    maxDeliverTime:"_maxDeliverTime",
                    pageSize:"_pageSize",
                    countries:"_countries",
                    customersRequest:"_customersRequest"
                },
                expireDays:1,
                set: function (cookieName, value) {
                    var exdate = new Date();
                    exdate.setDate(exdate.getDate() + cookieOperate.expireDays);
                    document.cookie = cookieName + "=" + escape(value) +
                        ((cookieOperate.expireDays == null) ? "" : ";expires=" + exdate.toGMTString());
                },
                delete: function (cookieName) {
                    setCookie(cookieName, "", -1);
                },
                get: function (cookieName) {
                    if (document.cookie.length > 0) {
                        c_start = document.cookie.indexOf(cookieName + "=");
                        if (c_start != -1) {
                            c_start = c_start + cookieName.length + 1;
                            c_end = document.cookie.indexOf(";", c_start);
                            if (c_end == -1) {
                                c_end = document.cookie.length;
                            };
                            return unescape(document.cookie.substring(c_start, c_end));
                        };
                    };
                    return "";
                }
            }
    

      

    js保存cookie数据

    cookieOperate.set(cookieOperate.cookieNames.companyCNName, postRequst.CompanyCNName);
    

      

    js获取cookie数据

    postRequst.CompanyCNName=cookieOperate.get(cookieOperate.cookieNames.companyCNName)
    

      

  • 相关阅读:
    java中讲讲PrintStream的用法,举例?
    Spark Scala当中reduceByKey的用法
    springboot与ActiveMQ整合
    solr(六): 集群
    zookeeper集群
    solr(五): centos中, 整合 tomcat&solr
    springboot redis(单机/集群)
    redis 五种数据类型
    redis 集群搭建: redis-cluster
    redis 持久化
  • 原文地址:https://www.cnblogs.com/panpanwelcome/p/10431851.html
Copyright © 2020-2023  润新知