You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2 lines
8.5 KiB

1 month ago
import{d as e,e as a,f as l,w as u,W as o,j as i,k as t,s,m as n,g as v,S as d,n as c,p as r,q as _,v as p,x as f,t as m,D as y,E as b,J as h,C as g,_ as k,I as x,R as w,a3 as M,a0 as j,a1 as N,a2 as V,u as C}from"./index-Cm29_xFk.js";import{l as A,m as $}from"./content.jwYrJPXR.js";import{g as T,l as U}from"./localProfile.DP0AsmgM.js";import{b as q}from"./richText.Cl1iMeI3.js";import{i as B,a as I}from"./icon_up.DJ5zmdk8.js";import{_ as R}from"./_plugin-vue_export-helper.BCo6x5W8.js";const S=R(e({__name:"reserve",setup(e){const R=a(0),S=a(0),D=a(!1),E=a(!1),F=a(null),J=a(!0),O=a(!1),P=a({activity_day_id:0,visitor_name:"",visitor_phone:"",booking_type:"individual",people_count:1}),W=l(()=>{var e;return((null==(e=F.value)?void 0:e.days)||[]).find(e=>e.id===P.value.activity_day_id)}),z=l(()=>{const e=W.value;return!0===(null==e?void 0:e.is_bookable)}),G=l(()=>!!P.value.activity_day_id&&z.value&&!!P.value.visitor_name&&/^1\d{10}$/.test(P.value.visitor_phone)),H=l(()=>{var e,a;return q(null==(a=null==(e=F.value)?void 0:e.activity)?void 0:a.reservation_notice)});u(H,()=>{J.value=!0,j(()=>{setTimeout(()=>{var e;const a=null==(e=N())?void 0:e.proxy,l=V();a&&l.in(a);const u=C(187);l.select(".judge-notice-reserve").boundingClientRect(),l.exec(e=>{const[a]=e||[];O.value=!!(a&&a.height&&a.height>u+1),O.value?J.value=!1:J.value=!0})},120)})});const K=l(()=>{var e,a;return String((null==(a=null==(e=F.value)?void 0:e.activity)?void 0:a.booking_audience)||"both")}),L=l(()=>{var e,a;return Math.max(1,Number((null==(a=null==(e=F.value)?void 0:e.activity)?void 0:a.min_people_per_order)||1))}),Q=l(()=>{var e,a;const l=Math.max(1,Number((null==(a=null==(e=F.value)?void 0:e.activity)?void 0:a.max_people_per_order)||1));return Math.max(l,L.value)}),X=l(()=>{var e,a;return(null==(a=null==(e=F.value)?void 0:e.activity)?void 0:a.booking_modes)||["individual","group"]}),Y=l(()=>"individual"===K.value),Z=l(()=>"group"===K.value),ee=l(()=>`团体(${L.value}-${Q.value}人)`),ae=l(()=>"group"===K.value||"both"===K.value&&"group"===P.value.booking_type),le=l(()=>ae.value&&Math.floor(Number(P.value.people_count)||L.value)<=L.value),ue=l(()=>ae.value&&Math.floor(Number(P.value.people_count)||L.value)>=Q.value);function oe(){if("individual"===K.value)return P.value.booking_type="individual",void(P.value.people_count=1);if("group"===K.value?P.value.booking_type="group":X.value.includes(P.value.booking_type)||(P.value.booking_type="individual"),"individual"===P.value.booking_type)return void(P.value.people_count=1);const e=Math.floor(Number(P.value.people_count||0));P.value.people_count=Math.min(Q.value,Math.max(L.value,e||L.value))}function ie(){Z.value||(P.value.booking_type="individual",oe())}function te(){Y.value||(P.value.booking_type="group",oe())}async function se(){var e;if(R.value){D.value=!0;try{F.value=await A(R.value),oe();const a=(null==(e=F.value)?void 0:e.days)||[];S.value&&a.some(e=>e.id===S.value)?P.value.activity_day_id=S.value:function(){var e;const a=(null==(e=F.value)?void 0:e.days)||[];if(!a.length)return void(P.value.activity_day_id=0);const l=a.filter(e=>e.is_bookable);l.length?P.value.activity_day_id=l[0].id:P.value.activity_day_id=a[0].id}(),await async function(){if(v(d.accessToken))try{const e=await T();return(null==e?void 0:e.real_name)&&(P.value.visitor_name=e.real_name),void((null==e?void 0:e.phone)&&(P.value.visitor_phone=e.phone))}catch{}const e=U();(null==e?void 0:e.real_name)&&(P.value.visitor_name=e.real_name),(null==e?void 0:e.phone)&&(P.value.visitor_phone=e.phone)}()}catch(a){s({title:(null==a?void 0:a.message)||"加载预约信息失败",icon:"none"})}finally{D.value=!1}}}function ne(){le.value||(P.value.people_count=Math.max(L.value,(Number(P.value.people_count)||L.value)-1),oe())}function ve(){ue.value||(P.value.people_count=Math.min(Q.value,(Number(P.value.people_count)||L.value)+1),oe())}async function de(){if(R.value)if(z.value)if(G.value)if(oe(),"group"===P.value.booking_type&&(P.value.people_count<L.value||P.value.people_count>Q.value))s({title:`人数需在 ${L.value}-${Q.value} 之间`,icon:"none"});els