stu-course.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330
  1. <template>
  2. <view class="content">
  3. <u-tabs-swiper ref="uTabs" :list="list" :is-scroll="false" active-color="#FF4600" :current="current" @change="tabsChange"
  4. :bold="false" swiperWidth="750"></u-tabs-swiper>
  5. <view class="empty" v-if="(perCourse.length==0 && current==0) || (!perCourse.length&& current==0)">
  6. <u-empty text="暂无私教课程" mode="favor" ></u-empty>
  7. </view>
  8. <view class="empty"v-if="course.length==0 && current==1 ">
  9. <u-empty text="暂无课程" mode="favor" ></u-empty>
  10. </view>
  11. <view class="per_course" v-for="(item,index) in perCourse" :key="index" v-if="current==0">
  12. <view class="per_name">
  13. <text class="name">{{item.card.name}}</text>
  14. <text class="course_type">私教课</text>
  15. </view>
  16. <view class="per_row">
  17. <text class="lable">总共预约</text>
  18. <text class="num">{{item.use_nums}}次</text>
  19. </view>
  20. <view class="per_row">
  21. <text class="lable">总次数</text>
  22. <text class="num">{{item.card.nums}}次</text><text class="num" style="margin-left: 10px;">(剩余{{item.card.nums-item.use_nums}}次)</text>
  23. </view>
  24. <view class="time_row">
  25. <text class="lable">课程名称:</text>
  26. <text class="time">{{item.swimming_type_text}}</text>
  27. </view>
  28. <view class="time_row">
  29. <text class="lable">学员姓名:</text>
  30. <text class="time">{{item.child.name}}</text>
  31. </view>
  32. <view class="time_row">
  33. <text class="lable">到期时间:</text>
  34. <text class="time">{{item.expiration_time}}</text>
  35. </view>
  36. </view>
  37. <view class="train" v-for="(item,index) in course" :key="index" v-if="current==1">
  38. <view class="train_name">
  39. <text class="name">{{item.course.name}}</text>
  40. <text class="course_type">培训班</text>
  41. </view>
  42. <view class="time_row">
  43. <view class="left">
  44. <text class="lable">教练名称:</text>
  45. <text class="time">{{item.coach.name}}</text>
  46. </view>
  47. </view>
  48. <view class="time_row">
  49. <view class="left">
  50. <text class="lable">学员姓名:</text>
  51. <text class="time">{{item.child.name}}</text>
  52. </view>
  53. <view class="right">
  54. </view>
  55. </view>
  56. <view class="train_row">
  57. <text class="lable">开班时间</text>
  58. <text class="num">{{item.start_time}}~{{item.end_time}}</text>
  59. </view>
  60. <view class="train_row">
  61. <text class="lable">上课时间</text>
  62. <text class="num">{{item.course.start}}~{{item.course.end}}</text>
  63. </view>
  64. </view>
  65. </view>
  66. </template>
  67. <script>
  68. export default {
  69. data() {
  70. return {
  71. list: [{
  72. name: '私教课'
  73. }, {
  74. name: '培训班'
  75. }],
  76. current: 0,
  77. swiperCurrent: 0,
  78. tran_courseName: "儿童六一蛙泳培训课",
  79. course: [],
  80. perCourse: [], //私教列表
  81. page:1,
  82. last:false
  83. }
  84. },
  85. onShow() {
  86. this.page = 1
  87. this.last = false
  88. this.course=[]
  89. console.log(this.page,'show')
  90. },
  91. onLoad() {
  92. this.getPer()
  93. },
  94. onReachBottom() {
  95. if (!this.last) {
  96. this.page++
  97. }
  98. if (this.current == 0) {
  99. this.getPer()
  100. } else if (this.current == 1) {
  101. this.getCourse()
  102. }
  103. },
  104. methods: {
  105. //获取课程里表
  106. getCourse() {
  107. let params = {
  108. page: this.page,
  109. type: 1
  110. }
  111. this.$u.get('/user/course', params).then(res => {
  112. console.log(res, 'course1')
  113. let data = res.data.data
  114. if (this.page > 1 && data.length == 0) {
  115. uni.showToast({
  116. title: '暂无更多'
  117. })
  118. this.last = true
  119. } else {
  120. this.course = this.course.concat(data)
  121. }
  122. })
  123. },
  124. //获取私教列表
  125. getPer() {
  126. let params = {
  127. page: this.page,
  128. shop_id:this.vuex_user.shop_id
  129. }
  130. this.$u.get('/user/card', params).then(res => {
  131. console.log(res.data, 'percourse')
  132. if(!res.data.data) return
  133. let data = res.data.data
  134. if (this.page > 1 && data.length == 0) {
  135. uni.showToast({
  136. title: '暂无更多'
  137. })
  138. this.last = true
  139. } else {
  140. this.perCourse = this.perCourse.concat(data)
  141. }
  142. // this.perCourse = res.data
  143. // console.log(this.perCourse.length,'length')
  144. })
  145. },
  146. //tabs通知swiper切换
  147. tabsChange(index) {
  148. console.log(index, 'tabsChange')
  149. this.current = index
  150. this.page=1
  151. this.last=false
  152. if(index==0){
  153. this.perCourse=[]
  154. this.getPer()
  155. }else if(index==1){
  156. this.course=[]
  157. this.getCourse()
  158. }
  159. },
  160. }
  161. }
  162. </script>
  163. <style lang="scss">
  164. page {
  165. background-color: #F5F5F5;
  166. .empty{
  167. margin-top: 40%;
  168. }
  169. .per_course {
  170. margin: 12px 12px 0;
  171. background-color: #FFFFFF;
  172. color: #333333;
  173. padding: 12px;
  174. border-radius: 12px;
  175. .per_name {
  176. display: flex;
  177. justify-content: space-between;
  178. align-items: center;
  179. .name {
  180. font-size: 17px;
  181. font-weight: bold;
  182. }
  183. .course_type {
  184. background-color: #E5FAF3;
  185. width: 54px;
  186. height: 24px;
  187. line-height: 24px;
  188. color: #00A421;
  189. font-size: 14px;
  190. text-align: center;
  191. }
  192. }
  193. .per_row {
  194. margin-top: 6px;
  195. .lable {
  196. width: 55px;
  197. height: 21px;
  198. display: inline-block;
  199. line-height: 21px;
  200. text-align: center;
  201. background-color: #F5F5F5;
  202. font-size: 12px;
  203. margin-right: 7px;
  204. }
  205. .num {
  206. font-size: 15px;
  207. color: #FF4600;
  208. }
  209. }
  210. .time_row {
  211. margin-top: 6px;
  212. .lable {
  213. display: inline-block;
  214. width: 60px;
  215. height: 21px;
  216. line-height: 21px;
  217. text-align: center;
  218. font-size: 12px;
  219. }
  220. .time {
  221. font-size: 14px;
  222. font-weight: bold;
  223. }
  224. }
  225. }
  226. .train {
  227. min-height: 160px;
  228. margin: 12px 12px 0;
  229. background-color: #FFFFFF;
  230. color: #333333;
  231. padding: 12px;
  232. border-radius: 8px;
  233. .train_name {
  234. display: flex;
  235. justify-content: space-between;
  236. align-items: center;
  237. .name {
  238. font-size: 17px;
  239. font-weight: bold;
  240. }
  241. .course_type {
  242. background-color: #DCE7FF;
  243. width: 54px;
  244. height: 24px;
  245. line-height: 24px;
  246. color: #4A80FF;
  247. font-size: 14px;
  248. text-align: center;
  249. }
  250. }
  251. .courseName {
  252. display: inline-block;
  253. color: #999999;
  254. font-size: 14px;
  255. margin-top: 6px;
  256. }
  257. .train_row {
  258. margin-top: 6px;
  259. .lable {
  260. width: 55px;
  261. height: 21px;
  262. display: inline-block;
  263. line-height: 21px;
  264. text-align: center;
  265. background-color: #F5F5F5;
  266. font-size: 12px;
  267. margin-right: 7px;
  268. }
  269. .num {
  270. font-size: 14px;
  271. font-weight: bold;
  272. // color: #FF4600;
  273. }
  274. }
  275. .time_row {
  276. margin-top: 6px;
  277. display: flex;
  278. justify-content: space-between;
  279. .lable {
  280. display: inline-block;
  281. width: 60px;
  282. height: 21px;
  283. line-height: 21px;
  284. text-align: center;
  285. font-size: 12px;
  286. // margin-right: 7px;
  287. // box-sizing: content-box;
  288. }
  289. .time {
  290. font-size: 14px;
  291. font-weight: bold;
  292. }
  293. }
  294. }
  295. }
  296. </style>