main.min.js 7.44 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-19":["d27c2b94-b7fb-46f9-9ffd-d3a86775bcf4","4571657e-929a-4d7e-9db3-03fd500a16c5","b8cb3a92-3d40-4bba-88bc-2a2d58648eba"],"2019-07-20":["65e07092-1c66-407c-a36c-c63024bfcbef","2c39ad8c-c98c-424e-9752-2cc549d105cf","c8b430df-6501-492f-9d3a-f135933b95e5"],"2019-07-21":["ae52d919-27ff-4954-a533-748cd130c634","62cacf6d-e39f-4a6d-a096-82010f2781e3","a28e9b14-a6c3-40b0-bcbd-8539b08d0372"],"2019-07-22":["61e9f48b-9218-4bb3-82b8-6baddd494941","a7120af1-0a06-439a-b447-03842e3f5e84","7689f136-b316-4df0-85ff-330f958bd7e4"],"2019-07-23":["7e666967-5f32-4e69-8126-6bfad68b868b","02fd13a7-9f8e-47d0-93fc-50752811508d","0b4668e2-d756-424d-b544-f029a670efd5"],"2019-07-24":["5e185a9c-e447-4634-af7f-cf4565f7c149","c58dff86-0b97-4d71-984f-5725ff2c37a2","4ac38e96-811c-4e9d-b3c9-89b3ad318bf0"]},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】冲冲冲!扫货必备600元优惠券一键到手",desc:"专属大额优惠券一网打尽,用券最高减300元!买潮流好鞋就在有货UFO,超万件商品任你选!",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()}}})});