江西小程序管理端
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.

333 lines
8.0 KiB

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. import { scheduleClassGetById, scheduleClassGet, getClassDateLimit } from '@/config/api.js'
  70. export default {
  71. data() {
  72. return {
  73. maxDate: 0,
  74. minDate: 0,
  75. monthArr: [],
  76. show: false,
  77. dateArr: [],
  78. currentDay: 0,//当前显示的日期组索引
  79. chooseDay: '',
  80. chooseMonth: '',
  81. timerArr: [
  82. {status: 1, timer: '06:00-07:00', id: 1},
  83. {status: 2, timer: '06:00-07:00', id: 2},
  84. {status: 3, timer: '06:00-07:00', id: 3},
  85. ],
  86. timerArr2: [
  87. {status: 1, timer: '06:00-07:00', id: 4},
  88. {status: 2, timer: '06:00-07:00', id: 5},
  89. {status: 3, timer: '06:00-07:00', id: 6},
  90. ],
  91. chooseTimerId: '',
  92. endDate: null,
  93. startDate: null,
  94. }
  95. },
  96. mounted() {
  97. this.initDate()
  98. },
  99. computed: {
  100. currentMonth() {
  101. let tiemr = new Date(this.chooseDay) * 1
  102. return this.$u.date(tiemr, 'yyyy.mm')
  103. }
  104. },
  105. methods: {
  106. // 获取排课日期范围
  107. async getClassDateLimitFn() {
  108. let obj = {
  109. coachId: this.vuex_coachId
  110. }
  111. const {data: res} = await getClassDateLimit(obj)
  112. this.startDate = res.beginDateLimit
  113. this.endDate = res.endDateLimit
  114. this.minDate = new Date(res.beginDateLimit)*1 + 86400000
  115. this.maxDate = new Date(res.endDateLimit)*1
  116. },
  117. // 获得排课
  118. async scheduleClassGetFn() {
  119. let id = this.vuex_userInfo.user.id
  120. let coachId = this.vuex_userInfo.user.coachId || '1591015108974329858'
  121. let classDate = '2023-10-1'
  122. const {data: res} = await scheduleClassGet({id, coachId, classDate: this.chooseDay})
  123. },
  124. // 初始化日期
  125. async initDate() {
  126. await this.getClassDateLimitFn()
  127. this.dateArr = getDates(this.startDate, this.endDate);
  128. console.log('this.dateArr')
  129. console.log(this.startDate)
  130. console.log(this.endDate)
  131. // this.chooseDay = this.dateArr[0][0].date
  132. // console.log(this.chooseDay)
  133. },
  134. // 点击月份
  135. changeMonth(val) {
  136. let startDate = this.$u.date(val.value, 'yyyy-mm-dd')
  137. for(let i=0; i<this.dateArr.length; i++) {
  138. for(let j=0; j<this.dateArr[i].length; j++) {
  139. let date = this.dateArr[i][j].date
  140. if(startDate==date) {
  141. this.currentDay = i
  142. this.chooseDay = date
  143. }
  144. }
  145. }
  146. this.show = false
  147. },
  148. // 选择时间
  149. chooseTimerClick(item) {
  150. if(item.status!=1) return this.$u.toast('请选择可预约时间')
  151. this.chooseTimerId = item.id
  152. },
  153. // 选择日期
  154. chooseDate(item) {
  155. this.chooseDay = item.date
  156. this.scheduleClassGetFn()
  157. console.log('*****')
  158. console.log(this.chooseDay)
  159. },
  160. changeDateIndex(num) {
  161. if(this.currentDay==0&&num==-1) return this.$u.toast('已是可选最小日期')
  162. if(this.currentDay==this.dateArr.length-1&&num==1) return this.$u.toast('已是可选最大日期')
  163. this.currentDay = this.currentDay + num
  164. this.chooseDay = this.dateArr[this.currentDay][0].date
  165. },
  166. }
  167. }
  168. </script>
  169. <style lang="scss" scoped>
  170. .card {
  171. width: 100%;
  172. margin-bottom: 24rpx;
  173. overflow: hidden;
  174. .dateBox {
  175. padding: 36rpx 0 40rpx 0;
  176. .month-row {
  177. display: flex;
  178. justify-content: center;
  179. align-items: center;
  180. margin-bottom: 36rpx;
  181. .month {
  182. font-size: 32rpx;
  183. color: $themC;
  184. }
  185. .arrow {
  186. margin-left: 6rpx;
  187. }
  188. }
  189. .date_row {
  190. width: 100%;
  191. height: 100rpx;
  192. position: relative;
  193. .icon {
  194. width: 40rpx;
  195. height: 40rpx;
  196. background: rgba(51,51,51,0.18);
  197. backdrop-filter: blur(4rpx);
  198. position: absolute;
  199. top: 50%;
  200. transform: translateY(-50%);
  201. display: flex;
  202. align-items: center;
  203. justify-content: center;
  204. border-radius: 50%;
  205. &.left {
  206. left: 16rpx;
  207. }
  208. &.right {
  209. right: 16rpx;
  210. }
  211. }
  212. .dateArr {
  213. display: flex;
  214. padding: 0 70rpx;
  215. // justify-content: space-between;
  216. &.oneDate {
  217. justify-content: center;
  218. }
  219. .dateWidth {
  220. width: 20%;
  221. display: flex;
  222. justify-content: center;
  223. }
  224. .date {
  225. width: 74rpx;
  226. height: 100rpx;
  227. border-radius: 16rpx;
  228. display: flex;
  229. flex-direction: column;
  230. align-items: center;
  231. justify-content: center;
  232. font-size: 28rpx;
  233. color: #333;
  234. .dian {
  235. width: 12rpx;
  236. height: 12rpx;
  237. background: #D8D8D8;
  238. border-radius: 50%;
  239. &.active {
  240. background: #1989FA;
  241. }
  242. }
  243. &.active {
  244. background: rgba(25,137,250,0.1);
  245. border: 2rpx solid #1989FA;
  246. color: $themC;
  247. }
  248. .week {
  249. }
  250. .num {
  251. margin-top: 4rpx;
  252. }
  253. }
  254. }
  255. }
  256. }
  257. }
  258. .card {
  259. .timeCon {
  260. padding: 0 24rpx 40rpx 24rpx;
  261. }
  262. .h2 {
  263. line-height: 90rpx;
  264. font-weight: 500;
  265. color: #333;
  266. }
  267. .time_box {
  268. display: flex;
  269. flex-wrap: wrap;
  270. justify-content: space-between;
  271. .time_item {
  272. width: 30%;
  273. height: 120rpx;
  274. background: #F8F8F8;
  275. border-radius: 12rpx;
  276. display: flex;
  277. flex-direction: column;
  278. justify-content: center;
  279. align-items: center;
  280. border-radius: 12rpx;
  281. color: #333;
  282. &.active {
  283. background: rgba(25,137,250,0.1);
  284. border: 2rpx solid #1989FA;
  285. color: $themC;
  286. }
  287. &.disable {
  288. opacity: 0.4;
  289. }
  290. .lab {
  291. font-size: 28rpx;
  292. font-weight: 500;
  293. }
  294. .time {
  295. font-size: 24rpx;
  296. margin-top: 4rpx;
  297. }
  298. }
  299. }
  300. }
  301. .btn {
  302. width: 47%;
  303. height: 72rpx;
  304. background: #1989FA;
  305. border-radius: 8rpx;
  306. font-size: 28rpx;
  307. color: #fff;
  308. text-align: center;
  309. line-height: 72rpx;
  310. margin: 108rpx auto 50rpx auto;
  311. }
  312. .noDate {
  313. }
  314. </style>