course.vue 7.8 KB

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