photoGraphyCalendar.vue 11.4 KB
<template>
  <div>
    <el-calendar v-model="currentDate" :range="calendarRange">
      <template #header="{date}">
        <el-row style="width: 100%">
          <el-col :span="7" />
          <el-col :span="10">
            <el-row align="middle" class="cTitle" justify="center">
              
              <!--              <div class="canBtn"><el-icon><ArrowLeftBold /></el-icon></div>-->
              <!--              <div>-->
              <!--&lt;!&ndash;                <el-date-picker&ndash;&gt;-->
              <!--&lt;!&ndash;                  v-model="value2"&ndash;&gt;-->
              <!--&lt;!&ndash;                  type="daterange"&ndash;&gt;-->
              <!--&lt;!&ndash;                  range-separator="-"&ndash;&gt;-->
              <!--&lt;!&ndash;                  start-placeholder="Start date"&ndash;&gt;-->
              <!--&lt;!&ndash;                  end-placeholder="End date"&ndash;&gt;-->
              <!--&lt;!&ndash;                  format="YYYY-MM-DD"&ndash;&gt;-->
              <!--&lt;!&ndash;                  value-format="YYYY-MM-DD"&ndash;&gt;-->
              <!--&lt;!&ndash;                  size="small"&ndash;&gt;-->
              <!--&lt;!&ndash;                  @change="changee"&ndash;&gt;-->
              <!--&lt;!&ndash;                />&ndash;&gt;-->
              <!--                <el-input readonly v-model="value2" type="text" size="small" style="width: 280px"></el-input>-->
              <!--              </div>-->
              <!--              <div class="canBtn"><el-icon><ArrowRightBold /></el-icon></div>-->
              {{ date }}
            </el-row>
          </el-col>
          <el-col :span="7">
            <div style="text-align: right;padding-right: 10px">
              <el-date-picker
                v-model="currentDate1"
                :clearable="false"
                :disabled-date="disabledDateRZ"
                format="YYYY-MM-DD"
                placeholder="YYYY-MM-DD"
                size="small"
                type="date"
                @change="dateChange"
              />
            </div>
          </el-col>
        </el-row>
      </template>
      <template #date-cell="data">
        <div :class="data.data.day==query.currentDate?'primaryDate date':'date'" @click="selectDate(data.data.day)">
          {{ data.data.day.slice(8, 10) }}
        </div>
      </template>
    </el-calendar>
    
    <div class="calendarList">
      <ul v-loading="loading">
        <li v-for="n in schList" :key="n.id">
          <el-row style="width: 100%">
            <div style="margin-right: 25px">
              <el-image :src="fillImgUrl(n.photos?.split(',')[0]) " fit="cover" style="width: 90px;height: 115px" />
            </div>
            <div style="flex: 1">
              <div class="hz-title">{{ n.name }}</div>
              <div>
                <el-row justify="space-between">
                  <el-row class="hz-p" style="flex: 1">
                    <el-col :span="8">
                      <div class="esp_3">{{ language == 0 ? '套餐说明' : 'Package Description' }}: <span
                        style="margin-right: 20px"
                      >{{ n.introduction }}</span></div>
                    </el-col>
                    
                    <el-col :span="8">
                      <div>{{ language == 0 ? '剩余' : '' }}<span class="sign">{{
                        n.num - n.counts
                      }}</span>{{ language == 0 ? '名额' : 'Places Remaining' }}
                      </div>
                    </el-col>
                    <el-col :span="8">
                      <div>{{ n.goHome == 1 ? language == 0 ? '上门拍照' : 'Door-to-door photo' : '' }}</div>
                    </el-col>
                  </el-row>
                  <el-row>
                    <div class="zh-margin" style="font-size: 36px;color: #ff8124"><span
                                                                                    style="font-size: 24px"
                                                                                  >{{ language == 0 ? '¥' : '€' }}  </span>
                      {{ language == 0 ? n.photoPrice : n.photoPriceEn }}
                    </div>
                    <el-button
                      :disabled="n.num-n.counts<=0||Date.now()>dayjs(currentDate).subtract(-1,'day').valueOf()"
                      class="btn-lineG w200px" round size="large" type="primary" @click="goMatch(n)"
                    >
                      {{ language == 0 ? '立即预约' : 'Select' }} ⇀
                    </el-button>
                  </el-row>
                </el-row>
              </div>
            </div>
          </el-row>
        </li>
      </ul>
      <el-empty
        v-if="schList.length== 0"
        :image="`/img/order_no.png`"
        :image-size="200"
        style="--el-empty-padding:0;--el-empty-description-margin-top:0"
      />
    </div>
  </div>
