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

262 lines
5.6 KiB

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