代码拉取完成,页面将自动刷新
var popup={sa:{},info:{app_id:"",show_log:!0},campaign_listener:{},lib_version:"0.4.8",defaultPara:{platform:"MINIPROGRAM",preload_image:!0,defer_render:!1},serverData:{},localData:{},event_list:[],popuping:!1,convertPlans:[],eventRule:{},popupTree:{},log:function(){if(popup.info.show_log&&"object"==typeof console&&console.log)try{return console.log.apply(console,arguments)}catch(t){console.log(arguments[0])}},CAMPAIGN_ERROR:{}},getRandomBasic=function(){var t=(new Date).getTime();return function(e){return Math.ceil((t=(9301*t+49297)%233280)/233280*e)}}(),_={getRgba:function(t){return"object"!=typeof t?t:"rgba("+t.r+","+t.g+","+t.b+","+t.a+")"},getRpx:function(t){if(t){if(/^[0|1]?\.\d+$/.test(t))return 100*Number(t)+"%";var e=/^(-?\d+(\.\d+)?)px$/.exec(t);return e?2*Number(e[1])+"rpx":t}},extend:function(t){var e=Array.prototype.slice;return _.each(e.call(arguments,1),function(e){for(var p in e)void 0!==e[p]&&(t[p]=e[p])}),t},each:function(t,e,p){var n=Array.prototype.forEach,o={};if(null==t)return!1;if(n&&t.forEach===n)t.forEach(e,p);else if(t.length===+t.length){for(var i=0,r=t.length;i<r;i++)if(i in t&&e.call(p,t[i],i,t)===o)return!1}else for(var a in t)if(hasOwnProperty.call(t,a)&&e.call(p,t[a],a,t)===o)return!1},extend2Lev:function(t){var e=Array.prototype.slice;return _.each(e.call(arguments,1),function(e){for(var p in e)void 0!==e[p]&&null!==e[p]&&(_.isObject(e[p])&&_.isObject(t[p])?_.extend(t[p],e[p]):t[p]=e[p])}),t},getRandom:function(){if("function"==typeof Uint32Array){var t="";if("undefined"!=typeof crypto?t=crypto:"undefined"!=typeof msCrypto&&(t=msCrypto),_.isObject(t)&&t.getRandomValues){var e=new Uint32Array(1);return t.getRandomValues(e)[0]/Math.pow(2,32)}}return getRandomBasic(1e19)/1e19},getUuid:function(){var t=function(){return _.getRandom().toString(16).replace(".","")};return function(){var e=function(){for(var t=1*new Date,e=0;t==1*new Date;)e++;return t.toString(16)+e.toString(16)}()+"-"+t()+"-"+t();return e||(String(_.getRandom())+String(_.getRandom())+String(_.getRandom())).slice(2,15)}},trim:function(t){return t.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"")},isEmptyObject:function(t){var e=Object.prototype.hasOwnProperty;if(_.isObject(t)){for(var p in t)if(e.call(t,p))return!1;return!0}return!1},filter:function(t,e,p){var n=Object.prototype.hasOwnProperty;if(t.filter)return t.filter(e);for(var o=[],i=0;i<t.length;i++)if(n.call(t,i)){var r=t[i];e.call(p,r,i,t)&&o.push(r)}return o},isObject:function(t){return null!=t&&"[object Object]"==Object.prototype.toString.call(t)},isArray:Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)},isString:function(t){return"[object String]"==Object.prototype.toString.call(t)},isDate:function(t){return"[object Date]"==Object.prototype.toString.call(t)},isBoolean:function(t){return"[object Boolean]"==Object.prototype.toString.call(t)},isNumber:function(t){return"[object Number]"==Object.prototype.toString.call(t)&&/[\d\.]+/.test(String(t))},isFunction:function(t){if(!t)return!1;var e=Object.prototype.toString.call(t);return"[object Function]"==e||"[object AsyncFunction]"==e},getURLSearchParams:function(t){for(var e=function(t){return decodeURIComponent(t)},p={},n=(t||"").split("&"),o=0;o<n.length;o++){var i=n[o].indexOf("=");if(-1!==i){var r=n[o].substring(0,i),a=n[o].substring(i+1);r=e(r),a=e(a),p[r]=a}}return p}};function decrypt(t){return _.isString(t)?(popup.sa&&-1!==t.indexOf("data:enc;")&&(t=rot13defs(t=t.substring("data:enc;".length))),t):t}function encrypt(t){var e=!1;if(popup.sa&&popup.sa.para&&(e=popup.sa.para.encrypt_storage),e){_.isObject(t)&&(t=JSON.stringify(t)),t="data:enc;"+rot13obfs(t)}return t}function rot13obfs(t,e){e="number"==typeof e?e:13;for(var p=(t=String(t)).split(""),n=0,o=p.length;n<o;n++){p[n].charCodeAt(0)<126&&(p[n]=String.fromCharCode((p[n].charCodeAt(0)+e)%126))}return p.join("")}function rot13defs(t){return rot13obfs(t=String(t),113)}_.setStorageSync=function(t,e){var p=function(){var p=encrypt(e);wx.setStorageSync(t,p)};try{p()}catch(t){logger.info("set Storage fail --",t);try{p()}catch(t){logger.info("set Storage fail again --",t)}}},_.getStorageSync=function(t){var e="";try{e=decrypt(e=wx.getStorageSync(t))}catch(p){try{e=decrypt(e=wx.getStorageSync(t))}catch(t){logger.info("getStorage fail")}}return e},_.parseStorageSync=function(t){var e=null;try{e=JSON.parse(_.getStorageSync(t))||null}catch(t){}return e},_.isArray=Array.isArray||function(t){return"[object Array]"===toString.call(t)},_.matchImage=function(t){for(var e,p,n,o=new RegExp('("(backgroundImage|image)":"(http(s)?://.[^"]*))',"g"),i=new RegExp("http(s)?://.[^S]*"),r={},a=t.length,u=[],s=0;s<a;s++)if(e=!1,_.isObject(t[s])&&"ACTIVE"===t[s].status.toLocaleUpperCase()&&t[s].is_audience&&(t[s].hasOwnProperty("strategy_id")?t[s].is_trigger&&(e=!0):t[s].is_control_group||(e=!0)),e&&t[s].popup_window_content&&t[s].popup_window_content.content&&(p=t[s].popup_window_content.content.match(o)))for(var l=0,c=p.length;l<c;l++)(n=p[l].match(i))&&n.length>0&&(r[n[0]]||(r[n[0]]=1));return _.each(r,function(t,e){u.push(e)}),u},_.getConvertNumberValue=function(t){return _.isString(t)&&(t=Number(t)),Math.floor(1e3*t)/1e3},_.wxrequest=function(t){var e=wx.request(t);setTimeout(function(){_.isObject(e)&&_.isFunction(e.abort)&&e.abort()},3e4)},_.getProject=function(t){if(t&&t.split("?")[1]){var e=decodeURIComponent(t.split("?")[1]);return _.getURLSearchParams(e).project||"default"}return"default"},_.getCurrentPage=function(){var t=getCurrentPages(),e=t[t.length-1];return!!_.isObject(e)&&e},_.getPropertiesValue=function(t,e){var p=t[e];return"$event_duration"===e&&void 0===p&&(p=t.event_duration),p},popup._=_,popup.handleEvents=function(t,e){if("send"===t){if(popup.popuping)return popup.event_list.push(e),!1;e.event&&popup.eventRule[e.event]&&popup.eventTriggerProcess(popup.eventRule[e.event],e)}if("changeDistinctId"===t&&popup.updateAndListenPlan.changeId(),"popup_display"===t){popup.popuping=!0;try{popup.info.popup_listener.onLoadSuccess(e.plan.plan_id)}catch(t){popup.log("popup_listener.onLoad error",t)}}if("popup_load_fail"===t){var p=e.plan_id,n=e.fail_code,o=e.fail_reason;try{popup.info.popup_listener.onLoadFailed(p,n,o)}catch(t){popup.log("popup_listener.onLoad error",t)}}if("popup_click"===t&&popup.track.popupClick(e),"popup_end"===t){popup.popuping=!1;var i={name:e.plan.cname,plan_id:e.plan.plan_id,content:e.plan.popup_window_content?e.plan.popup_window_content.content:"",type:e.plan.popup_window_content?e.plan.popup_window_content.popup_type:""};popup.CAMPAIGN_ERROR.onEnd||popup.campaign_listener.onEnd(i);try{popup.info.popup_listener.onClose(e.plan.plan_id)}catch(t){popup.log("popup_listener.onLoad error",t)}popup.updateGlobalCount(),popup.updatePlanInterval(e.plan),_.each(popup.event_list,function(t){t.event&&popup.eventRule[t.event]&&popup.eventTriggerProcess(popup.eventRule[t.event],t)}),popup.event_list=[]}},popup.setPara=function(t){if(_.isObject(t)||(t={}),popup.info=_.extend(popup.info,popup.defaultPara,t),popup.info.app_id||popup.log("\u521d\u59cb\u5316\u53c2\u6570 appid \u6821\u9a8c\u5931\u8d25\uff0c\u65e0\u6cd5\u62c9\u53d6\u5f39\u7a97\u8ba1\u5212!"),_.isString(popup.info.api_base_url)&&"http"===popup.info.api_base_url.slice(0,4)||popup.log("popup \u5fc5\u987b\u586b\u5199\u6709\u6548 api_base_url"),popup.info.project||(popup.info.project=_.getProject(popup.sa.para.server_url)),_.isObject(popup.info.popup_listener)){var e=popup.info.popup_listener;_.isFunction(e.onClick)||(popup.info.popup_listener.onClick=function(){}),_.isFunction(e.onLoadSuccess)||(popup.info.popup_listener.onLoadSuccess=function(){}),_.isFunction(e.onLoadFailed)||(popup.info.popup_listener.onLoadFailed=function(){}),_.isFunction(e.onClose)||(popup.info.popup_listener.onClose=function(){})}else popup.info.popup_listener={onClick:function(){},onLoadSuccess:function(){},onLoadFailed:function(){},onClose:function(){}};_.isObject(t.campaign_listener)?(popup.campaign_listener=_.extend({},t.campaign_listener),popup.campaign_listener.shouldStart&&_.isFunction(popup.campaign_listener.shouldStart)||(popup.campaign_listener.shouldStart=function(){return!0},popup.CAMPAIGN_ERROR.shouldStart={error_code:"4001",reeor_txt:"NOT_DEFINED OR DEFINED_ERROR"}),popup.campaign_listener.onStart?_.isFunction(popup.campaign_listener.onStart)||(popup.CAMPAIGN_ERROR.onStart={error_code:"4002",reeor_txt:"DEFINED_TYPE_ERROR"}):popup.CAMPAIGN_ERROR.onStart={error_code:"4001",reeor_txt:"NOT_DEFINED"},popup.campaign_listener.onEnd?_.isFunction(popup.campaign_listener.onEnd)||(popup.CAMPAIGN_ERROR.onEnd={error_code:"4002",reeor_txt:"DEFINED_TYPE_ERROR"}):popup.CAMPAIGN_ERROR.onEnd={error_code:"4001",reeor_txt:"NOT_DEFINED"},popup.campaign_listener.onFailed?_.isFunction(popup.campaign_listener.onFailed)||(popup.CAMPAIGN_ERROR.onFailed={error_code:"4002",reeor_txt:"DEFINED_TYPE_ERROR"}):popup.CAMPAIGN_ERROR.onFailed={error_code:"4001",reeor_txt:"NOT_DEFINED"}):(popup.campaign_listener.shouldStart=function(){return!0},popup.CAMPAIGN_ERROR.shouldStart={error_code:"4001",reeor_txt:"NOT_DEFINED"},popup.CAMPAIGN_ERROR.onStart={error_code:"4001",reeor_txt:"NOT_DEFINED"},popup.CAMPAIGN_ERROR.onEnd={error_code:"4001",reeor_txt:"NOT_DEFINED"},popup.CAMPAIGN_ERROR.onFailed={error_code:"4001",reeor_txt:"NOT_DEFINED"},popup.CAMPAIGN_ERROR.campaign_listener={error_code:"4003",errot_txt:"CAMPAIGN_CUSTOMIZED_NULL_LISTENER OR DEFINED ERROR"})},popup.dataRender={that:null,queue:[],notify:function(t){_.isFunction(this.handle)?this.handle(this.that,t):this.queue.push(t)}},popup.popupEmitter={image_list:[],loaded:!1,notify:function(t){var e=_.getCurrentPage(),p=this;e&&_.isObject(e)&&_.isFunction(e.selectComponent)&&(popup.info.defer_render?setTimeout(function(){p.renderPopup(e,t)},0):p.renderPopup(e,t))},renderPopup:function(t,e){var p=t.selectComponent("#sensors_popup");if(_.isObject(p)&&_.isFunction(p.handle))p.handle(e);else{var n="";try{var o=_.getCurrentPage();n=o?o.route:""}catch(t){}popup.log("\u5f53\u524d\u9875\u9762 "+n+" \u672a\u96c6\u6210\u5f39\u7a97\u7ec4\u4ef6")}},loadImage:function(t){if(JSON.stringify(t)!==JSON.stringify(this.image_list)&&(this.loaded=!1,this.image_list=t),!this.loaded){var e=_.getCurrentPage();if(e&&_.isObject(e)&&_.isFunction(e.selectComponent)){var p=e.selectComponent("#sensors_popup");_.isObject(p)&&_.isFunction(p.loadImage)&&(p.loadImage(t),this.loaded=!0)}}},attached:function(){this.loaded||this.loadImage(this.image_list)}},popup.testPopup=function(){wx.onAppShow(function(t){popup.updateAndListenPlan.pullPlan(),popup.testSend.start(t)})},popup.updateGlobalCount=function(){var t=popup.sa.store.getDistinctId(),e=popup.localData.user_list[t],p=(new Date).getTime();if(!_.isArray(popup.localData.plan_list[e].global_popup_count))return popup.localData.plan_list[e].global_popup_count=[],popup.localData.plan_list[e].global_popup_count.unshift(p),!1;popup.localData.plan_list[e].global_popup_count.shift(),popup.localData.plan_list[e].global_popup_count.unshift(p)},popup.updatePlanInterval=function(t){var e=(new Date).getTime();_.isObject(t)&&_.isObject(t.popup_interval)&&t.popup_interval.value&&(t.is_in_popup_interval_window=popup.ruleTime.getExpire(t.popup_interval,e))},popup.init=function(t,e){popup.log("\u5f39\u7a97\u5f00\u59cb\u521d\u59cb\u5316\uff01"),this.sa=t,this.setPara(e),this.sub=new t.eventSub(this.handleEvents),popup.updateAndListenPlan.initial(),popup.testPopup(),t.popupEmitter=popup.popupEmitter},popup.changeCovertStatus=function(t){var e=JSON.parse(JSON.stringify(popup.convertPlans));_.each(e,function(p,n){var o=p.is_in_convert_window.step,i=p.is_in_convert_window.uuid;if(popup.convertPlans[n].is_in_convert_window.step=Math.min(2*o,6e5),!t||!_.isArray(t)||0===t.length)return!1;_.each(t,function(t){t.popup_display_uuid===i&&t.convert_time&&(delete popup.convertPlans[n].is_in_convert_window,popup.convertPlans.splice(n,1),e.splice(n,1),n--)})}),popup.updateAndListenPlan.updateData()},popup.asyncConvert=function(t){var e=popup.info.project,p=!1;if(!t&&0===popup.convertPlans.length)return!1;t&&(_.each(popup.convertPlans,function(e){e.plan_id===t.plan_id&&(p=!0)}),p||popup.convertPlans.push(t)),function t(){if(_.isEmptyObject(popup.localData)||!_.isArray(popup.convertPlans)||0===popup.convertPlans.length)return!1;var p=popup.convertPlans,n=p[0].is_in_convert_window&&p[0].is_in_convert_window.step||5e3,o=[],i=Date.now();_.each(p,function(t){var e=t.is_in_convert_window;if(!e)return!1;e.step||(e.step=5e3),n>e.step&&(n=e.step)}),_.each(p,function(t){if(!t.is_in_convert_window)return!1;var e=t.is_in_convert_window.expire_time;if(i>e||n>e-i)return delete t.is_in_convert_window,!1;o.push(t.is_in_convert_window.uuid)});var r=_.filter(p,function(t){return!!t.is_in_convert_window&&i<t.is_in_convert_window.expire_time});if(popup.convertPlans=r,!o.length)return!1;popup.asyncConvert.timer&&clearTimeout(popup.asyncConvert.timer),popup.asyncConvert.timer=setTimeout(function(){_.wxrequest({url:popup.info.api_base_url+"/sfo/popup_displays?project="+encodeURIComponent(e)+"&popup_display_uuids="+encodeURIComponent(o)+"&time="+(new Date).getTime(),type:"GET",success:function(e){var p=e.data;popup.changeCovertStatus(p),t()},fail:function(){popup.changeCovertStatus(),t()}})},n)}()},popup.ruleTime={getExpire:function(t,e){var p=e,n=Number(t.value)||0,o=Number(t.value)||0,i=String(t.unit).toLowerCase(),r=null,a={day:function(){return(r=new Date(p)).setHours(23),r.setMinutes(59),r.setSeconds(59),r.setMilliseconds(999),r=r.getTime()+864e5*(o-1)},week:function(){var t=(r=new Date(p)).getDay();0===t&&(t=7);var e=7-t;return r.setHours(23),r.setMinutes(59),r.setSeconds(59),r.setMilliseconds(999),r=r.getTime()+24*e*60*60*1e3+7*(o-1)*24*60*60*1e3},month:function(){var t=(r=new Date(p)).getMonth()+o;return t>11?(r.setFullYear(r.getFullYear()+parseInt(t/12)),r.setMonth(t%12)):r.setMonth(t),r.setDate(1),r.setHours(0),r.setMinutes(0),r.setSeconds(0),r.setMilliseconds(0),r.getTime()},second:function(t){var e={month:2592e6,week:6048e5,day:864e5,hour:36e5,minute:6e4,second:1e3},o=null;return r=new Date(p),t in e&&(o=e[t]*n),r.getTime()+o}};return!0!==t.natural?a.second(i):i in a?a[i]():void 0},getLast:function(t,e){var p=Number(t.value)||0,n=Number(t.value)-1||0,o=String(t.unit).toLowerCase(),i=null,r={day:function(){return(i=new Date(e)).setHours(0),i.setMinutes(0),i.setSeconds(0),i.setMilliseconds(0),i=i.getTime()-864e5*n},week:function(){var t=(i=new Date(e)).getDay();return 0===t&&(t=7),--t,i.setHours(0),i.setMinutes(0),i.setSeconds(0),i.setMilliseconds(0),i=i.getTime()-(24*t*60*60*1e3+7*n*24*60*60*1e3)},month:function(){var t=(i=new Date(e)).getMonth()+1-n;return t<=0?(i.setFullYear(i.getFullYear()+(parseInt(t/12)-1)),i.setMonth(12+t%12-1)):i.setMonth(t-1),i.setDate(1),i.setHours(0),i.setMinutes(0),i.setSeconds(0),i.setMilliseconds(0),i.getTime()},second:function(t){var n={month:2592e6,week:6048e5,day:864e5,hour:36e5,minute:6e4,second:1e3},o=null;return i=new Date(e),t in n&&(o=n[t]*p),i.getTime()-o}};return!0!==t.natural?r.second(o):o in r?r[o]():void 0},getArrMatchCount:function(t,e){var p=0;for(p=0;p<t.length;p++)if(e>=t[p])return p;return t.length},checkRule:function(t,e){var p=new Date,n=e,o=Number(t.value)||0,i=Number(t.value)-1||0,r=String(t.unit).toLowerCase(),a=null,u={day:function(){return(a=new Date(n)).setHours(23),a.setMinutes(59),a.setSeconds(59),a.setMilliseconds(999),a=a.getTime()+864e5*i,p>a},week:function(){var t=(a=new Date(n)).getDay();0===t&&(t=7);var e=7-t;return a.setHours(23),a.setMinutes(59),a.setSeconds(59),a.setMilliseconds(999),a=a.getTime()+24*e*60*60*1e3+7*i*24*60*60*1e3,p>a},month:function(){var t=(a=new Date(n)).getMonth()+i;return t>=11?(a.setFullYear(a.getFullYear()+t/11),a.setMonth(t%11)):a.setMonth(t),a.setDate(1),a.setHours(0),a.setMinutes(0),a.setSeconds(0),a.setMilliseconds(0),p>a},second:function(t){return a=new Date(n),t in inteval&&(interval_time={month:2592e6,week:6048e5,day:864e5,hour:36e5,minute:6e4,second:1e3}[t]*o),p>a+null}};return!0!==t.natural?u.second(r):r in u?u[r]():void 0}},popup.eventTriggerProcess=function(t,e){var p=!1;_.isArray(t)&&t.length>0&&_.isObject(t[0])&&(popup.log("--------------------\u89e6\u53d1\u4e8b\u4ef6\u5f00\u59cb--------------------"),_.each(t,function(t){_.isObject(t)&&void 0!==t.match_state&&delete t.match_state,new popup.RuleCheck(t,e)}),_.each(t,function(t){!0===t.match_state?!1===p?(p=!0,popup.log("\u68c0\u67e5\u5b8c\u6bd5-\u4f18\u5148\u5f39\u7a97-\u5f00\u59cb",t.plan.cname),new popup.PopupCheck(t,!0)):!0===p&&(popup.log("\u68c0\u67e5\u5b8c\u6bd5-\u975e\u4f18\u5148\u5f39\u7a97-\u4e0d\u6e32\u67d3",t.plan.cname),new popup.PopupCheck(t,!1)):popup.log("\u68c0\u67e5\u5b8c\u6bd5-\u8ba1\u5212-\u4e0d\u6ee1\u8db3",t.plan.cname)}),popup.log("--------------------\u89e6\u53d1\u4e8b\u4ef6\u7ed3\u675f--------------------"))},popup.PopupCheck=function(t,e){this.plan=t.plan,this.current_time=(new Date).getTime(),e?this.displayPopup():this.hidePopup()},popup.PopupCheck.prototype.displayPopup=function(){var t=_.getUuid()(),e={props:{$sf_succeed:!0}};popup.popupTree={},e.uuid=t,e.plan=this.plan;var p=this.plan.popup_window_content,n="",o=!0;if(p&&p.content)try{n=JSON.parse(p.content),new popup.parseTree(n)}catch(t){n=!1,o=!1}else popup.log("\u8ba1\u5212\u65e0\u7a97\u4f53\u5185\u5bb9\uff01"),o=!1;e.popupTree=popup.popupTree;var i={name:this.plan.cname,plan_id:this.plan.plan_id,content:this.plan.popup_window_content?this.plan.popup_window_content.content:"",type:this.plan.popup_window_content?this.plan.popup_window_content.popup_type:""};this.plan.hasOwnProperty("strategy_id")?this.plan.is_trigger?popup.campaign_listener.shouldStart(i)?p?"CUSTOMIZED"===p.popup_type?(e.popupTree={},popup.CAMPAIGN_ERROR.onStart?(e.props={$sf_fail_reason:"onStart \u672a\u5b9a\u4e49",$sf_succeed:!1},popup.track.popupDisplay(e),popup.CAMPAIGN_ERROR.onFailed||popup.campaign_listener.onFailed(i,1004,"onStart \u672a\u5b9a\u4e49")):p.content?(popup.track.popupDisplay(e),popup.campaign_listener.onStart(i),popup.info.popup_listener.onLoadSuccess(this.plan.plan_id)):(e.props={$sf_fail_reason:"\u5f39\u7a97\u5185\u5bb9\u9519\u8bef",$sf_succeed:!1},popup.track.popupDisplay(e),popup.CAMPAIGN_ERROR.onFailed||popup.campaign_listener.onFailed(i,1001,"\u9884\u89c8\u4fe1\u606f\u89e3\u6790\u5931\u8d25\uff0c\u8bf7\u68c0\u67e5\u8ba1\u5212\u914d\u7f6e"))):o?(popup.track.popupDisplay(e),popup.CAMPAIGN_ERROR.onStart||popup.campaign_listener.onStart(i),this.renderPopup(e)):(e.props={$sf_fail_reason:"\u5f39\u7a97\u5185\u5bb9\u9519\u8bef",$sf_succeed:!1},popup.track.popupDisplay(e),popup.info.popup_listener.onLoadFailed(this.plan.plan_id,"1001","\u9884\u89c8\u4fe1\u606f\u89e3\u6790\u5931\u8d25\uff0c\u8bf7\u68c0\u67e5\u8ba1\u5212\u914d\u7f6e"),popup.CAMPAIGN_ERROR.onFailed||popup.campaign_listener.onFailed(i,"1001","\u9884\u89c8\u4fe1\u606f\u89e3\u6790\u5931\u8d25\uff0c\u8bf7\u68c0\u67e5\u8ba1\u5212\u914d\u7f6e")):(e.props={$sf_fail_reason:"\u5f39\u7a97\u5185\u5bb9\u9519\u8bef",$sf_succeed:!1},popup.track.popupDisplay(e),popup.info.popup_listener.onLoadFailed(this.plan.plan_id,"1001","\u9884\u89c8\u4fe1\u606f\u89e3\u6790\u5931\u8d25\uff0c\u8bf7\u68c0\u67e5\u8ba1\u5212\u914d\u7f6e"),popup.CAMPAIGN_ERROR.onFailed||popup.campaign_listener.onFailed(i,"1001","\u9884\u89c8\u4fe1\u606f\u89e3\u6790\u5931\u8d25\uff0c\u8bf7\u68c0\u67e5\u8ba1\u5212\u914d\u7f6e")):(e.props={$sf_fail_reason:"shouldStart \u63a5\u53e3\u8fd4\u56de false",$sf_succeed:!1},popup.track.popupDisplay(e),popup.CAMPAIGN_ERROR.onFailed||popup.campaign_listener.onFailed(i,"1004","shouldStart \u63a5\u53e3\u8fd4\u56de false")):(e.props={$sf_fail_reason:"\u8ba1\u5212\u4e0b\u53d1 is_trigger \u4e3a false",$sf_succeed:!1},popup.track.popupDisplay(e),p&&"PRESET"===p.popup_type&&popup.info.popup_listener.onLoadFailed(this.plan.plan_id,"1005","\u8ba1\u5212\u4e0b\u53d1 is_trigger \u4e3a false"),popup.CAMPAIGN_ERROR.onFailed||popup.campaign_listener.onFailed(i,"1005","\u8ba1\u5212\u4e0b\u53d1 is_trigger \u4e3a false")):this.plan.is_control_group?(e.props={$sf_fail_reason:"\u5bf9\u7167\u7ec4",$sf_succeed:!1},popup.track.popupDisplay(e),popup.info.popup_listener.onLoadFailed(this.plan.plan_id,"2000","\u5bf9\u7167\u7ec4"),popup.CAMPAIGN_ERROR.onFailed||popup.campaign_listener.onFailed(i,"2000","\u5bf9\u7167\u7ec4")):popup.campaign_listener.shouldStart(i)?o?(popup.track.popupDisplay(e),popup.CAMPAIGN_ERROR.onStart||popup.campaign_listener.onStart(i),this.renderPopup(e)):(e.props={$sf_fail_reason:"\u9884\u89c8\u4fe1\u606f\u89e3\u6790\u5931\u8d25\uff0c\u8bf7\u68c0\u67e5\u8ba1\u5212\u914d\u7f6e",$sf_succeed:!1},popup.track.popupDisplay(e),popup.info.popup_listener.onLoadFailed(this.plan.plan_id,"1001","\u9884\u89c8\u4fe1\u606f\u89e3\u6790\u5931\u8d25\uff0c\u8bf7\u68c0\u67e5\u8ba1\u5212\u914d\u7f6e"),popup.CAMPAIGN_ERROR.onFailed||popup.campaign_listener.onFailed(i,"1001","\u9884\u89c8\u4fe1\u606f\u89e3\u6790\u5931\u8d25\uff0c\u8bf7\u68c0\u67e5\u8ba1\u5212\u914d\u7f6e")):(e.props={$sf_fail_reason:"shouldStart \u63a5\u53e3\u8fd4\u56de false",$sf_succeed:!1},popup.track.popupDisplay(e),popup.info.popup_listener.onLoadFailed(this.plan.plan_id,"1004","shouldStart \u63a5\u53e3\u8fd4\u56de false"),popup.CAMPAIGN_ERROR.onFailed||popup.campaign_listener.onFailed(i,"1004","shouldStart \u63a5\u53e3\u8fd4\u56de false"));this.startConvertWindow(t),this.startPopupIntervalWindow(),this.startPopupLimitWindow(),this.setGlobalLimit(),this.deletePlanAllWindow(),popup.updateAndListenPlan.updateData()},popup.PopupCheck.prototype.hidePopup=function(){this.deletePlanAllWindow(),popup.updateAndListenPlan.updateData()},popup.PopupCheck.prototype.renderPopup=function(t){popup.log("\u6e32\u67d3\u5f39\u7a97"),popup.popupEmitter.notify(t)},popup.PopupCheck.prototype.startConvertWindow=function(t){popup.log("--\u5f39\u7a97\u5c55\u793a-\u8f6c\u5316\u7a97\u53e3\u8bbe\u7f6e"),_.isObject(this.plan.convert_window)&&this.plan.convert_window.value&&(this.plan.is_in_convert_window={expire_time:popup.ruleTime.getExpire(this.plan.convert_window,this.current_time),start_time:this.current_time,uuid:t},popup.asyncConvert(this.plan))},popup.PopupCheck.prototype.startPopupIntervalWindow=function(){_.isObject(this.plan.popup_interval)&&this.plan.popup_interval.value&&(this.plan.is_in_popup_interval_window=popup.ruleTime.getExpire(this.plan.popup_interval,this.current_time))},popup.PopupCheck.prototype.startPopupLimitWindow=function(){popup.log("--\u5f39\u7a97\u5c55\u793a-\u53c2\u4e0e\u9650\u5236\u7a97\u53e3\u8bbe\u7f6e\u91cd\u7f6e"),_.isObject(this.plan.re_enter)&&this.plan.re_enter.value&&(_.isObject(this.plan.is_in_popup_limit_window)?this.plan.is_in_popup_limit_window.count++:this.plan.is_in_popup_limit_window={expire_time:popup.ruleTime.getExpire(this.plan.re_enter,this.current_time),count:1})},popup.PopupCheck.prototype.setGlobalLimit=function(){popup.log("--\u5f39\u7a97\u5c55\u793a-\u5168\u5c40\u5f39\u7a97\u6b21\u6570\u8bbe\u7f6e");var t=popup.store.getCurrentUserPlanList();_.isArray(t.global_popup_count)||(t.global_popup_count=[]),t.global_popup_count.unshift(this.current_time);for(var e=t.global_popup_count,p=e[e.length-1];p+7776e6<this.current_time||e.length>3e3;)e.pop(),p=e[e.length-1]},popup.PopupCheck.prototype.deletePlanAllWindow=function(){var t=this.plan.pattern_popup.matcher_list;_.isArray(t)&&_.each(t,function(t){t.is_in_window&&(popup.log("--\u5f39\u7a97\u5c55\u793a-\u91cd\u7f6e\u5404\u4e2a\u89c4\u5219\u7684\u7a97\u53e3\u8ba1\u7b97-\u6210\u529f"),delete t.is_in_window)})},popup.RuleCheck=function(t,e){this.plan_match=t,this.plan=t.plan,this.rule_arr=t.rule,this.event_data=e,this.current_time=(new Date).getTime();var p="-------------\u68c0\u67e5-\u8ba1\u5212-("+this.plan.cname+")";_.each(this.rule_arr,function(t){p+="--\u5305\u542b\u89c4\u5219-("+t.event_name+"\uff09-\u89e6\u53d1"+t.params[0]+"\u6b21"}),popup.log(p),popup.log(this.plan),this.checkPlanIsExpire(),popup.updateAndListenPlan.updateData()},popup.RuleCheck.prototype.checkPlanIsExpire=function(){!this.plan.expire_at||_.isNumber(this.plan.expire_at)&&this.current_time<this.plan.expire_at?(popup.log("--\u8fc7\u671f-\u6ee1\u8db3"),this.checkPlanIsAudience()):popup.log("--\u8fc7\u671f-\u4e0d\u6ee1\u8db3")},popup.RuleCheck.prototype.checkPlanIsAudience=function(){!0===this.plan.is_audience?(popup.log("--\u662f\u5426\u53d7\u4f17-\u6ee1\u8db3"),this.checkPlanSuspend()):popup.log("--\u662f\u5426\u53d7\u4f17-\u4e0d\u6ee1\u8db3")},popup.RuleCheck.prototype.checkPlanSuspend=function(){this.plan.status&&"SUSPEND"===this.plan.status?popup.log("--\u6682\u505c-\u4e0d\u6ee1\u8db3"):(popup.log("--\u6682\u505c-\u6ee1\u8db3"),this.checkConvert())},popup.RuleCheck.prototype.checkConvert=function(){_.isObject(this.plan.is_in_convert_window)&&this.plan.is_in_convert_window.expire_time>this.current_time?popup.log("--\u5b58\u5728\u8f6c\u5316\u7a97\u53e3 - \u4e0d\u6ee1\u8db3",this.plan.is_in_convert_window):(popup.log("--\u4e0d\u5b58\u5728\u8f6c\u5316\u7a97\u53e3\u6216\u8005\u7a97\u53e3\u8d85\u65f6\u5df2\u7ecf\u8fc7\u671f - \u6ee1\u8db3",this.plan.is_in_convert_window),this.checkGlobalPopupInterval())},popup.RuleCheck.prototype.checkGlobalPopupInterval=function(){var t=popup.store.getCurrentUserPlanList(),e=t.global_popup_count;if(_.isArray(e)&&e.length>=1){var p=popup.ruleTime.getLast(t.popup_interval_global,this.current_time);p>e[0]?(popup.log("--\u5168\u5c40\u5f39\u7a97\u95f4\u9694-\u6ee1\u8db3-"+p+">\u4e0a\u6b21\u5f39\u7a97\u65f6\u95f4"+e[0]),this.checkPopupInterval()):popup.log("\u68c0\u67e5-\u5168\u5c40\u5f39\u7a97\u95f4\u9694-\u4e0d\u6ee1\u8db3-"+p+"<\u4e0a\u6b21\u5f39\u7a97\u65f6\u95f4"+e[0])}else popup.log("--\u5168\u5c40\u5f39\u7a97\u95f4\u9694-\u6ca1\u6709\u5f39\u8fc7\u7a97-\u6ee1\u8db3"),this.checkPopupInterval()},popup.RuleCheck.prototype.checkPopupInterval=function(){_.isNumber(this.plan.is_in_popup_interval_window)?this.current_time>this.plan.is_in_popup_interval_window?(popup.log("--\u5f39\u7a97\u95f4\u9694-\u5f53\u524d\u65f6\u95f4\u5927\u4e8e\u56fa\u5b9a\u5f39\u7a97\u95f4\u9694-\u6ee1\u8db3"),this.plan.is_in_popup_interval_window=null,this.checkProperties()):popup.log("--\u5f39\u7a97\u95f4\u9694-\u5f53\u524d\u65f6\u95f4\u5c0f\u4e8e\u56fa\u5b9a\u5f39\u7a97\u95f4\u9694-\u4e0d\u6ee1\u8db3"):(popup.log("--\u5f39\u7a97\u95f4\u9694-\u7a97\u53e3\u4e0d\u5b58\u5728-\u65b0\u5f00"),this.plan.is_in_popup_interval_window=null,this.checkProperties())},popup.RuleCheck.prototype.checkProperties=function(){var t={equal:function(t,e){if(!_.isNumber(t)&&!_.isString(t))return!1;for(var p=0,n=e.length;p<n;p++){if(!_.isNumber(e[p])&&!_.isString(e[p]))return!1;if(_.isString(t)){if(t===(_.isString(e[p])?e[p]:String(e[p])))return!0}else if(_.getConvertNumberValue(t)===_.getConvertNumberValue(e[p]))return!0}return!1},notEqual:function(t,e){if(!_.isNumber(t)&&!_.isString(t))return!1;for(var p=0,n=e.length;p<n;p++){if(!_.isNumber(e[p])&&!_.isString(e[p]))return!1;if(_.isString(t)){if(t===(_.isString(e[p])?e[p]:String(e[p])))return!1}else if(_.getConvertNumberValue(t)===_.getConvertNumberValue(e[p]))return!1}return!0},contain:function(t,e){return!!_.isString(t)&&t.indexOf(e[0])>=0},notContain:function(t,e){return!!_.isString(t)&&-1===t.indexOf(e[0])},isTrue:function(t){return!0===t},isFalse:function(t){return!1===t},isSet:function(t){return void 0!==t},notSet:function(t){return void 0===t},isEmpty:function(t){if(!_.isString(t)&&!_.isArray(t))return!1;if(_.isString(t))return""===t;for(var e=0;e<t.length;e++){if(""!==t[e].replace(/^\s+|\s+$/g,""))return!1}return!0},isNotEmpty:function(t){if(!_.isString(t)&&!_.isArray(t))return!1;if(_.isString(t))return""!==t;for(var e=0;e<t.length;e++){if(""===t[e].replace(/^\s+|\s+$/g,""))return!1}return!0},less:function(t,e){return!!_.isNumber(t)&&t<Number(e[0])},greater:function(t,e){return!!_.isNumber(t)&&t>Number(e[0])},between:function(t,e){return!!_.isNumber(t)&&(t>=Number(e[0])&&t<=Number(e[1]))},in:function(t,e){if(!_.isArray(t))return!1;for(var p=0;p<t.length;p++)if(e.indexOf(t[p])>=0)return!0;return!1},notInclude:function(t,e){if(!_.isArray(t))return!1;for(var p=0;p<t.length;p++)if(-1===e.indexOf(t[p]))return!0;return!1},absolute_between:function(t,e){try{var p=new Date(e[0]),n=new Date(e[1]),o=new Date(t);return o>=p&&o<=n}catch(t){popup.log("absolute_between Error",t)}},absoluteBetween:function(t,e){try{var p=new Date(e[0]),n=new Date(e[1]),o=new Date(t);return o>=p&&o<=n}catch(t){popup.log("absolute_between Error",t)}}},e=this,p=_.filter(this.rule_arr,function(p){if(!p.filter||p.filter.conditions&&0===p.filter.conditions.length)return!0;var n=p.filter,o=n.relation,i="or"===String(o).toLowerCase(),r="and"===String(o).toLowerCase(),a=!!r,u=!0;return _.each(n.conditions,function(p){if(!u)return!1;if(!p.field)return!1;var n=p.field.lastIndexOf("."),o=p.params,s=p.function;if(!t[s])return a=!1,u=!1,!1;if(n<0)return!1;var l=p.field.slice(n+1),c=e.event_data.properties,d=_.getPropertiesValue(c,l),g=t[s](d,o);i&&g&&(a=!0,u=!1),r&&!g&&(a=!1,u=!1)}),a});_.isArray(p)&&p.length>0?(this.checkWindowAndMatch(p),popup.log("--\u5c5e\u6027\u5339\u914d-\u6ee1\u8db3",p)):popup.log("--\u5c5e\u6027\u5339\u914d-\u4e0d\u6ee1\u8db3")},popup.RuleCheck.prototype.checkWindowAndMatch=function(t){var e=this,p=[];_.each(t,function(t){if(!t.params||!t.params[0])return popup.log("--\u7a97\u53e3\u671f\u548c\u6b21\u6570-\u89c4\u5219\u6570\u636e\u5f02\u5e38"),!1;var n=Number(t.params[0]);1===n?p.push(t):n>1&&_.isObject(t.window)&&t.window.value>0&&(!_.isObject(t.is_in_window)||!_.isNumber(t.is_in_window.expire_time)||t.is_in_window.expire_time<e.current_time?t.is_in_window={expire_time:popup.ruleTime.getExpire(t.window,e.current_time),count:1}:t.is_in_window.count=t.is_in_window.count+1,t.is_in_window.count>=n?p.push(t):popup.log("--\u7a97\u53e3\u671f\u548c\u6b21\u6570-\u89c4\u5219\u6570",t.is_in_window.count,"\u4e0d\u5339\u914d\u5f53\u524d\u6b21\u6570",n))}),p.length>0?(popup.log("--\u7a97\u53e3\u671f\u548c\u6b21\u6570-\u6709\u5339\u914d\u6210\u529f\u7684\u89c4\u5219",p),this.checkGlobalPopupLimit()):popup.log("--\u7a97\u53e3\u671f\u548c\u6b21\u6570-\u6ca1\u6709\u5339\u914d\u6210\u529f\u7684\u89c4\u5219",p)},popup.RuleCheck.prototype.checkGlobalPopupLimit=function(){var t=popup.store.getCurrentUserPlanList(),e=t.msg_limit_global,p=!0,n=this;_.isObject(e)&&!0===e.is_in_use&&_.isArray(e.limits)&&_.isArray(t.global_popup_count)&&!0===this.plan.global_msg_limit_enabled?(_.each(e.limits,function(e){if(_.isObject(e)&&_.isNumber(e.limit)){var o=popup.ruleTime.getLast(e,n.current_time),i=popup.ruleTime.getArrMatchCount(t.global_popup_count,o);popup.log("--\u5168\u5c40\u5f39\u7a97\u9650\u5236-\u5df2\u7ecf\u5f39\u7a97\u6b21\u6570-"+i+"-\u9650\u5236\u7684\u6b21\u6570"+e.limit+"-\u9650\u5236\u65f6\u95f4-"+o),p=i<e.limit?p&&!0:p&&!1}}),p?this.checkPopupLimit():popup.log("--\u5168\u5c40\u5f39\u7a97\u9650\u5236-\u4e0d\u6ee1\u8db3")):(popup.log("--\u5168\u5c40\u5f39\u7a97\u9650\u5236-\u4e0d\u6ee1\u8db3(\u53c2\u6570\u6b63\u5e38\uff0c\u5df2\u5f39\u8fc7\u7a97\uff0c\u5f53\u524d\u8ba1\u5212\u8bbe\u7f6e\u4e86\u9650\u5236)\u4e4b\u4e00 - \u6ee1\u8db3"),this.checkPopupLimit())},popup.RuleCheck.prototype.checkPopupLimit=function(){if(!_.isObject(this.plan.re_enter)||!_.isNumber(this.plan.re_enter.value)||!_.isNumber(this.plan.re_enter.limit))return this.plan_match.match_state=!0,!1;_.isObject(this.plan.is_in_popup_limit_window)&&_.isNumber(this.plan.is_in_popup_limit_window.expire_time)&&_.isNumber(this.plan.is_in_popup_limit_window.count)?this.plan.is_in_popup_limit_window.expire_time<this.current_time?(popup.log("--\u53c2\u4e0e\u9650\u5236-\u8d85\u8fc7\u4e86\u53c2\u4e0e\u9650\u5236\u7a97\u53e3-\u5f00\u542f\u65b0\u7a97\u53e3-\u6ee1\u8db3",this.plan.is_in_popup_limit_window),delete this.plan.is_in_popup_limit_window,this.plan_match.match_state=!0):this.plan.is_in_popup_limit_window.count<this.plan.re_enter.limit?(popup.log("--\u53c2\u4e0e\u9650\u5236-\u5728\u7a97\u53e3\u5185\u4e14\u5728\u53c2\u4e0e\u9650\u5236\u6b21\u6570\u5185-\u6ee1\u8db3",this.plan.is_in_popup_limit_window),this.plan_match.match_state=!0):popup.log("--\u53c2\u4e0e\u9650\u5236-\u5728\u7a97\u53e3\u5185\u4f46\u662f\u8d85\u8fc7\u4e86\u53c2\u4e0e\u9650\u5236-\u4e0d\u6ee1\u8db3",this.plan.is_in_popup_limit_window):(this.plan.is_in_popup_limit_window?(popup.log("--\u53c2\u4e0e\u9650\u5236-\u6709\u7a97\u53e3\u4f46\u662f\u7a97\u53e3\u6570\u636e\u5f02\u5e38-\u5f00\u65b0\u7a97\u53e3-\u6ee1\u8db3",this.plan.is_in_popup_limit_window),delete this.plan.is_in_popup_limit_window):popup.log("--\u53c2\u4e0e\u9650\u5236-\u4e0d\u5b58\u5728\u7a97\u53e3-\u5f00\u65b0\u7a97\u53e3-\u6ee1\u8db3",this.plan.is_in_popup_limit_window),this.plan_match.match_state=!0)},popup.store={getJSONData:function(){return _.parseStorageSync("sensorsdata202002-popupdata")},saveJSONData:function(){_.setStorageSync("sensorsdata202002-popupdata",JSON.stringify(popup.localData))},getUserId:function(){var t=popup.sa.store.getDistinctId();return popup.localData.user_list[t]},getCurrentUserPlanList:function(){var t=this.getUserId();return popup.localData.plan_list[t]}},popup.updateAndListenPlan={active_state:!0,interval_time:6e5,save_interval:null,data_interval:null,local_data:{},diffData:function(){var t=popup.store.getCurrentUserPlanList(),e=popup.store.getUserId(),p=JSON.parse(JSON.stringify(popup.serverData));if(!p||_.isEmptyObject(p))return!1;if(!t||_.isEmptyObject(t)||!t.popup_plans||0===t.popup_plans.length)return popup.localData.plan_list[e]=p,popup.localData.plan_list[e].update_time=Date.now(),!1;var n=p.popup_plans;_.each(n,function(e,p){var o=null;if(_.each(t.popup_plans,function(t){t.plan_id===e.plan_id&&(o=t,_.isObject(e.window_update)&&_.each(e.window_update,function(p,n){switch(n){case"trigger_window":t.window_update&&t.window_update[n]&&t.window_update[n]===p||(o.pattern_popup.matcher_list=e.pattern_popup.matcher_list);break;case"convert_window":t.window_update&&t.window_update[n]&&t.window_update[n]===p||_.isObject(o.is_in_convert_window)&&o.is_in_convert_window.expire_time&&o.is_in_convert_window.start_time&&(o.is_in_convert_window.expire_time=popup.ruleTime.getExpire(e.convert_window,o.is_in_convert_window.start_time))}}))}),!o)return!1;if(!e.window_update&&o.last_update_config_time!==e.last_update_config_time)return!1;e.audience_id||delete o.audience_id;var i=o.pattern_popup.matcher_list;_.extend2Lev(o,e),o.pattern_popup.matcher_list=i,n[p]=o});var o=t.global_popup_count;t={},o&&(t.global_popup_count=o),_.extend(t,p),t.update_time=Date.now(),popup.localData.plan_list[e]=t,popup.log("\u521d\u59cb\u5316-\u6bd4\u5bf9\u6570\u636e\u5f97\u5230\u9700\u8981\u7684-localData",popup.localData)},filterConvertPlans:function(){var t=popup.store.getCurrentUserPlanList();if(!t||_.isEmptyObject(t))return!1;var e=t.popup_plans,p=Date.now();if(!e||!_.isArray(e))return!1;var n=_.filter(e,function(t){return!!t.convert_window&&!!t.is_in_convert_window&&p<t.is_in_convert_window.expire_time});popup.convertPlans=n,popup.log("\u521d\u59cb\u5316-\u5f02\u6b65\u7684convertWindow",popup.convertPlans),popup.asyncConvert()},updateData:function(){var t=this.local_data,e=JSON.stringify(popup.localData);e!==t&&(t=e,popup.store.saveJSONData())},updateLocalData:function(){var t={get(e,p){try{return _.isObject(e[p])?(popup.localData.target[p]=new Proxy(e[p],t),new Proxy(e[p],t)):e[p]}catch(t){return e[p]}},set(t,e,p){var n=t[e];return n!==p&&popup.log("\u4fee\u6539 localdata \u6570\u636e: ",n," - ",p),t[e]=p,popup.store.saveJSONData(),!0},deleteProperty:function(t,e){return delete t[e],popup.log("deleteProperty localdata",t,e),popup.store.saveJSONData(),!0}};popup.localData=new Proxy(popup.localData,t)},getEventRule:function(){var t,e=popup.store.getCurrentUserPlanList(),p={};return!!e&&(!(!(t=e.popup_plans)||!_.isArray(t))&&(_.each(t,function(t){var e=t.pattern_popup.matcher_list;_.each(e,function(e){var n={plan:t,rule:[e]},o=e.event_name,i=!1;if(p[o]){if(_.each(p[o],function(p){p.plan.plan_id===t.plan_id&&(p.rule.push(e),i=!0)}),i)return!1;p[o].push(n)}else p[o]=[n]})}),_.each(p,function(t){t.sort(function(t,e){var p=e.plan.absolute_priority-t.plan.absolute_priority;return 0===p?e.plan.plan_id-t.plan.plan_id:p})}),popup.eventRule=p,popup.log("\u521d\u59cb\u5316-\u5f97\u5230\u4e8b\u4ef6\u548c\u8ba1\u5212\u7684\u5173\u7cfb"),void popup.log("--------------------\u521d\u59cb\u5316\u5b8c\u6210--------------------\u7b49\u5f85\u4e8b\u4ef6\u89e6\u53d1\u8ba1\u5212--------------------")))},setListenEvent:function(){this.updateUserPlans(),this.diffData(),this.filterConvertPlans(),this.getEventRule(),this.updateData()},setIntervalTime:function(t){var e=this;e.data_interval&&clearTimeout(e.data_interval),e.data_interval=setTimeout(function(){popup.log("10\u5206\u949f\u5b9a\u65f6\u4e0b\u62c9\u8ba1\u5212-------"),e.pullPlan()},t)},initial:function(){popup.distinct_id=popup.sa.store.getDistinctId();var t=popup.store.getJSONData()||{};t.user_list||t.plan_list?popup.localData=_.extend(popup.localData,t):this.transData(t),this.updateLocalPlans(),this.setListenEvent(),this.pullPlan()},changeId:function(){this.stopAllState(),this.startState()},stopAllState:function(){this.active_state=!1;var t=popup.store.getUserId();popup.eventRule={},this.data_interval&&clearTimeout(this.data_interval),this.save_interval&&clearInterval(this.save_interval),popup.asyncConvert.timer&&clearTimeout(popup.asyncConvert.timer),popup.convertPlans=[],popup.log("\u521d\u59cb\u5316-\u6e05\u7a7a-Data"),popup.serverData={},popup.localData.plan_list[t]={}},pullPlan:function(){var t=this;if(!t.active_state)return!1;var e=popup.sa.store.getDistinctId(),p=popup.info.platform,n=popup.info.project;_.wxrequest({url:popup.info.api_base_url+"/sfo/user_popup_configs?distinct_id="+encodeURIComponent(e)+"&app_id="+encodeURIComponent(popup.info.app_id)+"&sdk_version="+encodeURIComponent(popup.lib_version)+"&platform="+encodeURIComponent(p)+"&project="+encodeURIComponent(n)+"&time="+(new Date).getTime(),method:"GET",success:function(e){if(!t.active_state)return!1;var p=e.data;popup.log("\u5f39\u7a97-\u62c9\u53d6\u8ba1\u5212\u6570\u636e\u6210\u529f"),p.popup_test_window&&!_.isEmptyObject(p.popup_test_window)&&t.testRender(p.popup_test_window),_.isObject(p)&&p.server_current_time&&p.popup_plans&&p.min_sdk_version_required&&/\d+\.\d+/.test(p.min_sdk_version_required)&&parseFloat(p.min_sdk_version_required)<=parseFloat(popup.lib_version)?(popup.info.preload_image&&popup.popupEmitter.loadImage(_.matchImage(p.popup_plans)),popup.serverData=p,t.setListenEvent(),t.interval_time=p.config_pull_interval_ms,t.setIntervalTime(t.interval_time)):(popup.log("\u5f39\u7a97-\u8bf7\u6c42\u8fd4\u56de\u7684\u6570\u636e\u9519\u8bef"),popup.serverData={},t.setIntervalTime(t.interval_time))},fail:function(e){if(!t.active_state)return!1;popup.log("\u5f39\u7a97-\u8bf7\u6c42\u62c9\u53d6\u6570\u636e\u9519\u8bef: ",e),t.setIntervalTime(t.interval_time)},complete:function(){popup.sub.ready||popup.sub.isReady()}})},testRender:function(t){var e,p={content:t.content,type:t.popup_type},n=!0,o=_.getUuid()();try{e=JSON.parse(t.content)}catch(t){n=!1}var i={props:{$sf_succeed:!0},plan:{}};if(i.uuid=o,popup.popupTree={},"CUSTOMIZED"===t.popup_type)i.popupTree={},popup.CAMPAIGN_ERROR.onStart?(i.props={$sf_fail_reason:"onStart \u65b9\u6cd5\u672a\u5b9a\u4e49",$sf_succeed:!1},popup.track.popupDisplay(i),popup.CAMPAIGN_ERROR.onFailed||popup.campaign_listener.onFailed(p,"1004","onStart \u65b9\u6cd5\u672a\u5b9a\u4e49")):t.content?(popup.campaign_listener.onStart(p),popup.track.popupDisplay(i)):(i.props={$sf_fail_reason:"\u5f39\u7a97\u5185\u5bb9\u9519\u8bef",$sf_succeed:!1},popup.track.popupDisplay(i),popup.CAMPAIGN_ERROR.onFailed||popup.campaign_listener.onFailed(p));else{try{new popup.parseTree(e),i.popupTree=popup.popupTree,i.plan={popup_window_content:t}}catch(t){popup.log("--\u6d4b\u8bd5\u5f39\u7a97\u5c55\u793a-\u6e32\u67d3\u9519\u8bef",t),n=!1}n?(popup.track.popupDisplay(i),popup.CAMPAIGN_ERROR.onStart||popup.campaign_listener.onStart(p),popup.popupEmitter.notify(i)):(i.props={$sf_fail_reason:"\u5f39\u7a97\u5185\u5bb9\u5f02\u5e38",$sf_succeed:!1},popup.track.popupDisplay(i),popup.info.popup_listener.onLoadFailed(void 0,"1001","\u9884\u89c8\u4fe1\u606f\u89e3\u6790\u5931\u8d25\uff0c\u8bf7\u68c0\u67e5\u8ba1\u5212\u914d\u7f6e"),popup.CAMPAIGN_ERROR.onFailed||popup.campaign_listener.onFailed(p,"1001","\u9884\u89c8\u4fe1\u606f\u89e3\u6790\u5931\u8d25\uff0c\u8bf7\u68c0\u67e5\u8ba1\u5212\u914d\u7f6e"))}},startState:function(){this.active_state=!0,popup.localData=popup.store.getJSONData()||{},this.pullPlan(),this.updateData()},transData:function(t){var e=popup.sa.store.getDistinctId(),p={user_list:{},plan_list:{}};p.user_list[e]=e,p.plan_list[e]=JSON.parse(JSON.stringify(t)),p.plan_list[e].update_time=Date.now(),popup.localData=p,popup.store.saveJSONData()},updateLocalPlans:function(){var t=popup.store.getUserId(),e=Date.now();popup.localData.plan_list[t]&&(popup.localData.plan_list[t].update_time=e),_.each(popup.localData.plan_list,function(t,p){e-t.update_time>=2592e6&&delete popup.localData.plan_list[p]})},updateUserPlans:function(){var t=popup.serverData,e=popup.sa.store.getDistinctId();t.user_id?(popup.localData.user_list[e]=t.user_id,popup.localData.plan_list[t.user_id]||popup.localData.plan_list[e]&&(popup.localData.plan_list[t.user_id]=popup.localData.plan_list[e],delete popup.localData.plan_list[e])):popup.localData.user_list[e]||(popup.localData.user_list[e]=e)}};var IMAGE_MAP={close:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFoAAABaCAMAAAAPdrEwAAAAe1BMVEUAAAD////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////NgkbwAAAAKHRSTlMA5if6t/B0UjMSxpAtJB4MBfTr30oY6NjV0r2loZ6XkoaBenFp3UA/LNePaQAAAsxJREFUWMOsltlygzAMRRXMZsAsAZJmX9v6/7+wg1QXpjGxCDkvyWTIQZauDcCgzKLrPtnUSyGW9SbZX6OshDcQh36lH6j8MJ7pTZd6lGX6sr0IP7SDj7CA6chLoBkEFzm14nM1/P/2eGti1RZFq+LmdtwGw7afJ1Ue1dogcGCW4QptqCO2OPe1IbnL0Y7dE23wc2bJgSn44MFTvIMwLeMUXqZGfGKUkp+MPC2dwUjMGhWwUL7pnXRUsdbIIpow84VG1k9Xmf1e5U8Kq/R/68memAPqcggTCQUNc9SdL+iCL5jMd0B1j/RErh3LYrRyLa2po2x8KngJ9Uk5sWUwpZoVvIiiulNLhMwgHDhDED2MEH8X3zCDL4HV/R8lRTOEWYS0KWzt8GEm/mNLihpHKOeqJY6yLqDnbO42F1r9eXCzitMOfkuqfvkXTId6h1phSi5/ncbgneAtnDCAxTAzIn+POhfDFOObzAEsNLu0HXO06a4BCwd89wEk1h2ezdwl0rObvS5nNreHurg/lxKwsNPoHjXrHVhI+lMK3xjvMH4YelYzCSzc8V3zrx9CWtu5MG67eWEdhBSmI+GT7eIZt+Nny7YJ+y8ON9/cF1tWVL7LzTdTi6sSMtw9AE432wwl7u6MzqotMNwcM7Glc/TafRyB4+aa4dhdcoV993EDlptphlt3zZ72TgM8N88MDe3vDQWE5V6tWGaKyAbwqaiA5+aZQeETkk6QFtxuvhlaOkVwwxfgdq/IvHKbocBj6ac5OzYCIASBKGo10n+HBgakMswbaYDgTmX3fzgafhD4G+Hhg1cGXnT4PMFHVayCdVcBXGBu7cKwACOOC2YwTsIQ7KI7LBywJrlyByupK9Kw/lto4VFLAqLdmRwJiBDWwjDOI0QPPhPXRn3yTlyrILND4w7oOw3h5AlTPk5U/ddrZSk4RWW+C9hp2rgru6GiP/678n2UFPV1AAAAAElFTkSuQmCC"};popup.parseTree=function(t){this.img=void 0,this.content=void 0,this.title=void 0,this.button=[],this.image_button=void 0,this.buttonStyle={},this.view={},this.parseView(t.template),this.properties={maskCloseEnabled:t.properties.maskCloseEnabled,maskActionId:t.properties.maskActionId,maskColor:_.getRgba(t.properties.maskColor)},popup.popupTree.properties=this.properties},popup.parseTree.prototype={parseView:function(t){switch(t.type){case"column":case"row":this.getViewProp(t);break;case"image":this.getImg(t);break;case"label":this.getLabel(t);break;case"button":this.getButton(t);break;case"link":this.getLink(t);break;case"image_button":this.getImgButton(t)}this.img&&!_.isEmptyObject(this.img)&&(popup.popupTree.img=this.img),this.title&&!_.isEmptyObject(this.title)&&(popup.popupTree.title=this.title,popup.popupTree.diverseModule=!0),this.content&&!_.isEmptyObject(this.content)&&(popup.popupTree.content=this.content,popup.popupTree.diverseModule=!0),this.image_button&&!_.isEmptyObject(this.image_button)&&(popup.popupTree.image_button=this.image_button),this.buttonStyle&&!_.isEmptyObject(this.buttonStyle)&&(popup.popupTree.buttonStyle=this.buttonStyle),this.boxStyle&&!_.isEmptyObject(this.boxStyle)&&(popup.popupTree.boxStyle=this.boxStyle),this.container&&!_.isEmptyObject(this.container)&&(popup.popupTree.container=this.container),this.button&&!_.isEmptyObject(this.button)&&this.button.length>0&&(popup.popupTree.button=this.button,popup.popupTree.diverseModule=!0),this.view&&!_.isEmptyObject(this.view)&&(popup.popupTree.view=this.view),t.GRADE||(t.GRADE=0,this.view.container=Object.assign({},this.getViewProp(t))),t.subviews&&t.subviews.length>0&&_.each(t.subviews,function(e){e.GRADE=t.GRADE+1,this.parseView(e)},this)},getViewProp:function(t){switch(t.GRADE){case 0:return{style:"width: "+_.getRpx(t.layout.width)+";"};case 1:if(t.subviews.length>0){var e=Object.assign({},{backgroundImage:t.properties.backgroundImage?t.properties.backgroundImage:"",style:this.getStyle(t)}),p='background: url("'+e.backgroundImage+'");background-size: 100% 100%;'+e.style;this.view.content=Object.assign({},{style:p})}break;case 2:t.subviews&&t.subviews.length>0?this.view.button=Object.assign({},{type:t.type}):this.view.padding=Object.assign({},{style:"margin-top: "+_.getRpx(t.layout.margin.top)+";",type:t.type})}},isButtonBranch:function(t){var e=!0,p={image_button:1,link:1,button:1};return _.each(t,function(t,n){p[n]||(e=!1)}),e},getImg:function(t){this.img=_.extend({},this.getAttr(t.properties),this.getAction(t.action)),this.img.style=this.getStyle(t)},getImgButton:function(t){var e={};"close"===t.properties.msgType?t.properties.isHidden||(this.image_button=_.extend({},this.getAction(t.action),this.getAttr(t.properties)),t.layout.align&&(this.image_button.aligin=t.layout.align),this.image_button.style=this.getStyle(t),this.image_button.type=t.type):((e=_.extend({},this.getAction(t.action),this.getAttr(t.properties))).style=this.getStyle(t),e.type=t.type),_.isEmptyObject(e)||this.button.push(e)},getLabel:function(t){"title"===t.properties.msgType?(this.title=_.extend({},this.getAttr(t.properties)),this.title.style=this.getStyle(t)):"content"===t.properties.msgType&&(this.content=_.extend({},this.getAttr(t.properties)),this.content.style=this.getStyle(t))},getButton:function(t){var e={};(e=_.extend({},this.getAction(t.action),this.getAttr(t.properties))).style=this.getStyle(t),e.type=t.type,_.isEmptyObject(e)||this.button.push(e)},getLink:function(t){var e={};(e=_.extend({},this.getAction(t.action),this.getAttr(t.properties))).style=this.getStyle(t),e.type=t.type,_.isEmptyObject(e)||this.button.push(e)},getAttr:function(t){var e={};return t.text?e.innerText=t.text:t.image&&(t.localImageName?(e.src=IMAGE_MAP[t.localImageName],e.useLocalImage=!0):e.src=t.image),e},getAction:function(t){var e={};return t&&t.MINIPROGRAM&&(t=t.MINIPROGRAM[0],e.id=t.id,e.closeable=t.closeable,e.action_type=t.type,e.$sf_close_type=t.$sf_close_type,t.value&&(e.value=t.value),t.path&&(e.path=t.path),t.appid&&(e.appid=t.appid)),e},getStyle:function(t){var e,p={textAlign:"text-align",font:"font-size",backgroundColor:"background-color",borderWidth:function(t){return"border-width: "+t+";border-style: solid;"},borderColor:"border-color",cornerRadius:"border-radius",backgroundImage:function(t){return""},margin:this.boxModel("margin"),padding:this.boxModel("padding"),maxHeight:"max-height",maxWidth:"max-width"},n=["msgType","text","image","name","isHidden","align","localImageName"],o="";return e=_.extend({},t.layout,t.properties),_.each(e,function(t,e){t=_.getRpx(t);var i=p[e];if(n.indexOf(e)>=0)return!1;_.isString(i)?o+=i+":"+_.getRgba(t)+";":_.isFunction(i)?o+=i(t)+";":o+=e+":"+_.getRgba(t)+";"}),o},boxModel:function(t){return function(e){if("object"!=typeof e)return e;var p="";for(var n in e)p+=t+"-"+n+":"+_.getRpx(e[n]);return p}}};var QRCode={1011:1,1012:1,1013:1,1017:1,1047:1,1048:1,1049:1};popup.testSend={getPopupId:function(t){var e=0,p=t.query.scene;if(p){var n=decodeURIComponent(p).split("=");e="sf_test_id"===n[0]&&n[1]?n[1]:0}return e},start:function(t){if(!QRCode[t.scene])return!1;var e=this.getPopupId(t);if(!e)return!1;var p=popup.info.project,n=popup.info.platform,o=popup.sa.store.getDistinctId();_.wxrequest({url:popup.info.api_base_url+"/sfo/popup_windows/"+e+"?distinct_id="+encodeURIComponent(o)+"&app_id="+encodeURIComponent(popup.info.app_id)+"&project="+encodeURIComponent(p)+"&platform="+encodeURIComponent(n)+"&sdk_version="+encodeURIComponent(popup.lib_version)+"&time="+(new Date).getTime(),type:"GET",success:function(t){var e,p=t.data,n={content:p.content,type:p.popup_type},o=!0,i=_.getUuid()();try{e=JSON.parse(p.content)}catch(t){o=!1}var r={props:{$sf_succeed:!0},plan:{}};if(r.uuid=i,popup.popupTree={},"CUSTOMIZED"===p.popup_type)r.popupTree={},popup.CAMPAIGN_ERROR.onStart?(r.props={$sf_fail_reason:"onStart \u65b9\u6cd5\u672a\u5b9a\u4e49",$sf_succeed:!1},popup.track.popupDisplay(r),popup.CAMPAIGN_ERROR.onFailed||popup.campaign_listener.onFailed(n,"1004","onStart \u65b9\u6cd5\u672a\u5b9a\u4e49")):p.content?(popup.campaign_listener.onStart(n),popup.track.popupDisplay(r)):(r.props={$sf_fail_reason:"\u9884\u89c8\u4fe1\u606f\u89e3\u6790\u5931\u8d25\uff0c\u8bf7\u68c0\u67e5\u8ba1\u5212\u914d\u7f6e",$sf_succeed:!1},popup.track.popupDisplay(r),popup.CAMPAIGN_ERROR.onFailed||popup.campaign_listener.onFailed(n,"1001","\u9884\u89c8\u4fe1\u606f\u89e3\u6790\u5931\u8d25\uff0c\u8bf7\u68c0\u67e5\u8ba1\u5212\u914d\u7f6e"));else{try{new popup.parseTree(e),r.popupTree=popup.popupTree,r.plan={popup_window_content:p}}catch(t){popup.log("--\u6d4b\u8bd5\u5f39\u7a97-\u89e3\u6790\u9519\u8bef",t),o=!1}o?(popup.track.popupDisplay(r),popup.CAMPAIGN_ERROR.onStart||popup.campaign_listener.onStart(n),popup.popupEmitter.notify(r)):(r.props={$sf_fail_reason:"\u5f39\u7a97\u5185\u5bb9\u5f02\u5e38",$sf_succeed:!1},popup.track.popupDisplay(r),popup.info.popup_listener.onLoadFailed(void 0,"1001","\u9884\u89c8\u4fe1\u606f\u89e3\u6790\u5931\u8d25\uff0c\u8bf7\u68c0\u67e5\u8ba1\u5212\u914d\u7f6e"),popup.CAMPAIGN_ERROR.onFailed||popup.campaign_listener.onFailed(n,"1001","\u9884\u89c8\u4fe1\u606f\u89e3\u6790\u5931\u8d25\uff0c\u8bf7\u68c0\u67e5\u8ba1\u5212\u914d\u7f6e"))}}})}},popup.track={getPublicProps:function(){return{$sf_lib_version:popup.lib_version,$sf_plan_type:"\u8fd0\u8425\u8ba1\u5212",$sf_channel_service_name:"SENSORS_FOCUS",$sf_channel_category:"POPUP",$sf_platform_tag:popup.info.platform}},removeEmpty:function(t){_.each(t,function(e,p){""!==e&&void 0!==e||delete t[p]})},popupDisplay:function(t){var e=popup.track.getPublicProps(),p=popup.track.getPlanProps(t);_.extend(e,t.props,p),this.removeEmpty(e),popup.sa.track("$PlanPopupDisplay",e)},popupClick:function(t){var e=popup.track.getPublicProps(),p=popup.track.getPlanProps(t),n={type:t.props.$sf_msg_element_action,value:t.props.action_value||"",extra:t.props.action_value||""};try{popup.info.popup_listener.onClick(t.plan.plan_id,n)}catch(t){popup.log("popup_listener.onClick error",t)}delete t.props.action_value,_.extend(e,t.props,p),e.$sf_plan_id||delete e.$sf_plan_id,this.removeEmpty(e),popup.sa.track("$PlanPopupClick",e)},getPlanProps(t){var e={};if(!_.isObject(t))return e;var p=t.popupTree;if(e.$sf_msg_id=t.uuid,e.$sf_msg_title=p.title?p.title.innerText:"",e.$sf_msg_content=p.content?p.content.innerText:"",e.$sf_msg_image_url=p.img?p.img.src:"",e.$sf_plan_id=t.plan&&t.plan.plan_id||"",e.$sf_audience_id=t.plan&&t.plan.audience_id||"",t.plan.strategy_id?e.$sf_plan_strategy_id=t.plan.strategy_id:_.isBoolean(t.plan.is_control_group)&&(t.plan.is_control_group?e.$sf_plan_strategy_id=-1:e.$sf_plan_strategy_id=0),_.isObject(t.plan)){var n=t.plan.section_id;n&&(e.$sf_section_id=String(n),e.$sf_plan_type="\u65b0\u8d44\u6e90\u4f4d")}return e}};export default popup;
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。