学员端小程序
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.

247 lines
5.6 KiB

1 year ago
  1. <template>
  2. <view class="step1">
  3. <view class="card">
  4. <view class="dateBox">
  5. <view class="month-row">
  6. <view class="month">2032.08</view>
  7. <view class="arrow">
  8. <u-icon name="arrow-down" :size="12" :color="'#1989FA'"></u-icon>
  9. </view>
  10. </view>
  11. <view class="date_row">
  12. <view class="icon left" @click="changeDateIndex(-1)">
  13. <u-icon name="arrow-left" :size="12" :color="'#fff'"></u-icon>
  14. </view>
  15. <view class="dateArr" >
  16. <view class="dateWidth" v-for="(item,index) in dateArr[currentDay]" :key="index" @click="chooseDate(item)" >
  17. <view class="date" :class="{active: chooseDay==item.date}">
  18. <view class="week">{{ item.week }}</view>
  19. <view class="num">{{ item.num }}</view>
  20. </view>
  21. </view>
  22. </view>
  23. <view class="icon right" @click="changeDateIndex(1)">
  24. <u-icon name="arrow-right" :size="12" :color="'#fff'"></u-icon>
  25. </view>
  26. </view>
  27. </view>
  28. </view>
  29. <view class="card">
  30. <view class="timeCon">
  31. <view class="h2">上午</view>
  32. <view class="time_box">
  33. <view class="time_item" v-for="(item,index) in timerArr" :key="index" @click="chooseTimerClick(item)" :class="{active: item.id==chooseTimerId, disable: item.status!==1}">
  34. <view class="lab" v-if="item.status==3">已过期</view>
  35. <view class="lab" v-if="item.status==2">已约满</view>
  36. <view class="lab" v-if="item.status==1">可预约</view>
  37. <view class="time">{{ item.timer }}</view>
  38. </view>
  39. </view>
  40. <view class="h2">下午</view>
  41. <view class="time_box">
  42. <view class="time_item" v-for="(item,index) in timerArr2" :key="index" @click="chooseTimerClick(item)" :class="{active: item.id==chooseTimerId,disable: item.status!==1}">
  43. <view class="lab" v-if="item.status==3">已过期</view>
  44. <view class="lab" v-if="item.status==2">已约满</view>
  45. <view class="lab" v-if="item.status==1">可预约</view>
  46. <view class="time">{{ item.timer }}</view>
  47. </view>
  48. </view>
  49. </view>
  50. </view>
  51. </view>
  52. </template>
  53. <script>
  54. import { getDates } from '@/config/utils.js'
  55. export default {
  56. data() {
  57. return {
  58. dateArr: [],
  59. currentDay: 0,
  60. chooseDay: '',
  61. timerArr: [
  62. {status: 1, timer: '06:00-07:00', id: 1},
  63. {status: 2, timer: '06:00-07:00', id: 2},
  64. {status: 3, timer: '06:00-07:00', id: 3},
  65. ],
  66. timerArr2: [
  67. {status: 1, timer: '06:00-07:00', id: 4},
  68. {status: 2, timer: '06:00-07:00', id: 5},
  69. {status: 3, timer: '06:00-07:00', id: 6},
  70. ],
  71. chooseTimerId: ''
  72. }
  73. },
  74. mounted() {
  75. const startDate = new Date('2023-09-06');
  76. const endDate = new Date();
  77. this.dateArr = getDates(startDate, endDate);
  78. },
  79. methods: {
  80. // 选择时间
  81. chooseTimerClick(item) {
  82. if(item.status!=1) return this.$u.toast('请选择可预约时间')
  83. this.chooseTimerId = item.id
  84. },
  85. // 选择日期
  86. chooseDate(item) {
  87. this.chooseDay = item.date
  88. console.log(this.chooseDay)
  89. },
  90. changeDateIndex(num) {
  91. if(this.currentDay==0&&num==-1) return
  92. if(this.currentDay==this.dateArr.length-1&&num==1) return
  93. this.currentDay = this.currentDay + num
  94. console.log(this.currentDay)
  95. },
  96. }
  97. }
  98. </script>
  99. <style lang="scss" scoped>
  100. .card {
  101. width: 100%;
  102. margin-bottom: 24rpx;
  103. overflow: hidden;
  104. .dateBox {
  105. padding: 36rpx 0 40rpx 0;
  106. .month-row {
  107. display: flex;
  108. justify-content: center;
  109. align-items: center;
  110. margin-bottom: 36rpx;
  111. .month {
  112. font-size: 32rpx;
  113. color: $themC;
  114. }
  115. .arrow {
  116. margin-left: 6rpx;
  117. }
  118. }
  119. .date_row {
  120. width: 100%;
  121. height: 100rpx;
  122. position: relative;
  123. .icon {
  124. width: 40rpx;
  125. height: 40rpx;
  126. background: rgba(51,51,51,0.18);
  127. backdrop-filter: blur(4rpx);
  128. position: absolute;
  129. top: 50%;
  130. transform: translateY(-50%);
  131. display: flex;
  132. align-items: center;
  133. justify-content: center;
  134. border-radius: 50%;
  135. &.left {
  136. left: 16rpx;
  137. }
  138. &.right {
  139. right: 16rpx;
  140. }
  141. }
  142. .dateArr {
  143. display: flex;
  144. padding: 0 70rpx;
  145. // justify-content: space-between;
  146. &.oneDate {
  147. justify-content: center;
  148. }
  149. .dateWidth {
  150. width: 20%;
  151. display: flex;
  152. justify-content: center;
  153. }
  154. .date {
  155. width: 74rpx;
  156. height: 100rpx;
  157. border-radius: 16rpx;
  158. display: flex;
  159. flex-direction: column;
  160. align-items: center;
  161. justify-content: center;
  162. font-size: 28rpx;
  163. color: #333;
  164. &.active {
  165. background: rgba(25,137,250,0.1);
  166. border: 2rpx solid #1989FA;
  167. color: $themC;
  168. }
  169. .week {
  170. }
  171. .num {
  172. margin-top: 4rpx;
  173. }
  174. }
  175. }
  176. }
  177. }
  178. }
  179. .card {
  180. .timeCon {
  181. padding: 0 24rpx 40rpx 24rpx;
  182. }
  183. .h2 {
  184. line-height: 90rpx;
  185. font-weight: 500;
  186. color: #333;
  187. }
  188. .time_box {
  189. display: flex;
  190. flex-wrap: wrap;
  191. justify-content: space-between;
  192. .time_item {
  193. width: 30%;
  194. height: 120rpx;
  195. background: #F8F8F8;
  196. border-radius: 12rpx;
  197. display: flex;
  198. flex-direction: column;
  199. justify-content: center;
  200. align-items: center;
  201. border-radius: 12rpx;
  202. color: #333;
  203. &.active {
  204. background: rgba(25,137,250,0.1);
  205. border: 2rpx solid #1989FA;
  206. color: $themC;
  207. }
  208. &.disable {
  209. opacity: 0.4;
  210. }
  211. .lab {
  212. font-size: 28rpx;
  213. font-weight: 500;
  214. }
  215. .time {
  216. font-size: 24rpx;
  217. margin-top: 4rpx;
  218. }
  219. }
  220. }
  221. }
  222. .btn {
  223. width: 47%;
  224. height: 72rpx;
  225. background: #1989FA;
  226. border-radius: 8rpx;
  227. font-size: 28rpx;
  228. color: #fff;
  229. text-align: center;
  230. line-height: 72rpx;
  231. margin: 108rpx auto 50rpx auto;
  232. }
  233. </style>