marketingSaaS-front_ui/dist/build/h5/assets/pages-index-index.De1vpZYC.js

2 lines
4.4 KiB
JavaScript
Raw Normal View History

2024-07-12 11:49:43 +08:00
var t=Object.defineProperty,e=Object.defineProperties,a=Object.getOwnPropertyDescriptors,n=Object.getOwnPropertySymbols,o=Object.prototype.hasOwnProperty,l=Object.prototype.propertyIsEnumerable,s=(e,a,n)=>a in e?t(e,a,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[a]=n,i=(t,e)=>{for(var a in e||(e={}))o.call(e,a)&&s(t,a,e[a]);if(n)for(var a of n(e))l.call(e,a)&&s(t,a,e[a]);return t},c=(t,n)=>e(t,a(n)),r=(t,e,a)=>new Promise(((n,o)=>{var l=t=>{try{i(a.next(t))}catch(e){o(e)}},s=t=>{try{i(a.throw(t))}catch(e){o(e)}},i=t=>t.done?n(t.value):Promise.resolve(t.value).then(l,s);i((a=a.apply(t,e)).next())}));import{r as u,s as d,d as p,g as v,a as y,b as f,u as m,n as _,c as g,o as O,e as b,f as h,h as w,i as j,w as x,j as k,k as I,l as P,m as $,p as T,q as D,_ as C}from"./index-I1xPbMO1.js";const E=t=>new Promise(((e,a)=>{u(c(i({},t),{dataType:"json",header:{"content-type":"application/json"},responseType:"json",success(t){var n,o,l;(null==(n=t.data)?void 0:n.code)>=200&&(null==(o=t.data)?void 0:o.code)<300?e(t.data):401===(null==(l=t.data)?void 0:l.code)?(window.parent.postMessage({data:{type:"logout"}},"*"),a(t)):e(t.data)},fail(t){d({icon:"none",title:"网络错误,换个网络试试"}),a(t)}}))}));E.get=(t,e)=>E({url:t,query:e,method:"GET"}),E.post=(t,e,a,n=!1)=>E({url:t,query:a,data:e,method:"POST",hideErrorToast:n});const L=t=>E.get("/v1/content",t),S=C(p(c(i({},{name:"Home"}),{__name:"index",setup(t){const{safeAreaInsets:e}=v(),a=y({}),n=f(""),o=f(""),l=m();let s="activity",i=null;const c={Interface:"api_code",lottery:"lottery_code",activity:"activity_code"},u=y({url:"",title:""});function p(){return r(this,null,(function*(){const t={};t[c[s]]=n.value||"",l.reset();C(yield L(t))}))}function C(t){if(200===t.code){const{login_content_template:e,login_content_templates:s,content_templates:i,token:c}=t.data;n.value=t.data.activity_code,Object.assign(a,t.data),1===e.validate_login?(u.url=E(s.source+`?activity_code=${n.value}`),u.title=s.moduledesc):2===e.validate_login&&(u.url=E(i.source+`?activity_code=${n.value}&token=${c}`),u.title=i.moduledesc),g({title:u.title}),l.setUserInfo({srcList:u,contentData:a,activityCode:n.value,token:c,lottery:o.value})}else d({title:t.message,icon:"none"})}function E(t){const e=(new Date).getTime();return t+(t.includes("?")?"&timestamp=":"?timestamp=")+e}window.parent.addEventListener("message",(function(t){switch(t.data.data.type){case"login":case"couponBack":u.url=a.content_templates.source+`?activity_code=${n.value}`,u.title=a.content_templates.moduledesc;break;case"coupon":u.url=a.user_content_templates.source+`?activity_code=${n.value}`,u.title=a.user_content_templates.moduledesc;break;case"product":const e=`product_id=${t.data.data.product_id}&id=${t.data.data.id}&activity_code=${n.value}`;u.url=a.user_content_templates.source+`#/pages/coupon/product?url=${encodeURIComponent(e)}`,u.title=a.user_content_templates.moduledesc;break;case"logout":return p()}_((()=>{u.url=E(u.url),g({title:u.title}),l.setUserInfo({srcList:u,contentData:a,activityCode:n.value,token:a.token,lottery:o.value})}))}));const S=()=>{i=setInterval((()=>r(this,null,(function*(){const t={};t[c[s]]=o.value||"";const e=yield L(t);JSON.stringify(e.data)!==JSON.stringify(l.userInfo.contentData)&&(d({title:"活动发生变更",icon:"none"}),C(e))}))),6e4)};return O((()=>{const{srcList:t,lottery:e,activityCode:i,contentData:c}=l.userInfo;n.value=(()=>{const t=window.location.href;if(-1!==t.indexOf("#/")){let e="";const a=-1!==t.indexOf("#/")?t.split("#/")[1]:t.split("/")[t.split("/").length-1];return e=-1===a.indexOf("/")?a||"":a.split("/")[0],-1===e.indexOf("-")?s="activity":(s=e.split("-")[0],e=e.split("-")[1]),e}if(-1!==t.indexOf("?")){let e="";return e=t.split("=")[1],s=e.split("-")[0],e.split("-")[1]}{const e=t.split("/"),a=e[e.length-1];let n="";return-1===a.indexOf("-")?(n=a,s="activity"):(s=a.split("-")[0],n=a.split("-")[1]),n}})(),o.value=n.value,!t.url||e!==o.value&&i!==n.value?p():(n.value=i,Object.assign(u,t,{url:E(t.url)}),Object.assign(a,c),g({title:u.title})),S()})),b((()=>{clearInterval(i),i=null})),