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
9.4 KiB

2 days ago
import{d as e,e as l,f as a,Z as t,j as i,k as o,s as u,n,g as s,S as r,t as v,u as c,v as d,y as p,z as _,B as f,F as m,C as y,E as g,G as b,x as h,a1 as k,I as $,W as w,a7 as x}from"./index-BqJ4W6ZW.js";import{h as S,i as M}from"./content.B4VyUnMP.js";import{g as C,l as D}from"./localProfile.BwBNeB25.js";import{_ as N}from"./_plugin-vue_export-helper.BCo6x5W8.js";function V(e){if(null==e||""===e)return"";const l=String(e);let a="";if(/<[a-z][\s\S]*>/i.test(l))a=function(e){if(!e||"string"!=typeof e)return"";const l="max-width:100%;height:auto;display:block;vertical-align:top;";return e.replace(/<img\b([\s\S]*?)(\/>|>)/gi,(e,a,t)=>{const i=String(a).trim();return/style\s*=/i.test(i)?/max-width\s*:/i.test(i)?e:e.replace(/style\s*=\s*(["'])([\s\S]*?)\1/i,(e,a,t)=>/max-width/i.test(t)?e:`style=${a}${t};${l}${a}`):`<img ${i} style="${l}"${"/>"===t?" />":">"}`})}(l);else{const e=function(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}(l);a=`<div style="white-space:pre-wrap;font-size:13px;color:#4e5969;line-height:1.65;">${e}</div>`}return(t=a)&&String(t).trim()&&String(t).replace(/<[^>]+>/g," ").replace(/&nbsp;/gi," ").replace(/\s+/g," ").trim().length>0?a:"";var t}const j=N(e({__name:"reserve",setup(e){const N=l(0),j=l(!1),F=l(!1),T=l(null),z=l(!1),U=l({activity_day_id:0,visitor_name:"",visitor_phone:"",booking_type:"individual",people_count:1});a(()=>{var e;return((null==(e=T.value)?void 0:e.days)||[]).find(e=>e.id===U.value.activity_day_id)});const Y=a(()=>!!U.value.activity_day_id&&!!U.value.visitor_name&&/^1\d{10}$/.test(U.value.visitor_phone)),B=a(()=>{var e,l;return V(null==(l=null==(e=T.value)?void 0:e.activity)?void 0:l.reservation_notice)}),I=a(()=>{var e,l;return String((null==(l=null==(e=T.value)?void 0:e.activity)?void 0:l.booking_audience)||"both")}),q=a(()=>{var e,l;return Math.max(1,Number((null==(l=null==(e=T.value)?void 0:e.activity)?void 0:l.min_people_per_order)||1))}),E=a(()=>{var e,l;const a=Math.max(1,Number((null==(l=null==(e=T.value)?void 0:e.activity)?void 0:l.max_people_per_order)||1));return Math.max(a,q.value)}),G=a(()=>{var e,l;return(null==(l=null==(e=T.value)?void 0:e.activity)?void 0:l.booking_modes)||["individual","group"]}),O=a(()=>"individual"===I.value),P=a(()=>`团体(${q.value}-${E.value}人)`),W=a(()=>"group"===I.value||"both"===I.value&&"group"===U.value.booking_type),Z=a(()=>{var e;return[...(null==(e=T.value)?void 0:e.days)||[]].sort((e,l)=>String(e.activity_date).localeCompare(String(l.activity_date)))});function A(e){return String(e).padStart(2,"0")}function H(e){const l=new Date,a=`${l.getFullYear()}-${A(l.getMonth()+1)}-${A(l.getDate())}`,t=String(e).slice(0,10);if(t===a)return"今天";const i=new Date(l);i.setDate(i.getDate()+1);if(t===`${i.getFullYear()}-${A(i.getMonth()+1)}-${A(i.getDate())}`)return"明天";const o=new Date(l);o.setDate(o.getDate()+2);return t===`${o.getFullYear()}-${A(o.getMonth()+1)}-${A(o.getDate())}`?"后天":""}function J(e){const l=String(e).slice(0,10).split("-");return 3!==l.length?"":`${Number(l[1])}${Number(l[2])}`}function K(e){const l=Number((null==e?void 0:e.available_count)??0);return l<=0?"0张":`${l}`}function L(){if("individual"===I.value)return U.value.booking_type="individual",void(U.value.people_count=1);if("group"===I.value?U.value.booking_type="group":G.value.includes(U.value.booking_type)||(U.value.booking_type="individual"),"individual"===U.value.booking_type)return void(U.value.people_count=1);const e=Math.floor(Number(U.value.people_count||0));U.value.people_count=Math.min(E.value,Math.max(q.value,e||q.value))}function Q(){O.value||(U.value.booking_type="group",L())}async function R(){var e,l;if(N.value){j.value=!0;try{T.value=await S(N.value),L();const a=((null==(e=T.value)?void 0:e.days)||[]).find(e=>e.is_bookable);if(a)U.value.activity_day_id=a.id;else{const e=((null==(l=T.value)?void 0:l.days)||[])[0];e&&(U.value.activity_day_id=e.id)}await async function(){if(s(r.accessToken))try{const e=await C();return(null==e?void 0:e.real_name)&&(U.value.visitor_name=e.real_na