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

382 lines
9.4 KiB

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" v-if="timerArr.length">上午</view>
  33. <view class="time_box">
  34. <view class="time_item" v-for="(item,index) in timerArr" :key="index" @click="chooseCourse(item)" :class="{active: courseIds==item.id, disable: item.status!=0}" >
  35. <view class="flex" v-if="item.status==0">
  36. <view class="lab">{{ item.alreadyAppointmentCount ||0 }} <text>/</text> {{ item.appointmentSum}}</view>
  37. <view class="iconArrowBg" v-if="item.alreadyAppointmentCount">
  38. <u-icon name="arrow-right" :size="10" :color="'#fff'"></u-icon>
  39. </view>
  40. </view>
  41. <view class="lab" v-else>{{ statusTxt[item.status] }}</view>
  42. <view class="time">{{ item.classTime }}</view>
  43. </view>
  44. </view>
  45. <view class="h2" v-if="timerArr2.length">下午</view>
  46. <view class="time_box">
  47. <view class="time_item" v-for="(item,index) in timerArr2" :key="index" @click="chooseCourse(item)" :class="{active: courseIds==item.id, disable: item.status!=0}">
  48. <view class="flex" v-if="item.status==0">
  49. <view class="lab">{{ item.alreadyAppointmentCount ||0 }} <text>/</text> {{ item.appointmentSum}} </view>
  50. <view class="iconArrowBg" v-if="item.alreadyAppointmentCount">
  51. <u-icon name="arrow-right" :size="10" :color="'#fff'"></u-icon>
  52. </view>
  53. </view>
  54. <view class="lab" v-else>{{ statusTxt[item.status] }}</view>
  55. <view class="time">{{ item.classTime }}</view>
  56. </view>
  57. </view>
  58. </view>
  59. <view class="card" v-if="!timerArr2.length&&!timerArr.length">
  60. <nodata>暂无预约排课</nodata>
  61. </view>
  62. </view>
  63. <u-datetime-picker
  64. :show="show"
  65. v-model="chooseMonth"
  66. :minDate="minDate"
  67. :maxDate="maxDate"
  68. mode="year-month"
  69. @confirm="changeMonth"
  70. @cancel="show=false"
  71. ></u-datetime-picker>
  72. </view>
  73. </template>
  74. <script>
  75. import { getDates, getMonthsBetweenDates } from '@/config/utils.js'
  76. import { simulationClass } from '@/config/api.js'
  77. export default {
  78. props: ['step', 'FormData'],
  79. data() {
  80. return {
  81. maxDate: 0,
  82. minDate: 0,
  83. monthArr: [],
  84. show: false,
  85. dateArr: [],
  86. currentDay: 0,//当前显示的日期组索引
  87. chooseDay: '',
  88. chooseMonth: '',
  89. timerArr: [],
  90. statusTxt: ['可预约', '已过期', '已约满', ], //状态0、正常 2、已过期 3、已约满
  91. timerArr2: [],
  92. chooseTimerId: '',
  93. endDate: null,
  94. startDate: null,
  95. courseIds: '',
  96. radioVal: '',
  97. }
  98. },
  99. mounted() {
  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. watch: {
  109. courseIds: {
  110. handler(val) {
  111. let allTimer = [...this.timerArr,...this.timerArr2]
  112. let total = allTimer.reduce((pre, item)=>{
  113. if(item.status==1) {
  114. pre.push(item.classTime)
  115. }
  116. return pre
  117. },[])
  118. if(total.length==this.courseIds.length) {
  119. this.radioVal = 0
  120. }
  121. }
  122. }
  123. },
  124. methods: {
  125. // 获得排课
  126. async simulationClassFn() {
  127. // let id = this.vuex_userInfo.id
  128. let obj = { "pointId": this.FormData.pointId, "trainType": this.FormData.trainType, "classDate":this.chooseDay, "studentId": this.FormData.studentId}
  129. const {data: res} = await simulationClass(obj)
  130. this.timerArr2 = res.afternoonSimulationClass
  131. this.timerArr = res.morningSimulationClass
  132. console.log('this.timerArr')
  133. console.log(this.timerArr)
  134. // 如果是今天的日期检查有没有过期
  135. if(this.chooseDay==this.dateArr[0][0].date) {
  136. let arr = [...this.timerArr,...this.timerArr2]
  137. arr.forEach(item=>{
  138. let timer = new Date() * 1
  139. let date = this.chooseDay+' '+(item.classTime.split('-')[0])
  140. date = date.replace(/-/g,'/');
  141. let timer2 = new Date(date).getTime();
  142. // console.log(timer)
  143. // console.log(timer2)
  144. // console.log(date)
  145. if(timer>timer2) {
  146. item.status = 2
  147. }
  148. })
  149. }
  150. },
  151. // 初始化日期
  152. async initDate() {
  153. this.startDate = this.$u.timeFormat(new Date()*1, 'yyyy-mm-dd');
  154. this.maxDate = this.endDate = new Date('2023-11-30')*1
  155. this.minDate = new Date()*1
  156. this.dateArr = getDates(this.startDate, this.endDate);
  157. this.chooseDay = this.dateArr[0][0].date
  158. console.log(this.dateArr)
  159. this.simulationClassFn()
  160. },
  161. // 点击月份
  162. changeMonth(val) {
  163. let startDate = this.$u.date(val.value, 'yyyy-mm-dd')
  164. for(let i=0; i<this.dateArr.length; i++) {
  165. for(let j=0; j<this.dateArr[i].length; j++) {
  166. let date = this.dateArr[i][j].date
  167. if(startDate==date) {
  168. this.currentDay = i
  169. this.chooseDay = date
  170. }
  171. }
  172. }
  173. this.show = false
  174. },
  175. // 选择日期
  176. chooseDate(item) {
  177. this.chooseDay = item.date
  178. this.simulationClassFn()
  179. console.log('*****')
  180. console.log(item)
  181. },
  182. changeDateIndex(num) {
  183. if(this.currentDay==0&&num==-1) return this.$u.toast('已是可选最小日期')
  184. if(this.currentDay==this.dateArr.length-1&&num==1) return this.$u.toast('已是可选最大日期')
  185. this.currentDay = this.currentDay + num
  186. this.chooseDay = this.dateArr[this.currentDay][0].date
  187. },
  188. chooseCourse(item) {
  189. if(item.status!=0) return
  190. this.FormData.courseIds = this.courseIds = item.id
  191. this.FormData.classDate = item.classDate
  192. this.FormData.classTime = item.classTime
  193. console.log(item)
  194. },
  195. }
  196. }
  197. </script>
  198. <style lang="scss" scoped>
  199. .card {
  200. width: 100%;
  201. margin-bottom: 24rpx;
  202. overflow: hidden;
  203. .dateBox {
  204. padding: 36rpx 0 40rpx 0;
  205. .month-row {
  206. display: flex;
  207. justify-content: center;
  208. align-items: center;
  209. margin-bottom: 36rpx;
  210. .month {
  211. font-size: 32rpx;
  212. color: $themC;
  213. }
  214. .arrow {
  215. margin-left: 6rpx;
  216. }
  217. }
  218. .date_row {
  219. width: 100%;
  220. height: 100rpx;
  221. position: relative;
  222. .icon {
  223. width: 40rpx;
  224. height: 40rpx;
  225. background: rgba(51,51,51,0.18);
  226. backdrop-filter: blur(4rpx);
  227. position: absolute;
  228. top: 50%;
  229. transform: translateY(-50%);
  230. display: flex;
  231. align-items: center;
  232. justify-content: center;
  233. border-radius: 50%;
  234. &.left {
  235. left: 16rpx;
  236. }
  237. &.right {
  238. right: 16rpx;
  239. }
  240. }
  241. .dateArr {
  242. display: flex;
  243. padding: 0 70rpx;
  244. // justify-content: space-between;
  245. &.oneDate {
  246. justify-content: center;
  247. }
  248. .dateWidth {
  249. width: 20%;
  250. display: flex;
  251. justify-content: center;
  252. }
  253. .date {
  254. width: 74rpx;
  255. height: 100rpx;
  256. border-radius: 16rpx;
  257. display: flex;
  258. flex-direction: column;
  259. align-items: center;
  260. justify-content: center;
  261. font-size: 28rpx;
  262. color: #333;
  263. .dian {
  264. width: 12rpx;
  265. height: 12rpx;
  266. background: #D8D8D8;
  267. border-radius: 50%;
  268. &.active {
  269. background: #1989FA;
  270. }
  271. }
  272. &.active {
  273. background: rgba(25,137,250,0.1);
  274. border: 2rpx solid #1989FA;
  275. color: $themC;
  276. }
  277. .week {
  278. }
  279. .num {
  280. margin-top: 4rpx;
  281. }
  282. }
  283. }
  284. }
  285. }
  286. }
  287. .card {
  288. .timeCon {
  289. padding: 0 24rpx 40rpx 24rpx;
  290. }
  291. .h2 {
  292. line-height: 90rpx;
  293. font-weight: 500;
  294. color: #333;
  295. }
  296. .time_box {
  297. display: flex;
  298. flex-wrap: wrap;
  299. justify-content: space-between;
  300. &::after{
  301. display:block;
  302. content:"";
  303. width: 32%;
  304. height:0px;
  305. }
  306. .time_item {
  307. width: 30%;
  308. height: 120rpx;
  309. background: #F8F8F8;
  310. border-radius: 12rpx;
  311. display: flex;
  312. flex-direction: column;
  313. justify-content: center;
  314. align-items: center;
  315. border-radius: 12rpx;
  316. margin-bottom: 20rpx;
  317. color: #333;
  318. &.active {
  319. background: rgba(25,137,250,0.1);
  320. border: 2rpx solid #1989FA;
  321. color: $themC;
  322. }
  323. &.disable {
  324. opacity: 0.4;
  325. }
  326. .lab {
  327. font-size: 28rpx;
  328. font-weight: 500;
  329. }
  330. .time {
  331. font-size: 24rpx;
  332. margin-top: 4rpx;
  333. }
  334. }
  335. }
  336. }
  337. .btn {
  338. width: 47%;
  339. height: 72rpx;
  340. background: #1989FA;
  341. border-radius: 8rpx;
  342. font-size: 28rpx;
  343. color: #fff;
  344. text-align: center;
  345. line-height: 72rpx;
  346. margin: 108rpx auto 50rpx auto;
  347. }
  348. .iconArrowBg {
  349. background: #D8D8D8;
  350. width: 26rpx;
  351. height: 26rpx;
  352. border-radius: 50%;
  353. display: flex;
  354. justify-content: center;
  355. align-items: center;
  356. margin-left: 4px;
  357. }
  358. .step2 {
  359. display: flex;
  360. justify-content: space-between;
  361. align-items: center;
  362. padding-bottom: 40px;
  363. .btnBg {
  364. width: 310rpx;
  365. }
  366. }
  367. </style>