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