</template>

<script setup>
import { ref, onMounted } from 'vue'
import { dayjs } from 'element-plus'
import { useRoute, useRouter } from 'vue-router'
import * as booking from '@/apiPc/booking'
import { useStorage } from '@vueuse/core/index'
import useUserStore from '/@/store/modules/user'
import { getActivityPhotoVoListByShootId, getBaseInfoByActiveId } from '@/apiPc/booking'
import { ElMessageBox } from 'element-plus'
import { getCurrentInstance } from '@vue/runtime-core'

const { proxy } = getCurrentInstance()
const user = useUserStore().user
const language = useStorage('language', 0)
const router = useRouter()
const route = useRoute()
const currentDate = ref(new Date())
const currentDate1 = ref(new Date())
const calendarRange = ref([dayjs(currentDate.value).toDate(), (dayjs(currentDate.value).toDate())])
const schList = ref([])
const loading = ref(false)
const query = ref({
  lasId: route.params.id
})
const value2 = ref('')
const formTime = ref()

onMounted(() => {
  getBaseInfoByActiveId(route.params.cptId).then(res => {
    formTime.value = res.data || null
  }).catch(err => {
    console.log(err)
    formTime.value = null
  }).finally(() => {
    getData()
    getScheduleList()
  })
})


function getData() {
  if (!formTime.value.photoStart) return
  const toDay = dayjs(dayjs().format('YYYY-MM-DD')).valueOf()
  const start = dayjs(formTime.value.photoStart).valueOf()
  if (toDay < start) {
    currentDate1.value = query.value.currentDate = dayjs(start).format('YYYY-MM-DD')
  } else {
    currentDate1.value = query.value.currentDate = dayjs(toDay).format('YYYY-MM-DD')
  }
  calendarRange.value = [dayjs(currentDate1.value).toDate(), (dayjs(currentDate1.value).toDate())]
}


function getScheduleList() {
  loading.value = true
  query.value.currentDate = dayjs(currentDate.value).format('YYYY-MM-DD')
  console.log(query.value)
  booking.getActivityPhotoVoListByShootId(query.value).then(res => {
    loading.value = false
    schList.value = res.data
  })
}

function selectDate(date) {
  currentDate1.value = currentDate.value = dayjs(date).toDate()
  getScheduleList()
}

function dateChange() {
  currentDate.value = currentDate1.value
  calendarRange.value = [dayjs(currentDate.value).toDate(), (dayjs(currentDate.value).toDate())]
  getScheduleList()
}

async function goMatch(n) {
  console.log(11)
  const { data } = await getBaseInfoByActiveId(route.params.cptId)
  if (data.isPhotoView == 0) {
    return proxy.$modal.confirm(language.value == 0 ? '感谢您对本次比赛的关注,该服务暂无可预订信息,敬请期待。' : 'Thank you for your attention to this competition. The service is currently unavailable for booking. Please stay tuned.')
  }
  
  if (!user) {
    useUserStore().setVisitor()
    return
  }
  
  ElMessageBox.confirm(language.value == 0 ? `你当前所预约的时间为${query.value.currentDate}是否确定?` : `Your current appointment is ${query.value.currentDate}. Are you sure?`, { type: 'warning' })
    .then((rr) => {
      console.log(rr)
      router.push({
        name: 'photographyOrder',
        params: {
          lasId: n.id
        },
        query: {
          date: dayjs(currentDate.value).format('YYYY-MM-DD')
        }
      })
    })
    .catch((e) => {
      // catch error
      console.log(e)
    })
}

