searchResult.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  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)">
  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-toast ref="uToast" />
  45. </view>
  46. </template>
  47. <script>
  48. import * as homePageApi from '@/apis/parents/homePage.js'
  49. export default {
  50. data() {
  51. return {
  52. className: '',
  53. reCoursesList: [],
  54. courseSortId: ''
  55. }
  56. },
  57. onLoad(op) {
  58. if(op.id) {
  59. this.courseSortId = op.id;
  60. this.getReCoursesList();
  61. }
  62. },
  63. methods: {
  64. searchClass() {
  65. if(this.className) {
  66. this.getReCoursesList();
  67. }
  68. },
  69. backCourse() {
  70. uni.navigateBack({
  71. })
  72. },
  73. getReCoursesList() {
  74. uni.showLoading({
  75. title: "加载中",
  76. mask: true,
  77. })
  78. homePageApi.loadCoursesForHomeShow({
  79. courseSortId: this.courseSortId,
  80. className: this.className,
  81. pageNum: 1,
  82. pageSize: 10000
  83. }).then((res) => {
  84. uni.hideLoading();
  85. this.reCoursesList = res.data.data;
  86. }).catch(error => {
  87. uni.showToast({
  88. title: error,
  89. icon: "none"
  90. })
  91. })
  92. },
  93. toCourseDetails(item) {
  94. if(item.classStatus != '4') {
  95. uni.navigateTo({
  96. url: '/pages/parents/course/courseDetails?id='+item.course_id+'&classId='+item.class_id
  97. })
  98. } else {
  99. this.$refs.uToast.show({
  100. title: '请电话联系' + item.consultPhone,
  101. type: 'primary',
  102. duration: 3000
  103. })
  104. }
  105. }
  106. }
  107. }
  108. </script>
  109. <style lang="scss" scoped>
  110. .search {
  111. background-color: #fff;
  112. padding: 16rpx 24rpx;
  113. position: fixed;
  114. left: 0;
  115. right: 0;
  116. top: 0;
  117. display: flex;
  118. ::v-deep.u-icon--right {
  119. margin-right: 11px;
  120. }
  121. ::v-deep.u-action {
  122. width: 17.1%;
  123. text-align: center;
  124. line-height: 28px;
  125. border-radius: 50px;
  126. background-color: rgba(13, 186, 199, 1);
  127. color: rgba(255, 255, 255, 1);
  128. }
  129. ::v-deep.u-content {
  130. background-color: rgba(240, 244, 250, 1) !important;
  131. }
  132. ::v-deep.u-input {
  133. background-color: rgba(240, 244, 250, 1) !important;
  134. }
  135. }
  136. .main {
  137. margin-top: 120rpx;
  138. .result-box {
  139. border-radius: 12px;
  140. background-color: rgba(255, 255, 255, 1);
  141. margin: 0 16px 12px 16px;
  142. display: flex;
  143. padding: 12px;
  144. .picture {
  145. width: 200rpx;
  146. height: 200rpx;
  147. border-radius: 8rpx;
  148. overflow: hidden;
  149. img {
  150. width: 100%;
  151. height: 100%;
  152. }
  153. }
  154. .infos {
  155. margin-left: 12px;
  156. flex: 1;
  157. .title {
  158. color: rgba(51, 51, 51, 1);
  159. font-size: 16px;
  160. font-weight: bold;
  161. }
  162. .tag {
  163. display: flex;
  164. .item {
  165. // width: 128rpx;
  166. // height: 40rpx;
  167. line-height: 40rpx;
  168. border-radius: 8rpx;
  169. background-color: rgba(241, 243, 244, 1);
  170. color: rgba(16, 16, 16, 1);
  171. margin-right: 16rpx;
  172. margin-top: 24rpx;
  173. font-size: 12px;
  174. text-align: center;
  175. }
  176. }
  177. .teacher {
  178. display: flex;
  179. align-items: center;
  180. margin-top: 36rpx;
  181. .photo {
  182. width: 64rpx;
  183. height: 64rpx;
  184. border-radius: 100rpx;
  185. overflow: hidden;
  186. margin-right: 12px;
  187. img {
  188. width: 100%;
  189. height: 100%;
  190. }
  191. }
  192. .name {
  193. color: rgba(16, 16, 16, 1);
  194. width: 45%;
  195. }
  196. .phone-teacher {
  197. margin-right: 8px;
  198. }
  199. }
  200. }
  201. }
  202. }
  203. </style>