course.vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347
  1. <template>
  2. <view>
  3. <view class="head">
  4. <u-search placeholder="搜索课程" :show-action="false" height="80"></u-search>
  5. </view>
  6. <view class="main">
  7. <u-swiper :list="list"></u-swiper>
  8. <view class="content">
  9. <view class="classify">
  10. <view class="item" v-for="(m,index) in courseMenu" :key="index"
  11. :class="active==index ? 'chosen' : ''" @click="courseChose(m,index)">
  12. {{m.name}}
  13. </view>
  14. </view>
  15. <view class="details">
  16. <view class="infos-box" v-for="(item,index) in reCoursesList" :key="index"
  17. @click="gotoUrl('pages/parents/course/confirmOrder?id='+item.course_id)">
  18. <!-- <view class="picture" v-if="item.posterUrl != null">
  19. <img :src="item.posterUrl" alt="">
  20. </view>
  21. <view class="picture" v-else>
  22. <img src="../../../assets/img/classify1.png" alt="">
  23. </view> -->
  24. <view class="infos">
  25. <view class="name">
  26. {{item.className}}
  27. </view>
  28. <view class="tips">
  29. <view class="item" v-if="item.courseDesc != null">
  30. {{item.courseDesc}}
  31. </view>
  32. <view class="item" v-else>
  33. 暂无简介
  34. </view>
  35. </view>
  36. <view class="teacher-price">
  37. <view class="teacher">
  38. <view class="photo">
  39. <img src="../../../assets/img/teacher.png" alt="">
  40. </view>
  41. <view class="name">
  42. {{item.teacherName}}
  43. </view>
  44. <view class="img">
  45. <img src="../../../assets/img/riLine-smartphone-line@1x.png" alt="">
  46. </view>
  47. <view>
  48. {{item.consultPhone}}
  49. </view>
  50. </view>
  51. <!-- <view class="price">
  52. </view> -->
  53. </view>
  54. </view>
  55. </view>
  56. <u-divider v-if="reCoursesList.length == recordsTotal && recordsTotal != 0" style="margin-top: 10px">没有更多了</u-divider>
  57. <!-- <view class="title">
  58. 系列全部课程
  59. </view> -->
  60. <!-- <view class="details-box">
  61. <view class="item">
  62. 跆拳道
  63. </view>
  64. <view class="item">
  65. 围棋
  66. </view>
  67. <view class="item">
  68. 象棋
  69. </view>
  70. <view class="item">
  71. 乒乓球
  72. </view>
  73. <view class="item">
  74. 篮球
  75. </view>
  76. <view class="item">
  77. 足球
  78. </view>
  79. <view class="item">
  80. 花式跳绳
  81. </view>
  82. </view> -->
  83. </view>
  84. </view>
  85. </view>
  86. <ParentsTabbar :current="1" ref="tabbarMain"></ParentsTabbar>
  87. </view>
  88. </template>
  89. <script>
  90. import * as courseApi from '@/apis/parents/course.js'
  91. import * as homePageApi from '@/apis/parents/homePage.js'
  92. import ParentsTabbar from '@/components/ParentsTabbar.vue'
  93. export default {
  94. components: {
  95. ParentsTabbar
  96. },
  97. data() {
  98. return {
  99. active: 0,
  100. courseMenu: [],
  101. reCoursesList: [],
  102. courseSort: '',
  103. pageNum: 1,
  104. pageSize: 5,
  105. recordsTotal: 0,
  106. list: [{
  107. image: 'https://cdn.uviewui.com/uview/swiper/1.jpg',
  108. }, ],
  109. }
  110. },
  111. onReady() {
  112. this.getLoadTopCourseSorts();
  113. },
  114. onReachBottom() {
  115. if (this.reCoursesList.length < this.recordsTotal) {
  116. this.myLoadmore();
  117. }
  118. },
  119. methods: {
  120. myLoadmore() {
  121. this.pageNum += 1;
  122. this.getReCoursesList()
  123. },
  124. getReCoursesList(bl) {
  125. uni.showLoading({
  126. title: "加载中",
  127. mask: true,
  128. })
  129. if (bl) {
  130. this.reCoursesList = [];
  131. this.pageNum = 1;
  132. }
  133. homePageApi.loadCoursesForHomeShow({
  134. courseSort: this.courseSort,
  135. pageNum: this.pageNum,
  136. pageSize: this.pageSize
  137. }).then((res) => {
  138. uni.hideLoading();
  139. this.reCoursesList = [
  140. ...this.reCoursesList,
  141. ...res.data.data
  142. ];
  143. this.recordsTotal = res.data.recordsTotal;
  144. }).catch(error => {
  145. uni.showToast({
  146. title: error,
  147. icon: "none"
  148. })
  149. })
  150. },
  151. courseChose(m,index) {
  152. this.active = index;
  153. this.courseSort = m.id;
  154. this.getReCoursesList(true);
  155. },
  156. getLoadTopCourseSorts() {
  157. uni.showLoading({
  158. title: "加载中",
  159. mask: true,
  160. })
  161. courseApi.loadTopCourseSorts().then((response) => {
  162. uni.hideLoading();
  163. this.courseMenu = response.data;
  164. this.courseSort = response.data[0].id;
  165. this.getReCoursesList();
  166. }).catch(error => {
  167. uni.showToast({
  168. title: error,
  169. icon: "none"
  170. })
  171. })
  172. },
  173. }
  174. }
  175. </script>
  176. <style lang="scss" scoped>
  177. .head {
  178. padding: 20px 16px 40px 16px;
  179. background-color: rgba(13, 186, 199, 1);
  180. }
  181. .main {
  182. background-color: rgba(244, 246, 246, 1);
  183. border-radius: 20px 20px 0px 0px;
  184. padding: 20px 16px;
  185. margin-top: -16px;
  186. .content {
  187. display: flex;
  188. margin-top: 12px;
  189. .classify {
  190. background-color: #ffffff;
  191. border-radius: 12px;
  192. width: 28%;
  193. text-align: center;
  194. height:950rpx;
  195. overflow-y: scroll;
  196. .item {
  197. line-height: 32px;
  198. margin-top: 14px;
  199. font-size: 16px
  200. }
  201. .chosen {
  202. width: 66.7%;
  203. margin: 14px auto 0;
  204. border-radius: 50px;
  205. background-color: rgba(13, 186, 199, 1);
  206. color: #ffffff;
  207. overflow-y: scroll;
  208. }
  209. }
  210. .details {
  211. margin-left: 12px;
  212. width: 68.3%;
  213. height: 950rpx;
  214. overflow-y: scroll;
  215. .infos-box {
  216. border-radius: 12px;
  217. background-color: rgba(255, 255, 255, 1);
  218. padding: 12px;
  219. margin-bottom: 12px;
  220. display: flex;
  221. .picture {
  222. width: 200rpx;
  223. height: 200rpx;
  224. border-radius: 4px;
  225. overflow: hidden;
  226. img {
  227. width: 100%;
  228. height: 100%;
  229. }
  230. }
  231. .infos {
  232. flex: 1;
  233. margin-left: 12px;
  234. .name {
  235. color: rgba(51, 51, 51, 1);
  236. font-size: 16px;
  237. }
  238. .tips {
  239. display: flex;
  240. margin-top: 8px;
  241. .item {
  242. padding: 0 8px;
  243. line-height: 20px;
  244. border-radius: 4px;
  245. background-color: rgba(241, 243, 244, 1);
  246. color: rgba(16, 16, 16, 1);
  247. font-size: 12px;
  248. margin-right: 8px;
  249. }
  250. }
  251. .teacher-price {
  252. margin-top: 44rpx;
  253. display: flex;
  254. justify-content: space-between;
  255. align-items: center;
  256. .teacher {
  257. display: flex;
  258. align-items: center;
  259. .photo {
  260. width: 32px;
  261. height: 32px;
  262. border-radius: 50px;
  263. overflow: hidden;
  264. margin-right: 8px;
  265. img {
  266. width: 100%;
  267. height: 100%;
  268. }
  269. }
  270. .img {
  271. width: 32rpx;
  272. height: 32rpx;
  273. margin-left: 16rpx;
  274. img {
  275. width: 100%;
  276. height: 100%;
  277. }
  278. }
  279. }
  280. .price {
  281. color: rgba(119, 119, 119, 1);
  282. }
  283. }
  284. }
  285. }
  286. .title {
  287. color: rgba(51, 51, 51, 1);
  288. font-size: 16px;
  289. line-height: 44px;
  290. border-radius: 12px;
  291. background-color: rgba(255, 255, 255, 1);
  292. text-align: center;
  293. font-weight: bold;
  294. }
  295. .details-box {
  296. display: flex;
  297. flex-wrap: wrap;
  298. justify-content: space-between;
  299. .item {
  300. width: 44%;
  301. line-height: 44px;
  302. border-radius: 12px;
  303. background-color: rgba(255, 255, 255, 1);
  304. color: rgba(51, 51, 51, 1);
  305. margin-top: 12px;
  306. text-align: center;
  307. }
  308. }
  309. }
  310. }
  311. }
  312. </style>