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.

197 lines
3.6 KiB

8 months ago
8 months ago
  1. <template>
  2. <van-popup
  3. v-model:show="showBottom"
  4. round
  5. position="bottom"
  6. @close="close"
  7. :style="{ height: '75%' }"
  8. >
  9. <view class="box">
  10. <view class="title">
  11. {{ title }}
  12. </view>
  13. <view class="date-list">
  14. <view class="date-item"
  15. v-for="(item, index) in dateList"
  16. @click="selectDate(item, index)">
  17. <view>
  18. {{ item.format('dddd') }}
  19. </view>
  20. <view :class="{act : i == index}">
  21. {{ item.format('MM-DD') }}
  22. </view>
  23. </view>
  24. </view>
  25. <view style="display: flex;justify-content: center;" v-if="loading">
  26. <van-loading />
  27. </view>
  28. <view class="time-list" v-else-if="timeList.length">
  29. <view class="time-content">
  30. <view
  31. :class="{'time-item' : true,
  32. no : item.isDelete != 'Y' ||
  33. isDelete({time : item, date : dateList[i]})}"
  34. v-for="(item, index) in timeList"
  35. @click="selectTime({time : item, date : dateList[i]})">
  36. <view>
  37. {{ item.timeName }}
  38. </view>
  39. <view class="status">
  40. {{ item.isDelete != 'Y' ? '未开启' :
  41. isDelete({time : item, date : dateList[i]}) ? '过时' : '空闲'}}
  42. </view>
  43. </view>
  44. </view>
  45. </view>
  46. <van-empty v-else image="/static/empty/data.png" image-size="400rpx">
  47. <template #description>
  48. <view style="color: white;">
  49. 暂无服务时间数据
  50. </view>
  51. </template>
  52. </van-empty>
  53. </view>
  54. </van-popup>
  55. </template>
  56. <script>
  57. export default {
  58. name:"selectTime",
  59. props : ['show', 'title', 'dateList', 'timeList', 'loading'],
  60. data() {
  61. return {
  62. showBottom : false,
  63. i : 0
  64. };
  65. },
  66. onShow(){
  67. this.getAddressList();
  68. },
  69. methods : {
  70. isDelete(e){
  71. let day = e.date.format('YYYY-MM-DD')
  72. let selectTime = this.dayjs(`${day} ${e.time.timeName}`)
  73. let nowTime = this.dayjs()
  74. if(selectTime.isBefore(nowTime)){
  75. return true
  76. }
  77. if(e.time.isDelete != 'Y'){
  78. return true
  79. }
  80. return false
  81. },
  82. selectTime(e){
  83. if(this.isDelete(e)){
  84. return
  85. }
  86. this.$emit('select', e)
  87. },
  88. selectDate(e, index){
  89. this.i = index
  90. this.$emit('selectDate', e)
  91. },
  92. close(){
  93. this.$emit('close')
  94. }
  95. },
  96. watch: {
  97. show: {
  98. handler (newValue, oldValue) {
  99. this.showBottom = newValue
  100. },
  101. immediate: true
  102. }
  103. }
  104. }
  105. </script>
  106. <style lang="scss" scoped>
  107. .box{
  108. width: 100%;
  109. height: 100%;
  110. background: linear-gradient(#57CAA0, #55B16E);
  111. box-sizing: border-box;
  112. padding: 40rpx;
  113. .title{
  114. font-size: 32rpx;
  115. text-align: center;
  116. color: #fff;
  117. }
  118. .date-list{
  119. display: flex;
  120. width: 100%;
  121. overflow: hidden;
  122. overflow-x: scroll;
  123. padding: 30rpx 0;
  124. text-align: center;
  125. color: #fff;
  126. font-size: 24rpx;
  127. .date-item{
  128. flex-shrink: 0;
  129. padding: 0 10rpx;
  130. &>view{
  131. padding: 6rpx 10rpx;
  132. }
  133. .act{
  134. background-color: #fff;
  135. color: #55B16E;
  136. border-radius: 10rpx;
  137. }
  138. }
  139. }
  140. .time-list{
  141. width: 100%;
  142. font-size: 24rpx;
  143. overflow: hidden;
  144. height: calc(100% - 200rpx);
  145. overflow-y: scroll;
  146. .time-content{
  147. display: flex;
  148. flex-wrap: wrap;
  149. .time-item{
  150. padding: 10rpx;
  151. background-color: #fff;
  152. width: calc(25% - 20rpx);
  153. box-sizing: border-box;
  154. margin: 10rpx;
  155. border-radius: 16rpx;
  156. view{
  157. display: flex;
  158. align-items: center;
  159. justify-content: center;
  160. height: 40rpx;
  161. }
  162. .status{
  163. color: #56BD86;
  164. }
  165. &.no{
  166. background-color: #E4E4E4;
  167. color: #CCCCCC;
  168. .status{
  169. color: #EBA44B;
  170. }
  171. }
  172. }
  173. }
  174. .act{
  175. background-color: #fff;
  176. color: #55B16E;
  177. border-radius: 10rpx;
  178. }
  179. }
  180. }
  181. </style>