usercourse.vue 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375
  1. <template>
  2. <view >
  3. <view class="course_status_list">
  4. <view class="course_status_item" :class="requestParam.status==0?'active':''" @click="setStatus(0)"> 全部 </view>
  5. <view class="course_status_item" :class="requestParam.status==1?'active':''" @click="setStatus(1)"> 待上课 </view>
  6. <view class="course_status_item" :class="requestParam.status==2?'active':''" @click="setStatus(2)"> 已取消 </view>
  7. </view>
  8. <view class="course_list">
  9. <view class="course_item" v-for="(item,index) in productList" :key="index">
  10. <view class="course_title">
  11. <view class="course_prc">
  12. <image :src="item.teacher_pic" mode=""></image>
  13. </view>
  14. <view class="title">
  15. <view class="title_text">
  16. <view class="tea_name">
  17. {{item.teacher_name}}
  18. <!-- 王老师 -->
  19. </view>
  20. <view class="btn_1" @click="cancelPopup(index)" v-if="item.status===1" >
  21. 取消预约
  22. </view>
  23. <view class="btn_2" v-if="item.status===2">
  24. 已取消
  25. </view>
  26. <view class="btn_3" v-if="item.status===3">
  27. 已完成
  28. </view>
  29. </view>
  30. <view class="subtilte">
  31. {{item.course_name}}
  32. </view>
  33. <view class="course_arrt">
  34. <view class="text">
  35. 上课地址:
  36. </view>
  37. <view class="attr">
  38. {{item.course_address}}
  39. <!-- 深圳市龙华区民治街道和平路3号 -->
  40. </view>
  41. </view>
  42. </view>
  43. </view>
  44. <view class="classTime">
  45. <view class="text">
  46. 上课时间
  47. </view>
  48. <view class="time">
  49. {{timeStamp(item.start_time *1000).date+' '+timeStamp(item.start_time *1000).hour}}
  50. <!-- 2024--10-24周三上午10:30 -->
  51. </view>
  52. </view>
  53. </view>
  54. </view>
  55. <uni-popup ref="cancelPopup">
  56. <view class="cancel_layout">
  57. <view class="cancel_title">
  58. 取消预约
  59. </view>
  60. <view class="cancel_text">
  61. 是否确认取消课程?取消后可重新更新预约
  62. </view>
  63. <view class="cancel_btn">
  64. <view class="btn_1" @click="closeCancel()">
  65. 在想想
  66. </view>
  67. <view class="btn_2" @click="cancelCourse()">
  68. 确认
  69. </view>
  70. </view>
  71. </view>
  72. </uni-popup>
  73. <view class="to_bottom" > -----到底啦-----</view>
  74. </view>
  75. </template>
  76. <script>
  77. export default {
  78. data(){
  79. return{
  80. //产品列表
  81. productList:[],
  82. // 请求参数
  83. requestParam:{
  84. page:1,
  85. status:0,
  86. },
  87. // 是否最后一页
  88. isLast:false,
  89. // 是否请求中
  90. isReqing:false,
  91. //当前取消的index
  92. curIndex:0,
  93. };
  94. },
  95. onLoad() {
  96. },
  97. onShow() {
  98. // 没有数据的话,或者请求中,不允许刷新
  99. if( this.isReqing ) return ;
  100. // 请求参数
  101. this.requestParam.name = "";
  102. // 请求参数
  103. this.requestParam.page = 1;
  104. // 是否是最后一页
  105. this.isLast = false;
  106. // 设置请求中
  107. this.isReqing = true;
  108. this.$http.request('api/course/reservation_list',this.requestParam.page).then((re)=>{
  109. // 设置非请求中
  110. this.isReqing = false;
  111. // 成功结果
  112. if( re.code == 'success' ){
  113. if(re.data.last_page <= this.requestParam.page ) this.isLast = true;
  114. this.productList = re.data.data;
  115. }
  116. });
  117. },
  118. methods:{
  119. setStatus(status){
  120. // 登录提示
  121. if( !this.$checkAccess.alterLogin() ) return ;
  122. // 请求中,不再请求
  123. if( this.isReqing ) return;
  124. // 初始化页码为1
  125. this.requestParam.page = 1;
  126. // 是否是最后一页
  127. this.isLast = false;
  128. // 状态变更
  129. this.requestParam.status = status;
  130. // 设置请求中
  131. this.isReqing = true;
  132. // 请求列表
  133. this.$http.request('api/course/reservation_list',this.requestParam).then((re)=>{
  134. // 设置非请求中
  135. this.isReqing = false;
  136. // 成功结果
  137. if( re.code == 'success' ){
  138. if(re.data.last_page >= this.requestParam.page ) this.isLast = true;
  139. this.productList = re.data.data;
  140. }
  141. });
  142. },
  143. //弹出层
  144. cancelPopup(index){
  145. this.curIndex = index;
  146. this.$refs.cancelPopup.open("center");
  147. },
  148. //关闭弹出层
  149. closeCancel(){
  150. this.$refs.cancelPopup.close();
  151. },
  152. //取消预约事件
  153. cancelCourse(){
  154. let {id , schedule_id, orders_product_id} = this.productList[this.curIndex]
  155. console.log(id , schedule_id, orders_product_id);
  156. this.$http.request("api/course/cancel_reservation/",{id:id,schedule_id:schedule_id,orders_product_id:orders_product_id},'post').then((res)=>{
  157. if(res.code == 'success'){
  158. this.$http.request('api/course/reservation_list',this.requestParam).then((re)=>{
  159. // 设置非请求中
  160. this.isReqing = false;
  161. // 成功结果
  162. if( re.code == 'success' ){
  163. if(re.data.last_page >= this.requestParam.page ) this.isLast = true;
  164. this.productList = re.data.data;
  165. }
  166. });
  167. }else{
  168. uni.showToast({
  169. title:`${res.msg}`,
  170. icon:"error"
  171. })
  172. }
  173. })
  174. this.$refs.cancelPopup.close();
  175. },
  176. strFormat(str) {
  177. return str < 10 ? `0${str}` : str
  178. },
  179. //时间戳转日期
  180. timeStamp(time) {
  181. const dates = new Date(time)
  182. const year = dates.getFullYear()
  183. const month = dates.getMonth() + 1
  184. const date = dates.getDate()
  185. const day = dates.getDay()
  186. const hour = dates.getHours()
  187. const min = dates.getMinutes()
  188. const days = [ '日', '一', '二', '三', '四', '五', '六']
  189. return {
  190. allDate: `${year}/${this.strFormat(month)}/${this.strFormat(date)}`,
  191. date: `${this.strFormat(year)}-${this.strFormat(month)}-${this.strFormat(date)}`, //返回的日期 07-01
  192. day: `周${days[day]}`, //返回的礼拜天数 星期一
  193. hour: this.strFormat(hour) + ':' + this.strFormat(min) //返回的时钟 08:00
  194. }
  195. },
  196. },
  197. }
  198. </script>
  199. <style lang="less">
  200. .course_status_list{
  201. display: block;
  202. height: 60rpx;
  203. color: #666666;
  204. line-height: 60rpx;
  205. background: #FFFFFF;
  206. padding: 10rpx 35rpx;
  207. .course_status_item{
  208. float: left;
  209. font-size: 28rpx;
  210. padding: 0rpx 20rpx;
  211. }
  212. .course_status_item.active{
  213. color: #000000;
  214. font-weight: bold;
  215. }
  216. }
  217. .course_list{
  218. .course_item{
  219. background-color: #FFFFFF;
  220. margin: 20rpx 0rpx;
  221. padding-top: 1rpx;
  222. .course_title{
  223. width: 690rpx;
  224. margin: 20rpx auto 0rpx;
  225. display: flex;
  226. .course_prc{
  227. width: 164rpx;
  228. image{
  229. width: 164rpx;
  230. height: 164rpx;
  231. border-radius: 20rpx;
  232. border: 2rpx solid;
  233. }
  234. }
  235. .title{
  236. flex: 1;
  237. margin-left: 30rpx;
  238. .title_text{
  239. display: flex;
  240. justify-content: space-between;
  241. .tea_name{
  242. font-size: 30rpx;
  243. font-weight: 300;
  244. }
  245. .btn_1{
  246. display: inline-flex;
  247. justify-content: center;
  248. align-items: center;
  249. width: 200rpx;
  250. padding: 10rpx;
  251. color: #00bba5;
  252. border: 2rpx solid #00bba5;
  253. border-radius: 40rpx;
  254. }
  255. .btn_2{
  256. display: inline-flex;
  257. justify-content: center;
  258. align-items: center;
  259. width: 200rpx;
  260. padding: 10rpx;
  261. color: #FFFFFF;
  262. background-color: #d3d3d3;
  263. border-radius: 40rpx;
  264. }
  265. }
  266. .subtilte{
  267. padding: 5rpx 5rpx 5rpx 0rpx;
  268. font-size: 26rpx;
  269. }
  270. .course_arrt{
  271. display: flex;
  272. font-size: 24rpx;
  273. padding: 10rpx 10rpx 10rpx 0rpx;
  274. .text{
  275. display: inline-flex;
  276. justify-content: center;
  277. align-items: center;
  278. width: 120rpx;
  279. // border: 2rpx solid;
  280. }
  281. .attr{
  282. // border: 2rpx solid;
  283. flex: 1;
  284. flex-wrap: wrap;
  285. }
  286. }
  287. }
  288. }
  289. .classTime{
  290. width: 690rpx;
  291. // border: 2rpx solid;
  292. display: flex;
  293. margin: 0rpx auto;
  294. margin-top: 10rpx;
  295. padding: 10rpx;
  296. .text{
  297. font-size: 26rpx;
  298. display: inline-flex;
  299. justify-content: center;
  300. width: 164rpx;
  301. }
  302. .time{
  303. font-size: 26rpx;
  304. font-weight: bold;
  305. margin-left: 30rpx;
  306. }
  307. }
  308. }
  309. }
  310. .cancel_layout{
  311. background-color: #FFFFFF;
  312. width: 690rpx;
  313. height: 30vh;
  314. border-radius: 40rpx;
  315. display: flex;
  316. flex-direction: column;
  317. overflow: hidden;
  318. .cancel_title{
  319. display: inline-flex;
  320. justify-content: center;
  321. align-items: center;
  322. padding: 10rpx;
  323. margin: 20rpx;
  324. font-size: 40rpx;
  325. font-weight: bold;
  326. color: #000000;
  327. }
  328. .cancel_text{
  329. display: inline-flex;
  330. justify-content: center;
  331. align-items: center;
  332. margin: 30rpx auto;
  333. width: 576rpx;
  334. height: 50rpx;
  335. padding:30rpx;
  336. }
  337. .cancel_btn{
  338. border-top: 2rpx solid #d3d3d3;
  339. display: flex;
  340. justify-content: space-between;
  341. padding-top: 20rpx;
  342. height: 130rpx;
  343. .btn_1{
  344. display: inline-flex;
  345. justify-content: center;
  346. align-items: center;
  347. height: 100rpx;
  348. flex: 1;
  349. font-size: 30rpx;
  350. color: #51bf81;
  351. }
  352. .btn_2{
  353. display: inline-flex;
  354. justify-content: center;
  355. align-items: center;
  356. flex: 1;
  357. height: 100rpx;
  358. font-size: 30rpx;
  359. }
  360. }
  361. }
  362. </style>