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

381 lines
9.4 KiB

11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months 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. this.FormData.courseIds = this.courseIds = item.id
  190. this.FormData.classDate = item.classDate
  191. this.FormData.classTime = item.classTime
  192. console.log(item)
  193. },
  194. }
  195. }
  196. </script>
  197. <style lang="scss" scoped>
  198. .card {
  199. width: 100%;
  200. margin-bottom: 24rpx;
  201. overflow: hidden;
  202. .dateBox {
  203. padding: 36rpx 0 40rpx 0;
  204. .month-row {
  205. display: flex;
  206. justify-content: center;
  207. align-items: center;
  208. margin-bottom: 36rpx;
  209. .month {
  210. font-size: 32rpx;
  211. color: $themC;
  212. }
  213. .arrow {
  214. margin-left: 6rpx;
  215. }
  216. }
  217. .date_row {
  218. width: 100%;
  219. height: 100rpx;
  220. position: relative;
  221. .icon {
  222. width: 40rpx;
  223. height: 40rpx;
  224. background: rgba(51,51,51,0.18);
  225. backdrop-filter: blur(4rpx);
  226. position: absolute;
  227. top: 50%;
  228. transform: translateY(-50%);
  229. display: flex;
  230. align-items: center;
  231. justify-content: center;
  232. border-radius: 50%;
  233. &.left {
  234. left: 16rpx;
  235. }
  236. &.right {
  237. right: 16rpx;
  238. }
  239. }
  240. .dateArr {
  241. display: flex;
  242. padding: 0 70rpx;
  243. // justify-content: space-between;
  244. &.oneDate {
  245. justify-content: center;
  246. }
  247. .dateWidth {
  248. width: 20%;
  249. display: flex;
  250. justify-content: center;
  251. }
  252. .date {
  253. width: 74rpx;
  254. height: 100rpx;
  255. border-radius: 16rpx;
  256. display: flex;
  257. flex-direction: column;
  258. align-items: center;
  259. justify-content: center;
  260. font-size: 28rpx;
  261. color: #333;
  262. .dian {
  263. width: 12rpx;
  264. height: 12rpx;
  265. background: #D8D8D8;
  266. border-radius: 50%;
  267. &.active {
  268. background: #1989FA;
  269. }
  270. }
  271. &.active {
  272. background: rgba(25,137,250,0.1);
  273. border: 2rpx solid #1989FA;
  274. color: $themC;
  275. }
  276. .week {
  277. }
  278. .num {
  279. margin-top: 4rpx;
  280. }
  281. }
  282. }
  283. }
  284. }
  285. }
  286. .card {
  287. .timeCon {
  288. padding: 0 24rpx 40rpx 24rpx;
  289. }
  290. .h2 {
  291. line-height: 90rpx;
  292. font-weight: 500;
  293. color: #333;
  294. }
  295. .time_box {
  296. display: flex;
  297. flex-wrap: wrap;
  298. justify-content: space-between;
  299. &::after{
  300. display:block;
  301. content:"";
  302. width: 32%;
  303. height:0px;
  304. }
  305. .time_item {
  306. width: 30%;
  307. height: 120rpx;
  308. background: #F8F8F8;
  309. border-radius: 12rpx;
  310. display: flex;
  311. flex-direction: column;
  312. justify-content: center;
  313. align-items: center;
  314. border-radius: 12rpx;
  315. margin-bottom: 20rpx;
  316. color: #333;
  317. &.active {
  318. background: rgba(25,137,250,0.1);
  319. border: 2rpx solid #1989FA;
  320. color: $themC;
  321. }
  322. &.disable {
  323. opacity: 0.4;
  324. }
  325. .lab {
  326. font-size: 28rpx;
  327. font-weight: 500;
  328. }
  329. .time {
  330. font-size: 24rpx;
  331. margin-top: 4rpx;
  332. }
  333. }
  334. }
  335. }
  336. .btn {
  337. width: 47%;
  338. height: 72rpx;
  339. background: #1989FA;
  340. border-radius: 8rpx;
  341. font-size: 28rpx;
  342. color: #fff;
  343. text-align: center;
  344. line-height: 72rpx;
  345. margin: 108rpx auto 50rpx auto;
  346. }
  347. .iconArrowBg {
  348. background: #D8D8D8;
  349. width: 26rpx;
  350. height: 26rpx;
  351. border-radius: 50%;
  352. display: flex;
  353. justify-content: center;
  354. align-items: center;
  355. margin-left: 4px;
  356. }
  357. .step2 {
  358. display: flex;
  359. justify-content: space-between;
  360. align-items: center;
  361. padding-bottom: 40px;
  362. .btnBg {
  363. width: 310rpx;
  364. }
  365. }
  366. </style>