|
|
|
|
"use strict";var _constant=require("../../utils/constant"),_jump=require("../../utils/jump");function _typeof(e){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},_typeof(e)}function ownKeys(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,i)}return n}function _objectSpread(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?ownKeys(Object(n),!0).forEach(function(t){_defineProperty(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ownKeys(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function _defineProperty(e,t,n){return(t=_toPropertyKey(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function _toPropertyKey(e){var t=_toPrimitive(e,"string");return"symbol"===_typeof(t)?t:String(t)}function _toPrimitive(e,t){if("object"!==_typeof(e)||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var i=n.call(e,t||"default");if("object"!==_typeof(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}Component({properties:{sdkInstance:{type:Object,value:null}},data:{showAd:!1,showClose:!1,closedByUser:!1,ad:null,adId:null},observers:{sdkInstance:function(e){var t=this;e&&(this.sdkInstance=e,this.store=e.store,"function"==typeof this.unsub&&this.unsub(),this.unsub=null,this.unsub=this.store.get({liveInfo:function(e){var n,i,r,o=null==e||null===(n=e.Menus)||void 0===n?void 0:n.Market,s=1===(null==o?void 0:o.IsPageUpperAdvertisementEnable),a=Array.isArray(null==o?void 0:o.AdvertisementInfo)?o.AdvertisementInfo:[],d=s?a.find(function(e){return 3===(null==e?void 0:e.PageAdvertisementType)}):null;if(d){var l=null!==(i=null!==(r=null==d?void 0:d.Id)&&void 0!==r?r:null==d?void 0:d.Index)&&void 0!==i?i:null,u=l!==t.data.adId,c=0===(null==o?void 0:o.IsPageUpperAdvertisementCloseEnable),v=null==d?void 0:d.AdvertisementContent,y="string"==typeof v&&v.startsWith("//")?"https:".concat(v):v,p=_objectSpread(_objectSpread({},d),{},{AdvertisementContent:y}),f=!!u||!t.data.closedByUser,b=t.data.showAd;t.setData({showAd:f,showClose:c,closedByUser:!u&&t.data.closedByUser,ad:p,adId:l}),b!==f&&t.triggerEvent("visibilityChange",{visible:f})}else(t.data.showAd||t.data.ad)&&(t.setData({showAd:!1,showClose:!1,closedByUser:!1,ad:null,adId:null}),t.triggerEvent("visibilityChange",{visible:!1}))}}))}},lifetimes:{detached:function(){"function"==typeof this.unsub&&this.unsub(),this.unsub=null}},methods:{onAdClick:function(){var e,t,n;this.data.ad&&(null===(e=this.sdkInstance)||void 0===e||e.reportLogger("mini_sdk_ad_floating_click",_objectSpread({},this.data.ad)),null===(t=this.sdkInstance)||void 0===t||t.emitEvent(_constant.EVENTS.PUBLIC.adFloating.click,{AdvertisementRedirectUrl:this.data.ad.AdvertisementRedirectUrl}),null===(n=this.sdkInstance)||void 0===n||n.reportBusiness("view_ad",{AdType:this.data.ad.PageAdvertisementType,AdId:this.data.ad.Id,AdContent:this.data.ad.AdvertisementContent,AdLink:this.data.ad.AdvertisementRedirectUrl}),(0,_jump.navigateToConfiguredWebview)(this.sdkInstance,_jump.JUMP_FEATURES.AD_FLOATING,this.data.ad.AdvertisementRedirectUrl))},onClose:function(){this.setData({showAd:!1,closedByUser:!0}),this.triggerEvent("visibilityChange",{visible:!1})}}});
|