main.min.js 7.8 KB
"use strict";var queryObj=void 0;var getServerTimeApi="//m.yohobuy.com/activity/feature/getServerTimes";var getCouponApi="//m.yohobuy.com/activity/feature/couponSend";var UFO={app:null};function toVersion(){var b=arguments.length<=0||arguments[0]===undefined?"":arguments[0];var a=b.split(".").map(function(c){return Number(c)
});if(!a[0]){a[0]=0}if(!a[1]){a[1]=0}if(!a[2]){a[2]=0}return a}function toNumber(a){var b=a[0]*10000;var c=a[1]*100;var d=a[2]*1;return b+c+d}function compare(b,a){if(b>a){return 1}else{if(b<a){return -1}else{return 0}}}function verion(e,b){var d=toNumber(toVersion(e));var c=toNumber(toVersion(b));var a=compare(d,c);
  return a}$(document).ready(function(){queryObj=Utils.getQueryObj();try{var f=localStorage.getItem("_share_fromid_"+window.shareC.eventName);if(queryObj&&+queryObj.fid&&+queryObj.fid!==+f){if(queryObj.fid){localStorage.setItem("_share_fromid_"+window.shareC.eventName,queryObj.fid)}localStorage.removeItem("_share_preid_"+window.shareC.eventName);
  f=queryObj.fid}shareC&&(shareC.fid=f)}catch(o){console.log(o)}UFO.app=new Vue({el:"#mainContainer",data:{preid:0,env:"h5",uid:0,isShared:false,app_info:{uid:"0",app_version:"",client_type:"",session_key:""},fromPage:"iFP_SalesPromotion_h5",couponToken:{"2019-07-03":["14aea28d-5e4e-4410-9d03-73a0df8244a5","e4835f5a-d8bc-4479-ac4e-41a808df0c44","9931a10a-1a66-4b13-bfbd-4b1dfd58a1f7","bbe28a9e-e61f-43d6-bf60-de21a3a199ef"],"2019-07-04":["277d7cb9-4e36-4730-97d2-134c454b7683","8dcbf6b0-ab68-4297-bb56-3a245ac6ebc1","04c3117e-afb1-42e0-9d21-5c837bce4749","f2006c52-0afb-4011-8899-4a612c019cf8"],"2019-07-05":["f4e398f7-b20f-474a-940c-be56d6289c4f","295f7e51-9ac4-40ab-9d9a-368a002509db","47b84db5-d3f5-43d6-a3dd-170911d34e9e","20655f23-cda1-4d79-906b-e2bc54cdca73"],"2019-07-06":["d6497e27-e43d-4338-988c-7273289fa74d","931e765f-2111-45b5-9d0f-41915e364da8","47737f08-16f4-4575-9ea7-78ed0bf50802","16cf9bc3-7d00-4bec-a169-5bfefa92404f"],"2019-07-07":["042947b0-d335-45df-b357-69021d116161","278fa8c2-4048-43f3-846e-ce99585535c2","6d3b7ffd-7deb-4399-931b-0ade92d65fbd","95f576a7-43c6-4936-b33d-b49b6b40e618"],"2019-07-08":["cc002ff5-9723-43fe-86ff-b4f691e0bd8b","e5bf74d0-9df6-45e2-bf1d-21df5895ca94","152f313b-cb19-4988-9423-337a4120d06f","a89f9dc8-7011-40a0-856e-70d77814e08b"],"2019-07-09":["5b20139b-fa58-4be5-aa34-bfd6c679bc7d","3d991011-5c7f-475c-b45f-93f392757176","10a6e587-d26f-4a46-9872-6a4778d289ca","d56d6718-0c2d-41e7-816e-92ee460b89f9"]},productData:[],serverTime:"",serverTimeNumber:0,isShowShare:false,isShowTips:false,tipsMessage:""},created:function g(){this.productData=productData;
  if(navigator.userAgent.match(/ANDROID/i)){this.fromPage="aFP_SalesPromotion_h5"}},mounted:function b(){if(queryObj.uid){this.uid=queryObj.uid}if(navigator.userAgent.match(/yohobuy/i)){this.env="app"}else{if(navigator.userAgent.match(/miniprogram/i)){window.__wxjs_environment="miniprogram";this.weixinJSReady()
}else{if(!window.WeixinJSBridge||!window.WeixinJSBridge.invoke){document.addEventListener("WeixinJSBridgeReady",this.weixinJSReady,false)}}}this.yo_sdk=window.yo_sdk;this.getServerTime();this.preshare();this.getParams();this.getResource()},methods:{preshare:function n(){try{var w=this;var u=localStorage.getItem("_share_preid_"+window.shareC.eventName);
  if(u){this.preid=u;this.setShareLink(u);return}$.ajax({url:"//action.yoho.cn/api/share/preshare?callback=?",dataType:"jsonp",data:{eventName:shareC.eventName,shareUrl:shareC.shareUrl,fid:shareC.fid||0},success:function x(y){if(y){w.preid=y.preid||0;localStorage.setItem("_share_preid_"+window.shareC.eventName,w.preid);
    w.setShareLink(y.preid)}}})}catch(v){console.log(v)}},setShareLink:function m(u){shareC.link=document.location.href.split("?")[0]+"?fid="+u;share&&share()},weixinJSReady:function r(){if(window.__wxjs_environment==="miniprogram"){this.env="miniprogram"}},jumpToMiniapp:function p(v){var u=decodeURIComponent(v.currentTarget.dataset.url);
  var w=Utils.getQueryObj(u);if(w["openby:yohobuy"]){if(this.env==="miniprogram"){wx.miniProgram.navigateTo({url:"/pages/common/webback?url="+encodeURIComponent(u)})}}else{if(u.indexOf("mp.weixin.qq.com")>0){wx.miniProgram.navigateTo({url:"/pages/webview/webview?url="+encodeURIComponent(u)})}}},goLogin:function e(){var v=this;
  var y=window.yohoInterface;if(this.env==="app"&&y){var x={method:"get.uid"};var w=function w(z){if(!parseInt(z,10)){if(v.yo_sdk.goLogin){v.yo_sdk.goLogin()}}else{v.app_info.uid=v.uid=z;y.triggerEvent(function(A){v.app_info.session_key=A;v.checkShared()},function(){},{method:"get.sessionId"});v.setShareC(+z)
  }};var u=function u(){};y.triggerEvent(w,u,x)}else{if(v.yo_sdk.goLogin){v.yo_sdk.goLogin()}}},setShareC:function k(u){var v=this;shareC.uid=u;if(this.preid){$.ajax({url:"//action.yoho.cn/api/share/collect?callback=?",dataType:"jsonp",data:{uid:u,fid:this.preid}})}else{setTimeout(function(){v.setShareC(u)
},500)}},getParams:function s(){var w=this.uid=Utils.getCookie("app_uid")||queryObj.uid||"0";var u=Utils.getCookie("app_session_key")||queryObj.session_key||"";var v=Utils.getCookie("app_version")||queryObj.app_version||"";var x=Utils.getCookie("app_client_type")||queryObj.app_client_type||"";this.app_info={uid:w,session_key:u,app_version:v,client_type:x};
  if(w&&w!=="0"){this.setShareC(+w)}},checkShared:function q(){var u=this;if(!this.isShared){if(this.env==="app"){(function(){var x=false;var w=Utils.getCookie("app_vercode");var v=Utils.getCookie("app_version")||queryObj.app_version||"";if(verion(v,"6.9.5")>=0||w){x=true}document.addEventListener("deviceready",function(){var y=window.yohoInterface;
  window.successShare=function(){u.getCoupon()};y.triggerEvent(function(){},function(){},{method:"go.showshareaction",arguments:{title:"【有货UFO】暑期热卖大放价,UFO送你288元优惠券",desc:"买潮流好鞋就在有货UFO,用券最高减120元!限量好货燃爆全场!",imgUrl:document.location.href.split("?")[0].replace(/\/index\d{0,}\.html/,"")+"/share/logo.jpg",link:window.shareC&&shareC.link||document.location.href.split("?")[0],hideType:["4","5","6","7","8","9"],isCareCallBack:"1"}});
  if(!x){setTimeout(u.getCoupon,5000)}})})()}else{this.showShare();if(this.env==="miniprogram"){setTimeout(this.getCoupon,5000)}}}else{this.getCoupon()}},getCoupon:function h(){var u=this;if(!this.serverTime){this.showMessage("网络异常,请刷新重试");return}if(!this.couponToken[this.serverTime]){this.showMessage("活动已结束, 感谢您的参与");
  return}var w=this.couponToken[this.serverTime].join(",");if(this.app_info.uid){var v={token:w,uid:this.uid,coupontype:"ufo",app:this.app_info};$.ajax({url:getCouponApi+"?callback=?",type:"get",dataType:"jsonp",data:v,success:function x(y){if(y.code===200){u.showMessage("领券成功")}else{if(y.code===401){u.showMessage("已领完,请明日再来")
}else{if(y.code===403){u.showMessage("目前券已领完,请明日再来")}else{u.showMessage(y.message)}}}u.hideShare()}})}},getResource:function a(){var u=this;$(".products-list a").each(function(){if(u.env==="miniprogram"){$(this).on("click",u.jumpToMiniapp)}else{$(this).attr("href",$(this).data("url"));$(this).attr("target","_blank")
}})},getServerTime:function t(){var v=this;$.ajax({url:getServerTimeApi+"?callback=?",type:"get",dataType:"jsonp",data:{},success:function w(z){if(z){var B=new Date(z*1000);v.serverTimeNumber=B.getTime();var y=B.getFullYear();var A=B.getMonth()+1<10?"0"+(B.getMonth()+1):B.getMonth();var x=B.getDate()<10?"0"+B.getDate():B.getDate();
  v.serverTime=[y,A,x].join("-")}},error:function u(B){var A=new Date();var y=A.getFullYear();var z=A.getMonth()+1<10?"0"+(A.getMonth()+1):A.getMonth();var x=A.getDate();v.serverTime=[y,z,x].join("-")}})},showMessage:function j(u){this.tipsMessage=u;this.isShowTips=true},showShare:function d(){this.isShowShare=true
},hideShare:function i(){this.isShowShare=false},closeTips:function l(){this.tipsMessage="";this.isShowTips=false},refresh:function c(){document.location.reload()}}})});