searchResult.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. <template>
  2. <view>
  3. <view class="search">
  4. <u-icon name="arrow-left" @click="backCourse"></u-icon>
  5. <u-search placeholder="输入关键字搜索课程" action-text="查询" v-model="className" @custom="searchClass"></u-search>
  6. </view>
  7. <view class="main">
  8. <view class="result-box" v-for="(item,index) in reCoursesList" :key="index"
  9. @click="toCourseDetails(item)" v-if="item.classStatus != '3'">
  10. <view class="picture" v-if="item.posterUrl != null">
  11. <img :src="item.posterUrl" alt="">
  12. </view>
  13. <view class="picture" v-else>
  14. <img src="../../../assets/img/resultP.png" alt="">
  15. </view>
  16. <view class="infos">
  17. <view class="title">
  18. {{item.className}}
  19. </view>
  20. <view class="tag">
  21. <view class="item" v-if="item.courseDesc != null">
  22. {{item.courseDesc}}
  23. </view>
  24. <view class="item" v-else>
  25. 暂无简介
  26. </view>
  27. </view>
  28. <view class="teacher">
  29. <!-- <view class="photo">
  30. <u-avatar class="avatar"
  31. :src="item.headPhoto != null ? item.headPhoto : '../../assets/img/head.png'" size="64">
  32. </u-avatar>
  33. </view> -->
  34. <view class="name">
  35. 咨询电话:
  36. </view>
  37. <view class="phone-teacher">
  38. {{item.consultPhone != null ? item.consultPhone : '暂无'}}
  39. </view>
  40. </view>
  41. </view>
  42. </view>
  43. </view>
  44. <u-divider v-if="reCoursesList.length == 1" style="margin-top: 10px">暂时只开了一个班
  45. </u-divider>
  46. <u-toast ref="uToast" />
  47. </view>
  48. </template>
  49. <script>
  50. import * as homePageApi from '@/apis/youth/homePage.js'
  51. export default {
  52. data() {
  53. return {
  54. className: '',
  55. reCoursesList: [],
  56. courseSortId: ''
  57. }
  58. },
  59. onLoad(op) {
  60. if(op.id) {
  61. this.courseSortId = op.id;
  62. this.getReCoursesList();
  63. }
  64. },
  65. methods: {
  66. searchClass() {
  67. if(this.className) {
  68. this.getReCoursesList();
  69. }
  70. },
  71. backCourse() {
  72. uni.navigateBack({
  73. })
  74. },
  75. getReCoursesList() {
  76. uni.showLoading({
  77. title: "加载中",
  78. mask: true,
  79. })
  80. homePageApi.loadCoursesForHomeShow({
  81. courseSortId: this.courseSortId,
  82. className: this.className,
  83. pageNum: 1,
  84. pageSize: 10000
  85. }).then((res) => {
  86. uni.hideLoading();
  87. // this.reCoursesList = res.data.data;
  88. var list = res.data.data;
  89. var list2 = [];
  90. for (var i = 0; i < list.length; i++) {
  91. if(list[i].classStatus != '3') {
  92. list2.push(list[i]);
  93. }
  94. }
  95. this.reCoursesList = list2;
  96. }).catch(error => {
  97. uni.showToast({
  98. title: error,
  99. icon: "none"
  100. })
  101. })
  102. },
  103. toCourseDetails(item) {
  104. if(item.classStatus != '4') {
  105. uni.navigateTo({
  106. url: '/pages/youth/course/courseDetails?id='+item.course_id+'&classId='+item.class_id
  107. })
  108. }
  109. }
  110. }
  111. }
  112. </script>
  113. <style lang="scss" scoped>
  114. .search {
  115. background-color: #fff;
  116. padding: 16rpx 24rpx;
  117. position: fixed;
  118. left: 0;
  119. right: 0;
  120. top: 0;
  121. display: flex;
  122. ::v-deep.u-icon--right {
  123. margin-right: 11px;
  124. }
  125. ::v-deep.u-action {
  126. width: 17.1%;
  127. text-align: center;
  128. line-height: 28px;
  129. border-radius: 50px;
  130. background-color: rgba(13, 186, 199, 1);
  131. color: rgba(255, 255, 255, 1);
  132. }
  133. ::v-deep.u-content {
  134. background-color: rgba(240, 244, 250, 1) !important;
  135. }
  136. ::v-deep.u-input {
  137. background-color: rgba(240, 244, 250, 1) !important;
  138. }
  139. }
  140. .main {
  141. margin-top: 120rpx;
  142. .result-box {
  143. border-radius: 12px;
  144. background-color: rgba(255, 255, 255, 1);
  145. margin: 0 16px 12px 16px;
  146. display: flex;
  147. padding: 12px;
  148. .picture {
  149. width: 200rpx;
  150. height: 200rpx;
  151. border-radius: 8rpx;
  152. overflow: hidden;
  153. img {
  154. width: 100%;
  155. height: 100%;
  156. }
  157. }
  158. .infos {
  159. margin-left: 12px;
  160. flex: 1;
  161. .title {
  162. color: rgba(51, 51, 51, 1);
  163. font-size: 16px;
  164. font-weight: bold;
  165. }
  166. .tag {
  167. display: flex;
  168. .item {
  169. // width: 128rpx;
  170. // height: 40rpx;
  171. line-height: 40rpx;
  172. border-radius: 8rpx;
  173. background-color: rgba(241, 243, 244, 1);
  174. color: rgba(16, 16, 16, 1);
  175. margin-right: 16rpx;
  176. margin-top: 24rpx;
  177. font-size: 12px;
  178. text-align: center;
  179. }
  180. }
  181. .teacher {
  182. display: flex;
  183. align-items: center;
  184. margin-top: 36rpx;
  185. .photo {
  186. width: 64rpx;
  187. height: 64rpx;
  188. border-radius: 100rpx;
  189. overflow: hidden;
  190. margin-right: 12px;
  191. img {
  192. width: 100%;
  193. height: 100%;
  194. }
  195. }
  196. .name {
  197. color: rgba(16, 16, 16, 1);
  198. width: 45%;
  199. }
  200. .phone-teacher {
  201. margin-right: 8px;
  202. }
  203. }
  204. }
  205. }
  206. }
  207. </style>