course.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425
  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>
  52. </view>
  53. </view>
  54. <YouthTabbar :current="1" ref="tabbarMain"></YouthTabbar>
  55. </view>
  56. </template>
  57. <script>
  58. import * as courseApi from '@/apis/youth/course.js'
  59. import * as homePageApi from '@/apis/youth/homePage.js'
  60. import YouthTabbar from '@/components/YouthTabbar.vue'
  61. export default {
  62. components: {
  63. YouthTabbar
  64. },
  65. data() {
  66. return {
  67. active: 0,
  68. courseMenu: [],
  69. courseSort: '',
  70. pageNum: 1,
  71. pageSize: 5,
  72. recordsTotal: 0,
  73. current: 0,
  74. list: [{
  75. image: 'https://cdn.uviewui.com/uview/swiper/1.jpg',
  76. }, ],
  77. courseBaseList: [],
  78. teacherList: [],
  79. categorize: 1
  80. }
  81. },
  82. onReady() {
  83. this.getLoadTopCourseSorts();
  84. },
  85. methods: {
  86. toSearchResultById(item) {
  87. uni.navigateTo({
  88. url: '/pages/youth/search/searchResult?id=' + item.id
  89. })
  90. },
  91. toTeacherHomepage(item) {
  92. uni.navigateTo({
  93. url: '/pages/youth/teacherHomepage/teacherHomepage?id=' + item.employeeId
  94. })
  95. },
  96. getCourseBaseListBySortId(courseSortId) {
  97. uni.showLoading({
  98. title: "加载中",
  99. mask: true,
  100. })
  101. courseApi.getCourseBaseListBySortId({
  102. courseSortId: courseSortId
  103. }).then((response) => {
  104. uni.hideLoading();
  105. this.courseBaseList = response.data;
  106. }).catch(error => {
  107. uni.showToast({
  108. title: error,
  109. icon: "none"
  110. })
  111. })
  112. },
  113. getTeacherListBySortId(courseSortId) {
  114. uni.showLoading({
  115. title: "加载中",
  116. mask: true,
  117. })
  118. courseApi.getTeacherListBySortId({
  119. courseSortId: courseSortId
  120. }).then((response) => {
  121. uni.hideLoading();
  122. this.teacherList = response.data;
  123. }).catch(error => {
  124. uni.showToast({
  125. title: error,
  126. icon: "none"
  127. })
  128. })
  129. },
  130. toSearchResult() {
  131. uni.navigateTo({
  132. url: '/pages/youth/search/searchResult'
  133. })
  134. },
  135. courseChose(m, index) {
  136. this.active = index;
  137. this.courseSort = m.id;
  138. this.categorize = 1;
  139. this.getCourseBaseListBySortId(m.id)
  140. // this.getTeacherListBySortId(m.id)
  141. },
  142. getLoadTopCourseSorts() {
  143. uni.showLoading({
  144. title: "加载中",
  145. mask: true,
  146. })
  147. courseApi.loadTopCourseSorts().then((response) => {
  148. uni.hideLoading();
  149. this.courseMenu = response.data;
  150. this.courseSort = response.data[0].id;
  151. this.getCourseBaseListBySortId(this.courseSort);
  152. // this.getTeacherListBySortId(this.courseSort);
  153. }).catch(error => {
  154. uni.showToast({
  155. title: error,
  156. icon: "none"
  157. })
  158. })
  159. },
  160. }
  161. }
  162. </script>
  163. <style lang="scss" scoped>
  164. .head {
  165. padding: 20px 16px 40px 16px;
  166. background-color: rgba(13, 186, 199, 1);
  167. }
  168. .main {
  169. background-color: rgba(244, 246, 246, 1);
  170. border-radius: 20px 20px 0px 0px;
  171. padding: 20px 16px;
  172. margin-top: -16px;
  173. .content {
  174. display: flex;
  175. margin-top: 12px;
  176. .classify {
  177. background-color: #ffffff;
  178. border-radius: 12px;
  179. width: 28%;
  180. text-align: center;
  181. height: 1200rpx;
  182. overflow-y: scroll;
  183. .item {
  184. line-height: 32px;
  185. margin-top: 14px;
  186. font-size: 16px
  187. }
  188. .chosen {
  189. width: 80.7%;
  190. margin: 14px auto 0;
  191. border-radius: 50px;
  192. background-color: rgba(13, 186, 199, 1);
  193. color: #ffffff;
  194. overflow-y: scroll;
  195. }
  196. }
  197. .details {
  198. margin-left: 12px;
  199. width: 68.3%;
  200. height: 1200rpx;
  201. overflow-y: scroll;
  202. .infos-box {
  203. border-radius: 12px;
  204. background-color: rgba(255, 255, 255, 1);
  205. padding: 12px;
  206. margin-bottom: 12px;
  207. display: flex;
  208. .picture {
  209. width: 200rpx;
  210. height: 200rpx;
  211. border-radius: 4px;
  212. overflow: hidden;
  213. img {
  214. width: 100%;
  215. height: 100%;
  216. }
  217. }
  218. .infos {
  219. flex: 1;
  220. margin-left: 12px;
  221. .name {
  222. color: rgba(51, 51, 51, 1);
  223. font-size: 16px;
  224. }
  225. .tips {
  226. display: flex;
  227. margin-top: 8px;
  228. .item {
  229. padding: 0 8px;
  230. line-height: 20px;
  231. border-radius: 4px;
  232. background-color: rgba(241, 243, 244, 1);
  233. color: rgba(16, 16, 16, 1);
  234. font-size: 12px;
  235. margin-right: 8px;
  236. }
  237. }
  238. .teacher-price {
  239. margin-top: 44rpx;
  240. // display: flex;
  241. // justify-content: space-between;
  242. // align-items: center;
  243. .teacher {
  244. display: flex;
  245. align-items: center;
  246. .name-teacher {
  247. color: rgba(51, 51, 51, 1);
  248. font-size: 16px;
  249. width: 60%;
  250. }
  251. .phone-teacher {
  252. margin-right: 8px;
  253. }
  254. .photo {
  255. // width: 32px;
  256. // height: 32px;
  257. // border-radius: 50px;
  258. // overflow: hidden;
  259. margin-right: 8px;
  260. img {
  261. width: 100%;
  262. height: 100%;
  263. }
  264. }
  265. .img {
  266. width: 32rpx;
  267. height: 32rpx;
  268. margin-left: 16rpx;
  269. img {
  270. width: 100%;
  271. height: 100%;
  272. }
  273. }
  274. }
  275. .price {
  276. color: rgba(119, 119, 119, 1);
  277. }
  278. }
  279. }
  280. }
  281. .title {
  282. color: rgba(51, 51, 51, 1);
  283. font-size: 16px;
  284. line-height: 44px;
  285. border-radius: 12px;
  286. background-color: rgba(255, 255, 255, 1);
  287. text-align: center;
  288. font-weight: bold;
  289. }
  290. .details-box {
  291. display: flex;
  292. flex-wrap: wrap;
  293. justify-content: space-between;
  294. .item {
  295. width: 44%;
  296. line-height: 44px;
  297. border-radius: 12px;
  298. background-color: rgba(255, 255, 255, 1);
  299. color: rgba(51, 51, 51, 1);
  300. margin-top: 12px;
  301. text-align: center;
  302. }
  303. }
  304. }
  305. }
  306. }
  307. .classes {
  308. height: 88rpx;
  309. line-height: 88rpx;
  310. display: flex;
  311. background-color: #ffffff;
  312. margin-bottom: 24rpx;
  313. border-radius: 12px;
  314. border: 2px solid rgba(13, 186, 199, 1);
  315. color: rgba(13, 186, 199, 1);
  316. .checked {
  317. background-color: #0DBAC7;
  318. color: #fff
  319. }
  320. .item {
  321. width: 50%;
  322. text-align: center;
  323. }
  324. }
  325. .teacher-item {
  326. width: 100%;
  327. border-radius: 12px;
  328. background-color: rgba(255, 255, 255, 1);
  329. display: flex;
  330. align-items: center;
  331. margin-bottom: 24rpx;
  332. padding: 24rpx;
  333. .photo {
  334. width: 96rpx;
  335. height: 96rpx;
  336. border-radius: 8px;
  337. overflow: hidden;
  338. img {
  339. width: 100%;
  340. }
  341. }
  342. .infos {
  343. margin-left: 16rpx;
  344. .name {
  345. color: rgba(51, 51, 51, 1);
  346. font-size: 32rpx;
  347. margin-bottom: 16rpx;
  348. }
  349. }
  350. .course1 {
  351. color: rgba(119, 119, 119, 1);
  352. font-size: 28rpx;
  353. width: 200rpx;
  354. white-space: nowrap;
  355. overflow: hidden;
  356. text-overflow: ellipsis;
  357. }
  358. .more {
  359. margin-left: auto;
  360. }
  361. }
  362. .teacher-box {
  363. border-radius: 12px;
  364. background-color: rgba(255, 255, 255, 1);
  365. padding: 12px;
  366. margin-bottom: 12px;
  367. display: flex;
  368. }
  369. </style>