serve-time-pop.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. <template>
  2. <u-popup :show="show" @close="close" close-on-click-overlay closeable round="20rpx">
  3. <view class="pop_content column">
  4. <text class="center bold">服务时间</text>
  5. <text v-if="type=='order'" class="mtb30">原服务时间: {{oldTime}}</text>
  6. <view class="date_tabs">
  7. <u-tabs :list="tabsList" @click="e=>tabCurrent=e.index" :current="tabCurrent" keyName="day" :activeStyle="{
  8. color: '#fff',
  9. fontSize:'30rpx',
  10. background:'#36C3FF',
  11. padding:'5rpx 20rpx',
  12. borderRadius:'20rpx'
  13. }" :inactiveStyle="{
  14. color: '#242323',
  15. fontSize:'30rpx',
  16. background:'#DBDBDB',
  17. padding:'5rpx 20rpx',
  18. borderRadius:'20rpx'
  19. }" lineHeight="0" lineColor="#BFF6FF"></u-tabs>
  20. </view>
  21. <view class="content_time mt20">
  22. <view :class="timebCurrent==index?'time_item time_item_act':'time_item'"
  23. v-for="(item,index) in tabsList[tabCurrent]?tabsList[tabCurrent].time:[]" :key="index"
  24. @click="timebCurrent=index">{{item}}</view>
  25. </view>
  26. <view class="button justify-between m30">
  27. <u-button plain text="取消" @click="close" shape="circle"
  28. :style="{minWidth:'150rpx',marginRight:'10rpx'}"></u-button>
  29. <u-button text="确认" type="primary" @click="onConfirm" shape="circle"
  30. :style="{minWidth:'150rpx',marginLeft:'10rpx'}"></u-button>
  31. </view>
  32. </view>
  33. </u-popup>
  34. </template>
  35. <script setup>
  36. import {
  37. onMounted,
  38. ref,
  39. } from "vue";
  40. import {
  41. dateList
  42. } from "@/api/order";
  43. name: 'serve-time-pop'
  44. const emits = defineEmits(['update:show', 'complete', 'close'])
  45. const props = defineProps({
  46. show: {
  47. type: Boolean,
  48. default: false
  49. },
  50. type: {
  51. type: String,
  52. default: 'pay'
  53. },
  54. oldTime: {
  55. type: String,
  56. default: ''
  57. }
  58. })
  59. const tabsList = ref([])
  60. const tabCurrent = ref(0)
  61. const timebCurrent = ref(0)
  62. onMounted(async () => {
  63. getDateList()
  64. })
  65. // 获取时间
  66. const getDateList = async () => {
  67. let res = await dateList()
  68. if (res) {
  69. tabsList.value = res.data
  70. let serveTime =
  71. `${tabsList.value[0].date} ${tabsList.value[0].time[0]}`
  72. if (props.type == 'pay') {
  73. emits('complete', serveTime)
  74. emits('update:show', false)
  75. }
  76. }
  77. }
  78. // 关闭pop
  79. const close = () => {
  80. emits('close', false)
  81. emits('update:show', false)
  82. }
  83. // 选择
  84. const onConfirm = () => {
  85. let serveTime =
  86. `${tabsList.value[tabCurrent.value].date} ${tabsList.value[tabCurrent.value].time[timebCurrent.value]}`
  87. emits('complete', serveTime)
  88. emits('update:show', false)
  89. }
  90. </script>
  91. <style lang="scss" scoped>
  92. .pop_content {
  93. padding: 25rpx 15rpx;
  94. .content_time {
  95. display: grid;
  96. grid-template-columns: 1fr 1fr 1fr 1fr 1fr;
  97. grid-template-rows: 1fr 1fr 1fr 1fr 1fr;
  98. grid-gap: 0rpx;
  99. height: 500rpx;
  100. overflow-y: scroll;
  101. .time_item {
  102. padding: 22rpx 14rpx;
  103. border: 1px solid #E6E6E6;
  104. color: #BEBEBE;
  105. transition: .5s;
  106. height: 50rpx;
  107. line-height: 50rpx;
  108. text-align: center;
  109. }
  110. .time_item_act {
  111. background: $--base-bg;
  112. color: #fff;
  113. }
  114. }
  115. .button {
  116. width: calc(100% - 60rpx);
  117. }
  118. }
  119. </style>