course.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490
  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.introduce}}
  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/youth/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. <YouthTabbar :current="1" ref="tabbarMain"></YouthTabbar>
  83. </view>
  84. </template>
  85. <script>
  86. import * as courseApi from '@/apis/youth/course.js'
  87. import * as homePageApi from '@/apis/youth/homePage.js'
  88. import YouthTabbar from '@/components/YouthTabbar.vue'
  89. export default {
  90. components: {
  91. YouthTabbar
  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/youth/search/searchResult?id=' + item.id
  123. })
  124. },
  125. toTeacherHomepage(item) {
  126. uni.navigateTo({
  127. url: '/pages/youth/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. }).catch(error => {
  158. uni.showToast({
  159. title: error,
  160. icon: "none"
  161. })
  162. })
  163. },
  164. toSearchResult() {
  165. uni.navigateTo({
  166. url: '/pages/youth/search/searchResult'
  167. })
  168. },
  169. myLoadmore() {
  170. this.pageNum += 1;
  171. this.getReCoursesList()
  172. },
  173. getReCoursesList(bl) {
  174. uni.showLoading({
  175. title: "加载中",
  176. mask: true,
  177. })
  178. if (bl) {
  179. this.reCoursesList = [];
  180. this.pageNum = 1;
  181. }
  182. homePageApi.loadCoursesForHomeShow({
  183. courseSort: this.courseSort,
  184. pageNum: this.pageNum,
  185. pageSize: this.pageSize
  186. }).then((res) => {
  187. uni.hideLoading();
  188. this.reCoursesList = [
  189. ...this.reCoursesList,
  190. ...res.data.data
  191. ];
  192. this.recordsTotal = res.data.recordsTotal;
  193. }).catch(error => {
  194. uni.showToast({
  195. title: error,
  196. icon: "none"
  197. })
  198. })
  199. },
  200. courseChose(m, index) {
  201. this.active = index;
  202. this.courseSort = m.id;
  203. this.categorize = 1;
  204. // this.getReCoursesList(true);
  205. this.getCourseBaseListBySortId(m.id)
  206. this.getTeacherListBySortId(m.id)
  207. },
  208. getLoadTopCourseSorts() {
  209. uni.showLoading({
  210. title: "加载中",
  211. mask: true,
  212. })
  213. courseApi.loadTopCourseSorts().then((response) => {
  214. uni.hideLoading();
  215. this.courseMenu = response.data;
  216. this.courseSort = response.data[0].id;
  217. // this.getReCoursesList();
  218. this.getCourseBaseListBySortId(this.courseSort)
  219. this.getTeacherListBySortId(this.courseSort)
  220. }).catch(error => {
  221. uni.showToast({
  222. title: error,
  223. icon: "none"
  224. })
  225. })
  226. },
  227. }
  228. }
  229. </script>
  230. <style lang="scss" scoped>
  231. .head {
  232. padding: 20px 16px 40px 16px;
  233. background-color: rgba(13, 186, 199, 1);
  234. }
  235. .main {
  236. background-color: rgba(244, 246, 246, 1);
  237. border-radius: 20px 20px 0px 0px;
  238. padding: 20px 16px;
  239. margin-top: -16px;
  240. .content {
  241. display: flex;
  242. margin-top: 12px;
  243. .classify {
  244. background-color: #ffffff;
  245. border-radius: 12px;
  246. width: 28%;
  247. text-align: center;
  248. height: 1200rpx;
  249. overflow-y: scroll;
  250. .item {
  251. line-height: 32px;
  252. margin-top: 14px;
  253. font-size: 16px
  254. }
  255. .chosen {
  256. width: 80.7%;
  257. margin: 14px auto 0;
  258. border-radius: 50px;
  259. background-color: rgba(13, 186, 199, 1);
  260. color: #ffffff;
  261. overflow-y: scroll;
  262. }
  263. }
  264. .details {
  265. margin-left: 12px;
  266. width: 68.3%;
  267. height: 1200rpx;
  268. overflow-y: scroll;
  269. .infos-box {
  270. border-radius: 12px;
  271. background-color: rgba(255, 255, 255, 1);
  272. padding: 12px;
  273. margin-bottom: 12px;
  274. display: flex;
  275. .picture {
  276. width: 200rpx;
  277. height: 200rpx;
  278. border-radius: 4px;
  279. overflow: hidden;
  280. img {
  281. width: 100%;
  282. height: 100%;
  283. }
  284. }
  285. .infos {
  286. flex: 1;
  287. margin-left: 12px;
  288. .name {
  289. color: rgba(51, 51, 51, 1);
  290. font-size: 16px;
  291. }
  292. .tips {
  293. display: flex;
  294. margin-top: 8px;
  295. .item {
  296. padding: 0 8px;
  297. line-height: 20px;
  298. border-radius: 4px;
  299. background-color: rgba(241, 243, 244, 1);
  300. color: rgba(16, 16, 16, 1);
  301. font-size: 12px;
  302. margin-right: 8px;
  303. }
  304. }
  305. .teacher-price {
  306. margin-top: 44rpx;
  307. // display: flex;
  308. // justify-content: space-between;
  309. // align-items: center;
  310. .teacher {
  311. display: flex;
  312. align-items: center;
  313. .name-teacher {
  314. color: rgba(51, 51, 51, 1);
  315. font-size: 16px;
  316. width: 60%;
  317. }
  318. .phone-teacher {
  319. margin-right: 8px;
  320. }
  321. .photo {
  322. // width: 32px;
  323. // height: 32px;
  324. // border-radius: 50px;
  325. // overflow: hidden;
  326. margin-right: 8px;
  327. img {
  328. width: 100%;
  329. height: 100%;
  330. }
  331. }
  332. .img {
  333. width: 32rpx;
  334. height: 32rpx;
  335. margin-left: 16rpx;
  336. img {
  337. width: 100%;
  338. height: 100%;
  339. }
  340. }
  341. }
  342. .price {
  343. color: rgba(119, 119, 119, 1);
  344. }
  345. }
  346. }
  347. }
  348. .title {
  349. color: rgba(51, 51, 51, 1);
  350. font-size: 16px;
  351. line-height: 44px;
  352. border-radius: 12px;
  353. background-color: rgba(255, 255, 255, 1);
  354. text-align: center;
  355. font-weight: bold;
  356. }
  357. .details-box {
  358. display: flex;
  359. flex-wrap: wrap;
  360. justify-content: space-between;
  361. .item {
  362. width: 44%;
  363. line-height: 44px;
  364. border-radius: 12px;
  365. background-color: rgba(255, 255, 255, 1);
  366. color: rgba(51, 51, 51, 1);
  367. margin-top: 12px;
  368. text-align: center;
  369. }
  370. }
  371. }
  372. }
  373. }
  374. .classes {
  375. height: 88rpx;
  376. line-height: 88rpx;
  377. display: flex;
  378. background-color: #ffffff;
  379. margin-bottom: 24rpx;
  380. border-radius: 12px;
  381. border: 2px solid rgba(13, 186, 199, 1);
  382. color: rgba(13, 186, 199, 1);
  383. .checked {
  384. background-color: #0DBAC7;
  385. color: #fff
  386. }
  387. .item {
  388. width: 50%;
  389. text-align: center;
  390. }
  391. }
  392. .teacher-item {
  393. width: 100%;
  394. border-radius: 12px;
  395. background-color: rgba(255, 255, 255, 1);
  396. display: flex;
  397. align-items: center;
  398. margin-bottom: 24rpx;
  399. padding: 24rpx;
  400. .photo {
  401. width: 96rpx;
  402. height: 96rpx;
  403. border-radius: 8px;
  404. overflow: hidden;
  405. img {
  406. width: 100%;
  407. }
  408. }
  409. .infos {
  410. margin-left: 16rpx;
  411. .name {
  412. color: rgba(51, 51, 51, 1);
  413. font-size: 32rpx;
  414. margin-bottom: 16rpx;
  415. }
  416. }
  417. .course1 {
  418. color: rgba(119, 119, 119, 1);
  419. font-size: 28rpx;
  420. width: 200rpx;
  421. white-space: nowrap;
  422. overflow: hidden;
  423. text-overflow: ellipsis;
  424. }
  425. .more {
  426. margin-left: auto;
  427. }
  428. }
  429. .teacher-box {
  430. border-radius: 12px;
  431. background-color: rgba(255, 255, 255, 1);
  432. padding: 12px;
  433. margin-bottom: 12px;
  434. display: flex;
  435. }
  436. </style>