course.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519
  1. <template>
  2. <view>
  3. <view class="head">
  4. <u-search placeholder="搜索课程" :show-action="false" height="80" @focus="toSearchResult"></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" :class="active==index ? 'chosen' : ''"
  11. @click="courseChose(m,index)">
  12. {{m.name}}
  13. </view>
  14. </view>
  15. <view class="details">
  16. <view class="classes">
  17. <view class="item" @click="categorize = 1" :class="categorize==1 ? 'checked' : ''">
  18. 按课程
  19. </view>
  20. <view class="item" @click="categorize = 2" :class="categorize==2 ? 'checked' : ''">
  21. 按老师
  22. </view>
  23. </view>
  24. <view class="infos-box2">
  25. <view class="details-box" v-if="categorize==1">
  26. <view class="item" v-for="(item,index) in courseBaseList" :key="index"
  27. @click="toSearchResultById(item)">
  28. {{item.name}}
  29. </view>
  30. </view>
  31. <view class="teacher-item" v-for="(item,index) in teacherList" :key="index" v-if="categorize==2"
  32. @click="toTeacherHomepage(item)">
  33. <view class="photo">
  34. <u-avatar class="avatar" mode="square"
  35. :src="item.headPhoto != null ? item.headPhoto : '../../assets/img/head.png'" size="96">
  36. </u-avatar>
  37. </view>
  38. <view class="infos">
  39. <view class="name">
  40. {{item.employeeName}}
  41. </view>
  42. <view class="course1">
  43. {{item.courseName}}
  44. </view>
  45. </view>
  46. <view class="more">
  47. <u-icon name="arrow-right"></u-icon>
  48. </view>
  49. </view>
  50. </view>
  51. <view class="infos-box" v-for="(item,index) in reCoursesList" :key="index"
  52. @click="gotoUrl('pages/parents/course/courseDetails?id='+item.course_id+'&classId='+item.class_id)">
  53. <view class="infos">
  54. <view class="name">
  55. {{item.className}}
  56. </view>
  57. <view class="tips">
  58. <view class="item" v-if="item.courseDesc != null">
  59. {{item.courseDesc}}
  60. </view>
  61. <view class="item" v-else>
  62. 暂无简介
  63. </view>
  64. </view>
  65. <view class="teacher-price">
  66. <view class="teacher">
  67. <view class="name-teacher">
  68. 咨询电话:
  69. </view>
  70. <view class="phone-teacher">
  71. {{item.consultPhone != null ? item.consultPhone : '暂无'}}
  72. </view>
  73. </view>
  74. </view>
  75. </view>
  76. </view>
  77. <u-divider v-if="reCoursesList.length == recordsTotal && recordsTotal != 0"
  78. style="margin-top: 10px">没有更多了</u-divider>
  79. </view>
  80. </view>
  81. </view>
  82. <ParentsTabbar :current="1" ref="tabbarMain"></ParentsTabbar>
  83. </view>
  84. </template>
  85. <script>
  86. import * as courseApi from '@/apis/parents/course.js'
  87. import * as homePageApi from '@/apis/parents/homePage.js'
  88. import ParentsTabbar from '@/components/ParentsTabbar.vue'
  89. export default {
  90. components: {
  91. ParentsTabbar
  92. },
  93. data() {
  94. return {
  95. active: 0,
  96. courseMenu: [],
  97. reCoursesList: [],
  98. courseSort: '',
  99. pageNum: 1,
  100. pageSize: 5,
  101. recordsTotal: 0,
  102. current: 0,
  103. list: [{
  104. image: 'https://cdn.uviewui.com/uview/swiper/1.jpg',
  105. }, ],
  106. courseBaseList: [],
  107. teacherList: [],
  108. categorize: 1
  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. toSearchResultById(item) {
  121. uni.navigateTo({
  122. url: '/pages/parents/search/searchResult?id=' + item.id
  123. })
  124. },
  125. toTeacherHomepage(item) {
  126. uni.navigateTo({
  127. url: '/pages/parents/teacherHomepage/teacherHomepage?id=' + item.employeeId
  128. })
  129. },
  130. getCourseBaseListBySortId(courseSortId) {
  131. uni.showLoading({
  132. title: "加载中",
  133. mask: true,
  134. })
  135. courseApi.getCourseBaseListBySortId({
  136. courseSortId: courseSortId
  137. }).then((response) => {
  138. uni.hideLoading();
  139. this.courseBaseList = response.data;
  140. }).catch(error => {
  141. uni.showToast({
  142. title: error,
  143. icon: "none"
  144. })
  145. })
  146. },
  147. getTeacherListBySortId(courseSortId) {
  148. uni.showLoading({
  149. title: "加载中",
  150. mask: true,
  151. })
  152. courseApi.getTeacherListBySortId({
  153. courseSortId: courseSortId
  154. }).then((response) => {
  155. uni.hideLoading();
  156. this.teacherList = response.data;
  157. for (var i = 0; i < this.teacherList.length; i++) {
  158. this.getTeacherCourseList(this.teacherList[i].employeeId,i);
  159. }
  160. console.log(this.teacherList)
  161. }).catch(error => {
  162. uni.showToast({
  163. title: error,
  164. icon: "none"
  165. })
  166. })
  167. },
  168. getTeacherCourseList(teacherId,index) {
  169. uni.showLoading({
  170. title: "加载中",
  171. mask: true,
  172. })
  173. courseApi.getTeacherCourseList({
  174. teacherId: teacherId
  175. }).then((response) => {
  176. uni.hideLoading();
  177. var teacherCourseList = response.data;
  178. var courseNameList = [];
  179. var courseName = '';
  180. courseNameList = teacherCourseList.map(record => {
  181. return record.course_name;
  182. });
  183. courseName = courseNameList.join(',');
  184. this.teacherList[index]['courseName'] = courseName;
  185. }).catch(error => {
  186. uni.showToast({
  187. title: error,
  188. icon: "none"
  189. })
  190. })
  191. },
  192. toSearchResult() {
  193. uni.navigateTo({
  194. url: '/pages/parents/search/searchResult'
  195. })
  196. },
  197. myLoadmore() {
  198. this.pageNum += 1;
  199. this.getReCoursesList()
  200. },
  201. getReCoursesList(bl) {
  202. uni.showLoading({
  203. title: "加载中",
  204. mask: true,
  205. })
  206. if (bl) {
  207. this.reCoursesList = [];
  208. this.pageNum = 1;
  209. }
  210. homePageApi.loadCoursesForHomeShow({
  211. courseSort: this.courseSort,
  212. pageNum: this.pageNum,
  213. pageSize: this.pageSize
  214. }).then((res) => {
  215. uni.hideLoading();
  216. this.reCoursesList = [
  217. ...this.reCoursesList,
  218. ...res.data.data
  219. ];
  220. this.recordsTotal = res.data.recordsTotal;
  221. }).catch(error => {
  222. uni.showToast({
  223. title: error,
  224. icon: "none"
  225. })
  226. })
  227. },
  228. courseChose(m, index) {
  229. this.active = index;
  230. this.courseSort = m.id;
  231. this.categorize = 1;
  232. // this.getReCoursesList(true);
  233. this.getCourseBaseListBySortId(m.id)
  234. this.getTeacherListBySortId(m.id)
  235. },
  236. getLoadTopCourseSorts() {
  237. uni.showLoading({
  238. title: "加载中",
  239. mask: true,
  240. })
  241. courseApi.loadTopCourseSorts().then((response) => {
  242. uni.hideLoading();
  243. this.courseMenu = response.data;
  244. this.courseSort = response.data[0].id;
  245. // this.getReCoursesList();
  246. this.getCourseBaseListBySortId(this.courseSort)
  247. this.getTeacherListBySortId(this.courseSort)
  248. }).catch(error => {
  249. uni.showToast({
  250. title: error,
  251. icon: "none"
  252. })
  253. })
  254. },
  255. }
  256. }
  257. </script>
  258. <style lang="scss" scoped>
  259. .head {
  260. padding: 20px 16px 40px 16px;
  261. background-color: rgba(13, 186, 199, 1);
  262. }
  263. .main {
  264. background-color: rgba(244, 246, 246, 1);
  265. border-radius: 20px 20px 0px 0px;
  266. padding: 20px 16px;
  267. margin-top: -16px;
  268. .content {
  269. display: flex;
  270. margin-top: 12px;
  271. .classify {
  272. background-color: #ffffff;
  273. border-radius: 12px;
  274. width: 28%;
  275. text-align: center;
  276. height: 1200rpx;
  277. overflow-y: scroll;
  278. .item {
  279. line-height: 32px;
  280. margin-top: 14px;
  281. font-size: 16px
  282. }
  283. .chosen {
  284. width: 80.7%;
  285. margin: 14px auto 0;
  286. border-radius: 50px;
  287. background-color: rgba(13, 186, 199, 1);
  288. color: #ffffff;
  289. overflow-y: scroll;
  290. }
  291. }
  292. .details {
  293. margin-left: 12px;
  294. width: 68.3%;
  295. height: 1200rpx;
  296. overflow-y: scroll;
  297. .infos-box {
  298. border-radius: 12px;
  299. background-color: rgba(255, 255, 255, 1);
  300. padding: 12px;
  301. margin-bottom: 12px;
  302. display: flex;
  303. .picture {
  304. width: 200rpx;
  305. height: 200rpx;
  306. border-radius: 4px;
  307. overflow: hidden;
  308. img {
  309. width: 100%;
  310. height: 100%;
  311. }
  312. }
  313. .infos {
  314. flex: 1;
  315. margin-left: 12px;
  316. .name {
  317. color: rgba(51, 51, 51, 1);
  318. font-size: 16px;
  319. }
  320. .tips {
  321. display: flex;
  322. margin-top: 8px;
  323. .item {
  324. padding: 0 8px;
  325. line-height: 20px;
  326. border-radius: 4px;
  327. background-color: rgba(241, 243, 244, 1);
  328. color: rgba(16, 16, 16, 1);
  329. font-size: 12px;
  330. margin-right: 8px;
  331. }
  332. }
  333. .teacher-price {
  334. margin-top: 44rpx;
  335. // display: flex;
  336. // justify-content: space-between;
  337. // align-items: center;
  338. .teacher {
  339. display: flex;
  340. align-items: center;
  341. .name-teacher {
  342. color: rgba(51, 51, 51, 1);
  343. font-size: 16px;
  344. width: 60%;
  345. }
  346. .phone-teacher {
  347. margin-right: 8px;
  348. }
  349. .photo {
  350. // width: 32px;
  351. // height: 32px;
  352. // border-radius: 50px;
  353. // overflow: hidden;
  354. margin-right: 8px;
  355. img {
  356. width: 100%;
  357. height: 100%;
  358. }
  359. }
  360. .img {
  361. width: 32rpx;
  362. height: 32rpx;
  363. margin-left: 16rpx;
  364. img {
  365. width: 100%;
  366. height: 100%;
  367. }
  368. }
  369. }
  370. .price {
  371. color: rgba(119, 119, 119, 1);
  372. }
  373. }
  374. }
  375. }
  376. .title {
  377. color: rgba(51, 51, 51, 1);
  378. font-size: 16px;
  379. line-height: 44px;
  380. border-radius: 12px;
  381. background-color: rgba(255, 255, 255, 1);
  382. text-align: center;
  383. font-weight: bold;
  384. }
  385. .details-box {
  386. display: flex;
  387. flex-wrap: wrap;
  388. justify-content: space-between;
  389. .item {
  390. width: 44%;
  391. line-height: 44px;
  392. border-radius: 12px;
  393. background-color: rgba(255, 255, 255, 1);
  394. color: rgba(51, 51, 51, 1);
  395. margin-top: 12px;
  396. text-align: center;
  397. }
  398. }
  399. }
  400. }
  401. }
  402. .classes {
  403. height: 88rpx;
  404. line-height: 88rpx;
  405. display: flex;
  406. background-color: #ffffff;
  407. margin-bottom: 24rpx;
  408. border-radius: 12px;
  409. border: 2px solid rgba(13, 186, 199, 1);
  410. color: rgba(13, 186, 199, 1);
  411. .checked {
  412. background-color: #0DBAC7;
  413. color: #fff
  414. }
  415. .item {
  416. width: 50%;
  417. text-align: center;
  418. }
  419. }
  420. .teacher-item {
  421. width: 100%;
  422. border-radius: 12px;
  423. background-color: rgba(255, 255, 255, 1);
  424. display: flex;
  425. align-items: center;
  426. margin-bottom: 24rpx;
  427. padding: 24rpx;
  428. .photo {
  429. width: 96rpx;
  430. height: 96rpx;
  431. border-radius: 8px;
  432. overflow: hidden;
  433. img {
  434. width: 100%;
  435. }
  436. }
  437. .infos {
  438. margin-left: 16rpx;
  439. .name {
  440. color: rgba(51, 51, 51, 1);
  441. font-size: 32rpx;
  442. margin-bottom: 16rpx;
  443. }
  444. }
  445. .course1 {
  446. color: rgba(119, 119, 119, 1);
  447. font-size: 28rpx;
  448. width: 200rpx;
  449. white-space: nowrap;
  450. overflow: hidden;
  451. text-overflow: ellipsis;
  452. }
  453. .more {
  454. margin-left: auto;
  455. }
  456. }
  457. .teacher-box {
  458. border-radius: 12px;
  459. background-color: rgba(255, 255, 255, 1);
  460. padding: 12px;
  461. margin-bottom: 12px;
  462. display: flex;
  463. }
  464. </style>