first commit
This commit is contained in:
1
unpackage/dist/build/mp-weixin/pages/booking/booking.js
vendored
Normal file
1
unpackage/dist/build/mp-weixin/pages/booking/booking.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
"use strict";const e=require("../../common/vendor.js"),t=require("../../utils/api.js");if(!Array){(e.resolveComponent("t-loading")+e.resolveComponent("t-empty")+e.resolveComponent("t-tag")+e.resolveComponent("t-button")+e.resolveComponent("t-stepper")+e.resolveComponent("t-dialog"))()}Math||((()=>"../../uni_modules/tdesign-uniapp/components/loading/loading.js")+(()=>"../../uni_modules/tdesign-uniapp/components/empty/empty.js")+(()=>"../../uni_modules/tdesign-uniapp/components/tag/tag.js")+(()=>"../../uni_modules/tdesign-uniapp/components/button/button.js")+(()=>"../../uni_modules/tdesign-uniapp/components/stepper/stepper.js")+(()=>"../../uni_modules/tdesign-uniapp/components/dialog/dialog.js"))();const a=e.defineComponent({__name:"booking",setup(a){const o=e.ref((()=>{const e=new Date;return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,"0")}-${String(e.getDate()).padStart(2,"0")}`})()),l=e.ref([]),n=e.ref(!1),i=e.ref(!1),s=e.ref(null),r=e.ref(1),u=e.ref(""),p=e.ref(!1),c=e.ref(new Date),d=["日","一","二","三","四","五","六"],v=e.ref({}),g=e.ref({}),m=e.computed((()=>`${c.value.getFullYear()}年${c.value.getMonth()+1}月`)),h=e.computed((()=>l.value.reduce(((e,t)=>e+t.current_people),0))),_=e.computed((()=>{const e=c.value.getFullYear(),t=c.value.getMonth(),a=new Date(e,t,1),o=new Date(e,t+1,0),l=new Date,n=[];for(let i=a.getDay()-1;i>=0;i--)n.push({day:"",dateStr:"",isPlaceholder:!0,isOtherMonth:!1,isToday:!1,bookingCount:0,hasBookings:!1});for(let i=1;i<=o.getDate();i++){const a=new Date(e,t,i),o=a.getFullYear(),s=a.getMonth()+1,r=a.getDate(),u=`${o}-${String(s).padStart(2,"0")}-${String(r).padStart(2,"0")}`,p=l.getFullYear(),c=l.getMonth(),d=l.getDate(),m=o===p&&s-1===c&&r===d;n.push({day:i,dateStr:u,isPlaceholder:!1,isOtherMonth:!1,isToday:m,bookingCount:v.value[u]||0,hasBookings:g.value[u]||!1})}return n}));e.onMounted((()=>{e.index.getStorageSync("token")?(y(),f()):e.index.redirectTo({url:"/pages/login/login"})}));const f=async()=>{try{const e=await t.api.timeslots.getList({is_active:!0}),a={},o={};e.forEach((e=>{const t=e.date.split("T")[0];a[t]=(a[t]||0)+e.current_people,o[t]=!0})),v.value=a,g.value=o}catch(e){console.error("加载日期预约统计失败",e)}},y=async()=>{n.value=!0;try{const e=await t.api.timeslots.getList({date:o.value,is_active:!0});l.value=e}catch(e){console.error("加载时间槽失败",e)}finally{n.value=!1}},b=e=>{const t=(e.split("T")[1]||e).split("+")[0].split("Z")[0],[a,o]=t.split(":");return`${a}:${o}`},S=async()=>{if(s.value){p.value=!0;try{await t.api.appointments.create(s.value.id,r.value,u.value),e.index.showToast({title:"预约成功",icon:"success"}),i.value=!1,y(),f()}catch(a){i.value=!1}finally{p.value=!1}}};return(t,a)=>{var c,v,g,f;return e.e({a:e.t(m.value),b:e.f(d,((t,a,o)=>({a:e.t(t),b:t}))),c:e.f(_.value,((t,a,l)=>e.e({a:!t.isPlaceholder},t.isPlaceholder?{}:{b:e.t(t.day)},{c:!t.isPlaceholder&&t.bookingCount>0},!t.isPlaceholder&&t.bookingCount>0?{d:e.t(t.bookingCount)}:{},{e:t.dateStr||`placeholder-${a}`,f:t.isPlaceholder?1:"",g:t.dateStr===o.value?1:"",h:t.isToday?1:"",i:t.hasBookings||t.isPlaceholder?"":1,j:t.hasBookings?1:"",k:e.o((e=>!t.isPlaceholder&&(e=>{o.value=e.dateStr,y()})(t)),t.dateStr||`placeholder-${a}`)}))),d:e.t(o.value),e:h.value>0},h.value>0?{f:e.t(h.value)}:{},{g:n.value},n.value?{h:e.p({loading:!0})}:0===l.value.length?{j:e.p({description:"暂无可预约时间段"})}:{k:e.f(l.value,((t,a,o)=>({a:e.t(b(t.start_time)),b:e.t(b(t.end_time)),c:e.t(t.current_people),d:e.t(t.max_people),e:"6ce25a93-2-"+o,f:e.p({theme:t.current_people>=t.max_people?"danger":"success",size:"small"}),g:e.t(t.current_people>=t.max_people?"已满":"预约"),h:e.o((a=>(t=>{if(p.value)e.index.showToast({title:"正在处理,请稍候",icon:"none"});else{if(!t.is_active||t.current_people>=t.max_people)return console.log("时间槽不可用",t),void e.index.showToast({title:"该时间段已不可用",icon:"none"});s.value=t,r.value=1,u.value="",i.value=!0,console.log("打开弹窗",i.value)}})(t)),t.id),i:"6ce25a93-3-"+o,j:e.p({"t-class":"btn-primary",size:"small",theme:"primary",disabled:!t.is_active||t.current_people>=t.max_people}),k:t.id,l:!t.is_active||t.current_people>=t.max_people?1:""})))},{i:0===l.value.length,l:e.t(o.value),m:e.t((null==(c=s.value)?void 0:c.start_time)?b(s.value.start_time):""),n:e.t((null==(v=s.value)?void 0:v.end_time)?b(s.value.end_time):""),o:e.o((e=>r.value=e)),p:e.p({min:1,max:(null==(g=s.value)?void 0:g.max_people)-(null==(f=s.value)?void 0:f.current_people)||1,disabled:!0,size:"small",modelValue:r.value}),q:e.o(S),r:e.o((e=>i.value=!1)),s:e.o((e=>i.value=e)),t:e.p({title:"预约确认",cancelBtn:"取消",confirmBtn:"确认预约","t-class-confirm":"btn-primary",visible:i.value})})}}}),o=e._export_sfc(a,[["__scopeId","data-v-6ce25a93"]]);wx.createPage(o);
|
||||
11
unpackage/dist/build/mp-weixin/pages/booking/booking.json
vendored
Normal file
11
unpackage/dist/build/mp-weixin/pages/booking/booking.json
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"navigationBarTitleText": "我要预约",
|
||||
"usingComponents": {
|
||||
"t-loading": "../../uni_modules/tdesign-uniapp/components/loading/loading",
|
||||
"t-empty": "../../uni_modules/tdesign-uniapp/components/empty/empty",
|
||||
"t-tag": "../../uni_modules/tdesign-uniapp/components/tag/tag",
|
||||
"t-button": "../../uni_modules/tdesign-uniapp/components/button/button",
|
||||
"t-stepper": "../../uni_modules/tdesign-uniapp/components/stepper/stepper",
|
||||
"t-dialog": "../../uni_modules/tdesign-uniapp/components/dialog/dialog"
|
||||
}
|
||||
}
|
||||
1
unpackage/dist/build/mp-weixin/pages/booking/booking.wxml
vendored
Normal file
1
unpackage/dist/build/mp-weixin/pages/booking/booking.wxml
vendored
Normal file
@@ -0,0 +1 @@
|
||||
<view class="container data-v-6ce25a93"><view class="date-selector data-v-6ce25a93"><view class="calendar-header data-v-6ce25a93"><text class="month-title data-v-6ce25a93">{{a}}</text></view><view class="calendar-weekdays data-v-6ce25a93"><text wx:for="{{b}}" wx:for-item="day" wx:key="b" class="weekday data-v-6ce25a93">{{day.a}}</text></view><view class="calendar-days data-v-6ce25a93"><view wx:for="{{c}}" wx:for-item="day" wx:key="e" class="{{['calendar-day', 'data-v-6ce25a93', day.f && 'placeholder', day.g && 'selected', day.h && 'today', day.i && 'disabled', day.j && 'has-bookings']}}" bindtap="{{day.k}}"><text wx:if="{{day.a}}" class="day-number data-v-6ce25a93">{{day.b}}</text><text wx:if="{{day.c}}" class="booking-count data-v-6ce25a93">{{day.d}}人 </text></view></view></view><scroll-view class="timeslots-scroll data-v-6ce25a93" scroll-y="true"><view class="timeslots-section data-v-6ce25a93"><view class="section-title data-v-6ce25a93">{{d}} 可选时间段 <text wx:if="{{e}}" class="total-booking data-v-6ce25a93"> (总预约: {{f}}人) </text></view><t-loading wx:if="{{g}}" class="data-v-6ce25a93" u-i="6ce25a93-0" bind:__l="__l" u-p="{{h}}"/><view wx:elif="{{i}}" class="empty-state data-v-6ce25a93"><t-empty wx:if="{{j}}" class="data-v-6ce25a93" u-i="6ce25a93-1" bind:__l="__l" u-p="{{j}}"/></view><view wx:else class="timeslots-list data-v-6ce25a93"><view wx:for="{{k}}" wx:for-item="slot" wx:key="k" class="{{['timeslot-card', 'data-v-6ce25a93', slot.l && 'disabled']}}"><view class="timeslot-info data-v-6ce25a93"><view class="time-range data-v-6ce25a93">{{slot.a}} - {{slot.b}}</view><view class="slot-status data-v-6ce25a93"><t-tag wx:if="{{slot.f}}" class="data-v-6ce25a93" u-s="{{['d']}}" u-i="{{slot.e}}" bind:__l="__l" u-p="{{slot.f}}">{{slot.c}}/{{slot.d}}</t-tag></view></view><t-button wx:if="{{slot.j}}" class="data-v-6ce25a93" u-s="{{['d']}}" catchclick="{{slot.h}}" u-i="{{slot.i}}" bind:__l="__l" u-p="{{slot.j}}">{{slot.g}}</t-button></view></view></view></scroll-view><t-dialog wx:if="{{t}}" class="data-v-6ce25a93" u-s="{{['content']}}" bindconfirm="{{q}}" bindcancel="{{r}}" u-i="6ce25a93-4" bind:__l="__l" bindupdateVisible="{{s}}" u-p="{{t}}"><scroll-view type="list" scroll-y class="long-content data-v-6ce25a93" slot="content"><view class="booking-dialog data-v-6ce25a93"><view class="dialog-item data-v-6ce25a93"><text class="dialog-label data-v-6ce25a93">日期:</text><text class="dialog-value data-v-6ce25a93">{{l}}</text></view><view class="dialog-item data-v-6ce25a93"><text class="dialog-label data-v-6ce25a93">时间段:</text><text class="dialog-value data-v-6ce25a93">{{m}} - {{n}}</text></view><view class="dialog-item data-v-6ce25a93"><text class="dialog-label data-v-6ce25a93">人数:</text><t-stepper wx:if="{{p}}" class="data-v-6ce25a93" u-i="6ce25a93-5,6ce25a93-4" bind:__l="__l" bindupdateModelValue="{{o}}" u-p="{{p}}"/></view></view></scroll-view></t-dialog></view>
|
||||
1
unpackage/dist/build/mp-weixin/pages/booking/booking.wxss
vendored
Normal file
1
unpackage/dist/build/mp-weixin/pages/booking/booking.wxss
vendored
Normal file
@@ -0,0 +1 @@
|
||||
.container.data-v-6ce25a93{height:calc(100vh - var(--window-top));display:flex;flex-direction:column;background:#f5f5f5;overflow:hidden}.date-selector.data-v-6ce25a93{flex-shrink:0;background:#fff;margin:24rpx 32rpx;border-radius:16rpx;padding:32rpx;box-shadow:0 4rpx 12rpx rgba(0,0,0,.06)}.calendar-header.data-v-6ce25a93{text-align:center;margin-bottom:24rpx}.month-title.data-v-6ce25a93{font-size:32rpx;font-weight:700;color:#333}.calendar-weekdays.data-v-6ce25a93{display:grid;grid-template-columns:repeat(7,1fr);gap:8rpx;margin-bottom:16rpx;padding:0 10rpx}.weekday.data-v-6ce25a93{font-size:24rpx;color:#999;text-align:center}.calendar-days.data-v-6ce25a93{display:grid;grid-template-columns:repeat(7,1fr);gap:8rpx;padding:0 10rpx}.calendar-day.data-v-6ce25a93{height:100rpx;display:flex;flex-direction:column;align-items:center;justify-content:center;border-radius:8rpx;cursor:pointer;transition:all .3s ease}.calendar-day.placeholder.data-v-6ce25a93{visibility:hidden}.calendar-day.disabled.data-v-6ce25a93{opacity:.4;pointer-events:none}.calendar-day.has-bookings.data-v-6ce25a93{background:rgba(255,122,0,.08);border:2rpx solid #FF7A00}.calendar-day.today.data-v-6ce25a93{background:rgba(255,122,0,.12)}.calendar-day.selected.data-v-6ce25a93{background:linear-gradient(135deg,#ff7a00,#ff9500)}.calendar-day.selected .day-number.data-v-6ce25a93,.calendar-day.selected .booking-count.data-v-6ce25a93{color:#fff}.day-number.data-v-6ce25a93{font-size:28rpx;color:#333;margin-bottom:4rpx}.booking-count.data-v-6ce25a93{font-size:20rpx;color:#ff7a00}.timeslots-scroll.data-v-6ce25a93{flex:1;overflow:hidden}.timeslots-section.data-v-6ce25a93{padding:32rpx}.section-title.data-v-6ce25a93{font-size:32rpx;font-weight:700;color:#333;margin-bottom:24rpx;display:flex;align-items:center}.total-booking.data-v-6ce25a93{font-size:24rpx;color:#ff7a00;margin-left:16rpx;font-weight:400}.empty-state.data-v-6ce25a93{padding:80rpx 0}.timeslots-list.data-v-6ce25a93{display:flex;flex-direction:column;gap:20rpx}.timeslot-card.data-v-6ce25a93{background:#fff;border-radius:16rpx;padding:32rpx;display:flex;justify-content:space-between;align-items:center;box-shadow:0 2rpx 12rpx rgba(0,0,0,.06)}.timeslot-card.disabled.data-v-6ce25a93{opacity:.6}.timeslot-info.data-v-6ce25a93{flex:1}.time-range.data-v-6ce25a93{font-size:32rpx;font-weight:700;color:#333;margin-bottom:16rpx}.slot-status.data-v-6ce25a93{margin-top:8rpx}.booking-dialog.data-v-6ce25a93{padding:32rpx 0}.dialog-item.data-v-6ce25a93{display:flex;align-items:center;padding:20rpx 0;border-bottom:1rpx solid #f0f0f0}.dialog-item.data-v-6ce25a93:last-child{border-bottom:none}.dialog-label.data-v-6ce25a93{width:120rpx;font-size:28rpx;color:#666}.dialog-value.data-v-6ce25a93{flex:1;font-size:28rpx;color:#333;font-weight:500}.btn-primary{background:linear-gradient(135deg,#ff7a00,#ff9500)!important;border:none!important;border-radius:8rpx!important;color:#fff!important;box-shadow:0 4rpx 12rpx rgba(255,122,0,.3)!important;outline:none!important}.btn-primary:after{border:none!important;box-shadow:none!important}.btn-primary:active{background:linear-gradient(135deg,#ff6900,#ff8500)!important}
|
||||
Reference in New Issue
Block a user