function disabledDateRZ(date) {
  if (formTime.value) {
    const toDay = dayjs(dayjs().format('YYYY-MM-DD')).valueOf()
    const start = dayjs(formTime.value.photoStart).valueOf()
    const end = dayjs(formTime.value.photoEnd).valueOf()
    if (toDay < start) {
      return date.getTime() < start || date.getTime() > end
    } else if (toDay > start && toDay < end) {
      return date.getTime() < toDay || date.getTime() > end
    } else return true
  }
}
</script>

<style lang="scss" scoped>
.el-calendar {
  --el-calendar-border: none;
  --el-calendar-cell-width: 40px;
  text-align: center;
  --el-text-color-regular: #8E8D94;
  
  :deep(.el-calendar__header) {
    justify-content: center;
    padding: 0 0 10px
  }
  
  :deep(.el-calendar__body) {
    border: 1px solid #F0F0F0;
    padding: 0
  }
  
  :deep(.el-calendar-table .el-calendar-day) {
    padding: 1px;
  }
  
  :deep(.el-calendar-table td.is-selected) {
    background: transparent;
  }
  
  :deep(.el-calendar__button-group) {
    display: none;
  }
  
  :deep(.el-calendar-table thead th) {
    padding: 5px 0 0
  }
  
  .primaryDate {
    color: #fff;
    background: linear-gradient(90deg, #8623FC, #453DEA);
  }
  
  .date {
    margin: auto;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    line-height: 30px;
    font-weight: bold;
  }
}

.calendarList {
  border: 1px solid #F0F0F0;
  padding: 12px 20px;
  overflow: auto;
  height: 625px;
  
  ul {
    li {
      cursor: pointer;
      background: #F6F9FE;
      margin: 7px 0 7px 20px;
      position: relative;
      padding: 13px;
      border-radius: 10px;
      font-weight: 500;
      font-size: 15px;
      
      label {
        color: #453DEA;
        margin-right: 15px;
        
        &::before {
          content: '';
          background: #fff;
          left: -17px;
          top: 0px;
          bottom: 0;
          margin: auto;
          border-radius: 50%;
          width: 2px;
          height: 2px;
          position: absolute;
          z-index: 1
        }
      }
    }
    
    li::before {
      content: '';
      background: linear-gradient(0deg, #8623FC, #453DEA);
      border-radius: 50%;
      width: 8px;
      height: 8px;
      position: absolute;
      left: -20px;
      top: 0;
      bottom: 0;
      margin: auto;
      z-index: 1;
    }
    
    li::after {
      content: '';
      left: -16px;
      width: 1px;
      height: 100%;
      background: #EBEBEB;
      position: absolute;
      top: 20px
    }
    
    //li:hover {
    //  color: #fff;
    //  background: linear-gradient(-90deg, #8623FC, #453DEA);
    //
    //  label {
    //    color: #fff;
    //  }
    //}
  }
}

.hz-title {
  font-size: 20px;
  font-weight: 400;
  color: #000;
  margin-top: 20px;
  margin-bottom: 10px;
}

.zh-margin {
  font-weight: bold;
  font-size: 36px;
  color: #FF8124;
  margin-right: 30px;
}

.hz-p {
  font-size: 16px;
  color: #4C5359;
  font-weight: 400;
}

:deep(.el-calendar__header) {
  background: linear-gradient(90deg, #8623FC, #453DEA);
  height: 50px;
  line-height: 50px;
}

.canBtn {
  color: #453DEA;
  border-radius: 2px;
  width: 22px;
  height: 22px;
  line-height: 26px;
  text-align: center;
  background-color: #fff;
  margin: 0 16px -2px 16px;
  cursor: pointer
}

.cTitle {
  color: #fff;
  font-size: 20px;
  font-weight: 500;
}
</style>