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

250 lines
5.7 KiB

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