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
10 KiB
2 lines
10 KiB
|
6 months ago
|
import{d as e,e as l,f as a,W as t,j as i,k as o,s as u,v as n,g as s,S as d,t as c,u as r,n as v,y as _,z as p,B as f,F as m,C as y,E as g,G as b,x as h,_ as k,I as $,T as x,a4 as w}from"./index-BGcsYrai.js";import{h as S,i as V}from"./content.CxzBwpG2.js";import{g as M,l as C}from"./localProfile.9aru8Fu9.js";import{_ as D}from"./_plugin-vue_export-helper.BCo6x5W8.js";function N(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,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}(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(/ /gi," ").replace(/\s+/g," ").trim().length>0?a:"";var t}const j=D(e({__name:"reserve",setup(e){const D=l(0),j=l(!1),T=l(!1),F=l(null),U=l(!1),z=l({activity_day_id:0,visitor_name:"",visitor_phone:"",id_card:"",booking_type:"individual",people_count:1});a(()=>{var e;return((null==(e=F.value)?void 0:e.days)||[]).find(e=>e.id===z.value.activity_day_id)});const Y=a(()=>!!z.value.activity_day_id&&!!z.value.visitor_name&&/^1\d{10}$/.test(z.value.visitor_phone)),B=a(()=>{var e,l;return N(null==(l=null==(e=F.value)?void 0:e.activity)?void 0:l.reservation_notice)}),I=a(()=>{var e,l;return String((null==(l=null==(e=F.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=F.value)?void 0:e.activity)?void 0:l.min_people_per_order)||1))}),E=a(()=>{var e,l;return Math.max(1,Number((null==(l=null==(e=F.value)?void 0:e.activity)?void 0:l.max_people_per_order)||1))}),G=a(()=>{var e,l;return(null==(l=null==(e=F.value)?void 0:e.activity)?void 0:l.booking_modes)||["individual","group"]}),O=a(()=>{var e;return[...(null==(e=F.value)?void 0:e.days)||[]].sort((e,l)=>String(e.activity_date).localeCompare(String(l.activity_date)))});function P(e){return String(e).padStart(2,"0")}function W(e){const l=new Date,a=`${l.getFullYear()}-${P(l.getMonth()+1)}-${P(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()}-${P(i.getMonth()+1)}-${P(i.getDate())}`)return"明天";const o=new Date(l);o.setDate(o.getDate()+2);return t===`${o.getFullYear()}-${P(o.getMonth()+1)}-${P(o.getDate())}`?"后天":""}function X(e){const l=String(e).slice(0,10).split("-");return 3!==l.length?"":`${Number(l[1])}月${Number(l[2])}日`}function A(e){const l=Number((null==e?void 0:e.available_count)??0);return l<=0?"0张":`${l}张`}function H(){if("individual"===I.value)return z.value.booking_type="individual",void(z.value.people_count=1);if("group"===I.value?z.value.booking_type="group":G.value.includes(z.value.booking_type)||(z.value.booking_type="individual"),"individual"===z.value.booking_type)return void(z.value.people_count=1);const e=Math.floor(Number(z.value.people_count||0));z.value.people_count=Math.min(E.value,Math.max(q.value,e||q.value))}async function J(){var e,l;if(D.value){j.value=!0;try{F.value=await S(D.value),H();const a=((null==(e=F.value)?void 0:e.days)||[]).find(e=>e.is_bookable);if(a)z.value.activity_day_id=a.id;else{const e=((null==(l=F.value)?void 0:l.days)||[])[0];e&&(z.value.activity_day_id=e.id)}await async function(){if(s(d.accessToken))try{const e=await M();return(null==e?void 0:e.real_name)&&(z.value.visitor_name=e.real_name),(null==e?void 0:e.phone)&&(z.value.visitor_phone=e.phone),void((null==e?void 0:e.id_card)&&(z.value.id_card=e.id_card))}catch{}const e=C();(null==e?void 0:e.real_name)&&(z.value.visitor_name=e.real_name),(null==e?void 0:e.p
|