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

310 lines
7.2 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 year ago
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 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" @click="show=true">{{ currentMonth }}</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="dian"></view>
  19. <view class="week">{{ item.week }}</view>
  20. <view class="num">{{ item.num }}</view>
  21. </view>
  22. </view>
  23. </view>
  24. <view class="icon right" @click="changeDateIndex(1)">
  25. <u-icon name="arrow-right" :size="12" :color="'#fff'"></u-icon>
  26. </view>
  27. </view>
  28. </view>
  29. </view>
  30. <view class="card">
  31. <view class="timeCon">
  32. <view class="h2">上午</view>
  33. <view class="time_box">
  34. <view class="time_item" v-for="(item,index) in timerArr" :key="index" @click="chooseTimerClick(item)" :class="{active: item.id==chooseTimerId, disable: item.status!==1}">
  35. <view class="lab" v-if="item.status==3">已过期</view>
  36. <view class="lab" v-if="item.status==2">已约满</view>
  37. <view class="lab" v-if="item.status==1">可预约</view>
  38. <view class="time">{{ item.timer }}</view>
  39. </view>
  40. </view>
  41. <view class="h2">下午</view>
  42. <view class="time_box">
  43. <view class="time_item" v-for="(item,index) in timerArr2" :key="index" @click="chooseTimerClick(item)" :class="{active: item.id==chooseTimerId,disable: item.status!==1}">
  44. <view class="lab" v-if="item.status==3">已过期</view>
  45. <view class="lab" v-if="item.status==2">已约满</view>
  46. <view class="lab" v-if="item.status==1">可预约</view>
  47. <view class="time">{{ item.timer }}</view>
  48. </view>
  49. </view>
  50. </view>
  51. </view>
  52. <view class="card">
  53. <view class="noDate">
  54. <image src="http://192.168.1.20:81/zhili/image/20230927/ad178ebdf5394518b27b020c03ee48ab.png" mode=""></image>
  55. </view>
  56. </view>
  57. <u-datetime-picker
  58. :show="show"
  59. v-model="chooseMonth"
  60. :minDate="minDate"
  61. :maxDate="maxDate"
  62. mode="year-month"
  63. @confirm="changeMonth"
  64. ></u-datetime-picker>
  65. </view>
  66. </template>
  67. <script>
  68. import { getDates, getMonthsBetweenDates } from '@/config/utils.js'
  69. export default {
  70. data() {
  71. return {
  72. maxDate: 0,
  73. minDate: 0,
  74. monthArr: [],
  75. show: false,
  76. dateArr: [],
  77. currentDay: 0,//当前显示的日期组索引
  78. chooseDay: '',
  79. chooseMonth: '',
  80. timerArr: [
  81. {status: 1, timer: '06:00-07:00', id: 1},
  82. {status: 2, timer: '06:00-07:00', id: 2},
  83. {status: 3, timer: '06:00-07:00', id: 3},
  84. ],
  85. timerArr2: [
  86. {status: 1, timer: '06:00-07:00', id: 4},
  87. {status: 2, timer: '06:00-07:00', id: 5},
  88. {status: 3, timer: '06:00-07:00', id: 6},
  89. ],
  90. chooseTimerId: '',
  91. endDate: null,
  92. startDate: null,
  93. }
  94. },
  95. mounted() {
  96. this.startDate = new Date('2023-08-06');
  97. this.endDate = new Date();
  98. this.minDate = this.startDate*1
  99. this.maxDate = this.endDate*1
  100. this.initDate()
  101. },
  102. computed: {
  103. currentMonth() {
  104. let tiemr = new Date(this.chooseDay) * 1
  105. return this.$u.date(tiemr, 'yyyy.mm')
  106. }
  107. },
  108. methods: {
  109. // 初始化日期
  110. initDate() {
  111. this.dateArr = getDates(this.startDate, this.endDate);
  112. this.chooseDay = this.dateArr[0][0].date
  113. console.log(this.chooseDay)
  114. },
  115. // 点击月份
  116. changeMonth(val) {
  117. let startDate = this.$u.date(val.value, 'yyyy-mm-dd')
  118. for(let i=0; i<this.dateArr.length; i++) {
  119. for(let j=0; j<this.dateArr[i].length; j++) {
  120. let date = this.dateArr[i][j].date
  121. if(startDate==date) {
  122. this.currentDay = i
  123. this.chooseDay = date
  124. }
  125. }
  126. }
  127. this.show = false
  128. },
  129. // 选择时间
  130. chooseTimerClick(item) {
  131. if(item.status!=1) return this.$u.toast('请选择可预约时间')
  132. this.chooseTimerId = item.id
  133. },
  134. // 选择日期
  135. chooseDate(item) {
  136. this.chooseDay = item.date
  137. console.log(this.chooseDay)
  138. },
  139. changeDateIndex(num) {
  140. if(this.currentDay==0&&num==-1) return this.$u.toast('已是可选最小日期')
  141. if(this.currentDay==this.dateArr.length-1&&num==1) return this.$u.toast('已是可选最大日期')
  142. this.currentDay = this.currentDay + num
  143. this.chooseDay = this.dateArr[this.currentDay][0].date
  144. },
  145. }
  146. }
  147. </script>
  148. <style lang="scss" scoped>
  149. .card {
  150. width: 100%;
  151. margin-bottom: 24rpx;
  152. overflow: hidden;
  153. .dateBox {
  154. padding: 36rpx 0 40rpx 0;
  155. .month-row {
  156. display: flex;
  157. justify-content: center;
  158. align-items: center;
  159. margin-bottom: 36rpx;
  160. .month {
  161. font-size: 32rpx;
  162. color: $themC;
  163. }
  164. .arrow {
  165. margin-left: 6rpx;
  166. }
  167. }
  168. .date_row {
  169. width: 100%;
  170. height: 100rpx;
  171. position: relative;
  172. .icon {
  173. width: 40rpx;
  174. height: 40rpx;
  175. background: rgba(51,51,51,0.18);
  176. backdrop-filter: blur(4rpx);
  177. position: absolute;
  178. top: 50%;
  179. transform: translateY(-50%);
  180. display: flex;
  181. align-items: center;
  182. justify-content: center;
  183. border-radius: 50%;
  184. &.left {
  185. left: 16rpx;
  186. }
  187. &.right {
  188. right: 16rpx;
  189. }
  190. }
  191. .dateArr {
  192. display: flex;
  193. padding: 0 70rpx;
  194. // justify-content: space-between;
  195. &.oneDate {
  196. justify-content: center;
  197. }
  198. .dateWidth {
  199. width: 20%;
  200. display: flex;
  201. justify-content: center;
  202. }
  203. .date {
  204. width: 74rpx;
  205. height: 100rpx;
  206. border-radius: 16rpx;
  207. display: flex;
  208. flex-direction: column;
  209. align-items: center;
  210. justify-content: center;
  211. font-size: 28rpx;
  212. color: #333;
  213. .dian {
  214. width: 12rpx;
  215. height: 12rpx;
  216. background: #D8D8D8;
  217. border-radius: 50%;
  218. &.active {
  219. background: #1989FA;
  220. }
  221. }
  222. &.active {
  223. background: rgba(25,137,250,0.1);
  224. border: 2rpx solid #1989FA;
  225. color: $themC;
  226. }
  227. .week {
  228. }
  229. .num {
  230. margin-top: 4rpx;
  231. }
  232. }
  233. }
  234. }
  235. }
  236. }
  237. .card {
  238. .timeCon {
  239. padding: 0 24rpx 40rpx 24rpx;
  240. }
  241. .h2 {
  242. line-height: 90rpx;
  243. font-weight: 500;
  244. color: #333;
  245. }
  246. .time_box {
  247. display: flex;
  248. flex-wrap: wrap;
  249. justify-content: space-between;
  250. .time_item {
  251. width: 30%;
  252. height: 120rpx;
  253. background: #F8F8F8;
  254. border-radius: 12rpx;
  255. display: flex;
  256. flex-direction: column;
  257. justify-content: center;
  258. align-items: center;
  259. border-radius: 12rpx;
  260. color: #333;
  261. &.active {
  262. background: rgba(25,137,250,0.1);
  263. border: 2rpx solid #1989FA;
  264. color: $themC;
  265. }
  266. &.disable {
  267. opacity: 0.4;
  268. }
  269. .lab {
  270. font-size: 28rpx;
  271. font-weight: 500;
  272. }
  273. .time {
  274. font-size: 24rpx;
  275. margin-top: 4rpx;
  276. }
  277. }
  278. }
  279. }
  280. .btn {
  281. width: 47%;
  282. height: 72rpx;
  283. background: #1989FA;
  284. border-radius: 8rpx;
  285. font-size: 28rpx;
  286. color: #fff;
  287. text-align: center;
  288. line-height: 72rpx;
  289. margin: 108rpx auto 50rpx auto;
  290. }
  291. .noDate {
  292. }
  293. </style>